Skip to content

Commit 456dc36

Browse files
authored
feat: update rusty_v8 (V8 12.9) (#874)
- Fast functions will no longer be able to use `fallback`, instead they should raise exceptions directly - Fast function wasm memory has been removed
1 parent ca92275 commit 456dc36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+592
-705
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
os: macOS-latest
6868
jobs: [lint, test]
6969
windows:
70-
os: windows-2019
70+
os: windows-2022
7171
jobs: [lint, test]
7272
- name: Read job configuration (tag)
7373
uses: cloudposse/github-action-yaml-config-query@main

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
@@ -24,7 +24,7 @@ deno_ops = { version = "0.181.0", path = "./ops" }
2424
serde_v8 = { version = "0.214.0", path = "./serde_v8" }
2525
deno_core_testing = { path = "./testing" }
2626

27-
v8 = { version = "0.103.0", default-features = false }
27+
v8 = { version = "0.104.0", default-features = false }
2828
deno_ast = { version = "=0.40.0", features = ["transpiling"] }
2929
deno_unsync = "0.4.0"
3030
deno_core_icudata = "0.0.73"

core/benches/ops/async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ deno_core::extension!(
2626
],
2727
);
2828

29-
#[op2]
29+
#[op2(fast)]
3030
pub fn op_call_promise_resolver(scope: &mut v8::HandleScope, f: &v8::Function) {
3131
let recv = v8::undefined(scope).into();
3232
f.call(scope, recv, &[]);

core/benches/ops/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn op_string_option_u32(#[string] s: &str) -> Option<u32> {
101101
#[op2(fast)]
102102
pub fn op_local(_s: v8::Local<v8::String>) {}
103103

104-
#[op2]
104+
#[op2(fast)]
105105
pub fn op_local_scope(_scope: &mut v8::HandleScope, _s: v8::Local<v8::String>) {
106106
}
107107

@@ -118,7 +118,7 @@ pub fn op_global_scope(
118118
) {
119119
}
120120

121-
#[op2]
121+
#[op2(fast)]
122122
pub fn op_scope(_scope: &mut v8::HandleScope) {}
123123

124124
#[op2(nofast)]

core/cppgc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<T: GarbageCollected> std::ops::Deref for Ptr<T> {
8888
#[doc(hidden)]
8989
#[allow(clippy::needless_lifetimes)]
9090
pub fn try_unwrap_cppgc_object<'sc, T: GarbageCollected + 'static>(
91-
scope: &mut v8::HandleScope<'sc>,
91+
isolate: &mut v8::Isolate,
9292
val: v8::Local<'sc, v8::Value>,
9393
) -> Option<Ptr<T>> {
9494
let Ok(obj): Result<v8::Local<v8::Object>, _> = val.try_into() else {
@@ -100,7 +100,7 @@ pub fn try_unwrap_cppgc_object<'sc, T: GarbageCollected + 'static>(
100100
}
101101

102102
let obj =
103-
unsafe { v8::Object::unwrap::<CPPGC_TAG, CppGcObject<T>>(scope, obj) }?;
103+
unsafe { v8::Object::unwrap::<CPPGC_TAG, CppGcObject<T>>(isolate, obj) }?;
104104

105105
if obj.tag != TypeId::of::<T>() {
106106
return None;

core/examples/wasm.rs

Lines changed: 0 additions & 77 deletions
This file was deleted.

core/ops.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22

3-
use crate::error::AnyError;
43
use crate::error::GetErrorClassFn;
54
use crate::gotham_state::GothamState;
65
use crate::io::ResourceTable;
@@ -11,7 +10,6 @@ use crate::FeatureChecker;
1110
use crate::OpDecl;
1211
use futures::task::AtomicWaker;
1312
use std::cell::RefCell;
14-
use std::cell::UnsafeCell;
1513
use std::ops::Deref;
1614
use std::ops::DerefMut;
1715
use std::rc::Rc;
@@ -92,8 +90,6 @@ pub struct OpCtx {
9290
pub(crate) decl: OpDecl,
9391
pub(crate) fast_fn_info: Option<CFunction>,
9492
pub(crate) metrics_fn: Option<OpMetricsFn>,
95-
/// If the last fast op failed, stores the error to be picked up by the slow op.
96-
pub(crate) last_fast_error: UnsafeCell<Option<AnyError>>,
9793

9894
op_driver: Rc<OpDriverImpl>,
9995
runtime_state: *const JsRuntimeState,
@@ -129,7 +125,6 @@ impl OpCtx {
129125
decl,
130126
op_driver,
131127
fast_fn_info,
132-
last_fast_error: UnsafeCell::new(None),
133128
isolate,
134129
metrics_fn,
135130
}
@@ -194,32 +189,6 @@ impl OpCtx {
194189
}
195190
}
196191

197-
/// This takes the last error from an [`OpCtx`], assuming that no other code anywhere
198-
/// can hold a `&mut` to the last_fast_error field.
199-
///
200-
/// # Safety
201-
///
202-
/// Must only be called from op implementations.
203-
#[inline(always)]
204-
pub unsafe fn unsafely_take_last_error_for_ops_only(
205-
&self,
206-
) -> Option<AnyError> {
207-
let opt_mut = &mut *self.last_fast_error.get();
208-
opt_mut.take()
209-
}
210-
211-
/// This set the last error for an [`OpCtx`], assuming that no other code anywhere
212-
/// can hold a `&mut` to the last_fast_error field.
213-
///
214-
/// # Safety
215-
///
216-
/// Must only be called from op implementations.
217-
#[inline(always)]
218-
pub unsafe fn unsafely_set_last_error_for_ops_only(&self, error: AnyError) {
219-
let opt_mut = &mut *self.last_fast_error.get();
220-
*opt_mut = Some(error);
221-
}
222-
223192
pub(crate) fn op_driver(&self) -> &OpDriverImpl {
224193
&self.op_driver
225194
}

core/ops_builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ fn op_format_file_name(#[string] file_name: &str) -> String {
378378
format_file_name(file_name)
379379
}
380380

381-
#[op2]
381+
#[op2(fast)]
382382
fn op_str_byte_length(
383383
scope: &mut v8::HandleScope,
384384
value: v8::Local<v8::Value>,

core/ops_builtin_v8.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ pub fn op_set_handled_promise_rejection_handler(
4444
*exception_state.js_handled_promise_rejection_cb.borrow_mut() = f;
4545
}
4646

47-
#[op2]
47+
#[op2(fast)]
4848
pub fn op_ref_op(scope: &mut v8::HandleScope, promise_id: i32) {
4949
let context_state = JsRealm::state_from_scope(scope);
5050
context_state.unrefed_ops.borrow_mut().remove(&promise_id);
5151
}
5252

53-
#[op2]
53+
#[op2(fast)]
5454
pub fn op_unref_op(scope: &mut v8::HandleScope, promise_id: i32) {
5555
let context_state = JsRealm::state_from_scope(scope);
5656
context_state.unrefed_ops.borrow_mut().insert(promise_id);
5757
}
5858

59-
#[op2]
59+
#[op2(fast)]
6060
pub fn op_leak_tracing_enable(scope: &mut v8::HandleScope, enabled: bool) {
6161
let context_state = JsRealm::state_from_scope(scope);
6262
context_state.activity_traces.set_enabled(enabled);
6363
}
6464

65-
#[op2]
65+
#[op2(fast)]
6666
pub fn op_leak_tracing_submit(
6767
scope: &mut v8::HandleScope,
6868
#[smi] kind: u8,
@@ -168,7 +168,7 @@ pub fn op_timer_queue_immediate(
168168
context_state.timers.queue_timer(0, (task, 0)) as _
169169
}
170170

171-
#[op2]
171+
#[op2(fast)]
172172
pub fn op_timer_cancel(scope: &mut v8::HandleScope, id: f64) {
173173
let context_state = JsRealm::state_from_scope(scope);
174174
context_state.timers.cancel_timer(id as _);
@@ -177,13 +177,13 @@ pub fn op_timer_cancel(scope: &mut v8::HandleScope, id: f64) {
177177
.complete(RuntimeActivityType::Timer, id as _);
178178
}
179179

180-
#[op2]
180+
#[op2(fast)]
181181
pub fn op_timer_ref(scope: &mut v8::HandleScope, id: f64) {
182182
let context_state = JsRealm::state_from_scope(scope);
183183
context_state.timers.ref_timer(id as _);
184184
}
185185

186-
#[op2]
186+
#[op2(fast)]
187187
pub fn op_timer_unref(scope: &mut v8::HandleScope, id: f64) {
188188
let context_state = JsRealm::state_from_scope(scope);
189189
context_state.timers.unref_timer(id as _);
@@ -225,14 +225,14 @@ pub fn op_run_microtasks(isolate: *mut v8::Isolate) {
225225
};
226226
}
227227

228-
#[op2]
228+
#[op2(fast)]
229229
pub fn op_has_tick_scheduled(scope: &mut v8::HandleScope) -> bool {
230230
JsRealm::state_from_scope(scope)
231231
.has_next_tick_scheduled
232232
.get()
233233
}
234234

235-
#[op2]
235+
#[op2(fast)]
236236
pub fn op_set_has_tick_scheduled(scope: &mut v8::HandleScope, v: bool) {
237237
JsRealm::state_from_scope(scope)
238238
.has_next_tick_scheduled
@@ -776,7 +776,7 @@ pub fn op_get_promise_details<'a>(
776776
out.into()
777777
}
778778

779-
#[op2]
779+
#[op2(fast)]
780780
pub fn op_set_promise_hooks(
781781
scope: &mut v8::HandleScope,
782782
init_hook: v8::Local<v8::Value>,
@@ -1005,7 +1005,7 @@ pub fn op_destructure_error(
10051005
/// Effectively throw an uncatchable error. This will terminate runtime
10061006
/// execution before any more JS code can run, except in the REPL where it
10071007
/// should just output the error to the console.
1008-
#[op2(reentrant)]
1008+
#[op2(fast, reentrant)]
10091009
pub fn op_dispatch_exception(
10101010
scope: &mut v8::HandleScope,
10111011
exception: v8::Local<v8::Value>,
@@ -1129,7 +1129,7 @@ pub fn op_set_format_exception_callback<'a>(
11291129
old.map(|func| func.into())
11301130
}
11311131

1132-
#[op2]
1132+
#[op2(fast)]
11331133
pub fn op_event_loop_has_more_work(scope: &mut v8::HandleScope) -> bool {
11341134
JsRuntime::has_more_work(scope)
11351135
}

0 commit comments

Comments
 (0)