973: Add sign extension spec tests; add sign extension to singlepass r=nlewycky a=MarkMcCaskey

Adds missing spectests from official repo, implements instructions for singlepass

# Review

- [ ] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <5770194+markmccaskey@users.noreply.github.com>
This commit is contained in:
bors[bot]
2019-11-18 22:16:49 +00:00
committed by GitHub
5 changed files with 235 additions and 79 deletions

View File

@ -662,32 +662,34 @@ impl X64FunctionCode {
sz_dst: Size, sz_dst: Size,
dst: Location, dst: Location,
) { ) {
let tmp_src = m.acquire_temp_gpr().unwrap(); let inner = |m: &mut Machine, a: &mut Assembler, src: Location| match dst {
let tmp_dst = m.acquire_temp_gpr().unwrap();
match src {
Location::Imm32(_) | Location::Imm64(_) => {
a.emit_mov(Size::S64, src, Location::GPR(tmp_src));
src = Location::GPR(tmp_src);
}
Location::Memory(_, _) | Location::GPR(_) => {}
_ => unreachable!(),
}
match dst {
Location::Imm32(_) | Location::Imm64(_) => unreachable!(), Location::Imm32(_) | Location::Imm64(_) => unreachable!(),
Location::Memory(_, _) => { Location::Memory(_, _) => {
let tmp_dst = m.acquire_temp_gpr().unwrap();
op(a, sz_src, src, sz_dst, Location::GPR(tmp_dst)); op(a, sz_src, src, sz_dst, Location::GPR(tmp_dst));
a.emit_mov(Size::S64, Location::GPR(tmp_dst), dst); a.emit_mov(Size::S64, Location::GPR(tmp_dst), dst);
m.release_temp_gpr(tmp_dst);
} }
Location::GPR(_) => { Location::GPR(_) => {
op(a, sz_src, src, sz_dst, dst); op(a, sz_src, src, sz_dst, dst);
} }
_ => unreachable!(), _ => unreachable!(),
} };
m.release_temp_gpr(tmp_dst); match src {
m.release_temp_gpr(tmp_src); Location::Imm32(_) | Location::Imm64(_) => {
let tmp_src = m.acquire_temp_gpr().unwrap();
a.emit_mov(Size::S64, src, Location::GPR(tmp_src));
src = Location::GPR(tmp_src);
inner(m, a, src);
m.release_temp_gpr(tmp_src);
}
Location::GPR(_) | Location::Memory(_, _) => inner(m, a, src),
_ => unreachable!(),
}
} }
/// Moves `src` and `dst` to valid locations for generic instructions. /// Moves `src` and `dst` to valid locations for generic instructions.
@ -2952,6 +2954,106 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
ret, ret,
); );
} }
Operator::I32Extend8S => {
let loc =
get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let ret = self.machine.acquire_locations(
a,
&[(WpType::I32, MachineValue::WasmStack(self.value_stack.len()))],
false,
)[0];
self.value_stack.push(ret);
Self::emit_relaxed_zx_sx(
a,
&mut self.machine,
Assembler::emit_movsx,
Size::S8,
loc,
Size::S32,
ret,
);
}
Operator::I32Extend16S => {
let loc =
get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let ret = self.machine.acquire_locations(
a,
&[(WpType::I32, MachineValue::WasmStack(self.value_stack.len()))],
false,
)[0];
self.value_stack.push(ret);
Self::emit_relaxed_zx_sx(
a,
&mut self.machine,
Assembler::emit_movsx,
Size::S16,
loc,
Size::S32,
ret,
);
}
Operator::I64Extend8S => {
let loc =
get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let ret = self.machine.acquire_locations(
a,
&[(WpType::I64, MachineValue::WasmStack(self.value_stack.len()))],
false,
)[0];
self.value_stack.push(ret);
Self::emit_relaxed_zx_sx(
a,
&mut self.machine,
Assembler::emit_movsx,
Size::S8,
loc,
Size::S64,
ret,
);
}
Operator::I64Extend16S => {
let loc =
get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let ret = self.machine.acquire_locations(
a,
&[(WpType::I64, MachineValue::WasmStack(self.value_stack.len()))],
false,
)[0];
self.value_stack.push(ret);
Self::emit_relaxed_zx_sx(
a,
&mut self.machine,
Assembler::emit_movsx,
Size::S16,
loc,
Size::S64,
ret,
);
}
Operator::I64Extend32S => {
let loc =
get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let ret = self.machine.acquire_locations(
a,
&[(WpType::I64, MachineValue::WasmStack(self.value_stack.len()))],
false,
)[0];
self.value_stack.push(ret);
Self::emit_relaxed_zx_sx(
a,
&mut self.machine,
Assembler::emit_movsx,
Size::S32,
loc,
Size::S64,
ret,
);
}
Operator::I32WrapI64 => { Operator::I32WrapI64 => {
let loc = let loc =
get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap()); get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());

