From bea1a386a32afa2879622450549886b0e0bdeead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 4 Mar 2019 13:27:39 +0100 Subject: [PATCH] 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 Commit-Queue: Yang Guo Cr-Commit-Position: refs/heads/master@{#59697} Refs: https://github.com/v8/v8/commit/d3308d042c9637958491333831c33335ab9fc734 PR-URL: https://github.com/nodejs/node/pull/25852 Reviewed-By: Ujjwal Sharma Reviewed-By: Matteo Collina Reviewed-By: Ali Ijaz Sheikh --- common.gypi | 2 +- deps/v8/include/v8.h | 3 +++ deps/v8/src/api.cc | 5 +++++ deps/v8/test/cctest/test-api.cc | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index 74410fce11c8f0..4b108b44679974 100644 --- a/common.gypi +++ b/common.gypi @@ -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 ##### diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index b23114f4ff8bfa..97e3584d0befe1 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -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(); diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 77e7db3e3f17dd..85306decd7d764 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -7970,6 +7970,11 @@ void Isolate::SetIdle(bool is_idle) { isolate->SetIdle(is_idle); } +ArrayBuffer::Allocator* Isolate::GetArrayBufferAllocator() { + i::Isolate* isolate = reinterpret_cast(this); + return isolate->array_buffer_allocator(); +} + bool Isolate::InContext() { i::Isolate* isolate = reinterpret_cast(this); return !isolate->context().is_null(); diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 236c1f20ebd3d6..6615f1583a21c4 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -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;