Skip to content

Commit

Permalink
Implement the ref.eq Wasm GC instruction (#9392)
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen authored Oct 7, 2024
1 parent 623a821 commit b0e0559
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 8 additions & 3 deletions crates/cranelift/src/translate/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2723,17 +2723,22 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let (array, index, elem) = state.pop3();
environ.translate_array_set(builder, array_type_index, array, index, elem)?;
}
Operator::RefEq => {
let (r1, r2) = state.pop2();
let eq = builder.ins().icmp(ir::condcodes::IntCC::Equal, r1, r2);
let eq = builder.ins().uextend(ir::types::I32, eq);
state.push1(eq);
}

Operator::RefEq
| Operator::RefTestNonNull { .. }
Operator::RefTestNonNull { .. }
| Operator::RefTestNullable { .. }
| Operator::RefCastNonNull { .. }
| Operator::RefCastNullable { .. }
| Operator::BrOnCast { .. }
| Operator::BrOnCastFail { .. }
| Operator::AnyConvertExtern
| Operator::ExternConvertAny => {
return Err(wasm_unsupported!("GC operators are not yet implemented"));
return Err(wasm_unsupported!("GC operator not yet implemented: {op:?}"));
}

Operator::GlobalAtomicGet { .. }
Expand Down
1 change: 0 additions & 1 deletion tests/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ fn should_fail(test: &Path, strategy: Strategy) -> bool {
"br_on_cast.wast",
"extern.wast",
"ref_cast.wast",
"ref_eq.wast",
"ref_test.wast",
"table_sub.wast",
"type_canon.wast",
Expand Down

0 comments on commit b0e0559

Please sign in to comment.