WebAssembly image dithering example

Allen Garvey allen.garvey at gmail.com
Sun Aug 5 20:57:34 UTC 2018


On Sunday, 5 August 2018 at 14:06:25 UTC, kinke wrote:
> If you provide the start address as null literal directly in 
> the D code, the optimizer infers that you're going to read from 
> address 0x3 in the first iteration. If you provide the start 
> address as argument from outside code not available during 
> optimization, LLVM cannot make any assumptions in this regard.

I get that now, I guess I just meant it's sort of amusing in a 
philosophical sense, as it's not what you know, but how you know 
it.

> I wasn't sure about the enum array; it'd probably make more 
> sense to define it as static immutable directly in the 
> function. I'd then expect this global to live in the module's 
> memory (`exports.memory`) and be initialized properly during 
> instantiation; this means that the start address/offset of the 
> pixel data probably shouldn't be 0 and that you shouldn't 
> overwrite any existing data after instantiation, just appending 
> to it, in order not to overwrite any D globals.

Gotcha. I was wondering where exactly the enum array was being 
stored, but I see what you mean that it was being stored in the 
same place we were putting the pixel data. I've merged your 
changes and everything's looking good! Thanks again for taking 
the time to help me out with this.


More information about the digitalmars-d-ldc mailing list