[wasm] Move wasm-macro-gen.h to test/common/wasm

This header file is only used from tests.
Also, move the LoadStoreOpcodeOf method (only used in tests) from
wasm-opcodes.h to wasm-macro-gen.h.

R=ahaas@chromium.org

Change-Id: I8d4691be494b5c1fbe3084441329850930bad647
Reviewed-on: https://chromium-review.googlesource.com/486861
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44845}
This commit is contained in:
Clemens Hammacher 2017-04-25 13:29:17 +02:00 committed by Commit Bot
parent 64e06641eb
commit fc6d4a1f08
30 changed files with 80 additions and 96 deletions

View File

@ -1956,7 +1956,6 @@ v8_source_set("v8_base") {
"src/wasm/wasm-js.cc",
"src/wasm/wasm-js.h",
"src/wasm/wasm-limits.h",
"src/wasm/wasm-macro-gen.h",
"src/wasm/wasm-module-builder.cc",
"src/wasm/wasm-module-builder.h",
"src/wasm/wasm-module.cc",

View File

@ -13,7 +13,6 @@
#include "src/objects-inl.h"
#include "src/objects.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-opcodes.h"
namespace v8 {

View File

@ -14,7 +14,6 @@
#include "src/asmjs/asm-wasm-builder.h"
#include "src/asmjs/switch-logic.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/ast/ast.h"

View File

@ -1366,7 +1366,6 @@
'wasm/wasm-js.cc',
'wasm/wasm-js.h',
'wasm/wasm-limits.h',
'wasm/wasm-macro-gen.h',
'wasm/wasm-module.cc',
'wasm/wasm-module.h',
'wasm/wasm-module-builder.cc',

View File

@ -12,7 +12,6 @@
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/leb-helper.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"

View File

@ -10,7 +10,6 @@
#include "src/wasm/leb-helper.h"
#include "src/wasm/local-decl-encoder.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-result.h"

View File

@ -686,33 +686,6 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
}
}
// TODO(wasm): This method is only used for testing. Move to an approriate
// header.
static WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
switch (type.representation()) {
case MachineRepresentation::kWord8:
return store ? kExprI32StoreMem8
: type.IsSigned() ? kExprI32LoadMem8S : kExprI32LoadMem8U;
case MachineRepresentation::kWord16:
return store
? kExprI32StoreMem16
: type.IsSigned() ? kExprI32LoadMem16S : kExprI32LoadMem16U;
case MachineRepresentation::kWord32:
return store ? kExprI32StoreMem : kExprI32LoadMem;
case MachineRepresentation::kWord64:
return store ? kExprI64StoreMem : kExprI64LoadMem;
case MachineRepresentation::kFloat32:
return store ? kExprF32StoreMem : kExprF32LoadMem;
case MachineRepresentation::kFloat64:
return store ? kExprF64StoreMem : kExprF64LoadMem;
case MachineRepresentation::kSimd128:
return store ? kExprS128StoreMem : kExprS128LoadMem;
default:
UNREACHABLE();
return kExprNop;
}
}
static char ShortNameOf(ValueType type) {
switch (type) {
case kWasmI32:

View File

@ -12,6 +12,7 @@ v8_executable("cctest") {
### gcmole(all) ###
"../common/wasm/test-signatures.h",
"../common/wasm/wasm-macro-gen.h",
"asmjs/test-asm-typer.cc",
"ast-types-fuzz.h",
"cctest.cc",

View File

@ -337,6 +337,7 @@
],
'sources': [
'../common/wasm/test-signatures.h',
'../common/wasm/wasm-macro-gen.h',
'../common/wasm/wasm-module-runner.cc',
'../common/wasm/wasm-module-runner.h',
'<@(cctest_sources)',

View File

@ -9,12 +9,12 @@
#include "src/assembler-inl.h"
#include "src/base/bits.h"
#include "src/objects-inl.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
// If the target architecture is 64-bit, enable all tests.
#if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64
@ -1627,8 +1627,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
ADD_CODE(code, WASM_CALL_FUNCTION0(t.function_index()));
// Store the result in memory.
ADD_CODE(code,
static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)),
ADD_CODE(code, static_cast<byte>(LoadStoreOpcodeOf(result, true)),
ZERO_ALIGNMENT, ZERO_OFFSET);
// Return the expected value.

View File

@ -9,12 +9,11 @@
#include "src/assembler-inl.h"
#include "src/base/platform/elapsed-timer.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;

View File

@ -10,11 +10,11 @@
#include "src/assembler-inl.h"
#include "src/wasm/wasm-interpreter.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;

View File

@ -8,11 +8,11 @@
#include <string.h>
#include "src/assembler-inl.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;

View File

@ -9,7 +9,6 @@
#include "src/snapshot/code-serializer.h"
#include "src/version.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
@ -17,6 +16,7 @@
#include "test/cctest/cctest.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-module-runner.h"
using namespace v8::base;

View File

@ -10,6 +10,7 @@
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/c-signature.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::compiler;

View File

@ -3,10 +3,10 @@
// found in the LICENSE file.
#include "src/assembler-inl.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;

View File

@ -9,11 +9,11 @@
#include "src/assembler-inl.h"
#include "src/base/platform/elapsed-timer.h"
#include "src/utils.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
@ -1083,10 +1083,10 @@ WASM_EXEC_TEST(LoadMaxUint32Offset) {
r.module().AddMemoryElems<int32_t>(8);
BUILD(r, kExprI32Const, 0, // index
static_cast<byte>(v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(
MachineType::Int32(), false)), // --
0, // alignment
U32V_5(0xffffffff)); // offset
static_cast<byte>(
LoadStoreOpcodeOf(MachineType::Int32(), false)), // load opcode
0, // alignment
U32V_5(0xffffffff)); // offset
CHECK_TRAP32(r.Call());
}
@ -2352,8 +2352,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) {
ADD_CODE(code, WASM_CALL_FUNCTION0(t.function_index()));
// Store the result in memory.
ADD_CODE(code,
static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)),
ADD_CODE(code, static_cast<byte>(LoadStoreOpcodeOf(result, true)),
ZERO_ALIGNMENT, ZERO_OFFSET);
// Return the expected value.

