mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 07:33:20 +00:00
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.
This commit is contained in:
parent
998454028c
commit
0e5ecef848
Notes:
github-actions[bot]
2025-08-08 10:55:57 +00:00
Author: https://github.com/alimpfard
Commit: 0e5ecef848
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5060
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/gmta
9 changed files with 3217 additions and 1824 deletions
|
@ -435,6 +435,8 @@ void Printer::print(Wasm::Instruction const& instruction)
|
|||
print_indent();
|
||||
print("({}", instruction_name(instruction.opcode()));
|
||||
if (instruction.arguments().has<u8>()) {
|
||||
if (instruction.opcode() == Instructions::local_get || instruction.opcode() == Instructions::local_set || instruction.opcode() == Instructions::local_tee)
|
||||
print(" (local index {})", instruction.local_index());
|
||||
print(")\n");
|
||||
} else {
|
||||
print(" ");
|
||||
|
@ -478,7 +480,10 @@ void Printer::print(Wasm::Instruction const& instruction)
|
|||
[&](Instruction::TableTableArgs const& args) { print("(table_table (table index {}) (table index {}))", args.lhs.value(), args.rhs.value()); },
|
||||
[&](ValueType const& type) { print(type); },
|
||||
[&](Vector<ValueType> const&) { print("(types...)"); },
|
||||
[&](auto const& value) { print("{}", value); });
|
||||
[&](auto const& value) { print("(const {})", value); });
|
||||
|
||||
if (instruction.local_index().value())
|
||||
print(" (local index {})", instruction.local_index().value());
|
||||
|
||||
print(")\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue