diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 296046b..8685668 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -913,6 +913,7 @@ impl<'a> WasmFuncBackend<'a> { Operator::CallRef { sig_index } => { Some(wasm_encoder::Instruction::CallRef(sig_index.index() as u32)) } + Operator::RefIsNull => Some(wasm_encoder::Instruction::RefIsNull), Operator::RefFunc { func_index } => { Some(wasm_encoder::Instruction::RefFunc(func_index.index() as u32)) } diff --git a/src/frontend.rs b/src/frontend.rs index e28af19..ec5c1e0 100644 --- a/src/frontend.rs +++ b/src/frontend.rs @@ -1420,6 +1420,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> { | wasmparser::Operator::F32x4DemoteF64x2Zero | wasmparser::Operator::F64x2PromoteLowF32x4 | wasmparser::Operator::CallRef { .. } + | wasmparser::Operator::RefIsNull | wasmparser::Operator::RefFunc { .. } => { self.emit(Operator::try_from(&op).unwrap(), loc)? } diff --git a/src/op_traits.rs b/src/op_traits.rs index 9cb1a08..56c4bbc 100644 --- a/src/op_traits.rs +++ b/src/op_traits.rs @@ -482,6 +482,7 @@ pub fn op_inputs( params.push(Type::TypedFuncRef(true, sig_index.index() as u32)); Ok(params.into()) } + Operator::RefIsNull => Ok(vec![op_stack.last().unwrap().0].into()), Operator::RefFunc { .. } => Ok(Cow::Borrowed(&[])), } } @@ -945,6 +946,7 @@ pub fn op_outputs( Operator::CallRef { sig_index } => { Ok(Vec::from(module.signatures[*sig_index].returns.clone()).into()) } + Operator::RefIsNull => Ok(Cow::Borrowed(&[Type::I32])), Operator::RefFunc { func_index } => { let ty = module.funcs[*func_index].sig(); Ok(vec![Type::TypedFuncRef(true, ty.index() as u32)].into()) @@ -1415,6 +1417,7 @@ impl Operator { Operator::F64x2PromoteLowF32x4 => &[], Operator::CallRef { .. } => &[All], + Operator::RefIsNull => &[], Operator::RefFunc { .. } => &[], } } @@ -1906,6 +1909,7 @@ impl std::fmt::Display for Operator { Operator::F64x2PromoteLowF32x4 => write!(f, "f64x2promotelowf32x4")?, Operator::CallRef { sig_index } => write!(f, "call_ref<{}>", sig_index)?, + Operator::RefIsNull => write!(f, "ref_is_null")?, Operator::RefFunc { func_index } => write!(f, "ref_func<{}>", func_index)?, } diff --git a/src/ops.rs b/src/ops.rs index b5634c1..2ba7c66 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -634,6 +634,7 @@ pub enum Operator { CallRef { sig_index: Signature, }, + RefIsNull, RefFunc { func_index: Func, }, @@ -1269,6 +1270,7 @@ impl<'a, 'b> std::convert::TryFrom<&'b wasmparser::Operator<'a>> for Operator { &wasmparser::Operator::CallRef { type_index } => Ok(Operator::CallRef { sig_index: Signature::from(type_index), }), + &wasmparser::Operator::RefIsNull => Ok(Operator::RefIsNull), &wasmparser::Operator::RefFunc { function_index } => Ok(Operator::RefFunc { func_index: Func::from(function_index), }),