Commit d4392107 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Make LoadGlobal/StoreGlobal opcodes match what is coming in binary 0xC.

R=ahaas@chromium.org,bradnelson@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2209433002
Cr-Commit-Position: refs/heads/master@{#38262}
parent bb97d27a
...@@ -98,7 +98,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -98,7 +98,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
current_function_builder_->EmitGetLocal(static_cast<uint32_t>(pos)); current_function_builder_->EmitGetLocal(static_cast<uint32_t>(pos));
ForeignVariable* fv = &foreign_variables_[pos]; ForeignVariable* fv = &foreign_variables_[pos];
uint32_t index = LookupOrInsertGlobal(fv->var, fv->type); uint32_t index = LookupOrInsertGlobal(fv->var, fv->type);
current_function_builder_->EmitWithVarInt(kExprStoreGlobal, index); current_function_builder_->EmitWithVarInt(kExprSetGlobal, index);
} }
current_function_builder_ = nullptr; current_function_builder_ = nullptr;
} }
...@@ -546,7 +546,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -546,7 +546,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
DCHECK_NE(kAstStmt, var_type); DCHECK_NE(kAstStmt, var_type);
if (var->IsContextSlot()) { if (var->IsContextSlot()) {
current_function_builder_->EmitWithVarInt( current_function_builder_->EmitWithVarInt(
kExprLoadGlobal, LookupOrInsertGlobal(var, var_type)); kExprGetGlobal, LookupOrInsertGlobal(var, var_type));
} else { } else {
current_function_builder_->EmitGetLocal( current_function_builder_->EmitGetLocal(
LookupOrInsertLocal(var, var_type)); LookupOrInsertLocal(var, var_type));
...@@ -784,7 +784,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> { ...@@ -784,7 +784,7 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
DCHECK_NE(kAstStmt, var_type); DCHECK_NE(kAstStmt, var_type);
if (var->IsContextSlot()) { if (var->IsContextSlot()) {
current_function_builder_->EmitWithVarInt( current_function_builder_->EmitWithVarInt(
kExprStoreGlobal, LookupOrInsertGlobal(var, var_type)); kExprSetGlobal, LookupOrInsertGlobal(var, var_type));
} else { } else {
current_function_builder_->EmitSetLocal( current_function_builder_->EmitSetLocal(
LookupOrInsertLocal(var, var_type)); LookupOrInsertLocal(var, var_type));
......
...@@ -2921,7 +2921,7 @@ Node* WasmGraphBuilder::ChangeToRuntimeCall(Node* node, ...@@ -2921,7 +2921,7 @@ Node* WasmGraphBuilder::ChangeToRuntimeCall(Node* node,
return ret; return ret;
} }
Node* WasmGraphBuilder::LoadGlobal(uint32_t index) { Node* WasmGraphBuilder::GetGlobal(uint32_t index) {
MachineType mem_type = MachineType mem_type =
wasm::WasmOpcodes::MachineTypeFor(module_->GetGlobalType(index)); wasm::WasmOpcodes::MachineTypeFor(module_->GetGlobalType(index));
Node* addr = jsgraph()->RelocatableIntPtrConstant( Node* addr = jsgraph()->RelocatableIntPtrConstant(
...@@ -2935,7 +2935,7 @@ Node* WasmGraphBuilder::LoadGlobal(uint32_t index) { ...@@ -2935,7 +2935,7 @@ Node* WasmGraphBuilder::LoadGlobal(uint32_t index) {
return node; return node;
} }
Node* WasmGraphBuilder::StoreGlobal(uint32_t index, Node* val) { Node* WasmGraphBuilder::SetGlobal(uint32_t index, Node* val) {
MachineType mem_type = MachineType mem_type =
wasm::WasmOpcodes::MachineTypeFor(module_->GetGlobalType(index)); wasm::WasmOpcodes::MachineTypeFor(module_->GetGlobalType(index));
Node* addr = jsgraph()->RelocatableIntPtrConstant( Node* addr = jsgraph()->RelocatableIntPtrConstant(
......
...@@ -176,8 +176,8 @@ class WasmGraphBuilder { ...@@ -176,8 +176,8 @@ class WasmGraphBuilder {
// Operations that concern the linear memory. // Operations that concern the linear memory.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
Node* MemSize(uint32_t offset); Node* MemSize(uint32_t offset);
Node* LoadGlobal(uint32_t index); Node* GetGlobal(uint32_t index);
Node* StoreGlobal(uint32_t index, Node* val); Node* SetGlobal(uint32_t index, Node* val);
Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index, Node* LoadMem(wasm::LocalType type, MachineType memtype, Node* index,
uint32_t offset, uint32_t alignment, uint32_t offset, uint32_t alignment,
wasm::WasmCodePosition position); wasm::WasmCodePosition position);
......
...@@ -256,7 +256,7 @@ class WasmDecoder : public Decoder { ...@@ -256,7 +256,7 @@ class WasmDecoder : public Decoder {
case kExprF64Const: case kExprF64Const:
case kExprF32Const: case kExprF32Const:
case kExprGetLocal: case kExprGetLocal:
case kExprLoadGlobal: case kExprGetGlobal:
case kExprNop: case kExprNop:
case kExprUnreachable: case kExprUnreachable:
case kExprEnd: case kExprEnd:
...@@ -264,7 +264,7 @@ class WasmDecoder : public Decoder { ...@@ -264,7 +264,7 @@ class WasmDecoder : public Decoder {
case kExprLoop: case kExprLoop:
return 0; return 0;
case kExprStoreGlobal: case kExprSetGlobal:
case kExprSetLocal: case kExprSetLocal:
case kExprElse: case kExprElse:
return 1; return 1;
...@@ -339,8 +339,8 @@ class WasmDecoder : public Decoder { ...@@ -339,8 +339,8 @@ class WasmDecoder : public Decoder {
BreakDepthOperand operand(this, pc); BreakDepthOperand operand(this, pc);
return 1 + operand.length; return 1 + operand.length;
} }
case kExprStoreGlobal: case kExprSetGlobal:
case kExprLoadGlobal: { case kExprGetGlobal: {
GlobalIndexOperand operand(this, pc); GlobalIndexOperand operand(this, pc);
return 1 + operand.length; return 1 + operand.length;
} }
...@@ -891,19 +891,19 @@ class WasmFullDecoder : public WasmDecoder { ...@@ -891,19 +891,19 @@ class WasmFullDecoder : public WasmDecoder {
len = 1 + operand.length; len = 1 + operand.length;
break; break;
} }
case kExprLoadGlobal: { case kExprGetGlobal: {
GlobalIndexOperand operand(this, pc_); GlobalIndexOperand operand(this, pc_);
if (Validate(pc_, operand)) { if (Validate(pc_, operand)) {
Push(operand.type, BUILD(LoadGlobal, operand.index)); Push(operand.type, BUILD(GetGlobal, operand.index));
} }
len = 1 + operand.length; len = 1 + operand.length;
break; break;
} }
case kExprStoreGlobal: { case kExprSetGlobal: {
GlobalIndexOperand operand(this, pc_); GlobalIndexOperand operand(this, pc_);
if (Validate(pc_, operand)) { if (Validate(pc_, operand)) {
Value val = Pop(0, operand.type); Value val = Pop(0, operand.type);
BUILD(StoreGlobal, operand.index, val.node); BUILD(SetGlobal, operand.index, val.node);
Push(val.type, val.node); Push(val.type, val.node);
} }
len = 1 + operand.length; len = 1 + operand.length;
......
...@@ -1405,7 +1405,7 @@ class ThreadImpl : public WasmInterpreter::Thread { ...@@ -1405,7 +1405,7 @@ class ThreadImpl : public WasmInterpreter::Thread {
UNIMPLEMENTED(); UNIMPLEMENTED();
break; break;
} }
case kExprLoadGlobal: { case kExprGetGlobal: {
GlobalIndexOperand operand(&decoder, code->at(pc)); GlobalIndexOperand operand(&decoder, code->at(pc));
const WasmGlobal* global = &module()->globals[operand.index]; const WasmGlobal* global = &module()->globals[operand.index];
byte* ptr = instance()->globals_start + global->offset; byte* ptr = instance()->globals_start + global->offset;
...@@ -1426,7 +1426,7 @@ class ThreadImpl : public WasmInterpreter::Thread { ...@@ -1426,7 +1426,7 @@ class ThreadImpl : public WasmInterpreter::Thread {
len = 1 + operand.length; len = 1 + operand.length;
break; break;
} }
case kExprStoreGlobal: { case kExprSetGlobal: {
GlobalIndexOperand operand(&decoder, code->at(pc)); GlobalIndexOperand operand(&decoder, code->at(pc));
const WasmGlobal* global = &module()->globals[operand.index]; const WasmGlobal* global = &module()->globals[operand.index];
byte* ptr = instance()->globals_start + global->offset; byte* ptr = instance()->globals_start + global->offset;
......
...@@ -343,9 +343,9 @@ class LocalDeclEncoder { ...@@ -343,9 +343,9 @@ class LocalDeclEncoder {
static_cast<byte>(bit_cast<uint64_t>(val) >> 56) static_cast<byte>(bit_cast<uint64_t>(val) >> 56)
#define WASM_GET_LOCAL(index) kExprGetLocal, static_cast<byte>(index) #define WASM_GET_LOCAL(index) kExprGetLocal, static_cast<byte>(index)
#define WASM_SET_LOCAL(index, val) val, kExprSetLocal, static_cast<byte>(index) #define WASM_SET_LOCAL(index, val) val, kExprSetLocal, static_cast<byte>(index)
#define WASM_LOAD_GLOBAL(index) kExprLoadGlobal, static_cast<byte>(index) #define WASM_GET_GLOBAL(index) kExprGetGlobal, static_cast<byte>(index)
#define WASM_STORE_GLOBAL(index, val) \ #define WASM_SET_GLOBAL(index, val) \
val, kExprStoreGlobal, static_cast<byte>(index) val, kExprSetGlobal, static_cast<byte>(index)
#define WASM_LOAD_MEM(type, index) \ #define WASM_LOAD_MEM(type, index) \
index, static_cast<byte>( \ index, static_cast<byte>( \
v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \ v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \
......
...@@ -69,8 +69,8 @@ const WasmCodePosition kNoCodePosition = -1; ...@@ -69,8 +69,8 @@ const WasmCodePosition kNoCodePosition = -1;
V(CallIndirect, 0x17, _) \ V(CallIndirect, 0x17, _) \
V(CallImport, 0x18, _) \ V(CallImport, 0x18, _) \
V(I8Const, 0xcb, _) \ V(I8Const, 0xcb, _) \
V(LoadGlobal, 0xcc, _) \ V(GetGlobal, 0xbb, _) \
V(StoreGlobal, 0xcd, _) V(SetGlobal, 0xbc, _)
// Load memory expressions. // Load memory expressions.
#define FOREACH_LOAD_MEM_OPCODE(V) \ #define FOREACH_LOAD_MEM_OPCODE(V) \
......
...@@ -1371,8 +1371,8 @@ WASM_EXEC_TEST(I64Global) { ...@@ -1371,8 +1371,8 @@ WASM_EXEC_TEST(I64Global) {
int64_t* global = module.AddGlobal<int64_t>(kAstI64); int64_t* global = module.AddGlobal<int64_t>(kAstI64);
WasmRunner<int32_t> r(&module, MachineType::Int32()); WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0 // global = global + p0
BUILD(r, B2(WASM_STORE_GLOBAL( BUILD(r, B2(WASM_SET_GLOBAL(
0, WASM_I64_AND(WASM_LOAD_GLOBAL(0), 0, WASM_I64_AND(WASM_GET_GLOBAL(0),
WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))), WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
WASM_ZERO)); WASM_ZERO));
......
...@@ -162,14 +162,14 @@ TEST(Run_WasmModule_Global) { ...@@ -162,14 +162,14 @@ TEST(Run_WasmModule_Global) {
WasmFunctionBuilder* f = builder->FunctionAt(f1_index); WasmFunctionBuilder* f = builder->FunctionAt(f1_index);
f->SetSignature(sigs.i_v()); f->SetSignature(sigs.i_v());
byte code1[] = { byte code1[] = {
WASM_I32_ADD(WASM_LOAD_GLOBAL(global1), WASM_LOAD_GLOBAL(global2))}; WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
f->EmitCode(code1, sizeof(code1)); f->EmitCode(code1, sizeof(code1));
uint16_t f2_index = builder->AddFunction(); uint16_t f2_index = builder->AddFunction();
f = builder->FunctionAt(f2_index); f = builder->FunctionAt(f2_index);
f->SetSignature(sigs.i_v()); f->SetSignature(sigs.i_v());
ExportAsMain(f); ExportAsMain(f);
byte code2[] = {WASM_STORE_GLOBAL(global1, WASM_I32V_1(56)), byte code2[] = {WASM_SET_GLOBAL(global1, WASM_I32V_1(56)),
WASM_STORE_GLOBAL(global2, WASM_I32V_1(41)), WASM_SET_GLOBAL(global2, WASM_I32V_1(41)),
WASM_RETURN1(WASM_CALL_FUNCTION0(f1_index))}; WASM_RETURN1(WASM_CALL_FUNCTION0(f1_index))};
f->EmitCode(code2, sizeof(code2)); f->EmitCode(code2, sizeof(code2));
TestModule(&zone, builder, 97); TestModule(&zone, builder, 97);
......
...@@ -19,7 +19,7 @@ using namespace v8::internal::compiler; ...@@ -19,7 +19,7 @@ using namespace v8::internal::compiler;
TEST_BODY(float, F32, WASM_F32_ADD) \ TEST_BODY(float, F32, WASM_F32_ADD) \
TEST_BODY(double, F64, WASM_F64_ADD) TEST_BODY(double, F64, WASM_F64_ADD)
#define LOAD_STORE_GLOBAL_TEST_BODY(C_TYPE, MACHINE_TYPE, ADD) \ #define LOAD_SET_GLOBAL_TEST_BODY(C_TYPE, MACHINE_TYPE, ADD) \
TEST(WasmRelocateGlobal##MACHINE_TYPE) { \ TEST(WasmRelocateGlobal##MACHINE_TYPE) { \
TestingModule module(kExecuteCompiled); \ TestingModule module(kExecuteCompiled); \
module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \ module.AddGlobal<C_TYPE>(kAst##MACHINE_TYPE); \
...@@ -29,8 +29,7 @@ using namespace v8::internal::compiler; ...@@ -29,8 +29,7 @@ using namespace v8::internal::compiler;
WasmOpcodes::MachineTypeFor(kAst##MACHINE_TYPE)); \ WasmOpcodes::MachineTypeFor(kAst##MACHINE_TYPE)); \
\ \
/* global = global + p0 */ \ /* global = global + p0 */ \
BUILD(r, \ BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0)))); \
WASM_STORE_GLOBAL(1, ADD(WASM_LOAD_GLOBAL(0), WASM_GET_LOCAL(0)))); \
CHECK_EQ(1, module.instance->function_code.size()); \ CHECK_EQ(1, module.instance->function_code.size()); \
\ \
int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \ int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \
...@@ -58,4 +57,4 @@ using namespace v8::internal::compiler; ...@@ -58,4 +57,4 @@ using namespace v8::internal::compiler;
CHECK_EQ(2U, address_index); \ CHECK_EQ(2U, address_index); \
} }
FOREACH_TYPE(LOAD_STORE_GLOBAL_TEST_BODY) FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY)
...@@ -1861,8 +1861,8 @@ WASM_EXEC_TEST(Int32Global) { ...@@ -1861,8 +1861,8 @@ WASM_EXEC_TEST(Int32Global) {
int32_t* global = module.AddGlobal<int32_t>(kAstI32); int32_t* global = module.AddGlobal<int32_t>(kAstI32);
WasmRunner<int32_t> r(&module, MachineType::Int32()); WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0 // global = global + p0
BUILD(r, WASM_STORE_GLOBAL( BUILD(r, WASM_SET_GLOBAL(
0, WASM_I32_ADD(WASM_LOAD_GLOBAL(0), WASM_GET_LOCAL(0)))); 0, WASM_I32_ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))));
*global = 116; *global = 116;
for (int i = 9; i < 444444; i += 111111) { for (int i = 9; i < 444444; i += 111111) {
...@@ -1882,8 +1882,8 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) { ...@@ -1882,8 +1882,8 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) {
for (int g = 0; g < kNumGlobals; ++g) { for (int g = 0; g < kNumGlobals; ++g) {
// global = global + p0 // global = global + p0
WasmRunner<int32_t> r(&module, MachineType::Int32()); WasmRunner<int32_t> r(&module, MachineType::Int32());
BUILD(r, WASM_STORE_GLOBAL( BUILD(r, WASM_SET_GLOBAL(
g, WASM_I32_ADD(WASM_LOAD_GLOBAL(g), WASM_GET_LOCAL(0)))); g, WASM_I32_ADD(WASM_GET_GLOBAL(g), WASM_GET_LOCAL(0))));
// Check that reading/writing global number {g} doesn't alter the others. // Check that reading/writing global number {g} doesn't alter the others.
*globals[g] = 116 * g; *globals[g] = 116 * g;
...@@ -1905,8 +1905,8 @@ WASM_EXEC_TEST(Float32Global) { ...@@ -1905,8 +1905,8 @@ WASM_EXEC_TEST(Float32Global) {
float* global = module.AddGlobal<float>(kAstF32); float* global = module.AddGlobal<float>(kAstF32);
WasmRunner<int32_t> r(&module, MachineType::Int32()); WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0 // global = global + p0
BUILD(r, B2(WASM_STORE_GLOBAL( BUILD(r, B2(WASM_SET_GLOBAL(
0, WASM_F32_ADD(WASM_LOAD_GLOBAL(0), 0, WASM_F32_ADD(WASM_GET_GLOBAL(0),
WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))), WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))),
WASM_ZERO)); WASM_ZERO));
...@@ -1923,8 +1923,8 @@ WASM_EXEC_TEST(Float64Global) { ...@@ -1923,8 +1923,8 @@ WASM_EXEC_TEST(Float64Global) {
double* global = module.AddGlobal<double>(kAstF64); double* global = module.AddGlobal<double>(kAstF64);
WasmRunner<int32_t> r(&module, MachineType::Int32()); WasmRunner<int32_t> r(&module, MachineType::Int32());
// global = global + p0 // global = global + p0
BUILD(r, B2(WASM_STORE_GLOBAL( BUILD(r, B2(WASM_SET_GLOBAL(
0, WASM_F64_ADD(WASM_LOAD_GLOBAL(0), 0, WASM_F64_ADD(WASM_GET_GLOBAL(0),
WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))), WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
WASM_ZERO)); WASM_ZERO));
...@@ -1951,12 +1951,10 @@ WASM_EXEC_TEST(MixedGlobals) { ...@@ -1951,12 +1951,10 @@ WASM_EXEC_TEST(MixedGlobals) {
BUILD( BUILD(
r, r,
WASM_BLOCK( WASM_BLOCK(
WASM_STORE_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)), WASM_SET_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
WASM_STORE_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)), WASM_SET_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
WASM_STORE_GLOBAL(3, WASM_SET_GLOBAL(3, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)),
WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)), WASM_SET_GLOBAL(4, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
WASM_STORE_GLOBAL(4,
WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
WASM_ZERO)); WASM_ZERO));
memory[0] = 0xaa; memory[0] = 0xaa;
......
...@@ -149,8 +149,8 @@ var kExprCallFunction = 0x16; ...@@ -149,8 +149,8 @@ var kExprCallFunction = 0x16;
var kExprCallIndirect = 0x17; var kExprCallIndirect = 0x17;
var kExprCallImport = 0x18; var kExprCallImport = 0x18;
var kExprI8Const = 0xcb; var kExprI8Const = 0xcb;
var kExprLoadGlobal = 0xcc; var kExprGetGlobal = 0xbb;
var kExprStoreGlobal = 0xcd; var kExprSetGlobal = 0xbc;
var kExprI32LoadMem8S = 0x20; var kExprI32LoadMem8S = 0x20;
var kExprI32LoadMem8U = 0x21; var kExprI32LoadMem8U = 0x21;
......
...@@ -1347,8 +1347,8 @@ TEST_F(AstDecoderTest, Int32Globals) { ...@@ -1347,8 +1347,8 @@ TEST_F(AstDecoderTest, Int32Globals) {
module_env.AddGlobal(kAstI32); module_env.AddGlobal(kAstI32);
EXPECT_VERIFIES_INLINE(sig, WASM_LOAD_GLOBAL(0)); EXPECT_VERIFIES_INLINE(sig, WASM_GET_GLOBAL(0));
EXPECT_VERIFIES_INLINE(sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_VERIFIES_INLINE(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, Int32Globals_fail) { TEST_F(AstDecoderTest, Int32Globals_fail) {
...@@ -1361,15 +1361,15 @@ TEST_F(AstDecoderTest, Int32Globals_fail) { ...@@ -1361,15 +1361,15 @@ TEST_F(AstDecoderTest, Int32Globals_fail) {
module_env.AddGlobal(kAstF32); module_env.AddGlobal(kAstF32);
module_env.AddGlobal(kAstF64); module_env.AddGlobal(kAstF64);
EXPECT_FAILURE_INLINE(sig, WASM_LOAD_GLOBAL(0)); EXPECT_FAILURE_INLINE(sig, WASM_GET_GLOBAL(0));
EXPECT_FAILURE_INLINE(sig, WASM_LOAD_GLOBAL(1)); EXPECT_FAILURE_INLINE(sig, WASM_GET_GLOBAL(1));
EXPECT_FAILURE_INLINE(sig, WASM_LOAD_GLOBAL(2)); EXPECT_FAILURE_INLINE(sig, WASM_GET_GLOBAL(2));
EXPECT_FAILURE_INLINE(sig, WASM_LOAD_GLOBAL(3)); EXPECT_FAILURE_INLINE(sig, WASM_GET_GLOBAL(3));
EXPECT_FAILURE_INLINE(sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_FAILURE_INLINE(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
EXPECT_FAILURE_INLINE(sig, WASM_STORE_GLOBAL(1, WASM_GET_LOCAL(0))); EXPECT_FAILURE_INLINE(sig, WASM_SET_GLOBAL(1, WASM_GET_LOCAL(0)));
EXPECT_FAILURE_INLINE(sig, WASM_STORE_GLOBAL(2, WASM_GET_LOCAL(0))); EXPECT_FAILURE_INLINE(sig, WASM_SET_GLOBAL(2, WASM_GET_LOCAL(0)));
EXPECT_FAILURE_INLINE(sig, WASM_STORE_GLOBAL(3, WASM_GET_LOCAL(0))); EXPECT_FAILURE_INLINE(sig, WASM_SET_GLOBAL(3, WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, Int64Globals) { TEST_F(AstDecoderTest, Int64Globals) {
...@@ -1380,11 +1380,11 @@ TEST_F(AstDecoderTest, Int64Globals) { ...@@ -1380,11 +1380,11 @@ TEST_F(AstDecoderTest, Int64Globals) {
module_env.AddGlobal(kAstI64); module_env.AddGlobal(kAstI64);
module_env.AddGlobal(kAstI64); module_env.AddGlobal(kAstI64);
EXPECT_VERIFIES_INLINE(sig, WASM_LOAD_GLOBAL(0)); EXPECT_VERIFIES_INLINE(sig, WASM_GET_GLOBAL(0));
EXPECT_VERIFIES_INLINE(sig, WASM_LOAD_GLOBAL(1)); EXPECT_VERIFIES_INLINE(sig, WASM_GET_GLOBAL(1));
EXPECT_VERIFIES_INLINE(sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_VERIFIES_INLINE(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
EXPECT_VERIFIES_INLINE(sig, WASM_STORE_GLOBAL(1, WASM_GET_LOCAL(0))); EXPECT_VERIFIES_INLINE(sig, WASM_SET_GLOBAL(1, WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, Float32Globals) { TEST_F(AstDecoderTest, Float32Globals) {
...@@ -1394,8 +1394,8 @@ TEST_F(AstDecoderTest, Float32Globals) { ...@@ -1394,8 +1394,8 @@ TEST_F(AstDecoderTest, Float32Globals) {
module_env.AddGlobal(kAstF32); module_env.AddGlobal(kAstF32);
EXPECT_VERIFIES_INLINE(sig, WASM_LOAD_GLOBAL(0)); EXPECT_VERIFIES_INLINE(sig, WASM_GET_GLOBAL(0));
EXPECT_VERIFIES_INLINE(sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_VERIFIES_INLINE(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, Float64Globals) { TEST_F(AstDecoderTest, Float64Globals) {
...@@ -1405,11 +1405,11 @@ TEST_F(AstDecoderTest, Float64Globals) { ...@@ -1405,11 +1405,11 @@ TEST_F(AstDecoderTest, Float64Globals) {
module_env.AddGlobal(kAstF64); module_env.AddGlobal(kAstF64);
EXPECT_VERIFIES_INLINE(sig, WASM_LOAD_GLOBAL(0)); EXPECT_VERIFIES_INLINE(sig, WASM_GET_GLOBAL(0));
EXPECT_VERIFIES_INLINE(sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_VERIFIES_INLINE(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, AllLoadGlobalCombinations) { TEST_F(AstDecoderTest, AllGetGlobalCombinations) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType local_type = kLocalTypes[i]; LocalType local_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
...@@ -1419,15 +1419,15 @@ TEST_F(AstDecoderTest, AllLoadGlobalCombinations) { ...@@ -1419,15 +1419,15 @@ TEST_F(AstDecoderTest, AllLoadGlobalCombinations) {
module = &module_env; module = &module_env;
module_env.AddGlobal(global_type); module_env.AddGlobal(global_type);
if (local_type == global_type) { if (local_type == global_type) {
EXPECT_VERIFIES_INLINE(&sig, WASM_LOAD_GLOBAL(0)); EXPECT_VERIFIES_INLINE(&sig, WASM_GET_GLOBAL(0));
} else { } else {
EXPECT_FAILURE_INLINE(&sig, WASM_LOAD_GLOBAL(0)); EXPECT_FAILURE_INLINE(&sig, WASM_GET_GLOBAL(0));
} }
} }
} }
} }
TEST_F(AstDecoderTest, AllStoreGlobalCombinations) { TEST_F(AstDecoderTest, AllSetGlobalCombinations) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType local_type = kLocalTypes[i]; LocalType local_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
...@@ -1437,9 +1437,9 @@ TEST_F(AstDecoderTest, AllStoreGlobalCombinations) { ...@@ -1437,9 +1437,9 @@ TEST_F(AstDecoderTest, AllStoreGlobalCombinations) {
module = &module_env; module = &module_env;
module_env.AddGlobal(global_type); module_env.AddGlobal(global_type);
if (local_type == global_type) { if (local_type == global_type) {
EXPECT_VERIFIES_INLINE(&sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_VERIFIES_INLINE(&sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
} else { } else {
EXPECT_FAILURE_INLINE(&sig, WASM_STORE_GLOBAL(0, WASM_GET_LOCAL(0))); EXPECT_FAILURE_INLINE(&sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)));
} }
} }
} }
...@@ -1864,8 +1864,8 @@ TEST_F(WasmOpcodeLengthTest, MiscExpressions) { ...@@ -1864,8 +1864,8 @@ TEST_F(WasmOpcodeLengthTest, MiscExpressions) {
EXPECT_LENGTH(9, kExprF64Const); EXPECT_LENGTH(9, kExprF64Const);
EXPECT_LENGTH(2, kExprGetLocal); EXPECT_LENGTH(2, kExprGetLocal);
EXPECT_LENGTH(2, kExprSetLocal); EXPECT_LENGTH(2, kExprSetLocal);
EXPECT_LENGTH(2, kExprLoadGlobal); EXPECT_LENGTH(2, kExprGetGlobal);
EXPECT_LENGTH(2, kExprStoreGlobal); EXPECT_LENGTH(2, kExprSetGlobal);
EXPECT_LENGTH(3, kExprCallFunction); EXPECT_LENGTH(3, kExprCallFunction);
EXPECT_LENGTH(3, kExprCallImport); EXPECT_LENGTH(3, kExprCallImport);
EXPECT_LENGTH(3, kExprCallIndirect); EXPECT_LENGTH(3, kExprCallIndirect);
...@@ -1897,11 +1897,11 @@ TEST_F(WasmOpcodeLengthTest, I64Const) { ...@@ -1897,11 +1897,11 @@ TEST_F(WasmOpcodeLengthTest, I64Const) {
} }
TEST_F(WasmOpcodeLengthTest, VariableLength) { TEST_F(WasmOpcodeLengthTest, VariableLength) {
EXPECT_LENGTH_N(2, kExprLoadGlobal, U32V_1(1)); EXPECT_LENGTH_N(2, kExprGetGlobal, U32V_1(1));
EXPECT_LENGTH_N(3, kExprLoadGlobal, U32V_2(33)); EXPECT_LENGTH_N(3, kExprGetGlobal, U32V_2(33));
EXPECT_LENGTH_N(4, kExprLoadGlobal, U32V_3(44)); EXPECT_LENGTH_N(4, kExprGetGlobal, U32V_3(44));
EXPECT_LENGTH_N(5, kExprLoadGlobal, U32V_4(66)); EXPECT_LENGTH_N(5, kExprGetGlobal, U32V_4(66));
EXPECT_LENGTH_N(6, kExprLoadGlobal, U32V_5(77)); EXPECT_LENGTH_N(6, kExprGetGlobal, U32V_5(77));
} }
TEST_F(WasmOpcodeLengthTest, LoadsAndStores) { TEST_F(WasmOpcodeLengthTest, LoadsAndStores) {
...@@ -2107,8 +2107,8 @@ TEST_F(WasmOpcodeArityTest, Misc) { ...@@ -2107,8 +2107,8 @@ TEST_F(WasmOpcodeArityTest, Misc) {
EXPECT_ARITY(0, kExprF64Const); EXPECT_ARITY(0, kExprF64Const);
EXPECT_ARITY(0, kExprGetLocal); EXPECT_ARITY(0, kExprGetLocal);
EXPECT_ARITY(1, kExprSetLocal); EXPECT_ARITY(1, kExprSetLocal);
EXPECT_ARITY(0, kExprLoadGlobal); EXPECT_ARITY(0, kExprGetGlobal);
EXPECT_ARITY(1, kExprStoreGlobal); EXPECT_ARITY(1, kExprSetGlobal);
} }
TEST_F(WasmOpcodeArityTest, Calls) { TEST_F(WasmOpcodeArityTest, Calls) {
......
...@@ -52,7 +52,7 @@ TEST_F(WasmMacroGenTest, Statements) { ...@@ -52,7 +52,7 @@ TEST_F(WasmMacroGenTest, Statements) {
EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO)); EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO));
EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO)); EXPECT_SIZE(4, WASM_SET_GLOBAL(0, WASM_ZERO));
EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO)); EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO));
...@@ -101,9 +101,9 @@ TEST_F(WasmMacroGenTest, Expressions) { ...@@ -101,9 +101,9 @@ TEST_F(WasmMacroGenTest, Expressions) {
EXPECT_SIZE(2, WASM_GET_LOCAL(0)); EXPECT_SIZE(2, WASM_GET_LOCAL(0));
EXPECT_SIZE(2, WASM_GET_LOCAL(1)); EXPECT_SIZE(2, WASM_GET_LOCAL(1));
EXPECT_SIZE(2, WASM_GET_LOCAL(12)); EXPECT_SIZE(2, WASM_GET_LOCAL(12));
EXPECT_SIZE(2, WASM_LOAD_GLOBAL(0)); EXPECT_SIZE(2, WASM_GET_GLOBAL(0));
EXPECT_SIZE(2, WASM_LOAD_GLOBAL(1)); EXPECT_SIZE(2, WASM_GET_GLOBAL(1));
EXPECT_SIZE(2, WASM_LOAD_GLOBAL(12)); EXPECT_SIZE(2, WASM_GET_GLOBAL(12));
EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)); EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)); EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO));
EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)); EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment