Commit 34933570 authored by Stephan Herhut's avatar Stephan Herhut Committed by Commit Bot

Start using the v8 deleter to free array buffers.

Changes the v8 binding to propagate the custom v8 deleter for
array buffers into blinks internal DataHandle object. Also, always
use deleters, regardless of reservation mode.

As a follow-up, reservation mode and corresponding data can now be
removed.

Bug: v8:8073
Change-Id: I6db795d5a4f19ee0cea727a54d9085ff2ba5b5dc
Reviewed-on: https://chromium-review.googlesource.com/1186333
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586232}
parent 1583032c
......@@ -1045,16 +1045,13 @@ v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
default:
NOTREACHED();
};
// TODO(v8:8073): Use specific deallocator per mode once v8 provides information.
WTF::ArrayBufferContents::DataHandle data(v8Contents.AllocationBase(),
v8Contents.AllocationLength(),
v8Contents.Data(),
v8Contents.ByteLength(),
kind,
[](void* buffer, size_t length, void* alloc_data) {
WTF::ArrayBufferContents::FreeMemory(buffer);
},
nullptr);
v8Contents.Deleter(),
v8Contents.DeleterData());
WTF::ArrayBufferContents contents(std::move(data), WTF::ArrayBufferContents::k{% if interface_name == 'ArrayBuffer' %}Not{% endif %}Shared);
{{cpp_class}}* buffer = {{cpp_class}}::Create(contents);
v8::Local<v8::Object> associatedWrapper = buffer->AssociateWithWrapper(v8::Isolate::GetCurrent(), buffer->GetWrapperTypeInfo(), object);
......
......@@ -87,16 +87,13 @@ TestArrayBuffer* V8ArrayBuffer::ToImpl(v8::Local<v8::Object> object) {
default:
NOTREACHED();
};
// TODO(v8:8073): Use specific deallocator per mode once v8 provides information.
WTF::ArrayBufferContents::DataHandle data(v8Contents.AllocationBase(),
v8Contents.AllocationLength(),
v8Contents.Data(),
v8Contents.ByteLength(),
kind,
[](void* buffer, size_t length, void* alloc_data) {
WTF::ArrayBufferContents::FreeMemory(buffer);
},
nullptr);
v8Contents.Deleter(),
v8Contents.DeleterData());
WTF::ArrayBufferContents contents(std::move(data), WTF::ArrayBufferContents::kNotShared);
TestArrayBuffer* buffer = TestArrayBuffer::Create(contents);
v8::Local<v8::Object> associatedWrapper = buffer->AssociateWithWrapper(v8::Isolate::GetCurrent(), buffer->GetWrapperTypeInfo(), object);
......
......@@ -105,7 +105,8 @@ class WTF_EXPORT ArrayBufferContents {
deleter_(data_, data_length_, deleter_info_);
return;
case AllocationKind::kReservation:
base::FreePages(allocation_base_, allocation_length_);
DCHECK(deleter_);
deleter_(data_, data_length_, deleter_info_);
return;
}
}
......
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