[wasm] Switch to phantom handles in interpreter
The interpreter stores a weak reference to the WasmInstance it belongs to. Make this a phantom reference, so the GC can get rid of the interpreter and its associated memory already on the first GC. Drive-by: Some renamings/refactorings. R=ahaas@chromium.org Bug: chromium:875647 Change-Id: Ib49f6d8aa820b904f07fabe7df78ddf6df944264 Reviewed-on: https://chromium-review.googlesource.com/1221806 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#55831}
This commit is contained in:
parent
abc7c65f32
commit
2d7e221d40
@ -3090,20 +3090,21 @@ class WasmInterpreterInternals : public ZoneObject {
|
||||
};
|
||||
|
||||
namespace {
|
||||
// TODO(wasm): a finalizer is only required to delete the global handle.
|
||||
void GlobalHandleDeleter(const v8::WeakCallbackInfo<void>& data) {
|
||||
GlobalHandles::Destroy(reinterpret_cast<Object**>(
|
||||
reinterpret_cast<JSObject**>(data.GetParameter())));
|
||||
void NopFinalizer(const v8::WeakCallbackInfo<void>& data) {
|
||||
Object** global_handle_location =
|
||||
reinterpret_cast<Object**>(data.GetParameter());
|
||||
GlobalHandles::Destroy(global_handle_location);
|
||||
}
|
||||
|
||||
Handle<WasmInstanceObject> MakeWeak(
|
||||
Isolate* isolate, Handle<WasmInstanceObject> instance_object) {
|
||||
Handle<Object> handle = isolate->global_handles()->Create(*instance_object);
|
||||
// TODO(wasm): use a phantom handle in the WasmInterpreter.
|
||||
GlobalHandles::MakeWeak(handle.location(), handle.location(),
|
||||
&GlobalHandleDeleter,
|
||||
v8::WeakCallbackType::kFinalizer);
|
||||
return Handle<WasmInstanceObject>::cast(handle);
|
||||
Handle<WasmInstanceObject> weak_instance =
|
||||
isolate->global_handles()->Create<WasmInstanceObject>(*instance_object);
|
||||
Object** global_handle_location =
|
||||
Handle<Object>::cast(weak_instance).location();
|
||||
GlobalHandles::MakeWeak(global_handle_location, global_handle_location,
|
||||
&NopFinalizer, v8::WeakCallbackType::kParameter);
|
||||
return weak_instance;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user