diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc index f53392043f..b0c493feb8 100644 --- a/src/wasm/wasm-interpreter.cc +++ b/src/wasm/wasm-interpreter.cc @@ -2300,6 +2300,18 @@ class ThreadImpl { Push(WasmValue(ExecuteI64ReinterpretF64(val))); break; } +#define SIGN_EXTENSION_CASE(name, wtype, ntype) \ + case kExpr##name: { \ + ntype val = static_cast(Pop().to()); \ + Push(WasmValue(static_cast(val))); \ + break; \ + } + SIGN_EXTENSION_CASE(I32SExtendI8, int32_t, int8_t); + SIGN_EXTENSION_CASE(I32SExtendI16, int32_t, int16_t); + SIGN_EXTENSION_CASE(I64SExtendI8, int64_t, int8_t); + SIGN_EXTENSION_CASE(I64SExtendI16, int64_t, int16_t); + SIGN_EXTENSION_CASE(I64SExtendI32, int64_t, int32_t); +#undef SIGN_EXTENSION_CASE case kNumericPrefix: { ++len; if (!ExecuteNumericOp(opcode, &decoder, code, pc, len)) return; diff --git a/test/cctest/wasm/test-run-wasm-sign-extension.cc b/test/cctest/wasm/test-run-wasm-sign-extension.cc index e2d0afc6af..17a79bc27f 100644 --- a/test/cctest/wasm/test-run-wasm-sign-extension.cc +++ b/test/cctest/wasm/test-run-wasm-sign-extension.cc @@ -11,7 +11,7 @@ namespace internal { namespace wasm { // TODO(gdeepti): Enable tests to run in the interpreter. -WASM_COMPILED_EXEC_TEST(I32SExtendI8) { +WASM_EXEC_TEST(I32SExtendI8) { EXPERIMENTAL_FLAG_SCOPE(se); WasmRunner r(execution_mode); BUILD(r, WASM_I32_SIGN_EXT_I8(WASM_GET_LOCAL(0))); @@ -22,7 +22,7 @@ WASM_COMPILED_EXEC_TEST(I32SExtendI8) { CHECK_EQ(-0x80, r.Call(0x80)); } -WASM_COMPILED_EXEC_TEST(I32SExtendI16) { +WASM_EXEC_TEST(I32SExtendI16) { EXPERIMENTAL_FLAG_SCOPE(se); WasmRunner r(execution_mode); BUILD(r, WASM_I32_SIGN_EXT_I16(WASM_GET_LOCAL(0))); @@ -33,7 +33,7 @@ WASM_COMPILED_EXEC_TEST(I32SExtendI16) { CHECK_EQ(-0x8000, r.Call(0x8000)); } -WASM_COMPILED_EXEC_TEST(I64SExtendI8) { +WASM_EXEC_TEST(I64SExtendI8) { EXPERIMENTAL_FLAG_SCOPE(se); WasmRunner r(execution_mode); BUILD(r, WASM_I64_SIGN_EXT_I8(WASM_GET_LOCAL(0))); @@ -44,7 +44,7 @@ WASM_COMPILED_EXEC_TEST(I64SExtendI8) { CHECK_EQ(-0x80, r.Call(0x80)); } -WASM_COMPILED_EXEC_TEST(I64SExtendI16) { +WASM_EXEC_TEST(I64SExtendI16) { EXPERIMENTAL_FLAG_SCOPE(se); WasmRunner r(execution_mode); BUILD(r, WASM_I64_SIGN_EXT_I16(WASM_GET_LOCAL(0))); @@ -55,7 +55,7 @@ WASM_COMPILED_EXEC_TEST(I64SExtendI16) { CHECK_EQ(-0x8000, r.Call(0x8000)); } -WASM_COMPILED_EXEC_TEST(I64SExtendI32) { +WASM_EXEC_TEST(I64SExtendI32) { EXPERIMENTAL_FLAG_SCOPE(se); WasmRunner r(execution_mode); BUILD(r, WASM_I64_SIGN_EXT_I32(WASM_GET_LOCAL(0)));