cranelift: Fix endianness bug in filetests runner
Enabling runtests for the s390x backend exposed a pre-existing endian bug with handling bool test case return values. These are written as integers of the same width by the trampoline, but are always read out as the Rust "bool" type. This happens to work on little-endian systems, but fails for any boolean type larger than 1 byte on big-endian systems. See: https://github.com/bytecodealliance/wasmtime/pull/2964#issuecomment-855879866
This commit is contained in:
@@ -251,7 +251,13 @@ impl UnboxedValues {
|
||||
ir::types::I64 => DataValue::I64(ptr::read(p as *const i64)),
|
||||
ir::types::F32 => DataValue::F32(ptr::read(p as *const Ieee32)),
|
||||
ir::types::F64 => DataValue::F64(ptr::read(p as *const Ieee64)),
|
||||
_ if ty.is_bool() => DataValue::B(ptr::read(p as *const bool)),
|
||||
_ if ty.is_bool() => match ty.bytes() {
|
||||
1 => DataValue::B(ptr::read(p as *const i8) != 0),
|
||||
2 => DataValue::B(ptr::read(p as *const i16) != 0),
|
||||
4 => DataValue::B(ptr::read(p as *const i32) != 0),
|
||||
8 => DataValue::B(ptr::read(p as *const i64) != 0),
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
_ if ty.is_vector() && ty.bytes() == 16 => {
|
||||
DataValue::V128(ptr::read(p as *const [u8; 16]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user