Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: V8: cherry-pick 9df5ef70ff18 #45474

Merged
merged 2 commits into from Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Expand Up @@ -36,7 +36,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.19',
'v8_embedder_string': '-node.20',

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

Expand Down
1 change: 1 addition & 0 deletions deps/v8/AUTHORS
Expand Up @@ -60,6 +60,7 @@ Allan Sandfeld Jensen <allan.jensen@qt.io>
Amos Lim <eui-sang.lim@samsung.com>
Andreas Anyuru <andreas.anyuru@gmail.com>
Andrei Kashcha <anvaka@gmail.com>
Andreu Botella <andreu@andreubotella.com>
Andrew Paprocki <andrew@ishiboo.com>
Anna Henningsen <anna@addaleax.net>
Antoine du Hamel <duhamelantoine1995@gmail.com>
Expand Down
8 changes: 8 additions & 0 deletions deps/v8/include/v8-array-buffer.h
Expand Up @@ -240,6 +240,11 @@ class V8_EXPORT ArrayBuffer : public Object {
*/
bool IsDetachable() const;

/**
* Returns true if this ArrayBuffer has been detached.
*/
bool WasDetached() const;

/**
* Detaches this ArrayBuffer and all its views (typed arrays).
* Detaching sets the byte length of the buffer and all typed arrays to zero,
Expand All @@ -253,6 +258,9 @@ class V8_EXPORT ArrayBuffer : public Object {
* pointer coordinates the lifetime management of the internal storage
* with any live ArrayBuffers on the heap, even across isolates. The embedder
* should not attempt to manage lifetime of the storage through other means.
*
* The returned shared pointer will not be empty, even if the ArrayBuffer has
* been detached. Use |WasDetached| to tell if it has been detached instead.
*/
std::shared_ptr<BackingStore> GetBackingStore();

Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/api/api.cc
Expand Up @@ -8064,6 +8064,10 @@ bool v8::ArrayBuffer::IsDetachable() const {
return Utils::OpenHandle(this)->is_detachable();
}

bool v8::ArrayBuffer::WasDetached() const {
return Utils::OpenHandle(this)->was_detached();
}

namespace {
std::shared_ptr<i::BackingStore> ToInternal(
std::shared_ptr<i::BackingStoreBase> backing_store) {
Expand Down
1 change: 1 addition & 0 deletions deps/v8/test/cctest/cctest.status
Expand Up @@ -516,6 +516,7 @@
'test-api/WasmI32AtomicWaitCallback': [SKIP],
'test-api/WasmI64AtomicWaitCallback': [SKIP],
'test-api/WasmSetJitCodeEventHandler': [SKIP],
'test-api-array-buffer/ArrayBuffer_NonDetachableWasDetached': [SKIP],
'test-backing-store/Run_WasmModule_Buffer_Externalized_Regression_UseAfterFree': [SKIP],
'test-c-wasm-entry/*': [SKIP],
'test-compilation-cache/*': [SKIP],
Expand Down
31 changes: 31 additions & 0 deletions deps/v8/test/cctest/test-api-array-buffer.cc
Expand Up @@ -245,6 +245,37 @@ THREADED_TEST(ArrayBuffer_DetachingScript) {
CheckDataViewIsDetached(dv);
}

THREADED_TEST(ArrayBuffer_WasDetached) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);

Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 0);
CHECK(!ab->WasDetached());

ab->Detach();
CHECK(ab->WasDetached());
}

THREADED_TEST(ArrayBuffer_NonDetachableWasDetached) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope handle_scope(isolate);

CompileRun(R"JS(
var wasmMemory = new WebAssembly.Memory({initial: 1, maximum: 2});
)JS");

Local<v8::ArrayBuffer> non_detachable =
CompileRun("wasmMemory.buffer").As<v8::ArrayBuffer>();
CHECK(!non_detachable->IsDetachable());
CHECK(!non_detachable->WasDetached());

CompileRun("wasmMemory.grow(1)");
CHECK(!non_detachable->IsDetachable());
CHECK(non_detachable->WasDetached());
}

THREADED_TEST(ArrayBuffer_ExternalizeEmpty) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
Expand Down