Commit 70c36588 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Store native context in weak link

The WasmCompiledModule is kept alive from the Script, which again is
kept alive then the debugger is enabled. This, however, should not keep
the whole context alive, including the global object.
Hence, we only store a weak reference to the native context.

R=ahaas@chromium.org

Bug: chromium:750256
Change-Id: Ia409995c40fb3e90665534fbc94c6eafc081c4e5
Reviewed-on: https://chromium-review.googlesource.com/832126
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50174}
parent a1fcd777
......@@ -2377,7 +2377,9 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
compiled_module_->instance_id());
}
}
compiled_module_->set_native_context(*isolate_->native_context());
Handle<WeakCell> weak_native_context =
isolate_->factory()->NewWeakCell(isolate_->native_context());
compiled_module_->set_weak_native_context(*weak_native_context);
}
base::Optional<wasm::NativeModuleModificationScope>
native_module_modification_scope;
......
......@@ -1255,11 +1255,12 @@ Handle<WasmCompiledModule> WasmCompiledModule::New(
// WasmCompiledModule::cast would fail since fields are not set yet.
Handle<WasmCompiledModule> compiled_module(
reinterpret_cast<WasmCompiledModule*>(*ret), isolate);
compiled_module->set_native_context(*isolate->native_context());
Handle<WeakCell> weak_native_context =
isolate->factory()->NewWeakCell(isolate->native_context());
compiled_module->set_weak_native_context(*weak_native_context);
compiled_module->set_use_trap_handler(use_trap_handler);
if (!FLAG_wasm_jit_to_native) {
compiled_module->InitId();
compiled_module->set_native_context(*isolate->native_context());
compiled_module->set_code_table(*code_table);
compiled_module->set_export_wrappers(*export_wrappers);
// TODO(mtrofin): we copy these because the order of finalization isn't
......
......@@ -463,7 +463,7 @@ class WasmCompiledModule : public FixedArray {
// we embed the generated code with a value, then we track that value here.
#define CORE_WCM_PROPERTY_TABLE(MACRO) \
MACRO(WASM_OBJECT, WasmSharedModuleData, shared) \
MACRO(OBJECT, Context, native_context) \
MACRO(WEAK_LINK, Context, native_context) \
MACRO(CONST_OBJECT, FixedArray, export_wrappers) \
MACRO(OBJECT, FixedArray, weak_exported_functions) \
MACRO(WASM_OBJECT, WasmCompiledModule, next_instance) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment