Commit graph

9 commits

Author SHA1 Message Date
Ali Mohammad Pur
bf3fa13773 wasm: Don't use a new AbstractMachine to instantiate modules
Bad rebase conflict resolution broke code, grug sad.
2025-08-26 19:06:59 +02:00
Ali Mohammad Pur
191499696b wasm: Make it possible to provide exported functions using js
This can be done by passing
`--export-js <module>.<fn>[(<arg>:type, ...)][:type]=<source>`,
which uses a js function `(arg...) => source` to resolve the requested
import `module::fn`.

All literal wasm value types (i<n> and v128) are supported as both
parameter and return types.
2025-08-26 15:20:33 +02:00
Ali Mohammad Pur
6732e1cdc3 LibWasm: Don't clobber registers on (most) calls
This still passes the values on the stack, but registers are now allowed
to cross a call boundary.
This is a very significant (>50%) improvement on the small call
microbenchmarks on my machine.
2025-08-26 15:20:33 +02:00
ayeteadoe
a95e0d2777 Utilities/wasm: Enable on Windows 2025-08-24 12:58:27 -06:00
Ali Mohammad Pur
0e5ecef848 LibWasm: Try really hard to avoid touching the value stack
This commit adds a register allocator, with 8 available "register"
slots.
In testing with various random blobs, this moves anywhere from 30% to
74% of value accesses into predefined slots, and is about a ~20% perf
increase end-to-end.

To actually make this usable, a few structural changes were also made:
- we no longer do one instruction per interpret call
- trapping is an (unlikely) exit condition
- the label and frame stacks are replaced with linked lists with a huge
  node cache size, as we only need to touch the last element and
  push/pop is very frequent.
2025-08-08 12:54:06 +02:00
Ali Mohammad Pur
998454028c LibWasm+wasm: Remove the debug interpreter
This is largely unused (only in wasm.cpp)
A future reimplementation can bring it back as a separate interpreter
class that embeds the current bytecode interpreter.
2025-08-08 12:54:06 +02:00
Jelle Raaijmakers
ead0a2c78a Everywhere: Rename serenity_main to ladybird_main
No functional changes.
2025-07-08 09:17:16 -04:00
Ali Mohammad Pur
51bab5b186 LibWasm: Make traps hold on to externally-managed data
...instead of specially handling JS::Completion.
This makes it possible for LibWeb/LibJS to have full control over how
these things are made, stored, and visited (whenever).

Fixes an issue where we couldn't roundtrip a JS exception through Wasm.
2025-04-22 08:43:46 -06:00
Timothy Flynn
950e819ee7 Everywhere: Hoist the Utilities folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Utilities/wasm.cpp (Browse further)