summaryrefslogtreecommitdiff
path: root/deps/v8/src/api
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-12-11 17:15:54 +0100
committerMichaël Zasso <targos@protonmail.com>2021-02-11 19:10:38 +0100
commita74b7693e74882b4c754f3b9cfe58a8f4f4fcd7e (patch)
tree6de1c4266da105ee3ada6b2ac48135273d7c1166 /deps/v8/src/api
parent2dad8d43ccf65d6ecb1e7be12da67568aae82627 (diff)
downloadnode-new-a74b7693e74882b4c754f3b9cfe58a8f4f4fcd7e.tar.gz
deps: V8: backport 4bf051d536a1
Original commit message: [api] Add Context::GetMicrotaskQueue method Add a method that returns the microtask queue that is being used by the `v8::Context`. This is helpful in non-monolithic embedders like Node.js, which accept Contexts created by its own embedders like Electron, or for native Node.js addons. In particular, it enables: 1. Making sure that “nested” `Context`s use the correct microtask queue, i.e. the one from the outer Context. 2. Enqueueing microtasks into the correct microtask queue. Previously, these things only worked when the microtask queue for a given Context was the Isolate’s default queue. As an alternative, I considered adding a way to make new `Context`s inherit the queue from the `Context` that was entered at the time of their creation, but that seemed a bit more “magic”, less flexible, and didn’t take care of concern 2 listed above. Change-Id: I15ed796df90f23c97a545a8e1b30a3bf4a5c4320 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2579914 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#71710} Refs: https://github.com/v8/v8/commit/4bf051d536a172e7932845d82f918ad7280c7873 PR-URL: https://github.com/nodejs/node/pull/36482 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'deps/v8/src/api')
-rw-r--r--deps/v8/src/api/api.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc
index a29747da62..66afdb1968 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<Isolate*>(env->GetIsolate());
}
+v8::MicrotaskQueue* Context::GetMicrotaskQueue() {
+ i::Handle<i::Context> env = Utils::OpenHandle(this);
+ CHECK(env->IsNativeContext());
+ return i::Handle<i::NativeContext>::cast(env)->microtask_queue();
+}
+
v8::Local<v8::Object> Context::Global() {
i::Handle<i::Context> context = Utils::OpenHandle(this);
i::Isolate* isolate = context->GetIsolate();