diff --git a/common.gypi b/common.gypi index 00f545ba6aaa8b..96d7ebe61acfeb 100644 --- a/common.gypi +++ b/common.gypi @@ -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.16', + 'v8_embedder_string': '-node.20', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 82405e4824ab4f..d645c36544d18c 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -59,6 +59,7 @@ Allan Sandfeld Jensen Amos Lim Andreas Anyuru Andrei Kashcha +Andreu Botella Andrew Paprocki Anna Henningsen Antoine du Hamel diff --git a/deps/v8/include/v8-array-buffer.h b/deps/v8/include/v8-array-buffer.h index bab840f82c1a3d..cc5d2d4323000a 100644 --- a/deps/v8/include/v8-array-buffer.h +++ b/deps/v8/include/v8-array-buffer.h @@ -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, @@ -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 GetBackingStore(); diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 580ba47f1a727d..8d224bea2e2261 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -7917,6 +7917,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 ToInternal( std::shared_ptr backing_store) { diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index b46a64e2cc91ce..5e3f48e19e383a 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -581,6 +581,7 @@ 'test-api/WasmSetJitCodeEventHandler': [SKIP], 'test-api-wasm/WasmStreaming*': [SKIP], 'test-api-wasm/WasmCompileToWasmModuleObject': [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], diff --git a/deps/v8/test/cctest/test-api-array-buffer.cc b/deps/v8/test/cctest/test-api-array-buffer.cc index b087274b31137d..dff69296908cca 100644 --- a/deps/v8/test/cctest/test-api-array-buffer.cc +++ b/deps/v8/test/cctest/test-api-array-buffer.cc @@ -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 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 non_detachable = + CompileRun("wasmMemory.buffer").As(); + 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();