summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWasm
AgeCommit message (Collapse)Author
2021-08-12LibWasm: Move some Values and Vector<Value>s instead of copying themAli Mohammad Pur
2021-08-12LibWasm: Avoid calculating stack bounds on each wasm callAli Mohammad Pur
We only need to know the initial bounds, which we calculate by default when the interpreter is constructed. This cuts down on syscalls and makes wasm calls a lot cheaper.
2021-08-12LibWasm: Generate Value::type() on the fly instead of storing itAli Mohammad Pur
The variant member already contains enough information to give us the type when needed, so remove the type member and synthesize it when needed, this allows lots of optimisation opportunaties when copying and moving Values around.
2021-08-12LibWasm: Replace memory write macros with templated functionsAli Mohammad Pur
2021-08-12LibWasm: Make memory operation address calculation match the specAli Mohammad Pur
...or rather, match what the spec _means_ to say, not what it actually says.
2021-08-12LibWasm: Replace memory read macros with templated functionsAli Mohammad Pur
2021-08-12LibWasm: Replace the numeric operation macros with templated functionsAli Mohammad Pur
This should make debugging and profiling much better, at little to no runtime cost. Also moves off the operator definitions to a separate header, so it should also improve the editing experience quite a bit.
2021-07-22Everywhere: Prefer using {:#x} over 0x{:x}Gunnar Beutner
We have a dedicated format specifier which adds the "0x" prefix, so let's use that instead of adding it manually.
2021-07-17LibWasm: Remove a useless use of ScopeGuardAli Mohammad Pur
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-17LibWasm+Everywhere: Make the instruction count limit configurableAli Mohammad Pur
...and enable it for LibWeb and test-wasm. Note that `wasm` will not be limited by this.
2021-07-17LibWasm: Inline some very hot functionsAli Mohammad Pur
These are mostly pretty small functions too, and they were about ~10% of runtime.
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-12LibWasm: Adjust signed integer operations to avoid UBAndrew Kaster
Perform signed integer shifts, addition, subtraction, and rotations using their corresponding unsigned type. Additionally, mod the right hand side of shifts and rotations by the bit width of the integer per the spec. This seems strange, but the spec is clear on the desired wrapping behavior of arithmetic operations.
2021-07-12LibWasm: Skip initializing active empty data sectionsAli Mohammad Pur
2021-07-12LibWasm: Use AK::StackInfo to track stack sizeAli Mohammad Pur
This way, we can make sure that it doesn't overflow when ASAN is enabled.
2021-07-06LibWasm: Don't create useless temporary strings for trap reasonsAli Mohammad Pur
These strings are only used when execution traps, so there's no reason to create actual strings until that happens; instead switch to using StringViews.
2021-07-06LibWasm: Tweak the implementation-defined limits a bitAli Mohammad Pur
2021-07-06LibWasm: Allow overflow in normal 64-bit arithmetic instructionsAli Mohammad Pur
2021-07-06LibWasm: Limit module memory to 65536 pagesAli Mohammad Pur
The spec mentions this, and anything past that can't be correctly addressed by the 32-bit indices anyhow.
2021-07-06LibWasm: Fix data section initialization bounds checkingAli Mohammad Pur
2021-07-06LibWasm: Jump to the default label in br_table with negative valuesAli Mohammad Pur
Also adds a forgotten Wasm::Printer implementation for printing table branch arguments.
2021-07-06LibWasm: Use the number of bytes when comparing memory limitsAli Mohammad Pur
...instead of comparing page count with byte count.
2021-07-06LibWasm: Guard stack accesses with checksAli Mohammad Pur
If the stack is empty, let's just trap.
2021-07-04Everywhere: Fix incorrect usages of AK::CheckedIdan Horowitz
Specifically, explicitly specify the checked type, use the resulting value instead of doing the same calculation twice, and break down calculations to discrete operations to ensure no intermediary overflows are missed.
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-26AK: Undo bogus Variant::downcast() renameAndreas Kling
I accidentally renamed these to verify_cast() when doing the global AK::downcast() rename.
2021-06-24AK: Rename downcast<T> => verify_cast<T>Andreas Kling
This makes it much clearer what this cast actually does: it will VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-22LibWasm: Limit the call stack depth and the number of executed instsAli Mohammad Pur
These limits are described in the spec, and we're supposed to stop execution at some point. The limits are arbitrarily chosen.
2021-06-22LibWasm: Trap if a non-Value is used as a ValueAli Mohammad Pur
Otherwise we'd just crash, which is not a good thing
2021-06-22Meta+LibWasm: Add support for module linking testsAli Mohammad Pur
This commit makes the linking tests in the wasm spec test run.
2021-06-20LibWasm: Remove empty AbstractMachine/Interpreter.cppLinus Groh
This was moved to BytecodeInterpreter.cpp, so this is unused now.
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-09LibWasm: ALWAYS_INLINE some very hot functionsAli Mohammad Pur
These function couldn't be inlined before because the compiler would've started flagging invalid paths in Variant as maybe-uninitialized.
2021-06-09LibWasm: Implement saturating float truncation instructionsAli Mohammad Pur
With these, the only remaining unimplemented instructions are the following: - memory.init - data.drop - memory.copy - memory.fill - table.init - elem.drop - table.copy - table.grow - table.size - table.fill
2021-06-09LibWasm: Implement sign extension instructionsAli Mohammad Pur
2021-06-09LibWasm: Implement spec-compliant float min/max opsAli 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-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-04LibWasm: Implement the br.table instructionAli Mohammad Pur
Unlike its name, this instruction has nothing to do with tables, it's just a very simple switch-case instruction.
2021-06-04LibWasm: Read from and write to memory as little-endianAli Mohammad Pur
The spec says so, we must do so.
2021-06-03LibWasm: Use builtins for clz, ctz, and popcntBrandonKi
2021-06-03LibWasm: Implement rotr and rotlBrandonKi
2021-06-02AK+LibWasm+LibJS: Disallow Variant.has() on types that aren't containedAli Mohammad Pur
Checking for this (and get()'ing it) is always invalid, so let's just disallow it. This also finds two bugs where the code is checking for types that can never actually be in the variant (which was actually a refactor artifact).
2021-06-02LibWasm: Ensure that value signs are preserved when castingAli Mohammad Pur
Also makes normal arithmetic operations more spec-compliant by actually ignoring overflow on them.
2021-06-02LibWasm: Parse the "extend" set of instructionsAli Mohammad Pur
2021-06-02LibWasm: Don't execute the last instruction in the frame after returnAli Mohammad Pur
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