diff --git a/src/wasm/wasm-code-manager.cc b/src/wasm/wasm-code-manager.cc index 24d692bfe8..fbd677accf 100644 --- a/src/wasm/wasm-code-manager.cc +++ b/src/wasm/wasm-code-manager.cc @@ -442,20 +442,6 @@ void NativeModule::SetRuntimeStubs(Isolate* isolate) { #undef COPY_BUILTIN } -WasmModuleObject* NativeModule::module_object() const { - DCHECK_NOT_NULL(module_object_); - return *module_object_; -} - -void NativeModule::SetModuleObject(Handle module_object) { - DCHECK_NULL(module_object_); - module_object_ = module_object->GetIsolate() - ->global_handles() - ->Create(*module_object) - .location(); - GlobalHandles::MakeWeak(reinterpret_cast(&module_object_)); -} - WasmCode* NativeModule::AddAnonymousCode(Handle code, WasmCode::Kind kind) { std::unique_ptr reloc_info; @@ -732,14 +718,6 @@ void NativeModule::DisableTrapHandler() { NativeModule::~NativeModule() { TRACE_HEAP("Deleting native module: %p\n", reinterpret_cast(this)); - // Clear the handle at the beginning of destructor to make it robust against - // potential GCs in the rest of the destructor. - if (module_object_ != nullptr) { - Isolate* isolate = module_object()->GetIsolate(); - isolate->global_handles()->Destroy( - reinterpret_cast(module_object_)); - module_object_ = nullptr; - } wasm_code_manager_->FreeNativeModule(this); } diff --git a/src/wasm/wasm-code-manager.h b/src/wasm/wasm-code-manager.h index 5540992b0a..4dd410124b 100644 --- a/src/wasm/wasm-code-manager.h +++ b/src/wasm/wasm-code-manager.h @@ -311,11 +311,6 @@ class V8_EXPORT_PRIVATE NativeModule final { CompilationState* compilation_state() { return compilation_state_.get(); } - // TODO(mstarzinger): The link to the {WasmModuleObject} is deprecated and - // all uses should vanish to make {NativeModule} independent of the Isolate. - WasmModuleObject* module_object() const; - void SetModuleObject(Handle); - uint32_t num_functions() const { return num_functions_; } uint32_t num_imported_functions() const { return num_imported_functions_; } Vector code_table() const { @@ -399,11 +394,6 @@ class V8_EXPORT_PRIVATE NativeModule final { std::unique_ptr compilation_state_; - // A phantom reference to the {WasmModuleObject}. It is intentionally not - // typed {Handle} because this location will be cleared - // when the phantom reference is cleared. - WasmModuleObject** module_object_ = nullptr; - DisjointAllocationPool free_code_space_; DisjointAllocationPool allocated_code_space_; std::list owned_code_space_; diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc index cfaae968eb..64d15038df 100644 --- a/src/wasm/wasm-objects.cc +++ b/src/wasm/wasm-objects.cc @@ -307,13 +307,11 @@ Handle WasmModuleObject::New( module_object->set_asm_js_offset_table(*asm_js_offset_table); } - // Create the {NativeModule}, and link it bidirectionally to the - // {WasmModuleObject}. + // Create the {NativeModule}, and let the {WasmModuleObject} reference it. size_t memory_estimate = isolate->wasm_engine()->code_manager()->EstimateNativeModuleSize(module); auto native_module = isolate->wasm_engine()->code_manager()->NewNativeModule(isolate, env); - native_module->SetModuleObject(module_object); native_module->set_wire_bytes(std::move(wire_bytes), wire_bytes_len); native_module->SetRuntimeStubs(isolate); Handle> managed_native_module =