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: #25852
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
  • Loading branch information
targos committed Mar 14, 2019
1 parent cf649c9 commit bea1a38
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.2',
'v8_embedder_string': '-node.3',

##### V8 defaults for Node.js #####

Expand Down
3 changes: 3 additions & 0 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -7700,6 +7700,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 @@ -7970,6 +7970,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();
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 @@ -20620,6 +20620,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 bea1a38

Please sign in to comment.