summaryrefslogtreecommitdiff
path: root/Userland/Utilities/wasm.cpp
AgeCommit message (Collapse)Author
2022-01-09Userland: Port wasm to LibMainFederico Guerinoni
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-09-11wasm: Avoid making StringView of temporary ByteBufferBen Wiederhake
2021-07-17wasm: Don't try to print the function results if it trapsAli Mohammad Pur
2021-07-17Revert "LibWasm: Some more performance stuff (#8812)"Ali Mohammad Pur
This reverts commit 35394dbfaa23b44a293da85b20a63a10f73572c3. I pushed the wrong button again, hopefully this will be the last of such incidents.
2021-07-17LibWasm: Some more performance stuff (#8812)Ali Mohammad Pur
* wasm: Don't try to print the function results if it traps * LibWasm: Inline some very hot functions These are mostly pretty small functions too, and they were about ~10% of runtime. * LibWasm+Everywhere: Make the instruction count limit configurable ...and enable it for LibWeb and test-wasm. Note that `wasm` will not be limited by this. * LibWasm: Remove a useless use of ScopeGuard There are no multiple exit paths in that function, so we can just put the ending logic right at the end of the function instead.
2021-07-02LibWasm: Give traps a reason and display it when neededAli Mohammad Pur
This makes debugging wasm code a bit easier, as we now know what fails instead of just "too bad, something went wrong".
2021-06-17Everywhere: Replace the multiple impls of print_buffer() with :hex-dumpAli Mohammad Pur
2021-06-09wasm: Add a help command to the shell mode and start it on --shellAli Mohammad Pur
2021-06-05LibWasm: Move Wasm::BytecodeInterpreter into its own headerSahan Fernando
2021-06-04LibWasm+wasm: Switch to east-const to comply with project styleAli Mohammad Pur
Against my better judgement, this change is mandated by the project code style rules, even if it's not actually enforced.
2021-06-04Userland/wasm: Replace manual noop export with an automatic oneAli Mohammad Pur
Instead of manually specifying the types and names of imports to stub out, `--export-noop` can be used to export stub functions for any unresolved function import. This makes running and debugging random wasm files much easier.
2021-06-04LibWasm: Load and instantiate tablesAli Mohammad Pur
This commit is a fairly large refactor, mainly because it unified the two different ways that existed to represent references. Now Reference values are also a kind of value. It also implements a printer for values/references instead of copying the implementation everywhere.
2021-06-02wasm: Add a way to create dummy function exportsAli Mohammad Pur
This should allow running modules with their imports stubbed out in wasm, to debug them.
2021-06-02LibWasm: Implement reference instructions (ref.{null,func,is_null})Ali Mohammad Pur
2021-06-01Userland: Replace most printf-style APIs with AK::Format APIs :^)Linus Groh
2021-05-27LibWasm: Let the interpreter itself manage the call frameAli Mohammad Pur
2021-05-27LibWasm: Make Interpreter a virtual interfaceAli Mohammad Pur
This allows multiply different kinds of interpreters to be used by the runtime; currently a BytecodeInterpreter and a DebuggerBytecodeInterpreter is provided.
2021-05-27LibWasm: Make Frame a value type as wellAli Mohammad Pur
This means stack operations will no longer do extra allocations.
2021-05-26LibWasm: Add execution hooks and a debugger mode to the wasm toolAli Mohammad Pur
This is useful for debugging *our* implementation of wasm :P
2021-05-21LibWasm: Implement a very basic linkerAli Mohammad Pur
This will simply "link" any given module instances and produce a list of external values that can be used to instantiate a module. Note that this is extremely basic and cannot resolve circular dependencies, and depends on the instance order.
2021-05-21LibWasm: Make the instantiation process produce an OwnPtrAli Mohammad Pur
Managing the instantiated modules becomes a pain if they're on the stack, since an instantiated module will eventually reference itself. To make using this simpler, just avoid copying the instance.
2021-05-21LibWasm: Decouple ModuleInstance from the AbstractMachineAli Mohammad Pur
This fixes a FIXME and will allow linking only select modules together, instead of linking every instantiated module into a big mess of exported entities :P
2021-05-17Utilities/wasm: Say something when execution trapsAli Mohammad Pur
2021-05-17LibWasm: Start implementing a naive bytecode interpreterAli Mohammad Pur
As the parser now flattens out the instructions and inserts synthetic nesting/structured instructions where needed, we can treat the whole thing as a simple parsed bytecode stream. This currently knows how to execute the following instructions: - unreachable - nop - local.get - local.set - {i,f}{32,64}.const - block - loop - if/else - branch / branch_if - i32_add - i32_and/or/xor - i32_ne This also extends the 'wasm' utility to optionally execute the first function in the module with optionally user-supplied arguments.
2021-05-13LibWasm: Add basic support for module instantiation and execution stubsAli Mohammad Pur
This adds very basic support for module instantiation/allocation, as well as a stub for an interpreter (and executions APIs). The 'wasm' utility is further expanded to instantiate, and attempt executing the first non-imported function in the module. Note that as the execution is a stub, the expected result is a zero. Regardless, this will allow future commits to implement the JS WebAssembly API. :^)
2021-05-13LibWasm: Add a module pretty printerAli Mohammad Pur
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-08LibWasm: Add some more descriptive parse errorsAli Mohammad Pur
It's much better to tell the user "hey, the magic numbers don't check out" than "oh there was a problem with your input" :P Also refactors some stuff to make it possible to efficiently use the parser error enum without it getting in the way.
2021-05-08LibWasm: Start implementing a basic WebAssembly binary format parserAli Mohammad Pur
This can currently parse a really simple module. Note that it cannot parse the DataCount section, and it's still missing almost all of the instructions. This commit also adds a 'wasm' test utility that tries to parse a given webassembly binary file. It currently does nothing but exit when the parse fails, but it's a start :^)