summaryrefslogtreecommitdiff
path: root/ops
diff options
context:
space:
mode:
Diffstat (limited to 'ops')
-rw-r--r--ops/fast_call.rs5
-rw-r--r--ops/optimizer.rs14
-rw-r--r--ops/optimizer_tests/unit_result.out1
-rw-r--r--ops/optimizer_tests/unit_result2.out1
4 files changed, 15 insertions, 6 deletions
diff --git a/ops/fast_call.rs b/ops/fast_call.rs
index a7ca51d4f..12ff9e446 100644
--- a/ops/fast_call.rs
+++ b/ops/fast_call.rs
@@ -250,13 +250,14 @@ pub(crate) fn generate(
//
// V8 calls the slow path so we can take the slot
// value and throw.
- let result_wrap = q!(Vars { op_state }, {
+ let default = optimizer.fast_result.as_ref().unwrap().default_value();
+ let result_wrap = q!(Vars { op_state, default }, {
match result {
Ok(result) => result,
Err(err) => {
op_state.last_fast_op_error.replace(err);
__opts.fallback = true;
- Default::default()
+ default
}
}
});
diff --git a/ops/optimizer.rs b/ops/optimizer.rs
index a3ccd51b3..115011008 100644
--- a/ops/optimizer.rs
+++ b/ops/optimizer.rs
@@ -217,8 +217,8 @@ fn get_fast_scalar(s: &str) -> Option<FastValue> {
"bool" => Some(FastValue::Bool),
"u32" => Some(FastValue::U32),
"i32" => Some(FastValue::I32),
- "u64" => Some(FastValue::U64),
- "i64" => Some(FastValue::I64),
+ "u64" | "usize" => Some(FastValue::U64),
+ "i64" | "isize" => Some(FastValue::I64),
"f32" => Some(FastValue::F32),
"f64" => Some(FastValue::F64),
"* const c_void" | "* mut c_void" => Some(FastValue::Pointer),
@@ -254,6 +254,16 @@ pub(crate) enum FastValue {
Float64Array,
}
+impl FastValue {
+ pub fn default_value(&self) -> Quote {
+ match self {
+ FastValue::Pointer => q!({ ::std::ptr::null_mut() }),
+ FastValue::Void => q!({}),
+ _ => q!({ Default::default() }),
+ }
+ }
+}
+
impl Default for FastValue {
fn default() -> Self {
Self::Void
diff --git a/ops/optimizer_tests/unit_result.out b/ops/optimizer_tests/unit_result.out
index f9d1e0c34..f4e87ffa3 100644
--- a/ops/optimizer_tests/unit_result.out
+++ b/ops/optimizer_tests/unit_result.out
@@ -107,7 +107,6 @@ fn op_unit_result_fast_fn<'scope>(
Err(err) => {
op_state.last_fast_op_error.replace(err);
__opts.fallback = true;
- Default::default()
}
}
}
diff --git a/ops/optimizer_tests/unit_result2.out b/ops/optimizer_tests/unit_result2.out
index e297befcb..d1df0e041 100644
--- a/ops/optimizer_tests/unit_result2.out
+++ b/ops/optimizer_tests/unit_result2.out
@@ -142,7 +142,6 @@ fn op_set_nodelay_fast_fn<'scope>(
Err(err) => {
state.last_fast_op_error.replace(err);
__opts.fallback = true;
- Default::default()
}
}
}