View File

@ -7,13 +7,13 @@
#include "src/frames-inl.h"
#include "src/property-descriptor.h"
#include "src/utils.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-objects.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::wasm;

View File

@ -6,11 +6,11 @@
#include "src/assembler-inl.h"
#include "src/objects-inl.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-objects.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::wasm;

View File

@ -3,11 +3,11 @@
// found in the LICENSE file.
#include "src/assembler-inl.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;

View File

@ -4,11 +4,11 @@
#include "src/assembler-inl.h"
#include "src/trap-handler/trap-handler.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/cctest/cctest.h"
#include "test/cctest/compiler/value-helper.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;

View File

@ -29,7 +29,6 @@
#include "src/wasm/wasm-external-refs.h"
#include "src/wasm/wasm-interpreter.h"
#include "src/wasm/wasm-js.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes.h"

View File

@ -144,10 +144,10 @@
#define WASM_ZERO kExprI32Const, 0
#define WASM_ONE kExprI32Const, 1
#define I32V_MIN(length) -(1 << (6 + (7 * ((length) - 1))))
#define I32V_MAX(length) ((1 << (6 + (7 * ((length) - 1)))) - 1)
#define I64V_MIN(length) -(1LL << (6 + (7 * ((length) - 1))))
#define I64V_MAX(length) ((1LL << (6 + 7 * ((length) - 1))) - 1)
#define I32V_MIN(length) -(1 << (6 + (7 * ((length)-1))))
#define I32V_MAX(length) ((1 << (6 + (7 * ((length)-1)))) - 1)
#define I64V_MIN(length) -(1LL << (6 + (7 * ((length)-1))))
#define I64V_MAX(length) ((1LL << (6 + 7 * ((length)-1))) - 1)
#define I32V_IN_RANGE(value, length) \
((value) >= I32V_MIN(length) && (value) <= I32V_MAX(length))
@ -170,6 +170,30 @@ inline void CheckI64v(int64_t value, int length) {
DCHECK(length == 10 || I64V_IN_RANGE(value, length));
}
inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
switch (type.representation()) {
case MachineRepresentation::kWord8:
return store ? kExprI32StoreMem8
: type.IsSigned() ? kExprI32LoadMem8S : kExprI32LoadMem8U;
case MachineRepresentation::kWord16:
return store ? kExprI32StoreMem16
: type.IsSigned() ? kExprI32LoadMem16S : kExprI32LoadMem16U;
case MachineRepresentation::kWord32:
return store ? kExprI32StoreMem : kExprI32LoadMem;
case MachineRepresentation::kWord64:
return store ? kExprI64StoreMem : kExprI64LoadMem;
case MachineRepresentation::kFloat32:
return store ? kExprF32StoreMem : kExprF32LoadMem;
case MachineRepresentation::kFloat64:
return store ? kExprF64StoreMem : kExprF64LoadMem;
case MachineRepresentation::kSimd128:
return store ? kExprS128StoreMem : kExprS128LoadMem;
default:
UNREACHABLE();
return kExprNop;
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
@ -305,32 +329,29 @@ inline void CheckI64v(int64_t value, int length) {
#define WASM_GET_GLOBAL(index) kExprGetGlobal, static_cast<byte>(index)
#define WASM_SET_GLOBAL(index, val) \
val, kExprSetGlobal, static_cast<byte>(index)
#define WASM_LOAD_MEM(type, index) \
index, static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \
#define WASM_LOAD_MEM(type, index) \
index, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
ZERO_ALIGNMENT, ZERO_OFFSET
#define WASM_STORE_MEM(type, index, val) \
index, val, \
static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \
#define WASM_STORE_MEM(type, index, val) \
index, val, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, true)), \
ZERO_ALIGNMENT, ZERO_OFFSET
#define WASM_LOAD_MEM_OFFSET(type, offset, index) \
index, static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \
#define WASM_LOAD_MEM_OFFSET(type, offset, index) \
index, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
ZERO_ALIGNMENT, static_cast<byte>(offset)
#define WASM_STORE_MEM_OFFSET(type, offset, index, val) \
index, val, \
static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \
#define WASM_STORE_MEM_OFFSET(type, offset, index, val) \
index, val, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, true)), \
ZERO_ALIGNMENT, static_cast<byte>(offset)
#define WASM_LOAD_MEM_ALIGNMENT(type, index, alignment) \
index, static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \
#define WASM_LOAD_MEM_ALIGNMENT(type, index, alignment) \
index, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
alignment, ZERO_OFFSET
#define WASM_STORE_MEM_ALIGNMENT(type, index, alignment, val) \
index, val, \
static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \
#define WASM_STORE_MEM_ALIGNMENT(type, index, alignment, val) \
index, val, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, true)), \
alignment, ZERO_OFFSET
#define WASM_CALL_FUNCTION0(index) kExprCallFunction, static_cast<byte>(index)

