Skip to content

Commit 23b075d

Browse files
committed
deps: V8: cherry-pick d3308d0
Original commit message: [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} Refs: v8/v8@d3308d0 PR-URL: #26207 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent b0869c6 commit 23b075d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

deps/v8/include/v8.h

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

7645+
/** Returns the ArrayBuffer::Allocator used in this isolate. */
7646+
ArrayBuffer::Allocator* GetArrayBufferAllocator();
7647+
76457648
/** Returns true if this isolate has a current context. */
76467649
bool InContext();
76477650

deps/v8/src/api.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8007,6 +8007,11 @@ void Isolate::SetIdle(bool is_idle) {
80078007
isolate->SetIdle(is_idle);
80088008
}
80098009

8010+
ArrayBuffer::Allocator* Isolate::GetArrayBufferAllocator() {
8011+
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8012+
return isolate->array_buffer_allocator();
8013+
}
8014+
80108015
bool Isolate::InContext() {
80118016
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
80128017
return isolate->context() != nullptr;

deps/v8/test/cctest/test-api.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20881,6 +20881,7 @@ TEST(IsolateNewDispose) {
2088120881
CHECK_NOT_NULL(isolate);
2088220882
CHECK(current_isolate != isolate);
2088320883
CHECK(current_isolate == CcTest::isolate());
20884+
CHECK(isolate->GetArrayBufferAllocator() == CcTest::array_buffer_allocator());
2088420885

2088520886
isolate->SetFatalErrorHandler(StoringErrorCallback);
2088620887
last_location = last_message = nullptr;

0 commit comments

Comments
 (0)