[wasm] Enable sign extension operations in the interpreter

Change-Id: I204a021ffc8b120ffe232e3f5db924e54c6d980e
Reviewed-on: https://chromium-review.googlesource.com/1083337
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53478}
This commit is contained in:
Deepti Gandluri 2018-06-01 14:27:29 -07:00 committed by Commit Bot
parent dc6819ec56
commit 785bd43b7e
2 changed files with 17 additions and 5 deletions

View File

@ -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<ntype>(Pop().to<wtype>()); \
Push(WasmValue(static_cast<wtype>(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;

View File

@ -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<int32_t, int32_t> 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<int32_t, int32_t> 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<int64_t, int64_t> 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<int64_t, int64_t> 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<int64_t, int64_t> r(execution_mode);
BUILD(r, WASM_I64_SIGN_EXT_I32(WASM_GET_LOCAL(0)));