chore: enable microtask queue per window agent (#36870)

* chore: enable microtask queue per window agent

* chore: switch policies on context microtask queue

* fix: ensure node::Environment is valid
This commit is contained in:
Robo 2023-01-12 01:59:32 +09:00 committed by GitHub
parent 2a7d0a84c0
commit fefb22a83d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 115 additions and 54 deletions

View file

@ -9,3 +9,4 @@ fix_disable_implies_dcheck_for_node_stream_array_buffers.patch
revert_runtime_dhceck_terminating_exception_in_microtasks.patch
chore_disable_is_execution_terminating_dcheck.patch
force_cppheapcreateparams_to_be_noncopyable.patch
chore_allow_customizing_microtask_policy_per_context.patch

View file

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Wed, 11 Jan 2023 19:21:06 +0900
Subject: chore: allow customizing microtask policy per context
With https://github.com/electron/electron/issues/36813, microtask queue associated with a context
will be used if available, instead of the default associated with an isolate. We need the
capability to switch the microtask polciy of these per context microtask queue to support
Node.js integration in the renderer.
diff --git a/include/v8-microtask-queue.h b/include/v8-microtask-queue.h
index 85d227fa3fdce6fc29bc4927e30a0171987578ac..1a61190ed3a2aeb440aa774788a469079df13c79 100644
--- a/include/v8-microtask-queue.h
+++ b/include/v8-microtask-queue.h
@@ -97,6 +97,9 @@ class V8_EXPORT MicrotaskQueue {
*/
virtual int GetMicrotasksScopeDepth() const = 0;
+ virtual void set_microtasks_policy(v8::MicrotasksPolicy microtasks_policy) = 0;
+ virtual v8::MicrotasksPolicy microtasks_policy() const = 0;
+
MicrotaskQueue(const MicrotaskQueue&) = delete;
MicrotaskQueue& operator=(const MicrotaskQueue&) = delete;
diff --git a/src/execution/microtask-queue.h b/src/execution/microtask-queue.h
index 6091fa3575cf82ea532e88747c753040045cc9a0..55eee1dcede4daeed53bdc0447cfb714763d0d32 100644
--- a/src/execution/microtask-queue.h
+++ b/src/execution/microtask-queue.h
@@ -91,10 +91,10 @@ class V8_EXPORT_PRIVATE MicrotaskQueue final : public v8::MicrotaskQueue {
}
#endif
- void set_microtasks_policy(v8::MicrotasksPolicy microtasks_policy) {
+ void set_microtasks_policy(v8::MicrotasksPolicy microtasks_policy) override {
microtasks_policy_ = microtasks_policy;
}
- v8::MicrotasksPolicy microtasks_policy() const { return microtasks_policy_; }
+ v8::MicrotasksPolicy microtasks_policy() const override { return microtasks_policy_; }
intptr_t capacity() const { return capacity_; }
intptr_t size() const { return size_; }