cranelift-wasm: Allow more customization of ref type representations

* Allow different Cranelift IR types to be used for different Wasm reference
  types.

* Do not assume that all Wasm reference types are always a Cranelift IR
  reference type. For example, `funcref`s might not need GC in some
  implementations, and can therefore be represented with a pointer rather than a
  reference type.
This commit is contained in:
Nick Fitzgerald
2020-06-23 15:19:22 -07:00
parent 28fccaedc4
commit 03165e0cb5
5 changed files with 54 additions and 13 deletions

View File

@@ -196,8 +196,7 @@ fn declare_locals<FE: FuncEnvironment + ?Sized>(
let constant_handle = builder.func.dfg.constants.insert([0; 16].to_vec().into());
builder.ins().vconst(ir::types::I8X16, constant_handle)
}
ExternRef => builder.ins().null(environ.reference_type()),
FuncRef => builder.ins().null(environ.reference_type()),
ExternRef | FuncRef => environ.translate_ref_null(builder.cursor(), wasm_type)?,
ty => return Err(wasm_unsupported!("unsupported local type {:?}", ty)),
};