Commit 3f794f51 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove instance finalizer

The instance finalizer does nothing useful any more. Freeing the native
allocations is already done in the destructor of the Managed.

R=titzer@chromium.org

Bug: chromium:875647
Change-Id: I154b9da74cf377c2803f66dc959edb4837c6b766
Reviewed-on: https://chromium-review.googlesource.com/1221215Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55849}
parent e9922070
...@@ -1168,11 +1168,6 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -1168,11 +1168,6 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
LoadDataSegments(instance); LoadDataSegments(instance);
} }
//--------------------------------------------------------------------------
// Install a finalizer on the new instance object.
//--------------------------------------------------------------------------
WasmInstanceObject::InstallFinalizer(isolate_, instance);
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Debugging support. // Debugging support.
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
......
...@@ -72,16 +72,14 @@ class WasmInstanceNativeAllocations { ...@@ -72,16 +72,14 @@ class WasmInstanceNativeAllocations {
reinterpret_cast<Address*>( reinterpret_cast<Address*>(
calloc(num_imported_mutable_globals, sizeof(Address)))); calloc(num_imported_mutable_globals, sizeof(Address))));
} }
~WasmInstanceNativeAllocations() { free(); } ~WasmInstanceNativeAllocations() {
// Frees natively-allocated storage.
void free() {
::free(indirect_function_table_sig_ids_); ::free(indirect_function_table_sig_ids_);
::free(indirect_function_table_targets_);
::free(imported_function_targets_);
::free(imported_mutable_globals_);
indirect_function_table_sig_ids_ = nullptr; indirect_function_table_sig_ids_ = nullptr;
::free(indirect_function_table_targets_);
indirect_function_table_targets_ = nullptr; indirect_function_table_targets_ = nullptr;
::free(imported_function_targets_);
imported_function_targets_ = nullptr; imported_function_targets_ = nullptr;
::free(imported_mutable_globals_);
imported_mutable_globals_ = nullptr; imported_mutable_globals_ = nullptr;
} }
// Resizes the indirect function table. // Resizes the indirect function table.
...@@ -1297,44 +1295,6 @@ Handle<WasmInstanceObject> WasmInstanceObject::New( ...@@ -1297,44 +1295,6 @@ Handle<WasmInstanceObject> WasmInstanceObject::New(
return instance; return instance;
} }
namespace {
void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) {
DisallowHeapAllocation no_gc;
JSObject** p = reinterpret_cast<JSObject**>(data.GetParameter());
WasmInstanceObject* instance = reinterpret_cast<WasmInstanceObject*>(*p);
Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
// If a link to shared memory instances exists, update the list of memory
// instances before the instance is destroyed.
TRACE("Finalizing instance of %p {\n",
instance->module_object()->native_module());
// Since the order of finalizers is not guaranteed, it can be the case
// that {instance->compiled_module()->module()}, which is a
// {Managed<WasmModule>} has been collected earlier in this GC cycle.
// Weak references to this instance won't be cleared until
// the next GC cycle, so we need to manually break some links (such as
// the weak references from {WasmMemoryObject::instances}.
if (instance->has_memory_object()) {
WasmMemoryObject::RemoveInstance(handle(instance->memory_object(), isolate),
handle(instance, isolate));
}
// Free raw C++ memory associated with the instance.
GetNativeAllocations(instance)->free();
GlobalHandles::Destroy(reinterpret_cast<Object**>(p));
TRACE("}\n");
}
} // namespace
void WasmInstanceObject::InstallFinalizer(Isolate* isolate,
Handle<WasmInstanceObject> instance) {
Handle<Object> global_handle = isolate->global_handles()->Create(*instance);
GlobalHandles::MakeWeak(global_handle.location(), global_handle.location(),
InstanceFinalizer, v8::WeakCallbackType::kFinalizer);
}
Address WasmInstanceObject::GetCallTarget(uint32_t func_index) { Address WasmInstanceObject::GetCallTarget(uint32_t func_index) {
wasm::NativeModule* native_module = module_object()->native_module(); wasm::NativeModule* native_module = module_object()->native_module();
if (func_index < native_module->num_imported_functions()) { if (func_index < native_module->num_imported_functions()) {
......
...@@ -461,9 +461,6 @@ class WasmInstanceObject : public JSObject { ...@@ -461,9 +461,6 @@ class WasmInstanceObject : public JSObject {
static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmModuleObject>); static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmModuleObject>);
static void InstallFinalizer(Isolate* isolate,
Handle<WasmInstanceObject> instance);
Address GetCallTarget(uint32_t func_index); Address GetCallTarget(uint32_t func_index);
// Iterates all fields in the object except the untagged fields. // Iterates all fields in the object except the untagged fields.
......
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