Comments (9)
some_check
if
return
end
You should be able to shorten that if return end
even more to just br_if i
, where i
is the label of the function body – a br out of a function body is equivalent to return
.
from wabt.
It depends... on the size of the .wat, do you get a more concise output from binaryen's wasm-dis
or wasm-tools print
? If so... we can dive down to compare.
In terms of memory consumption of wat2wasm, wasm-tools parse
is probably going to be better (and also better than binaryen's wasm-as
) since I think it tries not to assemble an in-memory IR of the whole module.
from wabt.
Thanks for the prompt response, wasm-tools parse
worked (with more swap, takes quite some time).
But wat2wasm
still segfaults when run on the 20GB .wat file, I edited the issue accordingly.
FYI: both wasm-tools parse
and wat2wasm
require around 20GB of RAM.
from wabt.
Cool, what's the segfault? (E.g. if you make a debug build and run it in gdb, where does it segfault?)
from wabt.
What is the reason for wanting to support such large files? Done't Wasm runtimes have internal limits that make running such files impossible? Perhaps we should instead just impose a limit on the size of any file we process? (see https://webassembly.github.io/spec/core/appendix/implementation.html#binary-format).
from wabt.
Here is the segfault, hope it helps:
(gdb) run
Starting program: /home/wolfgang/ProjectsUni/Compilerstep/wabt/out/clang/Debug/wat2wasm color.wat -o color.wasm
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00005555555f3db3 in wabt::WastParser::GetToken (this=0x7fffffffd800)
at /home/wolfgang/ProjectsUni/Compilerstep/wabt/src/wast-parser.cc:585
585 if (tokens_.empty()) {
(gdb)
@sbc100 We extended the CertiCoq compiler with a Wasm backend.
One of the benchmarks of CertiCoq runs a graph coloring algorithm, the generated binary includes the representation of a graph in a functional language, compiled to Wasm.
Didn't have issues running the other (a little smaller) benchmarks, haven't tried this one yet.
And in case you're wandering, the roundtrip with wasm2wat
and wat2wasm
is not strictly necessary, we'll get rid of that soon.
from wabt.
What wasm engine are are you able to run 20GB program on (or even 1GB program for that matter)? I would have assumed that such a program would be exceed the internal limits of any engine.
from wabt.
It's just the color.wat
file that's so big (for some reason), the color.wasm
file is just ~2MB, I ran the color.wasm
file in both Node.js and wasmtime, both went fine.
(Node.js takes > 1 min to instantiate the module, but no crash :) )
from wabt.
I think I understand now, why the color.wat
file was so big, it has a quite large chain of nested if-statements, like so:
...
some_check
if
return
else
...
some_check
if
return
else
... ~20,000x this nesting
end
end
Presumably, this adds quite a lot of whitespace. (gzip reduces the 16GB wat file to ~25MB)
we now generate the semantically equivalent programs, where the else branch is moved to after the if-statement, like so:
some_check
if
return
end
...
some_check
if
return
end
...
This change reduced the color.wasm
from 1.8 MB to 1.7 MB, but the color.wat
from 16GB to 14MB
Also, we generate code in SSA form, so one function has ~20k locals before we run wasm-opt --coalesce-locals
:)
from wabt.
Related Issues (20)
- `wast2json` fails to parse `if.wast` from latest testsuite HOT 4
- Plan for GC and beyond HOT 9
- In the case of wasmGC, the encoding of the ref is incorrect. such as test/dump/typed_func_refds_params
- Mac ARM support HOT 15
- wasm2c: Are module instances truly thread-safe? HOT 5
- can wast2json write out binary modules as they are without error checking? HOT 4
- wat2wasm fails converting .wast files in testsuite: error: unexpected token (, expected EOF. HOT 4
- feature request: support for WASI preview 2 component model HOT 1
- Use of call_ref does not take a type indice in wat2wasm HOT 1
- Output results of the wasm-decompile to be easier to understand which function is called by call_indirect HOT 1
- [wasm2c] MSVC miscompiles for certain fp constants HOT 5
- WASM2C - What happened to wasm_rt_allocate_memory HOT 3
- Error using wasm2wat on a wasm file generated by Moonbit: "unexpected type form (got -0x30)" HOT 1
- Out-of-Memory Program Abort in wabt::interp::Table::Grow() HOT 2
- Out-of-Memory Program Abort in BinaryReaderInterp::OnDataCount()
- Invalid Memory Read in FreeList<wabt::interp::Object*>::IsUsed()
- error initializing module: invalid import "a.a" HOT 1
- Error while running testsuite (simd_lane, simd_load) "loop not vectorized" HOT 3
- wasm2wat: support component wasm HOT 1
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 wabt.