Commit graph

18 commits

Author SHA1 Message Date
Marcus Nilsson
bfa51c2555 LibWasm: Parse struct types and support multiple types in type section
This patch adds support for parsing structs in the type section.

It also removes the assumption that all types in the type section are
function types, adding appropriate validation.

Spec tests struct.3 and struct.4 have been disable as this would
require expanding `ValueType` to include more heap-types.
2026-02-04 14:29:22 +01:00
Ali Mohammad Pur
0e6943b17d LibWasm: Avoid unnecessary bounds checks in memory ops 2026-02-02 14:11:49 +01:00
Ali Mohammad Pur
921373a045 LibWasm: Implement call argument forwarding using call records 2026-02-02 14:11:49 +01:00
Ali Mohammad Pur
a72127c39d LibWasm: Move out addresses into their own allocation
Instead of trying to indirectly load 2x64 bits from *cc, load addresses
directly from their own contiguous allocation.

This allows a future optimisation where we defer loading addresses to
reduce memory port pressure.
2026-02-02 14:11:49 +01:00
Ali Mohammad Pur
be9d8288ef LibWasm: Take call arguments and results on registers if possible 2026-02-02 14:11:49 +01:00
Ali Mohammad Pur
b89ecfc6bc LibWasm: Split parameters from locals 2026-02-02 14:11:49 +01:00
Andreas Kling
8289b24a7e LibJS: Introduce VM::the() and use it instead of caching VM pointer
In our process architecture, there's only ever one JS::VM per process.
This allows us to have a VM::the() singleton getter that optimizes
down to a single global access everywhere.

Seeing 1-2% speed-up on all JS benchmarks from this.
2025-12-09 11:58:39 -06:00
Ali Mohammad Pur
92c0cbc453 LibWasm+LibWeb: Stub wasm-gc's heap reference types
WPT inserts these into all modules regardless of whether they're used,
so let's just parse and ignore them.
2025-10-15 01:26:29 +02:00
Ali Mohammad Pur
d99f663b1a LibWasm: Implement parsing/validation for proposal exception-handling
Actual execution traps for now.
2025-10-15 01:26:29 +02:00
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)