mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +00:00
LibWasm+LibWeb+test-wasm: Refcount Wasm::Module for function references
Prior to funcref, a partial chunk of an invalid module was never needed, but funcref allows a partially instantiated module to modify imported tables with references to its own functions, which means we need to keep the second module alive while that function reference is present within the imported table. This was tested by the spectests, but very rarely caught as our GC does not behave particularly predictably, making it so the offending module remains in memory just long enough to let the tests pass. This commit makes it so all function references keep their respective modules alive.
This commit is contained in:
parent
5606ce412e
commit
a60ecea16a
Notes:
github-actions[bot]
2024-08-22 07:37:30 +00:00
Author: https://github.com/alimpfard
Commit: a60ecea16a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1159
9 changed files with 54 additions and 37 deletions
|
@ -430,7 +430,7 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM& vm, JS::Value va
|
|||
auto& cache = get_cache(*vm.current_realm());
|
||||
for (auto& entry : cache.function_instances()) {
|
||||
if (entry.value == &function)
|
||||
return Wasm::Value { Wasm::Reference { Wasm::Reference::Func { entry.key } } };
|
||||
return Wasm::Value { Wasm::Reference { Wasm::Reference::Func { entry.key, cache.abstract_machine().store().get_module_for(entry.key) } } };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue