AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.85k stars 656 forks source link

Binaryen assertion fails #802

Closed jtenner closed 5 years ago

jtenner commented 5 years ago
> as-nes-olc@0.0.1-alpha asbuild:untouched C:\Users\Joshua Tenner\projects\as-nes
> asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug

Assertion failed: false, at: binaryen/src/wasm/wasm.cpp,928,getGlobal
Assertion failed: false, at: binaryen/src/wasm/wasm.cpp,928,getGlobal

...

TypeError: Cannot read property 'replace' of undefined
    at defaultCallback (C:\Users\Joshua Tenner\projects\as-nes\node_modules\assemblyscript\cli\asc.js:170:65)
    at Object.main (C:\Users\Joshua Tenner\projects\as-nes\node_modules\assemblyscript\cli\asc.js:594:12)
    at Object.<anonymous> (C:\Users\Joshua Tenner\projects\as-nes\node_modules\assemblyscript\bin\asc:21:26)

There's lots of other un-useful stuff that binaryen spits out. Looks like fun, and totally out of my expertise.

jtenner commented 5 years ago

https://github.com/WebAssembly/binaryen/blob/master/src/wasm/wasm.cpp#L994

Looks like the problem is here in this function.

dcodeIO commented 5 years ago

Can you try to create a reduced repro so I can investigate? If your assumption on the origin is correct, it looks like the compiler it attempting to obtain a global that does not exist, by name.

jtenner commented 5 years ago

https://github.com/jtenner/as-nes-olc/blob/master/assembly/index.ts

Hey good luck! It's a 6502 emulator. There's lots of functions here too. I'll try to help isolate it too.

jtenner commented 5 years ago

Ah yes.

It looks like the long list of opcode references are what is causing the issue.

So to reproduce:

let global = [(255 references...)];

Edit:

So this was something I needed to optimize away anyway. I can probably work around the issue for now :)

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.