WebAssembly image dithering example
kinke
noone at nowhere.com
Fri Aug 3 19:01:02 UTC 2018
On Thursday, 2 August 2018 at 22:04:50 UTC, Allen Garvey wrote:
> 4. I was not able to use any of the optimization flags except
> for enable inlining, since using any of them would optimize out
> the entire program. I'm assuming this is because there is no
> main function, so the compiler can't tell which functions are
> actually being called.
I won't be able to run your full example (I'll keep my personal
machine Node.js-free! ;)), so I just used `ldc2
-mtriple=wasm32-unknown-unknown-wasm -betterC -O main.wasm` with
current LDC master (and added the missing __assert stub).
The produced .wasm is 620 bytes small (without -O: 3,235 bytes);
loading it in Firefox shows that the functions are there, here's
an excerpt:
(func $fillBayerMatrix (;3;) (param $var0 i32) (param $var1 i32)
get_local $var1
i64.const 4469670136257392600
i64.store align=4
get_local $var1
i32.const 8
i32.add
i64.const -4753701902744867000
i64.store align=4
)
(func $dither (;5;) (param $var0 i32) (param $var1 i32) (param
$var2 i32) (param $var3 i32)
get_local $var2
i64.const 4469670136257392600
i64.store align=4
get_local $var2
i32.const 8
i32.add
i64.const -4753701902744867000
i64.store align=4
block $label0
get_local $var0
get_local $var1
i32.mul
i32.const 2
i32.shl
i32.const 1
i32.ge_s
br_if $label0
return
end $label0
unreachable
unreachable
)
More information about the digitalmars-d-ldc
mailing list