WebAssembly image dithering example

Allen Garvey allen.garvey at gmail.com
Fri Aug 3 04:06:15 UTC 2018


On Thursday, 2 August 2018 at 22:31:40 UTC, kinke wrote:
> 3. According to a Hello-world Rust tutorial (can't find the 
> link), global pointers (such as a "Hello world" string literal) 
> are relative to the module's linear memory, exposed as 
> something like an ArrayBuffer in exports.memory in JS IIRC. I 
> guess that's all done by LLVM and doesn't need any special 
> handling by LDC, but I haven't tested any of this yet.
>
> 4. I'll check it out.
>
> 5. To be expected. See 
> https://github.com/ldc-developers/ldc/pull/2787 to get an idea 
> of what'd be required to get parts of druntime and Phobos 
> working for bare-metal targets without C runtime libs.

Thanks for your response and your offer to look into 4. The links 
you posted look very helpful, and I will look into stubbing the 
assert, cbrt and min and max functions with JavaScript, as I 
found this C++ tutorial 
https://www.lucidchart.com/techblog/2017/05/16/webassembly-overview-so-fast-so-fun-sorta-difficult/ on how to pass in external functions from JavaScript.

With regards to 3, I found this link 
https://stackoverflow.com/questions/47529643/how-to-return-a-string-or-similar-from-rust-in-webassembly about passing in a string in Rust, not sure if that is what you were referring to. It seems a bit painful, so I think I'll avoid that for now. Not that I expect you to know, and I don't really know anything about compilers, but since it is possible for the compiler to reserve space on the stack for 4 float variables, I had assumed it would be the same thing if you were using an array of 4 floats, rather than having to manually do everything.

As for 5, I wasn't surprised that it didn't work, but I was sort 
of naively hoping it would. I don't have any experince with this 
type of low level programming, so I had thought no garbage 
collection meant it would run on anything, but I am starting to 
get my head around how the runtime is separated from the language.


More information about the digitalmars-d-ldc mailing list