From cb2ca234bb39d8e02b08d2866860e8d3a00b5887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 14 Apr 2023 02:41:32 +0200 Subject: 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 --- core/ops_builtin.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/ops_builtin.rs') diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index 7f9c48e01..2786299bf 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -43,8 +43,6 @@ crate::extension!( op_str_byte_length, ops_builtin_v8::op_ref_op, ops_builtin_v8::op_unref_op, - ops_builtin_v8::op_set_macrotask_callback, - ops_builtin_v8::op_set_next_tick_callback, ops_builtin_v8::op_set_promise_reject_callback, ops_builtin_v8::op_run_microtasks, ops_builtin_v8::op_has_tick_scheduled, @@ -74,6 +72,9 @@ crate::extension!( ops_builtin_v8::op_arraybuffer_was_detached, ], js = ["00_primordials.js", "01_core.js", "02_error.js"], + customizer = |ext: &mut crate::ExtensionBuilder| { + ext.deno_core(); + } ); /// Return map of resources with id as key -- cgit v1.2.3