Wasm: Ensure result of ref.is_null is I32

The (r32|r64).is_null instruction yields a boolean type, so we must
convert a Wasm `ref.is_null` to an integer so we don't get verifier
errors.
This commit is contained in:
Ryan Hunt
2019-11-27 14:18:51 -06:00
parent 41f225804b
commit 3b1dda8e92

View File

@@ -975,7 +975,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
Operator::RefIsNull => { Operator::RefIsNull => {
let arg = state.pop1(); let arg = state.pop1();
let val = builder.ins().is_null(arg); let val = builder.ins().is_null(arg);
state.push1(val); let val_int = builder.ins().bint(I32, val);
state.push1(val_int);
} }
Operator::RefFunc { function_index } => { Operator::RefFunc { function_index } => {
state.push1(environ.translate_ref_func(builder.cursor(), *function_index)?); state.push1(environ.translate_ref_func(builder.cursor(), *function_index)?);