New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setMemory fails silently in transform (regression?) #2670
Comments
This comment was marked as outdated.
This comment was marked as outdated.
Your signature is wrong. |
Thanks for the answer, I still don't get it.
How can I call assemblyscript.js -> setMemory() from within the afterCompile-hook? |
|
Yes, I'm aware of the different order of arguments. There are two functions called 1. assemblyscript.js setMemory(initial: Index, maximum: Index, segments: MemorySegment[], target: Target, exportName?: string | null, name?: string, shared?: boolean): void; 2. binaryen.js setMemory(initial: number, maximum: number, exportName?: string | null, segments?: MemorySegment[] | null, shared?: boolean, memory64?: boolean, internalName?: string): void;
|
AS doesn't use second version at all. As well as high level js API of binaryen.js. You can only use first version |
Thank you for your patience. I think I found the issue: Line 737 in 7a35ff8
It looks like If I replace |
@mnater check again, you are right, in If you want to use assemblyscript module, you can get it in afterInitialize(program) {
let asModule = program.module;
console.log("asModule", asModule);
} |
I cannot reproduce it in my mac m1, node v16.19.1. |
@HerrCai0907 Thanks, that's indeed a way to access the assemblyscript module. But I fear to run in to other issues, when I setMemory at this early stage. I'm on an old mac i7, node 19.6.0 |
@MaxGraey: what is the correct way to set up the https://github.com/AssemblyScript/assemblyscript/blob/main/src/module.ts#L1359 says If |
instead |
@HerrCai0907 assemblyscript/src/compiler.ts Line 731 in 9497c3d
So this approach seems a dead end. So I'm stuck with So my initial question remains: how can I prepopulate memory with (a large amount of) data? |
Bug description
I'm using the following transform to prefill wasm memory with ~100kb of data:
This worked great up to version 0.26.0. But with the update to 0.26.1 it stopped working. I haven't noticed until now, because here's no error message – the compiler just doesn't output the .wasm file.
I'm not sure if this is an issue with asc or with Binaryen. The release notes of 0.26.1 say that binaryen is updated, so I checked the binaryen source and it looks like the code of
setMemory
has changed. Notablyallocate
has been replaced bystackAlloc
. So maybe there's a stack overflow happening?Shall I report this in the binaryen repo?
Is there a more elegant way to prefill memory with data in asc (instead of using transforms)?
Steps to reproduce
Use the transform from above.
AssemblyScript version
v0.27.1
The text was updated successfully, but these errors were encountered: