Reputation: 111
I'm playing around with AssemblyScript to generate WebAssembly, and I'm not sure why the "optimized" WebAssembly module is so large. I modified the simple add function in the basic tutorial to be a multiplication function that looks like this:
export function mult(a: i32, b: i32): i32 {
return a * b;
}
I can find this function defined inside the optimized.wat file:
(func $assembly/index/mult (; 26 ;)
(type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0
local.get $1
i32.mul
)
However, there is a ton of extra code in the module. The total size of the module is more than 1800 lines. Seems like a lot of extra stuff I don't need. The WAT files in the example folder are all nice and small. The Mandlebrot example is only 200 lines of WAT, and the Game of Life example is only 400. Why would a simple multiplication produce 1800 lines? Is there an optimization setting I'm missing?
thanks
Upvotes: 1
Views: 304
Reputation: 361
Since version 0.7 AssemblyScript by default use full runtime which include ARC ops, GC and basic memory operations which also always exported to host and can't eliminating. If you don't handle memory on host and/or pass and allocate managed objects you could switch to --runtime none
or --runtime half
.
See all runtime variants on docs.assemblyscript.org
Upvotes: 2