Commit 70c94dfa authored by Ben Smith's avatar Ben Smith Committed by Commit Bot

[wasm] Rename memory.drop and table.drop

The new names for memory.drop and table.drop are data.drop and elem.drop
respectively. See
https://github.com/WebAssembly/bulk-memory-operations/issues/23 and
https://github.com/WebAssembly/bulk-memory-operations/pull/46.

Change-Id: I07aab8448fabe24eb9734dc7dac6f91c570cb553
Reviewed-on: https://chromium-review.googlesource.com/c/1446148
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59261}
parent bf18ee82
......@@ -4338,8 +4338,8 @@ Node* WasmGraphBuilder::MemoryInit(uint32_t data_segment_index, Node* dst,
return BuildCCall(&sig, function, dst, src, size);
}
Node* WasmGraphBuilder::MemoryDrop(uint32_t data_segment_index,
wasm::WasmCodePosition position) {
Node* WasmGraphBuilder::DataDrop(uint32_t data_segment_index,
wasm::WasmCodePosition position) {
Node* dropped_data_segments =
CheckDataSegmentIsPassiveAndNotDropped(data_segment_index, position);
const Operator* store_op = mcgraph()->machine()->Store(
......@@ -4405,8 +4405,8 @@ Node* WasmGraphBuilder::TableInit(uint32_t table_index,
return result;
}
Node* WasmGraphBuilder::TableDrop(uint32_t elem_segment_index,
wasm::WasmCodePosition position) {
Node* WasmGraphBuilder::ElemDrop(uint32_t elem_segment_index,
wasm::WasmCodePosition position) {
Node* dropped_elem_segments =
CheckElemSegmentIsPassiveAndNotDropped(elem_segment_index, position);
const Operator* store_op = mcgraph()->machine()->Store(
......
......@@ -370,14 +370,13 @@ class WasmGraphBuilder {
Node* size, wasm::WasmCodePosition position);
Node* MemoryCopy(Node* dst, Node* src, Node* size,
wasm::WasmCodePosition position);
Node* MemoryDrop(uint32_t data_segment_index,
wasm::WasmCodePosition position);
Node* DataDrop(uint32_t data_segment_index, wasm::WasmCodePosition position);
Node* MemoryFill(Node* dst, Node* fill, Node* size,
wasm::WasmCodePosition position);
Node* TableInit(uint32_t table_index, uint32_t elem_segment_index, Node* dst,
Node* src, Node* size, wasm::WasmCodePosition position);
Node* TableDrop(uint32_t elem_segment_index, wasm::WasmCodePosition position);
Node* ElemDrop(uint32_t elem_segment_index, wasm::WasmCodePosition position);
Node* TableCopy(uint32_t table_src_index, uint32_t table_dst_index, Node* dst,
Node* src, Node* size, wasm::WasmCodePosition position);
......
......@@ -1885,9 +1885,8 @@ class LiftoffCompiler {
const Value& src, const Value& size) {
unsupported(decoder, "memory.init");
}
void MemoryDrop(FullDecoder* decoder,
const MemoryDropImmediate<validate>& imm) {
unsupported(decoder, "memory.drop");
void DataDrop(FullDecoder* decoder, const DataDropImmediate<validate>& imm) {
unsupported(decoder, "data.drop");
}
void MemoryCopy(FullDecoder* decoder,
const MemoryCopyImmediate<validate>& imm, const Value& dst,
......@@ -1903,9 +1902,8 @@ class LiftoffCompiler {
Vector<Value> args) {
unsupported(decoder, "table.init");
}
void TableDrop(FullDecoder* decoder,
const TableDropImmediate<validate>& imm) {
unsupported(decoder, "table.drop");
void ElemDrop(FullDecoder* decoder, const ElemDropImmediate<validate>& imm) {
unsupported(decoder, "elem.drop");
}
void TableCopy(FullDecoder* decoder, const TableCopyImmediate<validate>& imm,
Vector<Value> args) {
......
......@@ -479,11 +479,11 @@ struct MemoryInitImmediate {
};
template <Decoder::ValidateFlag validate>
struct MemoryDropImmediate {
struct DataDropImmediate {
uint32_t index;
unsigned length;
inline MemoryDropImmediate(Decoder* decoder, const byte* pc) {
inline DataDropImmediate(Decoder* decoder, const byte* pc) {
index = decoder->read_i32v<validate>(pc + 2, &length, "data segment index");
}
};
......@@ -521,11 +521,11 @@ struct TableInitImmediate {
};
template <Decoder::ValidateFlag validate>
struct TableDropImmediate {
struct ElemDropImmediate {
uint32_t index;
unsigned length;
inline TableDropImmediate(Decoder* decoder, const byte* pc) {
inline ElemDropImmediate(Decoder* decoder, const byte* pc) {
index = decoder->read_i32v<validate>(pc + 2, &length, "elem segment index");
}
};
......@@ -713,13 +713,13 @@ struct ControlBase {
const MemoryAccessImmediate<validate>& imm, Value* result) \
F(MemoryInit, const MemoryInitImmediate<validate>& imm, const Value& dst, \
const Value& src, const Value& size) \
F(MemoryDrop, const MemoryDropImmediate<validate>& imm) \
F(DataDrop, const DataDropImmediate<validate>& imm) \
F(MemoryCopy, const MemoryCopyImmediate<validate>& imm, const Value& dst, \
const Value& src, const Value& size) \
F(MemoryFill, const MemoryIndexImmediate<validate>& imm, const Value& dst, \
const Value& value, const Value& size) \
F(TableInit, const TableInitImmediate<validate>& imm, Vector<Value> args) \
F(TableDrop, const TableDropImmediate<validate>& imm) \
F(ElemDrop, const ElemDropImmediate<validate>& imm) \
F(TableCopy, const TableCopyImmediate<validate>& imm, Vector<Value> args)
// Generic Wasm bytecode decoder with utilities for decoding immediates,
......@@ -1087,7 +1087,7 @@ class WasmDecoder : public Decoder {
return true;
}
inline bool Validate(MemoryDropImmediate<validate>& imm) {
inline bool Validate(DataDropImmediate<validate>& imm) {
if (!VALIDATE(module_ != nullptr &&
imm.index < module_->num_declared_data_segments)) {
errorf(pc_ + 2, "invalid data segment index: %u", imm.index);
......@@ -1122,7 +1122,7 @@ class WasmDecoder : public Decoder {
return true;
}
inline bool Validate(TableDropImmediate<validate>& imm) {
inline bool Validate(ElemDropImmediate<validate>& imm) {
if (!VALIDATE(module_ != nullptr &&
imm.index < module_->elem_segments.size())) {
errorf(pc_ + 2, "invalid element segment index: %u", imm.index);
......@@ -1239,8 +1239,8 @@ class WasmDecoder : public Decoder {
MemoryInitImmediate<validate> imm(decoder, pc);
return 2 + imm.length;
}
case kExprMemoryDrop: {
MemoryDropImmediate<validate> imm(decoder, pc);
case kExprDataDrop: {
DataDropImmediate<validate> imm(decoder, pc);
return 2 + imm.length;
}
case kExprMemoryCopy: {
......@@ -1255,8 +1255,8 @@ class WasmDecoder : public Decoder {
TableInitImmediate<validate> imm(decoder, pc);
return 2 + imm.length;
}
case kExprTableDrop: {
TableDropImmediate<validate> imm(decoder, pc);
case kExprElemDrop: {
ElemDropImmediate<validate> imm(decoder, pc);
return 2 + imm.length;
}
case kExprTableCopy: {
......@@ -2513,11 +2513,11 @@ class WasmFullDecoder : public WasmDecoder<validate> {
CALL_INTERFACE_IF_REACHABLE(MemoryInit, imm, dst, src, size);
break;
}
case kExprMemoryDrop: {
MemoryDropImmediate<validate> imm(this, this->pc_);
case kExprDataDrop: {
DataDropImmediate<validate> imm(this, this->pc_);
if (!this->Validate(imm)) break;
len += imm.length;
CALL_INTERFACE_IF_REACHABLE(MemoryDrop, imm);
CALL_INTERFACE_IF_REACHABLE(DataDrop, imm);
break;
}
case kExprMemoryCopy: {
......@@ -2548,11 +2548,11 @@ class WasmFullDecoder : public WasmDecoder<validate> {
CALL_INTERFACE_IF_REACHABLE(TableInit, imm, VectorOf(args_));
break;
}
case kExprTableDrop: {
TableDropImmediate<validate> imm(this, this->pc_);
case kExprElemDrop: {
ElemDropImmediate<validate> imm(this, this->pc_);
if (!this->Validate(imm)) break;
len += imm.length;
CALL_INTERFACE_IF_REACHABLE(TableDrop, imm);
CALL_INTERFACE_IF_REACHABLE(ElemDrop, imm);
break;
}
case kExprTableCopy: {
......
......@@ -510,9 +510,8 @@ class WasmGraphBuildingInterface {
BUILD(MemoryInit, imm.data_segment_index, dst.node, src.node, size.node,
decoder->position());
}
void MemoryDrop(FullDecoder* decoder,
const MemoryDropImmediate<validate>& imm) {
BUILD(MemoryDrop, imm.index, decoder->position());
void DataDrop(FullDecoder* decoder, const DataDropImmediate<validate>& imm) {
BUILD(DataDrop, imm.index, decoder->position());
}
void MemoryCopy(FullDecoder* decoder,
const MemoryCopyImmediate<validate>& imm, const Value& dst,
......@@ -529,9 +528,8 @@ class WasmGraphBuildingInterface {
BUILD(TableInit, imm.table.index, imm.elem_segment_index, args[0].node,
args[1].node, args[2].node, decoder->position());
}
void TableDrop(FullDecoder* decoder,
const TableDropImmediate<validate>& imm) {
BUILD(TableDrop, imm.index, decoder->position());
void ElemDrop(FullDecoder* decoder, const ElemDropImmediate<validate>& imm) {
BUILD(ElemDrop, imm.index, decoder->position());
}
void TableCopy(FullDecoder* decoder, const TableCopyImmediate<validate>& imm,
Vector<Value> args) {
......
......@@ -198,11 +198,11 @@ const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
CASE_CONVERT_SAT_OP(Convert, I64, F32, "f32", "trunc")
CASE_CONVERT_SAT_OP(Convert, I64, F64, "f64", "trunc")
CASE_OP(MemoryInit, "memory.init")
CASE_OP(MemoryDrop, "memory.drop")
CASE_OP(DataDrop, "data.drop")
CASE_OP(MemoryCopy, "memory.copy")
CASE_OP(MemoryFill, "memory.fill")
CASE_OP(TableInit, "table.init")
CASE_OP(TableDrop, "table.drop")
CASE_OP(ElemDrop, "elem.drop")
CASE_OP(TableCopy, "table.copy")
// SIMD opcodes.
......
......@@ -410,11 +410,11 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, bool hasBigIntFeature);
V(I64SConvertSatF64, 0xfc06, l_d) \
V(I64UConvertSatF64, 0xfc07, l_d) \
V(MemoryInit, 0xfc08, v_iii) \
V(MemoryDrop, 0xfc09, v_v) \
V(DataDrop, 0xfc09, v_v) \
V(MemoryCopy, 0xfc0a, v_iii) \
V(MemoryFill, 0xfc0b, v_iii) \
V(TableInit, 0xfc0c, v_iii) \
V(TableDrop, 0xfc0d, v_v) \
V(ElemDrop, 0xfc0d, v_v) \
V(TableCopy, 0xfc0e, v_iii)
#define FOREACH_ATOMIC_OPCODE(V) \
......
......@@ -592,14 +592,14 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_MEMORY_INIT(seg, dst, src, size) \
dst, src, size, WASM_NUMERIC_OP(kExprMemoryInit), U32V_1(seg), MEMORY_ZERO
#define WASM_MEMORY_DROP(seg) WASM_NUMERIC_OP(kExprMemoryDrop), U32V_1(seg)
#define WASM_DATA_DROP(seg) WASM_NUMERIC_OP(kExprDataDrop), U32V_1(seg)
#define WASM_MEMORY_COPY(dst, src, size) \
dst, src, size, WASM_NUMERIC_OP(kExprMemoryCopy), MEMORY_ZERO, MEMORY_ZERO
#define WASM_MEMORY_FILL(dst, val, size) \
dst, val, size, WASM_NUMERIC_OP(kExprMemoryFill), MEMORY_ZERO
#define WASM_TABLE_INIT(seg, dst, src, size) \
dst, src, size, WASM_NUMERIC_OP(kExprTableInit), U32V_1(seg), TABLE_ZERO
#define WASM_TABLE_DROP(seg) WASM_NUMERIC_OP(kExprTableDrop), U32V_1(seg)
#define WASM_ELEM_DROP(seg) WASM_NUMERIC_OP(kExprElemDrop), U32V_1(seg)
#define WASM_TABLE_COPY(dst, src, size) \
dst, src, size, WASM_NUMERIC_OP(kExprTableCopy), TABLE_ZERO, TABLE_ZERO
......
......@@ -143,7 +143,7 @@ function getMemoryInit(mem, segment_data) {
.exportAs('init');
builder.addFunction('drop', kSig_v_v)
.addBody([
kNumericPrefix, kExprMemoryDrop,
kNumericPrefix, kExprDataDrop,
0, // Data segment index.
])
.exportAs('drop');
......@@ -162,14 +162,14 @@ function getMemoryInit(mem, segment_data) {
assertTraps(kTrapDataSegmentDropped, () => instance.exports.drop());
})();
(function TestMemoryDropOnActiveSegment() {
(function TestDataDropOnActiveSegment() {
const builder = new WasmModuleBuilder();
builder.addMemory(1);
builder.addPassiveDataSegment([1, 2, 3]);
builder.addDataSegment(0, [4, 5, 6]);
builder.addFunction('drop', kSig_v_v)
.addBody([
kNumericPrefix, kExprMemoryDrop,
kNumericPrefix, kExprDataDrop,
1, // Data segment index.
])
.exportAs('drop');
......@@ -320,13 +320,13 @@ function getMemoryFill(mem) {
kTrapMemOutOfBounds, () => memoryFill(kPageSize + 1, v, kPageSize));
})();
(function TestTableDropActive() {
(function TestElemDropActive() {
const builder = new WasmModuleBuilder();
builder.setTableBounds(5, 5);
builder.addElementSegment(0, false, [0, 0, 0]);
builder.addFunction('drop', kSig_v_v)
.addBody([
kNumericPrefix, kExprTableDrop,
kNumericPrefix, kExprElemDrop,
0, // Element segment index.
])
.exportAs('drop');
......@@ -335,13 +335,13 @@ function getMemoryFill(mem) {
assertTraps(kTrapElemSegmentDropped, () => instance.exports.drop());
})();
(function TestTableDropTwice() {
(function TestElemDropTwice() {
const builder = new WasmModuleBuilder();
builder.setTableBounds(5, 5);
builder.addPassiveElementSegment([0, 0, 0]);
builder.addFunction('drop', kSig_v_v)
.addBody([
kNumericPrefix, kExprTableDrop,
kNumericPrefix, kExprElemDrop,
0, // Element segment index.
])
.exportAs('drop');
......
......@@ -376,11 +376,11 @@ let kAtomicPrefix = 0xfe;
// Numeric opcodes.
let kExprMemoryInit = 0x08;
let kExprMemoryDrop = 0x09;
let kExprDataDrop = 0x09;
let kExprMemoryCopy = 0x0a;
let kExprMemoryFill = 0x0b;
let kExprTableInit = 0x0c;
let kExprTableDrop = 0x0d;
let kExprElemDrop = 0x0d;
let kExprTableCopy = 0x0e;
// Atomic opcodes.
......
......@@ -2769,16 +2769,16 @@ TEST_F(FunctionBodyDecoderTest, MemoryInitInvalid) {
}
}
TEST_F(FunctionBodyDecoderTest, MemoryDrop) {
TEST_F(FunctionBodyDecoderTest, DataDrop) {
TestModuleBuilder builder;
builder.InitializeMemory();
builder.SetDataSegmentCount(1);
module = builder.module();
EXPECT_FAILURE(v_v, WASM_MEMORY_DROP(0));
EXPECT_FAILURE(v_v, WASM_DATA_DROP(0));
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(v_v, WASM_MEMORY_DROP(0));
EXPECT_FAILURE(v_v, WASM_MEMORY_DROP(1));
EXPECT_VERIFIES(v_v, WASM_DATA_DROP(0));
EXPECT_FAILURE(v_v, WASM_DATA_DROP(1));
}
TEST_F(FunctionBodyDecoderTest, MemoryCopy) {
......@@ -2833,16 +2833,16 @@ TEST_F(FunctionBodyDecoderTest, TableInitInvalid) {
}
}
TEST_F(FunctionBodyDecoderTest, TableDrop) {
TEST_F(FunctionBodyDecoderTest, ElemDrop) {
TestModuleBuilder builder;
builder.InitializeTable();
builder.AddPassiveElementSegment();
module = builder.module();
EXPECT_FAILURE(v_v, WASM_TABLE_DROP(0));
EXPECT_FAILURE(v_v, WASM_ELEM_DROP(0));
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(v_v, WASM_TABLE_DROP(0));
EXPECT_FAILURE(v_v, WASM_TABLE_DROP(1));
EXPECT_VERIFIES(v_v, WASM_ELEM_DROP(0));
EXPECT_FAILURE(v_v, WASM_ELEM_DROP(1));
}
TEST_F(FunctionBodyDecoderTest, TableCopy) {
......@@ -2862,7 +2862,7 @@ TEST_F(FunctionBodyDecoderTest, BulkTableOpsWithoutTable) {
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_FAILURE(v_v, WASM_TABLE_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO));
EXPECT_FAILURE(v_v, WASM_TABLE_DROP(0));
EXPECT_FAILURE(v_v, WASM_ELEM_DROP(0));
EXPECT_FAILURE(v_v, WASM_TABLE_COPY(WASM_ZERO, WASM_ZERO, 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