v8/test/cctest/wasm/test-run-wasm-sign-extension.cc
Ben L. Titzer 3d35921eb3 [wasm] Unify all enums representing execution tiers
R=mstarzinger@chromium.org

Change-Id: Iacdff28dd1383d77d7708de4ee22d9f2a77d872a
Reviewed-on: https://chromium-review.googlesource.com/1183440
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55284}
2018-08-21 15:45:18 +00:00

72 lines
2.0 KiB
C++

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "test/cctest/cctest.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {
// TODO(gdeepti): Enable tests to run in the interpreter.
WASM_EXEC_TEST(I32SExtendI8) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_I32_SIGN_EXT_I8(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
CHECK_EQ(0x7a, r.Call(0x7a));
CHECK_EQ(-0x80, r.Call(0x80));
}
WASM_EXEC_TEST(I32SExtendI16) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_I32_SIGN_EXT_I16(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
CHECK_EQ(0x7afa, r.Call(0x7afa));
CHECK_EQ(-0x8000, r.Call(0x8000));
}
WASM_EXEC_TEST(I64SExtendI8) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I8(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
CHECK_EQ(0x7a, r.Call(0x7a));
CHECK_EQ(-0x80, r.Call(0x80));
}
WASM_EXEC_TEST(I64SExtendI16) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I16(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
CHECK_EQ(0x7afa, r.Call(0x7afa));
CHECK_EQ(-0x8000, r.Call(0x8000));
}
WASM_EXEC_TEST(I64SExtendI32) {
EXPERIMENTAL_FLAG_SCOPE(se);
WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_I64_SIGN_EXT_I32(WASM_GET_LOCAL(0)));
CHECK_EQ(0, r.Call(0));
CHECK_EQ(1, r.Call(1));
CHECK_EQ(-1, r.Call(-1));
CHECK_EQ(0x7fffffff, r.Call(0x7fffffff));
CHECK_EQ(-0x80000000LL, r.Call(0x80000000));
}
} // namespace wasm
} // namespace internal
} // namespace v8