Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 37a86ef

Browse files
committed
feat: upgrade V8 to 136
1 parent ec04024 commit 37a86ef

9 files changed

Lines changed: 90 additions & 86 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ deno_ast = { version = "=0.45.1", features = ["transpiling"] }
2929
deno_core_icudata = "0.74.0"
3030
deno_error = { version = "0.5.6", features = ["serde_json", "serde", "url", "tokio"] }
3131
deno_unsync = "0.4.2"
32-
v8 = { version = "135.1.0", default-features = false }
32+
v8 = { version = "136.0.0", default-features = false }
3333

3434
anyhow = "1"
3535
bencher = "0.1"

core/runtime/jsruntime.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ pub(crate) struct InnerIsolateState {
150150
main_realm: ManuallyDrop<JsRealm>,
151151
pub(crate) state: ManuallyDropRc<JsRuntimeState>,
152152
v8_isolate: ManuallyDrop<v8::OwnedIsolate>,
153-
v8_cpp_heap: ManuallyDrop<v8::UniqueRef<v8::cppgc::Heap>>,
154153
}
155154

156155
impl InnerIsolateState {
@@ -187,23 +186,13 @@ impl InnerIsolateState {
187186
debug_assert_eq!(Rc::strong_count(&self.state), 1);
188187
}
189188

190-
pub fn cleanup_cpp_heap(&mut self) {
191-
self.v8_isolate.detach_cpp_heap();
192-
self.v8_cpp_heap.terminate();
193-
unsafe {
194-
ManuallyDrop::drop(&mut self.v8_cpp_heap);
195-
}
196-
}
197-
198189
pub fn prepare_for_snapshot(mut self) -> v8::OwnedIsolate {
199190
self.cleanup();
200191

201192
// SAFETY: We're copying out of self and then immediately forgetting self
202193
unsafe {
203194
ManuallyDrop::drop(&mut self.state.0);
204195

205-
self.cleanup_cpp_heap();
206-
207196
let isolate = ManuallyDrop::take(&mut self.v8_isolate);
208197

209198
std::mem::forget(self);
@@ -220,8 +209,6 @@ impl Drop for InnerIsolateState {
220209
unsafe {
221210
ManuallyDrop::drop(&mut self.state.0);
222211

223-
self.cleanup_cpp_heap();
224-
225212
if self.will_snapshot {
226213
// Create the snapshot and just drop it.
227214
#[allow(clippy::print_stderr)]
@@ -953,8 +940,6 @@ impl JsRuntime {
953940
maybe_startup_snapshot,
954941
external_refs_static,
955942
);
956-
let mut cpp_heap = setup::create_cpp_heap();
957-
isolate.attach_cpp_heap(&mut cpp_heap);
958943

959944
if state_rc.import_assertions_support.has_warning() {
960945
isolate.add_message_listener_with_error_level(
@@ -1166,7 +1151,6 @@ impl JsRuntime {
11661151
main_realm: ManuallyDrop::new(main_realm),
11671152
state: ManuallyDropRc(ManuallyDrop::new(state_rc)),
11681153
v8_isolate: ManuallyDrop::new(isolate),
1169-
v8_cpp_heap: ManuallyDrop::new(cpp_heap),
11701154
},
11711155
allocations: isolate_allocations,
11721156
files_loaded_from_fs_during_snapshot: vec![],

core/runtime/setup.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ fn v8_init(
8080
});
8181
v8::V8::initialize_platform(v8_platform.clone());
8282
v8::V8::initialize();
83-
84-
v8::cppgc::initialize_process(v8_platform);
8583
}
8684

8785
pub fn init_v8(
@@ -114,13 +112,6 @@ pub fn init_v8(
114112
});
115113
}
116114

117-
pub fn create_cpp_heap() -> v8::UniqueRef<v8::cppgc::Heap> {
118-
v8::cppgc::Heap::create(
119-
v8::V8::get_current_platform(),
120-
v8::cppgc::HeapCreateParams::default(),
121-
)
122-
}
123-
124115
pub fn create_isolate(
125116
will_snapshot: bool,
126117
maybe_create_params: Option<v8::CreateParams>,

core/runtime/tests/ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ fn duplicate_op_names() {
310310
}
311311
}
312312

313+
#[allow(clippy::unnecessary_wraps)]
313314
#[op2]
314315
#[string]
315316
pub fn op_test() -> Result<String, JsErrorBox> {
@@ -332,6 +333,7 @@ fn ops_in_js_have_proper_names() {
332333
Ok(String::from("Test"))
333334
}
334335

336+
#[allow(clippy::unnecessary_wraps)]
335337
#[op2(async)]
336338
#[string]
337339
async fn op_test_async() -> Result<String, JsErrorBox> {

dcore/src/main.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,35 @@ fn main() -> Result<(), Error> {
4949

5050
init_v8_flags(&v8_flags);
5151

52-
let (metrics_summary, mut js_runtime) = if matches.get_flag("strace-ops")
53-
|| matches.get_flag("strace-ops-summary")
54-
{
55-
let (summary, op_metrics_factory_fn) = create_metrics(
56-
matches.get_flag("strace-ops"),
57-
matches.get_flag("strace-ops-summary"),
58-
);
59-
(
60-
Some(summary),
61-
deno_core_testing::create_runtime_from_snapshot_with_options(
62-
SNAPSHOT,
63-
inspector_server.is_some(),
64-
vec![],
65-
RuntimeOptions {
66-
op_metrics_factory_fn: Some(op_metrics_factory_fn),
67-
..Default::default()
68-
},
69-
),
70-
)
71-
} else {
72-
(
73-
None,
74-
create_runtime_from_snapshot(
52+
let (metrics_summary, mut js_runtime, _worker_host_side) =
53+
if matches.get_flag("strace-ops") || matches.get_flag("strace-ops-summary")
54+
{
55+
let (summary, op_metrics_factory_fn) = create_metrics(
56+
matches.get_flag("strace-ops"),
57+
matches.get_flag("strace-ops-summary"),
58+
);
59+
60+
let (runtime, worker_host_side) =
61+
deno_core_testing::create_runtime_from_snapshot_with_options(
62+
SNAPSHOT,
63+
inspector_server.is_some(),
64+
None,
65+
vec![],
66+
RuntimeOptions {
67+
op_metrics_factory_fn: Some(op_metrics_factory_fn),
68+
..Default::default()
69+
},
70+
);
71+
(Some(summary), runtime, worker_host_side)
72+
} else {
73+
let (runtime, worker_host_side) = create_runtime_from_snapshot(
7574
SNAPSHOT,
7675
inspector_server.is_some(),
76+
None,
7777
vec![],
78-
),
79-
)
80-
};
78+
);
79+
(None, runtime, worker_host_side)
80+
};
8181

8282
let runtime = tokio::runtime::Builder::new_current_thread()
8383
.enable_all()
@@ -96,7 +96,7 @@ fn main() -> Result<(), Error> {
9696
);
9797
}
9898

99-
let future = async move {
99+
let future = async {
100100
let mod_id = js_runtime.load_main_es_module(&main_module).await?;
101101
let result = js_runtime.mod_evaluate(mod_id);
102102
js_runtime.run_event_loop(Default::default()).await?;

testing/checkin/runner/mod.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::future::Future;
2222
use std::rc::Rc;
2323
use std::sync::Arc;
2424
use std::sync::Mutex;
25-
use std::sync::OnceLock;
2625
use std::sync::mpsc::RecvTimeoutError;
2726
use std::sync::mpsc::channel;
2827
use std::time::Duration;
@@ -93,40 +92,32 @@ impl TestData {
9392
}
9493
}
9594

96-
pub fn create_runtime(
97-
parent: Option<WorkerCloseWatcher>,
98-
additional_extensions: Vec<Extension>,
99-
) -> (JsRuntime, WorkerHostSide) {
100-
let (worker, worker_host_side) = worker_create(parent);
101-
102-
static SNAPSHOT: OnceLock<Box<[u8]>> = OnceLock::new();
103-
104-
let snapshot = SNAPSHOT.get_or_init(snapshot::create_snapshot);
105-
106-
let runtime =
107-
create_runtime_from_snapshot(snapshot, false, additional_extensions);
108-
runtime.op_state().borrow_mut().put(worker);
109-
(runtime, worker_host_side)
110-
}
111-
11295
pub fn create_runtime_from_snapshot(
11396
snapshot: &'static [u8],
11497
inspector: bool,
98+
parent: Option<WorkerCloseWatcher>,
11599
additional_extensions: Vec<Extension>,
116-
) -> JsRuntime {
100+
) -> (JsRuntime, WorkerHostSide) {
117101
create_runtime_from_snapshot_with_options(
118102
snapshot,
119103
inspector,
104+
parent,
120105
additional_extensions,
121106
RuntimeOptions::default(),
122107
)
123108
}
109+
110+
pub struct Snapshot(&'static [u8]);
111+
124112
pub fn create_runtime_from_snapshot_with_options(
125113
snapshot: &'static [u8],
126114
inspector: bool,
115+
parent: Option<WorkerCloseWatcher>,
127116
additional_extensions: Vec<Extension>,
128117
options: RuntimeOptions,
129-
) -> JsRuntime {
118+
) -> (JsRuntime, WorkerHostSide) {
119+
let (worker, worker_host_side) = worker_create(parent);
120+
130121
let mut extensions = vec![extensions::checkin_runtime::init_ops::<()>()];
131122
extensions.extend(additional_extensions);
132123
let module_loader =
@@ -147,8 +138,10 @@ pub fn create_runtime_from_snapshot_with_options(
147138

148139
let stats = runtime.runtime_activity_stats_factory();
149140
runtime.op_state().borrow_mut().put(stats);
150-
runtime.op_state().borrow_mut().put(Output::default());
151-
runtime
141+
runtime.op_state().borrow_mut().put(worker);
142+
runtime.op_state().borrow_mut().put(Snapshot(snapshot));
143+
144+
(runtime, worker_host_side)
152145
}
153146

154147
fn run_async(f: impl Future<Output = Result<(), anyhow::Error>>) {

testing/checkin/runner/ops_worker.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright 2018-2025 the Deno authors. MIT license.
22

33
use super::Output;
4-
use super::create_runtime;
4+
use super::Snapshot;
5+
use super::create_runtime_from_snapshot;
56
use super::run_async;
67
use anyhow::anyhow;
78
use deno_core::GarbageCollected;
@@ -25,6 +26,7 @@ use tokio::sync::mpsc::unbounded_channel;
2526
use tokio::sync::watch;
2627

2728
/// Our cppgc object.
29+
#[derive(Debug)]
2830
pub struct WorkerControl {
2931
worker_channel: WorkerChannel,
3032
close_watcher: WorkerCloseWatcher,
@@ -34,16 +36,18 @@ pub struct WorkerControl {
3436

3537
impl GarbageCollected for WorkerControl {}
3638

39+
#[derive(Debug)]
3740
pub struct WorkerChannel {
3841
tx: UnboundedSender<String>,
3942
rx: Mutex<UnboundedReceiver<String>>,
4043
}
4144

42-
#[derive(Clone)]
45+
#[derive(Debug, Clone)]
4346
pub struct WorkerCloseWatcher {
4447
watcher: Arc<Mutex<watch::Receiver<bool>>>,
4548
}
4649

50+
#[derive(Debug)]
4751
pub struct Worker {
4852
_close_send: watch::Sender<bool>,
4953
pub(crate) close_watcher: WorkerCloseWatcher,
@@ -92,16 +96,22 @@ pub fn worker_create(
9296
pub fn op_worker_spawn(
9397
#[state] this_worker: &Worker,
9498
#[state] output: &Output,
99+
#[state] snapshot: &Snapshot,
95100
#[string] base_url: String,
96101
#[string] main_script: String,
97102
) -> Result<WorkerControl, std::sync::mpsc::RecvError> {
98103
let output = output.clone();
104+
let snapshot = snapshot.0;
99105
let close_watcher = this_worker.close_watcher.clone();
100106
let (init_send, init_recv) = channel();
101107
let (shutdown_tx, shutdown_rx) = unbounded_channel();
102108
std::thread::spawn(move || {
103-
let (mut runtime, worker_host_side) =
104-
create_runtime(Some(close_watcher), vec![]);
109+
let (mut runtime, worker_host_side) = create_runtime_from_snapshot(
110+
snapshot,
111+
false,
112+
Some(close_watcher),
113+
vec![],
114+
);
105115
runtime.op_state().borrow_mut().put(output.clone());
106116
init_send
107117
.send(WorkerControl {
@@ -147,11 +157,21 @@ async fn run_worker_task(
147157
let state = state.borrow();
148158
let output: &Output = state.borrow();
149159
for line in e.to_string().split('\n') {
160+
println!("[ERR] {line}");
161+
output.line(format!("[ERR] {line}"));
162+
}
163+
return Ok(());
164+
} else if let Err(e) = f.await {
165+
let state = runtime.op_state().clone();
166+
let state = state.borrow();
167+
let output: &Output = state.borrow();
168+
for line in e.to_string().split('\n') {
169+
println!("[ERR] {line}");
150170
output.line(format!("[ERR] {line}"));
151171
}
152172
return Ok(());
153173
}
154-
_ = f.await;
174+
155175
Ok(())
156176
}
157177

0 commit comments

Comments
 (0)