mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 05:52:53 +00:00
LibWeb: Isolate WebAssembly cache by global object
This change moves WebAssembly related data that was previously globally accessible into the `WebAssemblyCache` object and creates one of these per global object. This ensures that WebAssembly data cannot be accessed across realms.
This commit is contained in:
parent
5e75afd549
commit
6d4b8bde55
Notes:
sideshowbarker
2024-07-17 02:57:43 +09:00
Author: https://github.com/tcl3
Commit: 6d4b8bde55
Pull-request: https://github.com/SerenityOS/serenity/pull/24051
Reviewed-by: https://github.com/alimpfard ✅
9 changed files with 121 additions and 116 deletions
|
@ -21,13 +21,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Module>> Module::construct_impl(JS::Realm&
|
|||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
auto index = TRY(Detail::parse_module(vm, bytes->raw_object()));
|
||||
return vm.heap().allocate<Module>(realm, realm, index);
|
||||
auto compiled_module = TRY(Detail::parse_module(vm, bytes->raw_object()));
|
||||
return vm.heap().allocate<Module>(realm, realm, move(compiled_module));
|
||||
}
|
||||
|
||||
Module::Module(JS::Realm& realm, size_t index)
|
||||
Module::Module(JS::Realm& realm, NonnullRefPtr<Detail::CompiledWebAssemblyModule> compiled_module)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_index(index)
|
||||
, m_compiled_module(move(compiled_module))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,4 @@ void Module::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE_WITH_CUSTOM_NAME(Module, WebAssembly.Module);
|
||||
}
|
||||
|
||||
Wasm::Module const& Module::module() const
|
||||
{
|
||||
return Detail::s_compiled_modules.at(index())->module;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue