summaryrefslogtreecommitdiff
path: root/ops/optimizer.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-02-17 18:48:09 +0530
committerGitHub <noreply@github.com>2023-02-17 18:48:09 +0530
commitf8435d20b0e9408e50bfb24793becc0e476cc285 (patch)
tree221044e2b0dbc7bbabe0f12412ddedeb4daf4851 /ops/optimizer.rs
parent7ce1a68637840c5800d48abf275f4385c80f5658 (diff)
feat(ext/node): implement `node:v8` (#17806)
Closes https://github.com/denoland/deno/issues/17115 Implements `cachedDataVersionTag` and `getHeapStatistics`.
Diffstat (limited to 'ops/optimizer.rs')
-rw-r--r--ops/optimizer.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/ops/optimizer.rs b/ops/optimizer.rs
index 7c19a7cfd..ae3175511 100644
--- a/ops/optimizer.rs
+++ b/ops/optimizer.rs
@@ -43,6 +43,7 @@ enum TransformKind {
V8Value,
SliceU32(bool),
SliceU8(bool),
+ SliceF64(bool),
PtrU8,
WasmMemory,
}
@@ -69,6 +70,13 @@ impl Transform {
}
}
+ fn slice_f64(index: usize, is_mut: bool) -> Self {
+ Transform {
+ kind: TransformKind::SliceF64(is_mut),
+ index,
+ }
+ }
+
fn wasm_memory(index: usize) -> Self {
Transform {
kind: TransformKind::WasmMemory,
@@ -150,6 +158,20 @@ impl Transform {
unsafe { (&*var).get_storage_if_aligned().unwrap_unchecked() };
})
}
+ TransformKind::SliceF64(_) => {
+ *ty =
+ parse_quote! { *const #core::v8::fast_api::FastApiTypedArray<f64> };
+
+ q!(Vars { var: &ident }, {
+ let var = match unsafe { &*var }.get_storage_if_aligned() {
+ Some(v) => v,
+ None => {
+ unsafe { &mut *fast_api_callback_options }.fallback = true;
+ return Default::default();
+ }
+ };
+ })
+ }
TransformKind::WasmMemory => {
// Note: `ty` is correctly set to __opts by the fast call tier.
// U8 slice is always byte-aligned.
@@ -214,6 +236,7 @@ pub(crate) enum FastValue {
V8Value,
Uint8Array,
Uint32Array,
+ Float64Array,
}
impl Default for FastValue {
@@ -620,6 +643,15 @@ impl Optimizer {
.insert(index, Transform::slice_u32(index, is_mut_ref))
.is_none());
}
+ // Is `T` a f64?
+ PathSegment { ident, .. } if ident == "f64" => {
+ self.needs_fast_callback_option = true;
+ self.fast_parameters.push(FastValue::Float64Array);
+ assert!(self
+ .transforms
+ .insert(index, Transform::slice_f64(index, is_mut_ref))
+ .is_none());
+ }
_ => return Err(BailoutReason::FastUnsupportedParamType),
}
}