Commit d3308d04 authored by Anna Henningsen's avatar Anna Henningsen Committed by Commit Bot

[api] Add `Isolate::GetArrayBufferAllocator()`

This allows non-monolithic embedders to always allocate memory
for ArrayBuffer instances using the right allocation method.

This is based on a patch that Electron is currently using.

Refs: https://github.com/electron/electron/blob/1898f9162073910c05958295c612deec6121a892/patches/common/v8/array_buffer.patch
Change-Id: I39a614343118a0594aab48699a99cc2aad5b7ba9
Reviewed-on: https://chromium-review.googlesource.com/c/1462003Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59697}
parent a5b5a3c1
......@@ -7818,6 +7818,9 @@ class V8_EXPORT Isolate {
*/
void SetIdle(bool is_idle);
/** Returns the ArrayBuffer::Allocator used in this isolate. */
ArrayBuffer::Allocator* GetArrayBufferAllocator();
/** Returns true if this isolate has a current context. */
bool InContext();
......
......@@ -7979,6 +7979,11 @@ void Isolate::SetIdle(bool is_idle) {
isolate->SetIdle(is_idle);
}
ArrayBuffer::Allocator* Isolate::GetArrayBufferAllocator() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->array_buffer_allocator();
}
bool Isolate::InContext() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return !isolate->context().is_null();
......
......@@ -19999,6 +19999,7 @@ TEST(IsolateNewDispose) {
CHECK_NOT_NULL(isolate);
CHECK(current_isolate != isolate);
CHECK(current_isolate == CcTest::isolate());
CHECK(isolate->GetArrayBufferAllocator() == CcTest::array_buffer_allocator());
isolate->SetFatalErrorHandler(StoringErrorCallback);
last_location = last_message = nullptr;
......
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