Closed nom4dv3 closed 1 year ago
I have tried
asc test.ts -O --noAssert -o demo.wasm --disable bulk-memory
, which emited a loop with many store instructions instead of memory.fill
.
The version of asc
I used is 0.27.0
.
Could you try to compile your assemblyscript again?
ah right, turns out I didn't add -O
together with --disable bulk-memory
, causing memfill
left in the wasm. Thx for point it out!
But the resulting wasm is still failed on setup. I found it's because new
introduced a bunch of things, e.g. importing env.abort
etc.
Even I replace the env.abort
with an empty func, still no luck.
The only way I found to replace new
is to use heap.alloc
as it's unsafe operation. Still trying...
I wrote a Bytes class wrapping Uint8Array, providing a clean version of 'new' based on heap.alloc. And implement a 'read_bytes_from_u64' for as.
I was trying to add
read_bytes_from_i64
support in assemblyscript-compiled wasm, but observed that anynew Array/ArrayBuffer/TypedArray
would fail at the setup stage on zkwasm.Minimum sample as code:
compiled with
asc test.ts -t test.wat -o test.wasm
(test.zip)Looking into the wat, it seems has something to do with the
memory.fill
instruction.I also tried
--disable bulk-memory
, no luck, can't get rid of memfill, and failed at setup as expected. so it seems there no workaround.