summaryrefslogtreecommitdiff
path: root/ops/optimizer.rs
diff options
context:
space:
mode:
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),
}
}