View File

@ -8,6 +8,7 @@ v8_executable("unittests") {
testonly = true
sources = [
"../../test/common/wasm/wasm-macro-gen.h",
"../../testing/gmock-support.h",
"../../testing/gtest-support.h",
"api/access-check-unittest.cc",

View File

@ -6,9 +6,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "src/v8.h"
#include "src/wasm/wasm-interpreter.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-macro-gen.h"
using testing::MakeMatcher;
using testing::Matcher;

View File

@ -6,7 +6,7 @@
#include "src/objects-inl.h"
#include "src/wasm/decoder.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {

View File

@ -4,22 +4,20 @@
#include "test/unittests/test-utils.h"
#include "src/v8.h"
#include "test/common/wasm/test-signatures.h"
#include "src/objects-inl.h"
#include "src/objects.h"
#include "src/v8.h"
#include "src/wasm/function-body-decoder-impl.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/local-decl-encoder.h"
#include "src/wasm/signature-map.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {

View File

@ -4,18 +4,16 @@
#include "test/unittests/test-utils.h"
#include "src/v8.h"
#include "test/common/wasm/test-signatures.h"
#include "src/bit-vector.h"
#include "src/objects-inl.h"
#include "src/objects.h"
#include "src/v8.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
#define WASM_SET_ZERO(i) WASM_SET_LOCAL(i, WASM_ZERO)
namespace v8 {

View File

@ -8,8 +8,8 @@
#include "src/objects-inl.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-opcodes.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {

View File

@ -4,7 +4,7 @@
#include "test/unittests/test-utils.h"
#include "src/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {