Skip to content

Commit d3308d0

Browse files
addaleaxCommit Bot
authored andcommitted
[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/1462003 Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#59697}
1 parent a5b5a3c commit d3308d0

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

include/v8.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7818,6 +7818,9 @@ class V8_EXPORT Isolate {
78187818
*/
78197819
void SetIdle(bool is_idle);
78207820

7821+
/** Returns the ArrayBuffer::Allocator used in this isolate. */
7822+
ArrayBuffer::Allocator* GetArrayBufferAllocator();
7823+
78217824
/** Returns true if this isolate has a current context. */
78227825
bool InContext();
78237826

src/api.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7979,6 +7979,11 @@ void Isolate::SetIdle(bool is_idle) {
79797979
isolate->SetIdle(is_idle);
79807980
}
79817981

7982+
ArrayBuffer::Allocator* Isolate::GetArrayBufferAllocator() {
7983+
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
7984+
return isolate->array_buffer_allocator();
7985+
}
7986+
79827987
bool Isolate::InContext() {
79837988
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
79847989
return !isolate->context().is_null();

test/cctest/test-api.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19999,6 +19999,7 @@ TEST(IsolateNewDispose) {
1999919999
CHECK_NOT_NULL(isolate);
2000020000
CHECK(current_isolate != isolate);
2000120001
CHECK(current_isolate == CcTest::isolate());
20002+
CHECK(isolate->GetArrayBufferAllocator() == CcTest::array_buffer_allocator());
2000220003

2000320004
isolate->SetFatalErrorHandler(StoringErrorCallback);
2000420005
last_location = last_message = nullptr;

0 commit comments

Comments
 (0)