Use ConstantData exclusively for inserting data into the constant pool

Previously we allowed anything that could be converted into ConstantData (e.g. a Vec).
This commit is contained in:
Andrew Brown
2019-10-11 09:26:08 -07:00
parent a69b0fc221
commit 67733bd2fc
5 changed files with 30 additions and 28 deletions

View File

@@ -998,7 +998,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
return Err(wasm_unsupported!("proposed bulk memory operator {:?}", op));
}
Operator::V128Const { value } => {
let handle = builder.func.dfg.constants.insert(value.bytes().to_vec());
let data = value.bytes().to_vec().into();
let handle = builder.func.dfg.constants.insert(data);
let value = builder.ins().vconst(I8X16, handle);
// the v128.const is typed in CLIF as a I8x16 but raw_bitcast to a different type before use
state.push1(value)

View File

@@ -189,7 +189,7 @@ fn declare_locals<FE: FuncEnvironment + ?Sized>(
F32 => builder.ins().f32const(ir::immediates::Ieee32::with_bits(0)),
F64 => builder.ins().f64const(ir::immediates::Ieee64::with_bits(0)),
V128 => {
let constant_handle = builder.func.dfg.constants.insert([0; 16].to_vec());
let constant_handle = builder.func.dfg.constants.insert([0; 16].to_vec().into());
builder.ins().vconst(ir::types::I8X16, constant_handle)
}
AnyRef => builder.ins().null(environ.reference_type()),