View File

@ -1,6 +1,11 @@
(module (module
(func (export "i64.extend_i32_s") (param $x i32) (result i64) (i64.extend_i32_s (local.get $x))) (func (export "i64.extend_i32_s") (param $x i32) (result i64) (i64.extend_i32_s (local.get $x)))
(func (export "i64.extend_i32_u") (param $x i32) (result i64) (i64.extend_i32_u (local.get $x))) (func (export "i64.extend_i32_u") (param $x i32) (result i64) (i64.extend_i32_u (local.get $x)))
(func (export "i64.extend32_s") (param $x i64) (result i64) (i64.extend32_s (local.get $x)))
(func (export "i64.extend16_s") (param $x i64) (result i64) (i64.extend16_s (local.get $x)))
(func (export "i64.extend8_s") (param $x i64) (result i64) (i64.extend8_s (local.get $x)))
(func (export "i32.extend16_s") (param $x i32) (result i32) (i32.extend16_s (local.get $x)))
(func (export "i32.extend8_s") (param $x i32) (result i32) (i32.extend8_s (local.get $x)))
(func (export "i32.wrap_i64") (param $x i64) (result i32) (i32.wrap_i64 (local.get $x))) (func (export "i32.wrap_i64") (param $x i64) (result i32) (i32.wrap_i64 (local.get $x)))
(func (export "i32.trunc_f32_s") (param $x f32) (result i32) (i32.trunc_f32_s (local.get $x))) (func (export "i32.trunc_f32_s") (param $x f32) (result i32) (i32.trunc_f32_s (local.get $x)))
(func (export "i32.trunc_f32_u") (param $x f32) (result i32) (i32.trunc_f32_u (local.get $x))) (func (export "i32.trunc_f32_u") (param $x f32) (result i32) (i32.trunc_f32_u (local.get $x)))
@ -497,3 +502,46 @@
(assert_invalid (module (func (result f64) (f64.convert_i64_u (i32.const 0)))) "type mismatch") (assert_invalid (module (func (result f64) (f64.convert_i64_u (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result f64) (f64.promote_f32 (i32.const 0)))) "type mismatch") (assert_invalid (module (func (result f64) (f64.promote_f32 (i32.const 0)))) "type mismatch")
(assert_invalid (module (func (result f64) (f64.reinterpret_i64 (i32.const 0)))) "type mismatch") (assert_invalid (module (func (result f64) (f64.reinterpret_i64 (i32.const 0)))) "type mismatch")
(assert_return (invoke "i32.extend8_s" (i32.const 0)) (i32.const 0))
(assert_return (invoke "i32.extend8_s" (i32.const 0x7f)) (i32.const 127))
(assert_return (invoke "i32.extend8_s" (i32.const 0x80)) (i32.const -128))
(assert_return (invoke "i32.extend8_s" (i32.const 0xff)) (i32.const -1))
(assert_return (invoke "i32.extend8_s" (i32.const 0x012345_00)) (i32.const 0))
(assert_return (invoke "i32.extend8_s" (i32.const 0xfedcba_80)) (i32.const -0x80))
(assert_return (invoke "i32.extend8_s" (i32.const -1)) (i32.const -1))
(assert_return (invoke "i32.extend16_s" (i32.const 0)) (i32.const 0))
(assert_return (invoke "i32.extend16_s" (i32.const 0x7fff)) (i32.const 32767))
(assert_return (invoke "i32.extend16_s" (i32.const 0x8000)) (i32.const -32768))
(assert_return (invoke "i32.extend16_s" (i32.const 0xffff)) (i32.const -1))
(assert_return (invoke "i32.extend16_s" (i32.const 0x0123_0000)) (i32.const 0))
(assert_return (invoke "i32.extend16_s" (i32.const 0xfedc_8000)) (i32.const -0x8000))
(assert_return (invoke "i32.extend16_s" (i32.const -1)) (i32.const -1))
(assert_return (invoke "i64.extend8_s" (i64.const 0)) (i64.const 0))
(assert_return (invoke "i64.extend8_s" (i64.const 0x7f)) (i64.const 127))
(assert_return (invoke "i64.extend8_s" (i64.const 0x80)) (i64.const -128))
(assert_return (invoke "i64.extend8_s" (i64.const 0xff)) (i64.const -1))
(assert_return (invoke "i64.extend8_s" (i64.const 0x01234567_89abcd_00)) (i64.const 0))
(assert_return (invoke "i64.extend8_s" (i64.const 0xfedcba98_765432_80)) (i64.const -0x80))
(assert_return (invoke "i64.extend8_s" (i64.const -1)) (i64.const -1))
(assert_return (invoke "i64.extend16_s" (i64.const 0)) (i64.const 0))
(assert_return (invoke "i64.extend16_s" (i64.const 0x7fff)) (i64.const 32767))
(assert_return (invoke "i64.extend16_s" (i64.const 0x8000)) (i64.const -32768))
(assert_return (invoke "i64.extend16_s" (i64.const 0xffff)) (i64.const -1))
(assert_return (invoke "i64.extend16_s" (i64.const 0x12345678_9abc_0000)) (i64.const 0))
(assert_return (invoke "i64.extend16_s" (i64.const 0xfedcba98_7654_8000)) (i64.const -0x8000))
(assert_return (invoke "i64.extend16_s" (i64.const -1)) (i64.const -1))
(assert_return (invoke "i64.extend32_s" (i64.const 0)) (i64.const 0))
(assert_return (invoke "i64.extend32_s" (i64.const 0x7fff)) (i64.const 32767))
(assert_return (invoke "i64.extend32_s" (i64.const 0x8000)) (i64.const 32768))
(assert_return (invoke "i64.extend32_s" (i64.const 0xffff)) (i64.const 65535))
(assert_return (invoke "i64.extend32_s" (i64.const 0x7fffffff)) (i64.const 0x7fffffff))
(assert_return (invoke "i64.extend32_s" (i64.const 0x80000000)) (i64.const -0x80000000))
(assert_return (invoke "i64.extend32_s" (i64.const 0xffffffff)) (i64.const -1))
(assert_return (invoke "i64.extend32_s" (i64.const 0x01234567_00000000)) (i64.const 0))
(assert_return (invoke "i64.extend32_s" (i64.const 0xfedcba98_80000000)) (i64.const -0x80000000))
(assert_return (invoke "i64.extend32_s" (i64.const -1)) (i64.const -1))

View File

@ -396,73 +396,73 @@ singlepass:fail:call_indirect.wast:493 # AssertTrap - expected trap, got Runtime
singlepass:fail:call_indirect.wast:494 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:call_indirect.wast:494 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:call_indirect.wast:500 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:call_indirect.wast:500 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:call_indirect.wast:501 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:call_indirect.wast:501 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:70 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:71 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:72 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:73 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:74 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:75 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:75 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:76 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:76 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:77 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:77 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:92 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:78 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:93 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:79 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:94 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:80 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:95 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:81 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:96 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:82 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:97 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:97 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:98 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:98 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:99 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:99 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:115 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:100 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:116 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:101 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:117 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:102 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:118 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:103 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:119 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:104 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:120 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:120 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:121 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:121 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:122 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:122 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:138 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:123 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:139 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:124 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:140 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:125 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:141 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:126 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:142 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:127 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:143 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:143 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:144 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:144 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:145 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:145 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:146 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:146 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:147 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:147 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:148 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:148 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:166 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:149 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:167 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:150 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:168 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:151 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:169 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:152 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:170 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:153 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:171 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:171 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:172 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:172 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:173 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:173 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:186 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:174 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:187 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:175 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:188 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:176 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:189 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:177 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:190 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:178 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:191 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:191 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:192 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:192 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:193 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:193 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:211 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:194 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:212 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:195 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:213 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:196 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:214 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:197 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:215 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:198 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:216 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:216 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:217 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:217 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:218 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:218 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:235 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:219 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:236 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:220 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:237 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:221 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:238 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:222 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:239 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:223 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:240 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:240 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:241 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:241 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:242 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:conversions.wast:242 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:243 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:244 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:245 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:246 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:conversions.wast:247 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:elem.wast:353 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:elem.wast:353 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:func_ptrs.wast:78 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:func_ptrs.wast:78 # AssertTrap - expected trap, got Runtime:Error unknown error
singlepass:fail:func_ptrs.wast:79 # AssertTrap - expected trap, got Runtime:Error unknown error singlepass:fail:func_ptrs.wast:79 # AssertTrap - expected trap, got Runtime:Error unknown error

View File

@ -186,6 +186,7 @@ mod tests {
let mut features = wabt::Features::new(); let mut features = wabt::Features::new();
features.enable_simd(); features.enable_simd();
features.enable_threads(); features.enable_threads();
features.enable_sign_extension();
let mut parser: ScriptParser = let mut parser: ScriptParser =
ScriptParser::from_source_and_name_with_features(&source, filename, features) ScriptParser::from_source_and_name_with_features(&source, filename, features)
.expect(&format!("Failed to parse script {}", &filename)); .expect(&format!("Failed to parse script {}", &filename));

View File

@ -96,6 +96,29 @@ struct PrestandardFeatures {
all: bool, all: bool,
} }
impl PrestandardFeatures {
/// Generate [`wabt::Features`] struct from CLI options
pub fn into_wabt_features(&self) -> wabt::Features {
let mut features = wabt::Features::new();
if self.simd || self.all {
features.enable_simd();
}
if self.threads || self.all {
features.enable_threads();
}
features.enable_sign_extension();
features
}
/// Generate [`Features`] struct from CLI options
pub fn into_backend_features(&self) -> Features {
Features {
simd: self.simd || self.all,
threads: self.threads || self.all,
}
}
}
#[cfg(feature = "backend-llvm")] #[cfg(feature = "backend-llvm")]
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt, Clone)]
/// LLVM backend flags. /// LLVM backend flags.
@ -393,13 +416,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
} }
if !utils::is_wasm_binary(&wasm_binary) { if !utils::is_wasm_binary(&wasm_binary) {
let mut features = wabt::Features::new(); let features = options.features.into_wabt_features();
if options.features.simd || options.features.all {
features.enable_simd();
}
if options.features.threads || options.features.all {
features.enable_threads();
}
wasm_binary = wabt::wat2wasm_with_features(wasm_binary, features) wasm_binary = wabt::wat2wasm_with_features(wasm_binary, features)
.map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?; .map_err(|e| format!("Can't convert from wast to wasm: {:?}", e))?;
} }
@ -443,10 +460,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
memory_bound_check_mode: MemoryBoundCheckMode::Disable, memory_bound_check_mode: MemoryBoundCheckMode::Disable,
enforce_stack_check: true, enforce_stack_check: true,
track_state, track_state,
features: Features { features: options.features.into_backend_features(),
simd: options.features.simd || options.features.all,
threads: options.features.threads || options.features.all,
},
..Default::default() ..Default::default()
}, },
&*compiler, &*compiler,
@ -458,10 +472,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
CompilerConfig { CompilerConfig {
symbol_map: em_symbol_map.clone(), symbol_map: em_symbol_map.clone(),
track_state, track_state,
features: Features { features: options.features.into_backend_features(),
simd: options.features.simd || options.features.all,
threads: options.features.threads || options.features.all,
},
..Default::default() ..Default::default()
}, },
&*compiler, &*compiler,
@ -506,10 +517,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
CompilerConfig { CompilerConfig {
symbol_map: em_symbol_map.clone(), symbol_map: em_symbol_map.clone(),
track_state, track_state,
features: Features { features: options.features.into_backend_features(),
simd: options.features.simd || options.features.all,
threads: options.features.threads || options.features.all,
},
..Default::default() ..Default::default()
}, },
&*compiler, &*compiler,
@ -807,10 +815,7 @@ fn validate_wasm(validate: Validate) -> Result<(), String> {
wasmer_runtime_core::validate_and_report_errors_with_features( wasmer_runtime_core::validate_and_report_errors_with_features(
&wasm_binary, &wasm_binary,
Features { validate.features.into_backend_features(),
simd: validate.features.simd || validate.features.all,
threads: validate.features.threads || validate.features.all,
},
) )
.map_err(|err| format!("Validation failed: {}", err))?; .map_err(|err| format!("Validation failed: {}", err))?;