diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-04-14 02:41:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 02:41:32 +0200 |
commit | cb2ca234bb39d8e02b08d2866860e8d3a00b5887 (patch) | |
tree | 660044dbb6f6ce62c3f542ade150788870e483a5 /core/extensions.rs | |
parent | d192d84a0e0b9954882211b827f17512ad37be7d (diff) |
refactor(core): limit number of boundary crossings between Rust and V8 (#18652)
This commit refactors "deno_core" to do fewer boundary crossings
from Rust to V8. In other words we are now calling V8 from Rust fewer
times.
This is done by merging 3 distinct callbacks into a single one. Instead
of having "op resolve" callback, "next tick" callback and "macrotask
queue" callback, we now have only "Deno.core.eventLoopTick" callback,
which is responsible for doing the same actions previous 3 callbacks.
On each of the event loop we were doing at least 2 boundary crosses
(timers macrotask queue callback and unhandled promise rejection
callback) and up to 4 crosses if there were op response and next tick
callbacks coming from Node.js compatibility layer. Now this is all done
in a single callback.
Closes https://github.com/denoland/deno/issues/18620
Diffstat (limited to 'core/extensions.rs')
-rw-r--r-- | core/extensions.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/extensions.rs b/core/extensions.rs index 685ac0ab7..02cff1a23 100644 --- a/core/extensions.rs +++ b/core/extensions.rs @@ -348,6 +348,7 @@ pub struct Extension { name: &'static str, deps: Option<&'static [&'static str]>, force_op_registration: bool, + pub(crate) is_core: bool, } // Note: this used to be a trait, but we "downgraded" it to a single concrete type @@ -472,6 +473,7 @@ pub struct ExtensionBuilder { name: &'static str, deps: &'static [&'static str], force_op_registration: bool, + is_core: bool, } impl ExtensionBuilder { @@ -547,6 +549,7 @@ impl ExtensionBuilder { name: self.name, force_op_registration: self.force_op_registration, deps, + is_core: self.is_core, } } @@ -568,8 +571,15 @@ impl ExtensionBuilder { name: self.name, deps, force_op_registration: self.force_op_registration, + is_core: self.is_core, } } + + #[doc(hidden)] + pub(crate) fn deno_core(&mut self) -> &mut Self { + self.is_core = true; + self + } } /// Helps embed JS files in an extension. Returns a vector of |