mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 06:29:43 +00:00
LibWeb/WebAssembly: Avoid scanning all externs when resolving references
This was very hot on a profile of ruffle.
This commit is contained in:
parent
33cd5ae08c
commit
1ef536194d
Notes:
github-actions[bot]
2025-08-08 10:55:41 +00:00
Author: https://github.com/alimpfard
Commit: 1ef536194d
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
2 changed files with 11 additions and 5 deletions
|
@ -560,10 +560,8 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM& vm, JS::Value va
|
|||
if (value.is_null())
|
||||
return Wasm::Value(Wasm::ValueType { Wasm::ValueType::Kind::ExternReference });
|
||||
auto& cache = get_cache(*vm.current_realm());
|
||||
for (auto& entry : cache.extern_values()) {
|
||||
if (entry.value == value)
|
||||
return Wasm::Value { Wasm::Reference { Wasm::Reference::Extern { entry.key } } };
|
||||
}
|
||||
if (auto entry = cache.inverse_extern_values().get(value); entry.has_value())
|
||||
return Wasm::Value { Wasm::Reference { Wasm::Reference::Extern { *entry } } };
|
||||
Wasm::ExternAddress extern_addr = cache.extern_values().size();
|
||||
cache.add_extern_value(extern_addr, value);
|
||||
return Wasm::Value { Wasm::Reference { Wasm::Reference::Extern { extern_addr } } };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue