diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp index 46a110481b3..acae97f951e 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp @@ -48,6 +48,12 @@ void visit_edges(JS::Object& object, JS::Cell::Visitor& visitor) } } +void finalize(JS::Object& object) +{ + auto& global_object = HTML::relevant_global_object(object); + Detail::s_caches.remove(global_object); +} + // https://webassembly.github.io/spec/js-api/#dom-webassembly-validate bool validate(JS::VM& vm, JS::Handle& bytes) { diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.h index 10429f34898..c73d9a22a9d 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.h @@ -19,6 +19,7 @@ namespace Web::WebAssembly { void visit_edges(JS::Object&, JS::Cell::Visitor&); +void finalize(JS::Object&); bool validate(JS::VM&, JS::Handle& bytes); WebIDL::ExceptionOr compile(JS::VM&, JS::Handle& bytes); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.idl b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.idl index c544b408d16..ca421a4df7f 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.idl +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssembly.idl @@ -7,7 +7,7 @@ dictionary WebAssemblyInstantiatedSource { }; // https://webassembly.github.io/spec/js-api/#webassembly-namespace -[Exposed=*, WithGCVisitor] +[Exposed=*, WithGCVisitor, WithFinalizer] namespace WebAssembly { boolean validate(BufferSource bytes); Promise compile(BufferSource bytes);