Commit 9efaf554 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Rename (Get|Set)Table to Table(Get|Set)

When I implemented these instructions, I copied the naming scheme of
{GetGlobal}. That's not appropriate for the table.get instruction
though, and I decided I suffered enough from that bad name now.

R=clemensh@chromium.org

Bug: v8:7581, v8:9396
Change-Id: Id1796425458f3d06a2da774374f02c49d665d2c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1690835Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62563}
parent 011a6f35
......@@ -3484,7 +3484,7 @@ void WasmGraphBuilder::GetTableBaseAndOffset(uint32_t table_index,
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(0)));
}
Node* WasmGraphBuilder::GetTable(uint32_t table_index, Node* index,
Node* WasmGraphBuilder::TableGet(uint32_t table_index, Node* index,
wasm::WasmCodePosition position) {
if (env_->module->tables[table_index].type == wasm::kWasmAnyRef) {
Node* base = nullptr;
......@@ -3513,7 +3513,7 @@ Node* WasmGraphBuilder::GetTable(uint32_t table_index, Node* index,
Effect(), Control())));
}
Node* WasmGraphBuilder::SetTable(uint32_t table_index, Node* index, Node* val,
Node* WasmGraphBuilder::TableSet(uint32_t table_index, Node* index, Node* val,
wasm::WasmCodePosition position) {
if (env_->module->tables[table_index].type == wasm::kWasmAnyRef) {
Node* base = nullptr;
......
......@@ -285,9 +285,9 @@ class WasmGraphBuilder {
Node* GetGlobal(uint32_t index);
Node* SetGlobal(uint32_t index, Node* val);
Node* GetTable(uint32_t table_index, Node* index,
Node* TableGet(uint32_t table_index, Node* index,
wasm::WasmCodePosition position);
Node* SetTable(uint32_t table_index, Node* index, Node* val,
Node* TableSet(uint32_t table_index, Node* index, Node* val,
wasm::WasmCodePosition position);
//-----------------------------------------------------------------------
// Operations that concern the linear memory.
......
......@@ -1344,15 +1344,13 @@ class LiftoffCompiler {
__ Store(addr, no_reg, offset, reg, type, {}, nullptr, true);
}
void GetTable(
FullDecoder* decoder, const Value& index, Value* result,
TableIndexImmediate<validate>& imm) { // NOLINT(runtime/references)
void TableGet(FullDecoder* decoder, const Value& index, Value* result,
const TableIndexImmediate<validate>& imm) {
unsupported(decoder, kAnyRef, "table_get");
}
void SetTable(
FullDecoder* decoder, const Value& index, const Value& value,
TableIndexImmediate<validate>& imm) { // NOLINT(runtime/references)
void TableSet(FullDecoder* decoder, const Value& index, const Value& value,
const TableIndexImmediate<validate>& imm) {
unsupported(decoder, kAnyRef, "table_set");
}
......
......@@ -719,9 +719,9 @@ struct ControlBase {
const LocalIndexImmediate<validate>& imm) \
F(GetGlobal, Value* result, const GlobalIndexImmediate<validate>& imm) \
F(SetGlobal, const Value& value, const GlobalIndexImmediate<validate>& imm) \
F(GetTable, const Value& index, Value* result, \
F(TableGet, const Value& index, Value* result, \
const TableIndexImmediate<validate>& imm) \
F(SetTable, const Value& index, const Value& value, \
F(TableSet, const Value& index, const Value& value, \
const TableIndexImmediate<validate>& imm) \
F(Unreachable) \
F(Select, const Value& cond, const Value& fval, const Value& tval, \
......@@ -1248,8 +1248,8 @@ class WasmDecoder : public Decoder {
GlobalIndexImmediate<validate> imm(decoder, pc);
return 1 + imm.length;
}
case kExprGetTable:
case kExprSetTable: {
case kExprTableGet:
case kExprTableSet: {
TableIndexImmediate<validate> imm(decoder, pc);
return 1 + imm.length;
}
......@@ -1438,11 +1438,11 @@ class WasmDecoder : public Decoder {
case kExprSelect:
case kExprSelectWithType:
return {3, 1};
case kExprSetTable:
case kExprTableSet:
FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE)
return {2, 0};
FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
case kExprGetTable:
case kExprTableGet:
case kExprTeeLocal:
case kExprMemoryGrow:
return {1, 1};
......@@ -2161,7 +2161,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
CALL_INTERFACE_IF_REACHABLE(SetGlobal, value, imm);
break;
}
case kExprGetTable: {
case kExprTableGet: {
CHECK_PROTOTYPE_OPCODE(anyref);
TableIndexImmediate<validate> imm(this, this->pc_);
len = 1 + imm.length;
......@@ -2169,17 +2169,17 @@ class WasmFullDecoder : public WasmDecoder<validate> {
DCHECK_NOT_NULL(this->module_);
auto index = Pop(0, kWasmI32);
auto* result = Push(this->module_->tables[imm.index].type);
CALL_INTERFACE_IF_REACHABLE(GetTable, index, result, imm);
CALL_INTERFACE_IF_REACHABLE(TableGet, index, result, imm);
break;
}
case kExprSetTable: {
case kExprTableSet: {
CHECK_PROTOTYPE_OPCODE(anyref);
TableIndexImmediate<validate> imm(this, this->pc_);
len = 1 + imm.length;
if (!this->Validate(this->pc_, imm)) break;
auto value = Pop(1, this->module_->tables[imm.index].type);
auto index = Pop(0, kWasmI32);
CALL_INTERFACE_IF_REACHABLE(SetTable, index, value, imm);
CALL_INTERFACE_IF_REACHABLE(TableSet, index, value, imm);
break;
}
......
......@@ -291,14 +291,14 @@ class WasmGraphBuildingInterface {
BUILD(SetGlobal, imm.index, value.node);
}
void GetTable(FullDecoder* decoder, const Value& index, Value* result,
void TableGet(FullDecoder* decoder, const Value& index, Value* result,
const TableIndexImmediate<validate>& imm) {
result->node = BUILD(GetTable, imm.index, index.node, decoder->position());
result->node = BUILD(TableGet, imm.index, index.node, decoder->position());
}
void SetTable(FullDecoder* decoder, const Value& index, const Value& value,
void TableSet(FullDecoder* decoder, const Value& index, const Value& value,
const TableIndexImmediate<validate>& imm) {
BUILD(SetTable, imm.index, index.node, value.node, decoder->position());
BUILD(TableSet, imm.index, index.node, value.node, decoder->position());
}
void Unreachable(FullDecoder* decoder) {
......
......@@ -152,8 +152,8 @@ const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
CASE_OP(TeeLocal, "local.tee")
CASE_OP(GetGlobal, "global.get")
CASE_OP(SetGlobal, "global.set")
CASE_OP(GetTable, "table.get")
CASE_OP(SetTable, "table.set")
CASE_OP(TableGet, "table.get")
CASE_OP(TableSet, "table.set")
CASE_ALL_OP(Const, "const")
CASE_OP(MemorySize, "memory.size")
CASE_OP(MemoryGrow, "memory.grow")
......
......@@ -51,8 +51,8 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, bool hasBigIntFeature);
V(TeeLocal, 0x22, _) \
V(GetGlobal, 0x23, _) \
V(SetGlobal, 0x24, _) \
V(GetTable, 0x25, _) \
V(SetTable, 0x26, _) \
V(TableGet, 0x25, _) \
V(TableSet, 0x26, _) \
V(I32Const, 0x41, _) \
V(I64Const, 0x42, _) \
V(F32Const, 0x43, _) \
......
......@@ -172,8 +172,8 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes,
os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index;
break;
}
case kExprGetTable:
case kExprSetTable: {
case kExprTableGet:
case kExprTableSet: {
TableIndexImmediate<Decoder::kNoValidate> imm(&i, i.pc());
os << WasmOpcodes::OpcodeName(opcode) << ' ' << imm.index;
break;
......
......@@ -368,10 +368,10 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_GET_GLOBAL(index) kExprGetGlobal, static_cast<byte>(index)
#define WASM_SET_GLOBAL(index, val) \
val, kExprSetGlobal, static_cast<byte>(index)
#define WASM_GET_TABLE(table_index, index) \
index, kExprGetTable, static_cast<byte>(table_index)
#define WASM_SET_TABLE(table_index, index, val) \
index, val, kExprSetTable, static_cast<byte>(table_index)
#define WASM_TABLE_GET(table_index, index) \
index, kExprTableGet, static_cast<byte>(table_index)
#define WASM_TABLE_SET(table_index, index, val) \
index, val, kExprTableSet, static_cast<byte>(table_index)
#define WASM_LOAD_MEM(type, index) \
index, \
static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
......
......@@ -36,7 +36,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
const builder = new WasmModuleBuilder();
const table_index = builder.addImportedTable("imp", "table", 3, 10, kWasmAnyRef);
builder.addFunction('get', kSig_r_v)
.addBody([kExprI32Const, 0, kExprGetTable, table_index]);
.addBody([kExprI32Const, 0, kExprTableGet, table_index]);
let table_ref = new WebAssembly.Table({element: "anyref", initial: 3, maximum: 10});
builder.instantiate({imp:{table: table_ref}});
......
......@@ -13,12 +13,12 @@ function addTableWithAccessors(builder, type, size, name) {
builder.addFunction('set_' + name, set_sig)
.addBody([kExprGetLocal, 0,
kExprGetLocal, 1,
kExprSetTable, table.index])
kExprTableSet, table.index])
.exportFunc();
const get_sig = makeSig([kWasmI32], [type]);
builder.addFunction('get_' + name, get_sig)
.addBody([kExprGetLocal, 0, kExprGetTable, table.index])
.addBody([kExprGetLocal, 0, kExprTableGet, table.index])
.exportFunc();
}
......@@ -66,7 +66,7 @@ const dummy_func = exports.set_table_func1;
assertTraps(kTrapTableOutOfBounds, () => exports.set_table_ref1(44, dummy_ref));
})();
(function testSetTable() {
(function testTableSet() {
print(arguments.callee.name);
assertSame(null, exports.get_table_func1(3));
exports.set_table_func1(3, dummy_func);
......@@ -109,10 +109,10 @@ const dummy_func = exports.set_table_func1;
const f2 = builder.addFunction('f', kSig_i_v).addBody([kExprI32Const, value2]);
const f3 = builder.addFunction('f', kSig_i_v).addBody([kExprI32Const, value3]);
builder.addFunction('get_t1', kSig_a_i)
.addBody([kExprGetLocal, 0, kExprGetTable, t1])
.addBody([kExprGetLocal, 0, kExprTableGet, t1])
.exportFunc();
builder.addFunction('get_t2', kSig_a_i)
.addBody([kExprGetLocal, 0, kExprGetTable, t2])
.addBody([kExprGetLocal, 0, kExprTableGet, t2])
.exportFunc();
const offset1 = 3;
......@@ -143,7 +143,7 @@ const dummy_func = exports.set_table_func1;
.addBody([
kExprI32Const, index, // entry index
kExprRefFunc, function_index, // function reference
kExprSetTable, table_index, // --
kExprTableSet, table_index, // --
kExprI32Const, index, // entry index
kExprCallIndirect, sig_index, table_index // --
......
......@@ -38,7 +38,7 @@ for (index of [import_ref, internal_ref]) {
.exportFunc();
builder.addFunction(`get${index}`, kSig_r_i)
.addBody([kExprGetLocal, 0, kExprGetTable, index])
.addBody([kExprGetLocal, 0, kExprTableGet, index])
.exportFunc();
}
......
......@@ -38,7 +38,7 @@ function testGrowInternalAnyRefTable(table_index) {
.exportFunc();
builder.addFunction('get', kSig_r_i)
.addBody([kExprGetLocal, 0, kExprGetTable, table_index])
.addBody([kExprGetLocal, 0, kExprTableGet, table_index])
.exportFunc();
const instance = builder.instantiate();
......
......@@ -214,8 +214,8 @@ let kExprSetLocal = 0x21;
let kExprTeeLocal = 0x22;
let kExprGetGlobal = 0x23;
let kExprSetGlobal = 0x24;
let kExprGetTable = 0x25;
let kExprSetTable = 0x26;
let kExprTableGet = 0x25;
let kExprTableSet = 0x26;
let kExprI32LoadMem = 0x28;
let kExprI64LoadMem = 0x29;
let kExprF32LoadMem = 0x2a;
......
......@@ -2031,7 +2031,7 @@ TEST_F(FunctionBodyDecoderTest, AllSetGlobalCombinations) {
}
}
TEST_F(FunctionBodyDecoderTest, SetTable) {
TEST_F(FunctionBodyDecoderTest, TableSet) {
WASM_FEATURE_SCOPE(anyref);
TestModuleBuilder builder;
module = builder.module();
......@@ -2044,37 +2044,37 @@ TEST_F(FunctionBodyDecoderTest, SetTable) {
byte local_ref = 0;
byte local_func = 1;
byte local_int = 2;
ExpectValidates(&sig, {WASM_SET_TABLE(tab_ref1, WASM_I32V(6),
ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref1, WASM_I32V(6),
WASM_GET_LOCAL(local_ref))});
ExpectValidates(&sig, {WASM_SET_TABLE(tab_func1, WASM_I32V(5),
ExpectValidates(&sig, {WASM_TABLE_SET(tab_func1, WASM_I32V(5),
WASM_GET_LOCAL(local_func))});
ExpectValidates(&sig, {WASM_SET_TABLE(tab_func2, WASM_I32V(7),
ExpectValidates(&sig, {WASM_TABLE_SET(tab_func2, WASM_I32V(7),
WASM_GET_LOCAL(local_func))});
ExpectValidates(&sig, {WASM_SET_TABLE(tab_ref2, WASM_I32V(8),
ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref2, WASM_I32V(8),
WASM_GET_LOCAL(local_ref))});
// We can store anyfunc values as anyref, but not the other way around.
ExpectValidates(&sig, {WASM_SET_TABLE(tab_ref1, WASM_I32V(4),
ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref1, WASM_I32V(4),
WASM_GET_LOCAL(local_func))});
ExpectFailure(&sig, {WASM_SET_TABLE(tab_func1, WASM_I32V(9),
ExpectFailure(&sig, {WASM_TABLE_SET(tab_func1, WASM_I32V(9),
WASM_GET_LOCAL(local_ref))});
ExpectFailure(&sig, {WASM_SET_TABLE(tab_func2, WASM_I32V(3),
ExpectFailure(&sig, {WASM_TABLE_SET(tab_func2, WASM_I32V(3),
WASM_GET_LOCAL(local_ref))});
ExpectValidates(&sig, {WASM_SET_TABLE(tab_ref2, WASM_I32V(2),
ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref2, WASM_I32V(2),
WASM_GET_LOCAL(local_func))});
ExpectFailure(&sig, {WASM_SET_TABLE(tab_ref1, WASM_I32V(9),
ExpectFailure(&sig, {WASM_TABLE_SET(tab_ref1, WASM_I32V(9),
WASM_GET_LOCAL(local_int))});
ExpectFailure(&sig, {WASM_SET_TABLE(tab_func1, WASM_I32V(3),
ExpectFailure(&sig, {WASM_TABLE_SET(tab_func1, WASM_I32V(3),
WASM_GET_LOCAL(local_int))});
// Out-of-bounds table index should fail.
byte oob_tab = 37;
ExpectFailure(
&sig, {WASM_SET_TABLE(oob_tab, WASM_I32V(9), WASM_GET_LOCAL(local_ref))});
ExpectFailure(&sig, {WASM_SET_TABLE(oob_tab, WASM_I32V(3),
&sig, {WASM_TABLE_SET(oob_tab, WASM_I32V(9), WASM_GET_LOCAL(local_ref))});
ExpectFailure(&sig, {WASM_TABLE_SET(oob_tab, WASM_I32V(3),
WASM_GET_LOCAL(local_func))});
}
TEST_F(FunctionBodyDecoderTest, GetTable) {
TEST_F(FunctionBodyDecoderTest, TableGet) {
WASM_FEATURE_SCOPE(anyref);
TestModuleBuilder builder;
module = builder.module();
......@@ -2089,39 +2089,39 @@ TEST_F(FunctionBodyDecoderTest, GetTable) {
byte local_int = 2;
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_ref, WASM_GET_TABLE(tab_ref1, WASM_I32V(6)))});
{WASM_SET_LOCAL(local_ref, WASM_TABLE_GET(tab_ref1, WASM_I32V(6)))});
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_ref, WASM_GET_TABLE(tab_ref2, WASM_I32V(8)))});
{WASM_SET_LOCAL(local_ref, WASM_TABLE_GET(tab_ref2, WASM_I32V(8)))});
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_func, WASM_GET_TABLE(tab_func1, WASM_I32V(5)))});
{WASM_SET_LOCAL(local_func, WASM_TABLE_GET(tab_func1, WASM_I32V(5)))});
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_func, WASM_GET_TABLE(tab_func2, WASM_I32V(7)))});
{WASM_SET_LOCAL(local_func, WASM_TABLE_GET(tab_func2, WASM_I32V(7)))});
// We can store anyfunc values as anyref, but not the other way around.
ExpectFailure(&sig, {WASM_SET_LOCAL(local_func,
WASM_GET_TABLE(tab_ref1, WASM_I32V(4)))});
WASM_TABLE_GET(tab_ref1, WASM_I32V(4)))});
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_ref, WASM_GET_TABLE(tab_func1, WASM_I32V(9)))});
{WASM_SET_LOCAL(local_ref, WASM_TABLE_GET(tab_func1, WASM_I32V(9)))});
ExpectValidates(
&sig,
{WASM_SET_LOCAL(local_ref, WASM_GET_TABLE(tab_func2, WASM_I32V(3)))});
{WASM_SET_LOCAL(local_ref, WASM_TABLE_GET(tab_func2, WASM_I32V(3)))});
ExpectFailure(&sig, {WASM_SET_LOCAL(local_func,
WASM_GET_TABLE(tab_ref2, WASM_I32V(2)))});
WASM_TABLE_GET(tab_ref2, WASM_I32V(2)))});
ExpectFailure(&sig, {WASM_SET_LOCAL(local_int,
WASM_GET_TABLE(tab_ref1, WASM_I32V(9)))});
WASM_TABLE_GET(tab_ref1, WASM_I32V(9)))});
ExpectFailure(&sig, {WASM_SET_LOCAL(
local_int, WASM_GET_TABLE(tab_func1, WASM_I32V(3)))});
local_int, WASM_TABLE_GET(tab_func1, WASM_I32V(3)))});
// Out-of-bounds table index should fail.
byte oob_tab = 37;
ExpectFailure(
&sig, {WASM_SET_LOCAL(local_ref, WASM_GET_TABLE(oob_tab, WASM_I32V(9)))});
&sig, {WASM_SET_LOCAL(local_ref, WASM_TABLE_GET(oob_tab, WASM_I32V(9)))});
ExpectFailure(&sig, {WASM_SET_LOCAL(local_func,
WASM_GET_TABLE(oob_tab, WASM_I32V(3)))});
WASM_TABLE_GET(oob_tab, WASM_I32V(3)))});
}
TEST_F(FunctionBodyDecoderTest, MultiTableCallIndirect) {
......
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