Skip to content

Commit

Permalink
deps: V8: cherry-pick d3308d0
Browse files Browse the repository at this point in the history
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: nodejs#26207
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
addaleax committed Feb 28, 2019
1 parent 68accb5 commit ce5da3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -7717,6 +7717,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();

Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8084,6 +8084,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() != nullptr;
Expand Down
1 change: 1 addition & 0 deletions deps/v8/test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20773,6 +20773,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;
Expand Down

0 comments on commit ce5da3f

Please sign in to comment.