diff --git a/common.gypi b/common.gypi index 2a82642e350028..d81bac25e30fb6 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.15', + 'v8_embedder_string': '-node.16', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 1e3077bbf72eb9..f6426f8edf2bab 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -10494,9 +10494,12 @@ class V8_EXPORT Context { */ void Exit(); - /** Returns an isolate associated with a current context. */ + /** Returns the isolate associated with a current context. */ Isolate* GetIsolate(); + /** Returns the microtask queue associated with a current context. */ + MicrotaskQueue* GetMicrotaskQueue(); + /** * The field at kDebugIdIndex used to be reserved for the inspector. * It now serves no purpose. diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index a29747da62ff4e..66afdb19681517 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -6137,6 +6137,12 @@ v8::Isolate* Context::GetIsolate() { return reinterpret_cast(env->GetIsolate()); } +v8::MicrotaskQueue* Context::GetMicrotaskQueue() { + i::Handle env = Utils::OpenHandle(this); + CHECK(env->IsNativeContext()); + return i::Handle::cast(env)->microtask_queue(); +} + v8::Local Context::Global() { i::Handle context = Utils::OpenHandle(this); i::Isolate* isolate = context->GetIsolate(); diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 3264a1aa3bd528..8c9c81873e9106 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -28804,3 +28804,13 @@ TEST(CodeLikeFunction) { CHECK(CompileRun("new Function(new Other())()").IsEmpty()); ExpectInt32("new Function(new CodeLike())()", 7); } + +THREADED_TEST(MicrotaskQueueOfContext) { + auto microtask_queue = v8::MicrotaskQueue::New(CcTest::isolate()); + v8::HandleScope scope(CcTest::isolate()); + v8::Local context = Context::New( + CcTest::isolate(), nullptr, v8::MaybeLocal(), + v8::MaybeLocal(), v8::DeserializeInternalFieldsCallback(), + microtask_queue.get()); + CHECK_EQ(context->GetMicrotaskQueue(), microtask_queue.get()); +}