Comments (13)
Sorry for coming back so late to you ! I have upgraded to latest AssemblyScript version and indeed it works now ;)
Thanks so much for the help !
from assemblyscript.
Here is the complete error it seems:
Cannot enlarge memory, requested 2147504128 bytes, but the limit is 2147483648 bytes!
Cannot enlarge memory, requested 2147508224 bytes, but the limit is 2147483648 bytes!
Aborted(native code called abort())
▌ Whoops, the AssemblyScript compiler has crashed during optimize :-(
▌
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌
▌ RuntimeError: Aborted(native code called abort())
▌ at abort (file:///Users/blumiere/Projects/assemblyscript/node_modules/binaryen/index.js:422:15)
▌ at _abort (file:///Users/blumiere/Projects/assemblyscript/node_modules/binaryen/index.js:3478:7)
▌ at binaryen_wasm.wasm.MixedArena::allocSpace(unsigned long, unsigned long) (wasm://wasm/binaryen_wasm.wasm-021889a6:wasm-function[813]:0x71d58)
▌ at invoke_iiii (file:///Users/blumiere/Projects/assemblyscript/node_modules/binaryen/index.js:5722:40)
▌ at binaryen_wasm.wasm.wasm::optimizeBlock(wasm::Block*, wasm::Module*, wasm::PassOptions&, wasm::BranchUtils::BranchSeekerCache&) (wasm://wasm/binaryen_wasm.wasm-021889a6:wasm-function[5986]:0x309bda)
▌ at binaryen_wasm.wasm.wasm::Walker<wasm::MergeBlocks, wasm::UnifiedExpressionVisitor<wasm::MergeBlocks, void>>::doVisitBlock(wasm::MergeBlocks*, wasm::Expression**) (wasm://wasm/binaryen_wasm.wasm-021889a6:wasm-function[5895]:0x30659f)
▌ at binaryen_wasm.wasm.wasm::Walker<wasm::MergeBlocks, wasm::UnifiedExpressionVisitor<wasm::MergeBlocks, void>>::walk(wasm::Expression*&) (wasm://wasm/binaryen_wasm.wasm-021889a6:wasm-function[5891]:0x305335)
▌ at binaryen_wasm.wasm.wasm::WalkerPass<wasm::PostWalker<wasm::MergeBlocks, wasm::UnifiedExpressionVisitor<wasm::MergeBlocks, void>>>::runOnFunction(wasm::Module*, wasm::Function*) (wasm://wasm/binaryen_wasm.wasm-021889a6:wasm-function[5893]:0x306521)
▌ at invoke_viii (file:///Users/blumiere/Projects/assemblyscript/node_modules/binaryen/index.js:5733:33)
▌ at binaryen_wasm.wasm.wasm::PassRunner::runPassOnFunction(wasm::Pass*, wasm::Function*) (wasm://wasm/binaryen_wasm.wasm-021889a6:wasm-function[2178]:0x1723f2)
▌
▌ If you see where the error is, feel free to send us a pull request. If not,
▌ please let us know: https://github.com/AssemblyScript/assemblyscript/issues
▌
▌ Thank you!
from assemblyscript.
It seems to work if binaryen.js is built with a maximum of 4 GiB of memory (which is the hard maximum according to wasm-ld, likely because it's Wasm32).
Here's the gzipped bla.wasm by the way.
The time needed on my 15" mid-2014 MacBook Pro: node ../assemblyscript/bin/asc -O bla.ts -o bla.wasm 484.24s user 1.51s system 102% cpu 7:55.49 total
from assemblyscript.
Thanks so much @CountBleck ! I have a couple of questions then :
- when you say "built with a maximum of 4 GiB of memory" you mean the amount of memory that's available to binaryen for optimization ?
- how would you go about detecting that error and reporting it in a more user friendly manner ?
from assemblyscript.
Yes, I mean the amount of memory available to Binaryen.
To detect that error, perhaps one could check the size of HEAP8
and compare it to the maximum.
Also, it might be good to bump the maximum memory in binaryen.js to 4 GiB regardless.
from assemblyscript.
Also, it might be good to bump the maximum memory in binaryen.js to 4 GiB regardless.
How do you do that ? I see only a few options are forwarded to binaryen from asc
To detect that error, perhaps one could check the size of HEAP8 and compare it to the maximum.
Same ... any pointers on how I can access these ?
from assemblyscript.
Binaryen should use add_link_flag("-sMAXIMUM_MEMORY=4gb")
for that. Just need to add this flag here:
https://github.com/WebAssembly/binaryen/blob/main/CMakeLists.txt#L337
from assemblyscript.
Yeah, that's basically the flag I used.
How do you do that ? I see only a few options are forwarded to binaryen from asc
That's done when binaryen.js is built, using the flag Max said.
any pointers on how I can access these ?
That would likely be done within asc
and not in your code.
from assemblyscript.
Also, we could try to update binaryen.js to latest. Perhaps there are some fixes, improvements and less memory leakage or consumption.
from assemblyscript.
Also, we could try to update binaryen.js to latest. Perhaps there are some fixes, improvements and less memory leakage or consumption.
I have zero experience with updating AS's binaryen.js version, which is why I haven't just stuck the flag in the action yet.
Also, I tested AS with the latest version of binaryen.js, and it doesn't work with the default 2 GiB.
from assemblyscript.
@sebpiq Sadly, I'm not sure if there's a reliable way to detect OOM. I might look into it further, but the next version of AS (released in a day or two) should allow your code to be built.
from assemblyscript.
Thanks a lot !
Sorry I haven't responded before. I'll try with the newest version and see what I get.
Thanks also for all the great work with assemblyscript !
from assemblyscript.
It may also be memory leak in binaryen: WebAssembly/binaryen#6239
from assemblyscript.
Related Issues (20)
- incorrect variable resolving for class default initializer
- asc crash when use same name in class and namespace HOT 1
- missing diagnose for interface with initialized field
- compiler crash HOT 1
- Hello HOT 1
- AS supports WASMGC? HOT 6
- Blazor Web App (Server) .NET8.0 call Web API with MVC HOT 1
- The results of arithmetic operations with u8 are not truncated to 8 bits, when assigned to f64 HOT 1
- Stale Memory Reads HOT 17
- I look at the source code and find that there is code related to wasmGC, will wasmGC be supported soon? HOT 1
- npx asinit .
- Support type alias as syntactic sugar for class HOT 4
- Incorrect overriden function call HOT 2
- `env` module isn't imported, using `moduleImports` and `--importMemory` together
- I hope compiling to native binary was added for AssemblyScript. HOT 1
- Loop and variable bug HOT 2
- as crash when try to alloc large data HOT 2
- crash when shifting BigInt HOT 1
- Can't get export info in transform without reloading the module HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from assemblyscript.