[wasm] Remove bulk-memory flag

bulk-memory shipped in V8 v7.5, hence the feature flag can be removed
now. This saves some binary size and a few dynamic checks for the flag.

R=ahaas@chromium.org

Bug: v8:11074
Change-Id: Ia73622637939f2192940fdd6909520786ed27286
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2622913
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72045}
This commit is contained in:
Clemens Backes 2021-01-12 14:47:25 +01:00 committed by Commit Bot
parent cab067c653
commit 4e57789f26
10 changed files with 29 additions and 267 deletions

View File

@ -8665,7 +8665,7 @@ class V8_EXPORT Isolate {
kWasmSimdOpcodes = 106,
kVarRedeclaredCatchBinding = 107,
kWasmRefTypes = 108,
kWasmBulkMemory = 109,
kWasmBulkMemory = 109, // Unused.
kWasmMultiValue = 110,
// If you add new values here, you'll also need to update Chromium's:

View File

@ -3146,8 +3146,6 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (full_opcode == kExprTableGrow || full_opcode == kExprTableSize ||
full_opcode == kExprTableFill) {
CHECK_PROTOTYPE_OPCODE(reftypes);
} else if (full_opcode >= kExprMemoryInit) {
CHECK_PROTOTYPE_OPCODE(bulk_memory);
}
trace_msg->AppendOpcode(full_opcode);
return DecodeNumericOpcode(full_opcode, opcode_length);

View File

@ -755,7 +755,6 @@ void UpdateFeatureUseCounts(Isolate* isolate, const WasmFeatures& detected) {
using Feature = v8::Isolate::UseCounterFeature;
constexpr static std::pair<WasmFeature, Feature> kUseCounters[] = {
{kFeature_reftypes, Feature::kWasmRefTypes},
{kFeature_bulk_memory, Feature::kWasmBulkMemory},
{kFeature_mv, Feature::kWasmMultiValue},
{kFeature_simd, Feature::kWasmSimdOpcodes},
{kFeature_threads, Feature::kWasmThreadOpcodes}};

View File

@ -499,11 +499,7 @@ class ModuleDecoderImpl : public Decoder {
}
break;
case kDataCountSectionCode:
if (enabled_features_.has_bulk_memory()) {
DecodeDataCountSection();
} else {
errorf(pc(), "unexpected section <%s>", SectionName(section_code));
}
break;
case kExceptionSectionCode:
if (enabled_features_.has_eh()) {
@ -1972,21 +1968,7 @@ class ModuleDecoderImpl : public Decoder {
ValueType* type, uint32_t* table_index,
WasmInitExpr* offset) {
const byte* pos = pc();
uint32_t flag;
if (enabled_features_.has_bulk_memory() ||
enabled_features_.has_reftypes()) {
flag = consume_u32v("flag");
} else {
uint32_t table_index = consume_u32v("table index");
// The only valid flag value without bulk_memory or externref is '0'.
if (table_index != 0) {
error(
"Element segments with table indices require "
"--experimental-wasm-bulk-memory or --experimental-wasm-reftypes");
return;
}
flag = 0;
}
uint32_t flag = consume_u32v("flag");
// The mask for the bit in the flag which indicates if the segment is
// active or not.
@ -2022,24 +2004,6 @@ class ModuleDecoderImpl : public Decoder {
"Declarative element segments require --experimental-wasm-reftypes");
return;
}
if (*status == WasmElemSegment::kStatusPassive &&
!enabled_features_.has_bulk_memory()) {
error("Passive element segments require --experimental-wasm-bulk-memory");
return;
}
if (*functions_as_elements && !enabled_features_.has_bulk_memory()) {
error(
"Illegal segment flag. Did you forget "
"--experimental-wasm-bulk-memory?");
return;
}
if (flag != 0 && !enabled_features_.has_bulk_memory() &&
!enabled_features_.has_reftypes()) {
error(
"Invalid segment flag. Enable with --experimental-wasm-bulk-memory "
"or --experimental-wasm-reftypes");
return;
}
if ((flag & kFullMask) != flag) {
errorf(pos, "illegal flag value %u. Must be between 0 and 7", flag);
}
@ -2088,21 +2052,9 @@ class ModuleDecoderImpl : public Decoder {
uint32_t flag = consume_u32v("flag");
// Some flag values are only valid for specific proposals.
if (flag == SegmentFlags::kPassive) {
if (!enabled_features_.has_bulk_memory()) {
error(
"Passive element segments require --experimental-wasm-bulk-memory");
return;
}
} else if (flag == SegmentFlags::kActiveWithIndex) {
if (!(enabled_features_.has_bulk_memory() ||
enabled_features_.has_reftypes())) {
error(
"Element segments with table indices require "
"--experimental-wasm-bulk-memory or --experimental-wasm-reftypes");
return;
}
} else if (flag != SegmentFlags::kActiveNoIndex) {
if (flag != SegmentFlags::kActiveNoIndex &&
flag != SegmentFlags::kPassive &&
flag != SegmentFlags::kActiveWithIndex) {
errorf(pos, "illegal flag value %u. Must be 0, 1, or 2", flag);
return;
}

View File

@ -655,45 +655,6 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
InitializeExceptions(instance);
}
// The bulk memory proposal changes the MVP behavior here; the segments are
// written as if `memory.init` and `table.init` are executed directly, and
// not bounds checked ahead of time.
if (!enabled_.has_bulk_memory()) {
//--------------------------------------------------------------------------
// Check that indirect function table segments are within bounds.
//--------------------------------------------------------------------------
for (const WasmElemSegment& elem_segment : module_->elem_segments) {
if (elem_segment.status != WasmElemSegment::kStatusActive) continue;
DCHECK_LT(elem_segment.table_index, table_count);
uint32_t base = EvalUint32InitExpr(instance, elem_segment.offset);
// Because of imported tables, {table_size} has to come from the table
// object itself.
auto table_object = handle(WasmTableObject::cast(instance->tables().get(
elem_segment.table_index)),
isolate_);
uint32_t table_size = table_object->current_length();
if (!base::IsInBounds<uint32_t>(
base, static_cast<uint32_t>(elem_segment.entries.size()),
table_size)) {
thrower_->LinkError("table initializer is out of bounds");
return {};
}
}
//--------------------------------------------------------------------------
// Check that memory segments are within bounds.
//--------------------------------------------------------------------------
for (const WasmDataSegment& seg : module_->data_segments) {
if (!seg.active) continue;
uint32_t base = EvalUint32InitExpr(instance, seg.dest_addr);
if (!base::IsInBounds<uint64_t>(base, seg.source.length(),
instance->memory_size())) {
thrower_->LinkError("data segment is out of bounds");
return {};
}
}
}
//--------------------------------------------------------------------------
// Set up the exports object for the new instance.
//--------------------------------------------------------------------------
@ -862,7 +823,6 @@ void InstanceBuilder::LoadDataSegments(Handle<WasmInstanceObject> instance) {
for (const WasmDataSegment& segment : module_->data_segments) {
uint32_t size = segment.source.length();
if (enabled_.has_bulk_memory()) {
// Passive segments are not copied during instantiation.
if (!segment.active) continue;
@ -877,18 +837,6 @@ void InstanceBuilder::LoadDataSegments(Handle<WasmInstanceObject> instance) {
if (size == 0) continue;
std::memcpy(instance->memory_start() + dest_offset,
wire_bytes.begin() + segment.source.offset(), size);
} else {
DCHECK(segment.active);
// Segments of size == 0 are just nops.
if (size == 0) continue;
uint32_t dest_offset = EvalUint32InitExpr(instance, segment.dest_addr);
DCHECK(base::IsInBounds<uint64_t>(dest_offset, size,
instance->memory_size()));
byte* dest = instance->memory_start() + dest_offset;
const byte* src = wire_bytes.begin() + segment.source.offset();
base::Memcpy(dest, src, size);
}
}
}
@ -1994,7 +1942,6 @@ void InstanceBuilder::LoadTableSegments(Handle<WasmInstanceObject> instance) {
// a dropped passive segment and an active segment have the same
// behavior.
instance->dropped_elem_segments()[segment_index] = 1;
if (enabled_.has_bulk_memory()) {
if (!success) {
thrower_->RuntimeError("table initializer is out of bounds");
// Break out instead of returning; we don't want to continue to
@ -2002,9 +1949,6 @@ void InstanceBuilder::LoadTableSegments(Handle<WasmInstanceObject> instance) {
// dispatch tables below.
break;
}
} else {
CHECK(success);
}
}
int table_count = static_cast<int>(module_->tables.size());

View File

@ -80,13 +80,6 @@
// Shipped features (enabled by default). Remove the feature flag once they hit
// stable and are expected to stay enabled.
#define FOREACH_WASM_SHIPPED_FEATURE_FLAG(V) /* (force 80 columns) */ \
/* Bulk memory operations. */ \
/* https://github.com/webassembly/bulk-memory-operations */ \
/* V8 side owner: binji */ \
/* Shipped in v7.5. */ \
/* ITS: https://groups.google.com/forum/#!topic/v8-users/zM05lYEBVog */ \
V(bulk_memory, "bulk memory opcodes", true) \
\
/* Multi-value proposal. */ \
/* https://github.com/WebAssembly/multi-value */ \
/* V8 side owner: thibaudm */ \

View File

@ -46,7 +46,6 @@ void CheckMemoryEqualsFollowedByZeroes(TestingModuleBuilder* builder,
} // namespace
WASM_EXEC_TEST(MemoryInit) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
@ -83,7 +82,6 @@ WASM_EXEC_TEST(MemoryInit) {
}
WASM_EXEC_TEST(MemoryInitOutOfBoundsData) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
@ -105,7 +103,6 @@ WASM_EXEC_TEST(MemoryInitOutOfBoundsData) {
}
WASM_EXEC_TEST(MemoryInitOutOfBounds) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
const byte data[kWasmPageSize] = {};
@ -137,7 +134,6 @@ WASM_EXEC_TEST(MemoryInitOutOfBounds) {
}
WASM_EXEC_TEST(MemoryCopy) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
byte* mem = r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -166,7 +162,6 @@ WASM_EXEC_TEST(MemoryCopy) {
}
WASM_EXEC_TEST(MemoryCopyOverlapping) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
byte* mem = r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -189,7 +184,6 @@ WASM_EXEC_TEST(MemoryCopyOverlapping) {
}
WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
byte* mem = r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -218,7 +212,6 @@ WASM_EXEC_TEST(MemoryCopyOutOfBoundsData) {
}
WASM_EXEC_TEST(MemoryCopyOutOfBounds) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -248,7 +241,6 @@ WASM_EXEC_TEST(MemoryCopyOutOfBounds) {
}
WASM_EXEC_TEST(MemoryFill) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -272,7 +264,6 @@ WASM_EXEC_TEST(MemoryFill) {
}
WASM_EXEC_TEST(MemoryFillValueWrapsToByte) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -286,7 +277,6 @@ WASM_EXEC_TEST(MemoryFillValueWrapsToByte) {
}
WASM_EXEC_TEST(MemoryFillOutOfBoundsData) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -299,7 +289,6 @@ WASM_EXEC_TEST(MemoryFillOutOfBoundsData) {
}
WASM_EXEC_TEST(MemoryFillOutOfBounds) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
BUILD(
@ -322,7 +311,6 @@ WASM_EXEC_TEST(MemoryFillOutOfBounds) {
}
WASM_EXEC_TEST(DataDropTwice) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0};
@ -334,7 +322,6 @@ WASM_EXEC_TEST(DataDropTwice) {
}
WASM_EXEC_TEST(DataDropThenMemoryInit) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
@ -348,7 +335,6 @@ WASM_EXEC_TEST(DataDropThenMemoryInit) {
void TestTableCopyInbounds(TestExecutionTier execution_tier, int table_dst,
int table_src) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
const uint32_t kTableSize = 5;
// Add 10 function tables, even though we only test one table.
@ -411,7 +397,6 @@ void CheckTableCall(Isolate* isolate, Handle<WasmTableObject> table,
} // namespace
void TestTableInitElems(TestExecutionTier execution_tier, int table_index) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
TestSignatures sigs;
@ -489,7 +474,6 @@ WASM_COMPILED_EXEC_TEST(TableInitElems9) {
}
void TestTableInitOob(TestExecutionTier execution_tier, int table_index) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
TestSignatures sigs;
@ -569,7 +553,6 @@ WASM_COMPILED_EXEC_TEST(TableInitOob9) {
void TestTableCopyElems(TestExecutionTier execution_tier, int table_dst,
int table_src) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
TestSignatures sigs;
@ -651,7 +634,6 @@ WASM_COMPILED_EXEC_TEST(TableCopyElemsFrom6To6) {
void TestTableCopyCalls(TestExecutionTier execution_tier, int table_dst,
int table_src) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
TestSignatures sigs;
@ -726,7 +708,6 @@ WASM_COMPILED_EXEC_TEST(TableCopyCallsTo6From6) {
void TestTableCopyOobWrites(TestExecutionTier execution_tier, int table_dst,
int table_src) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
TestSignatures sigs;
@ -802,7 +783,6 @@ WASM_COMPILED_EXEC_TEST(TableCopyOobWritesFrom6To6) {
void TestTableCopyOob1(TestExecutionTier execution_tier, int table_dst,
int table_src) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
const uint32_t kTableSize = 5;
@ -860,7 +840,6 @@ WASM_COMPILED_EXEC_TEST(TableCopyOob1From6To6) {
}
WASM_COMPILED_EXEC_TEST(ElemDropTwice) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t> r(execution_tier);
r.builder().AddIndirectFunctionTable(nullptr, 1);
r.builder().AddPassiveElementSegment({});
@ -871,7 +850,6 @@ WASM_COMPILED_EXEC_TEST(ElemDropTwice) {
}
WASM_COMPILED_EXEC_TEST(ElemDropThenTableInit) {
EXPERIMENTAL_FLAG_SCOPE(bulk_memory);
WasmRunner<uint32_t, uint32_t> r(execution_tier);
r.builder().AddIndirectFunctionTable(nullptr, 1);
r.builder().AddPassiveElementSegment({});

View File

@ -904,41 +904,6 @@ TEST(EmptyMemoryEmptyDataSegment) {
Cleanup();
}
TEST(MemoryWithOOBEmptyDataSegment) {
{
FlagScope<bool> no_bulk_memory(
&v8::internal::FLAG_experimental_wasm_bulk_memory, false);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
testing::SetupIsolateForWasmModule(isolate);
ErrorThrower thrower(isolate, "Run_WasmModule_InitDataAtTheUpperLimit");
const byte data[] = {
WASM_MODULE_HEADER, // --
kMemorySectionCode, // --
U32V_1(4), // section size
ENTRY_COUNT(1), // --
kWithMaximum, // --
1, // initial size
1, // maximum size
kDataSectionCode, // --
U32V_1(9), // section size
ENTRY_COUNT(1), // --
0, // linear memory index
WASM_I32V_4(0x2468ACE), // destination offset
kExprEnd,
U32V_1(0), // source size
};
CompileAndInstantiateForTesting(
isolate, &thrower, ModuleWireBytes(data, data + arraysize(data)));
// It should not be possible to instantiate this module.
CHECK(thrower.error());
}
Cleanup();
}
#undef EMIT_CODE_WITH_END
} // namespace test_run_wasm_module

View File

@ -3171,9 +3171,6 @@ TEST_F(FunctionBodyDecoderTest, MemoryInit) {
builder.InitializeMemory();
builder.SetDataSegmentCount(1);
ExpectFailure(sigs.v_v(),
{WASM_MEMORY_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(),
{WASM_MEMORY_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
ExpectFailure(sigs.v_v(),
@ -3184,7 +3181,6 @@ TEST_F(FunctionBodyDecoderTest, MemoryInitInvalid) {
builder.InitializeMemory();
builder.SetDataSegmentCount(1);
WASM_FEATURE_SCOPE(bulk_memory);
byte code[] = {WASM_MEMORY_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO),
WASM_END};
for (size_t i = 0; i <= arraysize(code); ++i) {
@ -3196,8 +3192,6 @@ TEST_F(FunctionBodyDecoderTest, DataDrop) {
builder.InitializeMemory();
builder.SetDataSegmentCount(1);
ExpectFailure(sigs.v_v(), {WASM_DATA_DROP(0)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(), {WASM_DATA_DROP(0)});
ExpectFailure(sigs.v_v(), {WASM_DATA_DROP(1)});
}
@ -3206,7 +3200,6 @@ TEST_F(FunctionBodyDecoderTest, DataSegmentIndexUnsigned) {
builder.InitializeMemory();
builder.SetDataSegmentCount(65);
WASM_FEATURE_SCOPE(bulk_memory);
// Make sure that the index is interpreted as an unsigned number; 64 is
// interpreted as -64 when decoded as a signed LEB.
ExpectValidates(sigs.v_v(),
@ -3217,9 +3210,6 @@ TEST_F(FunctionBodyDecoderTest, DataSegmentIndexUnsigned) {
TEST_F(FunctionBodyDecoderTest, MemoryCopy) {
builder.InitializeMemory();
ExpectFailure(sigs.v_v(),
{WASM_MEMORY_COPY(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(),
{WASM_MEMORY_COPY(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
}
@ -3227,15 +3217,11 @@ TEST_F(FunctionBodyDecoderTest, MemoryCopy) {
TEST_F(FunctionBodyDecoderTest, MemoryFill) {
builder.InitializeMemory();
ExpectFailure(sigs.v_v(),
{WASM_MEMORY_FILL(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(),
{WASM_MEMORY_FILL(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, BulkMemoryOpsWithoutMemory) {
WASM_FEATURE_SCOPE(bulk_memory);
ExpectFailure(sigs.v_v(),
{WASM_MEMORY_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
ExpectFailure(sigs.v_v(),
@ -3248,9 +3234,6 @@ TEST_F(FunctionBodyDecoderTest, TableInit) {
builder.InitializeTable(wasm::kWasmFuncRef);
builder.AddPassiveElementSegment(wasm::kWasmFuncRef);
ExpectFailure(sigs.v_v(),
{WASM_TABLE_INIT(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(),
{WASM_TABLE_INIT(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
ExpectFailure(sigs.v_v(),
@ -3262,7 +3245,6 @@ TEST_F(FunctionBodyDecoderTest, TableInitWrongType) {
uint32_t element_index =
builder.AddPassiveElementSegment(wasm::kWasmExternRef);
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
ExpectFailure(sigs.v_v(), {WASM_TABLE_INIT(table_index, element_index,
WASM_ZERO, WASM_ZERO, WASM_ZERO)});
@ -3272,7 +3254,6 @@ TEST_F(FunctionBodyDecoderTest, TableInitInvalid) {
builder.InitializeTable(wasm::kWasmFuncRef);
builder.AddPassiveElementSegment(wasm::kWasmFuncRef);
WASM_FEATURE_SCOPE(bulk_memory);
byte code[] = {WASM_TABLE_INIT(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO),
WASM_END};
for (size_t i = 0; i <= arraysize(code); ++i) {
@ -3284,8 +3265,6 @@ TEST_F(FunctionBodyDecoderTest, ElemDrop) {
builder.InitializeTable(wasm::kWasmFuncRef);
builder.AddPassiveElementSegment(wasm::kWasmFuncRef);
ExpectFailure(sigs.v_v(), {WASM_ELEM_DROP(0)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(), {WASM_ELEM_DROP(0)});
ExpectFailure(sigs.v_v(), {WASM_ELEM_DROP(1)});
}
@ -3294,7 +3273,6 @@ TEST_F(FunctionBodyDecoderTest, TableInitDeclarativeElem) {
builder.InitializeTable(wasm::kWasmFuncRef);
builder.AddDeclarativeElementSegment();
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
byte code[] = {WASM_TABLE_INIT(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO),
WASM_END};
@ -3307,8 +3285,6 @@ TEST_F(FunctionBodyDecoderTest, DeclarativeElemDrop) {
builder.InitializeTable(wasm::kWasmFuncRef);
builder.AddDeclarativeElementSegment();
ExpectFailure(sigs.v_v(), {WASM_ELEM_DROP(0)});
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
ExpectValidates(sigs.v_v(), {WASM_ELEM_DROP(0)});
ExpectFailure(sigs.v_v(), {WASM_ELEM_DROP(1)});
@ -3319,7 +3295,6 @@ TEST_F(FunctionBodyDecoderTest, RefFuncDeclared) {
byte function_index = builder.AddFunction(sigs.v_i());
ExpectFailure(sigs.a_v(), {WASM_REF_FUNC(function_index)});
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
ExpectValidates(sigs.a_v(), {WASM_REF_FUNC(function_index)});
}
@ -3328,7 +3303,6 @@ TEST_F(FunctionBodyDecoderTest, RefFuncUndeclared) {
builder.InitializeTable(wasm::kWasmStmt);
byte function_index = builder.AddFunction(sigs.v_i(), false);
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
ExpectFailure(sigs.a_v(), {WASM_REF_FUNC(function_index)});
}
@ -3339,7 +3313,6 @@ TEST_F(FunctionBodyDecoderTest, ElemSegmentIndexUnsigned) {
builder.AddPassiveElementSegment(wasm::kWasmFuncRef);
}
WASM_FEATURE_SCOPE(bulk_memory);
// Make sure that the index is interpreted as an unsigned number; 64 is
// interpreted as -64 when decoded as a signed LEB.
ExpectValidates(sigs.v_v(),
@ -3350,9 +3323,6 @@ TEST_F(FunctionBodyDecoderTest, ElemSegmentIndexUnsigned) {
TEST_F(FunctionBodyDecoderTest, TableCopy) {
builder.InitializeTable(wasm::kWasmStmt);
ExpectFailure(sigs.v_v(),
{WASM_TABLE_COPY(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
WASM_FEATURE_SCOPE(bulk_memory);
ExpectValidates(sigs.v_v(),
{WASM_TABLE_COPY(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
}
@ -3361,7 +3331,6 @@ TEST_F(FunctionBodyDecoderTest, TableCopyWrongType) {
uint32_t dst_table_index = builder.InitializeTable(wasm::kWasmFuncRef);
uint32_t src_table_index = builder.InitializeTable(wasm::kWasmExternRef);
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
ExpectFailure(sigs.v_v(), {WASM_TABLE_COPY(dst_table_index, src_table_index,
WASM_ZERO, WASM_ZERO, WASM_ZERO)});
@ -3438,18 +3407,14 @@ TEST_F(FunctionBodyDecoderTest, TableOpsWithoutTable) {
{WASM_TABLE_FILL(0, WASM_ONE, WASM_REF_NULL(kExternRefCode),
WASM_ONE)});
}
{
WASM_FEATURE_SCOPE(bulk_memory);
builder.AddPassiveElementSegment(wasm::kWasmFuncRef);
ExpectFailure(sigs.v_v(),
{WASM_TABLE_INIT(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
ExpectFailure(sigs.v_v(),
{WASM_TABLE_COPY(0, 0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
}
}
TEST_F(FunctionBodyDecoderTest, TableCopyMultiTable) {
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
{
TestModuleBuilder builder;
@ -3499,7 +3464,6 @@ TEST_F(FunctionBodyDecoderTest, TableCopyMultiTable) {
}
TEST_F(FunctionBodyDecoderTest, TableInitMultiTable) {
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
{
TestModuleBuilder builder;

View File

@ -280,7 +280,6 @@ TEST_F(WasmModuleVerifyTest, S128Global) {
TEST_F(WasmModuleVerifyTest, ExternRefGlobal) {
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -329,7 +328,6 @@ TEST_F(WasmModuleVerifyTest, ExternRefGlobal) {
TEST_F(WasmModuleVerifyTest, FuncRefGlobal) {
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -1628,7 +1626,6 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTables) {
// Test that if we have multiple tables, in the element section we can target
// and initialize all tables.
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -1661,7 +1658,6 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTables) {
// Test that if we have multiple tables, both imported and module-defined, in
// the element section we can target and initialize all tables.
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -1719,7 +1715,6 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTablesArbitraryOrder) {
// Test that the order in which tables are targeted in the element secion
// can be arbitrary.
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -1756,7 +1751,6 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) {
// Test that the order in which tables are targeted in the element secion can
// be arbitrary. In this test, tables can be both imported and module-defined.
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -1812,7 +1806,6 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) {
TEST_F(WasmModuleVerifyTest, ElementSectionInitExternRefTableWithFuncRef) {
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -1847,7 +1840,6 @@ TEST_F(WasmModuleVerifyTest, ElementSectionDontInitExternRefImportedTable) {
// Test that imported tables of type ExternRef cannot be initialized in the
// elements section.
WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
// sig#0 ---------------------------------------------------------------
TYPE_SECTION_ONE_SIG_VOID_VOID,
@ -3016,8 +3008,6 @@ TEST_F(WasmModuleVerifyTest, PassiveDataSegment) {
// data segments --------------------------------------------------------
SECTION(Data, ENTRY_COUNT(1), PASSIVE, ADD_COUNT('h', 'i')),
};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(data);
EXPECT_OFF_END_FAILURE(data, arraysize(data) - 5);
}
@ -3036,8 +3026,6 @@ TEST_F(WasmModuleVerifyTest, ActiveElementSegmentWithElements) {
REF_FUNC_ELEMENT(0), REF_FUNC_ELEMENT(0), REF_NULL_ELEMENT),
// code ------------------------------------------------------------------
ONE_EMPTY_BODY};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(data);
EXPECT_OFF_END_FAILURE(data, arraysize(data) - 5);
}
@ -3056,8 +3044,6 @@ TEST_F(WasmModuleVerifyTest, PassiveElementSegment) {
REF_NULL_ELEMENT),
// code ------------------------------------------------------------------
ONE_EMPTY_BODY};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(data);
EXPECT_OFF_END_FAILURE(data, arraysize(data) - 5);
}
@ -3075,7 +3061,6 @@ TEST_F(WasmModuleVerifyTest, PassiveElementSegmentExternRef) {
U32V_1(0)),
// code ------------------------------------------------------------------
ONE_EMPTY_BODY};
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_FAILURE(data);
}
@ -3092,8 +3077,6 @@ TEST_F(WasmModuleVerifyTest, PassiveElementSegmentWithIndices) {
ENTRY_COUNT(3), U32V_1(0), U32V_1(0), U32V_1(0)),
// code ------------------------------------------------------------------
ONE_EMPTY_BODY};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(data);
EXPECT_OFF_END_FAILURE(data, arraysize(data) - 5);
}
@ -3113,14 +3096,11 @@ TEST_F(WasmModuleVerifyTest, DeclarativeElementSegmentFuncRef) {
// code ------------------------------------------------------------------
ONE_EMPTY_BODY};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(reftypes);
EXPECT_VERIFIES(data);
}
TEST_F(WasmModuleVerifyTest, DeclarativeElementSegmentWithInvalidIndex) {
WASM_FEATURE_SCOPE(bulk_memory);
WASM_FEATURE_SCOPE(reftypes);
static const byte data[] = {
// sig#0 -----------------------------------------------------------------
@ -3144,15 +3124,12 @@ TEST_F(WasmModuleVerifyTest, DataCountSectionCorrectPlacement) {
static const byte data[] = {SECTION(Element, ENTRY_COUNT(0)),
SECTION(DataCount, ENTRY_COUNT(0)),
SECTION(Code, ENTRY_COUNT(0))};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(data);
}
TEST_F(WasmModuleVerifyTest, DataCountSectionAfterCode) {
static const byte data[] = {SECTION(Code, ENTRY_COUNT(0)),
SECTION(DataCount, ENTRY_COUNT(0))};
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result,
"The DataCount section must appear before the Code section");
@ -3161,7 +3138,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSectionAfterCode) {
TEST_F(WasmModuleVerifyTest, DataCountSectionBeforeElement) {
static const byte data[] = {SECTION(DataCount, ENTRY_COUNT(0)),
SECTION(Element, ENTRY_COUNT(0))};
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "unexpected section <Element>");
}
@ -3178,7 +3154,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSectionAfterStartBeforeElement) {
SECTION(DataCount, ENTRY_COUNT(0)), // DataCount section.
SECTION(Element, ENTRY_COUNT(0)) // Element section.
};
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "unexpected section <Element>");
}
@ -3186,7 +3161,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSectionAfterStartBeforeElement) {
TEST_F(WasmModuleVerifyTest, MultipleDataCountSections) {
static const byte data[] = {SECTION(DataCount, ENTRY_COUNT(0)),
SECTION(DataCount, ENTRY_COUNT(0))};
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "Multiple DataCount sections not allowed");
}
@ -3198,8 +3172,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSegmentCountMatch) {
SECTION(Data, ENTRY_COUNT(1), LINEAR_MEMORY_INDEX_0, // Data section.
WASM_INIT_EXPR_I32V_1(12), ADD_COUNT('h', 'i'))};
EXPECT_FAILURE(data);
WASM_FEATURE_SCOPE(bulk_memory);
EXPECT_VERIFIES(data);
}
@ -3208,7 +3180,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_greater) {
SECTION(Memory, ENTRY_COUNT(1), 0, 1), // Memory section.
SECTION(DataCount, ENTRY_COUNT(3)), // DataCount section.
SECTION(Data, ENTRY_COUNT(0))}; // Data section.
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "data segments count 0 mismatch (3 expected)");
}
@ -3219,7 +3190,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_less) {
SECTION(DataCount, ENTRY_COUNT(0)), // DataCount section.
SECTION(Data, ENTRY_COUNT(1), LINEAR_MEMORY_INDEX_0, // Data section.
WASM_INIT_EXPR_I32V_1(12), ADD_COUNT('a', 'b', 'c'))};
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "data segments count 1 mismatch (0 expected)");
}
@ -3227,7 +3197,6 @@ TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_less) {
TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_omitted) {
static const byte data[] = {SECTION(Memory, ENTRY_COUNT(1), 0, 1),
SECTION(DataCount, ENTRY_COUNT(1))};
WASM_FEATURE_SCOPE(bulk_memory);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "data segments count 0 mismatch (1 expected)");
}