Commit fd8309e8 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by V8 LUCI CQ

[wasm] Rename "initializer" expression to "constant"

Change-Id: I6f2e5fa04eba1b3c97212be945b776ebc2be5915
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3726210Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81399}
parent 2b3bff58
...@@ -1366,14 +1366,13 @@ class WasmDecoder : public Decoder { ...@@ -1366,14 +1366,13 @@ class WasmDecoder : public Decoder {
if (decoding_mode == kConstantExpression) { if (decoding_mode == kConstantExpression) {
if (!VALIDATE(!imm.global->mutability)) { if (!VALIDATE(!imm.global->mutability)) {
this->DecodeError(pc, this->DecodeError(pc,
"mutable globals cannot be used in initializer " "mutable globals cannot be used in constant "
"expressions"); "expressions");
return false; return false;
} }
if (!VALIDATE(imm.global->imported || this->enabled_.has_gc())) { if (!VALIDATE(imm.global->imported || this->enabled_.has_gc())) {
this->DecodeError( this->DecodeError(
pc, pc, "non-imported globals cannot be used in constant expressions");
"non-imported globals cannot be used in initializer expressions");
return false; return false;
} }
} }
...@@ -3691,7 +3690,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -3691,7 +3690,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
#undef DECODE #undef DECODE
static int NonConstError(WasmFullDecoder* decoder, WasmOpcode opcode) { static int NonConstError(WasmFullDecoder* decoder, WasmOpcode opcode) {
decoder->DecodeError("opcode %s is not allowed in init. expressions", decoder->DecodeError("opcode %s is not allowed in constant expressions",
WasmOpcodes::OpcodeName(opcode)); WasmOpcodes::OpcodeName(opcode));
return 0; return 0;
} }
...@@ -4094,9 +4093,9 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4094,9 +4093,9 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
uint32_t DecodeSimdOpcode(WasmOpcode opcode, uint32_t opcode_length) { uint32_t DecodeSimdOpcode(WasmOpcode opcode, uint32_t opcode_length) {
if (decoding_mode == kConstantExpression) { if (decoding_mode == kConstantExpression) {
// Currently, only s128.const is allowed in initializer expressions. // Currently, only s128.const is allowed in constant expressions.
if (opcode != kExprS128Const) { if (opcode != kExprS128Const) {
this->DecodeError("opcode %s is not allowed in init. expressions", this->DecodeError("opcode %s is not allowed in constant expressions",
this->SafeOpcodeNameAt(this->pc())); this->SafeOpcodeNameAt(this->pc()));
return 0; return 0;
} }
...@@ -4248,7 +4247,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4248,7 +4247,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
#define NON_CONST_ONLY \ #define NON_CONST_ONLY \
if (decoding_mode == kConstantExpression) { \ if (decoding_mode == kConstantExpression) { \
this->DecodeError("opcode %s is not allowed in init. expressions", \ this->DecodeError("opcode %s is not allowed in constant expressions", \
this->SafeOpcodeNameAt(this->pc())); \ this->SafeOpcodeNameAt(this->pc())); \
return 0; \ return 0; \
} }
...@@ -5825,11 +5824,9 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -5825,11 +5824,9 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
bool TypeCheckStackAgainstMerge(uint32_t drop_values, Merge<Value>* merge) { bool TypeCheckStackAgainstMerge(uint32_t drop_values, Merge<Value>* merge) {
static_assert(validate, "Call this function only within VALIDATE"); static_assert(validate, "Call this function only within VALIDATE");
constexpr const char* merge_description = constexpr const char* merge_description =
merge_type == kBranchMerge merge_type == kBranchMerge ? "branch"
? "branch" : merge_type == kReturnMerge ? "return"
: merge_type == kReturnMerge : merge_type == kInitExprMerge ? "constant expression"
? "return"
: merge_type == kInitExprMerge ? "init. expression"
: "fallthru"; : "fallthru";
uint32_t arity = merge->arity; uint32_t arity = merge->arity;
uint32_t actual = stack_size() - control_.back().stack_depth; uint32_t actual = stack_size() - control_.back().stack_depth;
......
...@@ -1682,7 +1682,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1682,7 +1682,7 @@ class ModuleDecoderImpl : public Decoder {
WasmError intermediate_error_; WasmError intermediate_error_;
ModuleOrigin origin_; ModuleOrigin origin_;
AccountingAllocator allocator_; AccountingAllocator allocator_;
Zone init_expr_zone_{&allocator_, "initializer expression zone"}; Zone init_expr_zone_{&allocator_, "constant expr. zone"};
bool has_seen_unordered_section(SectionCode section_code) { bool has_seen_unordered_section(SectionCode section_code) {
return seen_unordered_sections_ & (1 << section_code); return seen_unordered_sections_ & (1 << section_code);
...@@ -1943,7 +1943,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1943,7 +1943,7 @@ class ModuleDecoderImpl : public Decoder {
#define TYPE_CHECK(found) \ #define TYPE_CHECK(found) \
if (V8_UNLIKELY(!IsSubtypeOf(found, expected, module_.get()))) { \ if (V8_UNLIKELY(!IsSubtypeOf(found, expected, module_.get()))) { \
errorf(pc() + 1, \ errorf(pc() + 1, \
"type error in init. expression[0] (expected %s, got %s)", \ "type error in constant expression[0] (expected %s, got %s)", \
expected.name().c_str(), found.name().c_str()); \ expected.name().c_str(), found.name().c_str()); \
return {}; \ return {}; \
} }
...@@ -2027,7 +2027,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -2027,7 +2027,7 @@ class ModuleDecoderImpl : public Decoder {
} }
if (!decoder.interface().end_found()) { if (!decoder.interface().end_found()) {
error("Initializer expression is missing 'end'"); error("constant expression is missing 'end'");
return {}; return {};
} }
...@@ -2153,7 +2153,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -2153,7 +2153,7 @@ class ModuleDecoderImpl : public Decoder {
// - for non-active tables, whether the table is declarative (vs. passive). // - for non-active tables, whether the table is declarative (vs. passive).
constexpr uint8_t kHasTableIndexOrIsDeclarativeMask = 1 << 1; constexpr uint8_t kHasTableIndexOrIsDeclarativeMask = 1 << 1;
// The mask for the bit in the flag which indicates if the functions of this // The mask for the bit in the flag which indicates if the functions of this
// segment are defined as function indices (0) or init. expressions (1). // segment are defined as function indices (0) or constant expressions (1).
constexpr uint8_t kExpressionsAsElementsMask = 1 << 2; constexpr uint8_t kExpressionsAsElementsMask = 1 << 2;
constexpr uint8_t kFullMask = kNonActiveMask | constexpr uint8_t kFullMask = kNonActiveMask |
kHasTableIndexOrIsDeclarativeMask | kHasTableIndexOrIsDeclarativeMask |
......
...@@ -445,7 +445,7 @@ InstanceBuilder::InstanceBuilder(Isolate* isolate, ...@@ -445,7 +445,7 @@ InstanceBuilder::InstanceBuilder(Isolate* isolate,
module_object_(module_object), module_object_(module_object),
ffi_(ffi), ffi_(ffi),
memory_buffer_(memory_buffer), memory_buffer_(memory_buffer),
init_expr_zone_(isolate_->allocator(), "init. expression zone") { init_expr_zone_(isolate_->allocator(), "constant expression zone") {
sanitized_imports_.reserve(module_->import_table.size()); sanitized_imports_.reserve(module_->import_table.size());
} }
......
...@@ -21,9 +21,9 @@ namespace wasm { ...@@ -21,9 +21,9 @@ namespace wasm {
struct WasmModule; struct WasmModule;
class WasmFeatures; class WasmFeatures;
// Representation of an initializer expression. Unlike {ConstantExpression} in // Representation of an constant expression. Unlike {ConstantExpression}, this
// wasm-module.h, this does not use {WireBytesRef}, i.e., it does not depend on // does not use {WireBytesRef}, i.e., it does not depend on a wasm module's
// a wasm module's bytecode representation. // bytecode representation.
class WasmInitExpr : public ZoneObject { class WasmInitExpr : public ZoneObject {
public: public:
enum Operator { enum Operator {
......
...@@ -880,7 +880,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const { ...@@ -880,7 +880,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const {
for (auto segment : data_segments_) { for (auto segment : data_segments_) {
buffer->write_u8(0); // linear memory segment buffer->write_u8(0); // linear memory segment
buffer->write_u8(kExprI32Const); // initializer expression for dest buffer->write_u8(kExprI32Const); // constant expression for dest
buffer->write_u32v(segment.dest); buffer->write_u32v(segment.dest);
buffer->write_u8(kExprEnd); buffer->write_u8(kExprEnd);
buffer->write_u32v(static_cast<uint32_t>(segment.data.size())); buffer->write_u32v(static_cast<uint32_t>(segment.data.size()));
......
...@@ -292,9 +292,9 @@ std::ostream& operator<<(std::ostream& os, const PrintName& name) { ...@@ -292,9 +292,9 @@ std::ostream& operator<<(std::ostream& os, const PrintName& name) {
return os.put('\'').write(name.name.begin(), name.name.size()).put('\''); return os.put('\'').write(name.name.begin(), name.name.size()).put('\'');
} }
// An interface for WasmFullDecoder used to decode initializer expressions. As // An interface for WasmFullDecoder used to decode constant expressions. As
// opposed to the one in src/wasm/, this emits {WasmInitExpr} as opposed to a // opposed to the one in src/wasm/, this emits {WasmInitExpr} as opposed to a
// {WasmValue}. // {ConstantExpression} (which evaluates to {WasmValue}).
class InitExprInterface { class InitExprInterface {
public: public:
static constexpr Decoder::ValidateFlag validate = Decoder::kFullValidation; static constexpr Decoder::ValidateFlag validate = Decoder::kFullValidation;
...@@ -439,7 +439,7 @@ class InitExprInterface { ...@@ -439,7 +439,7 @@ class InitExprInterface {
Zone* zone_; Zone* zone_;
}; };
// Appends an initializer expression encoded in {wire_bytes}, in the offset // Appends an constant expression encoded in {wire_bytes}, in the offset
// contained in {expr}. // contained in {expr}.
void AppendInitExpr(std::ostream& os, const WasmInitExpr& expr) { void AppendInitExpr(std::ostream& os, const WasmInitExpr& expr) {
os << "WasmInitExpr."; os << "WasmInitExpr.";
...@@ -572,7 +572,7 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes, ...@@ -572,7 +572,7 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
CHECK_NOT_NULL(module); CHECK_NOT_NULL(module);
AccountingAllocator allocator; AccountingAllocator allocator;
Zone zone(&allocator, "init. expression zone"); Zone zone(&allocator, "constant expression zone");
StdoutStream os; StdoutStream os;
......
...@@ -107,5 +107,5 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -107,5 +107,5 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
() => builder.instantiate({m : {g : () => builder.instantiate({m : {g :
new WebAssembly.Global({value: "anyfunc", mutable: true}, null)}}), new WebAssembly.Global({value: "anyfunc", mutable: true}, null)}}),
WebAssembly.CompileError, WebAssembly.CompileError,
/mutable globals cannot be used in initializer expressions/); /mutable globals cannot be used in constant expressions/);
})(); })();
...@@ -914,5 +914,5 @@ function js_div(a, b) { return (a / b) | 0; } ...@@ -914,5 +914,5 @@ function js_div(a, b) { return (a / b) | 0; }
assertThrows( assertThrows(
() => builder.instantiate(), WebAssembly.CompileError, () => builder.instantiate(), WebAssembly.CompileError,
/non-imported globals cannot be used in initializer expressions/); /non-imported globals cannot be used in constant expressions/);
})(); })();
...@@ -1534,9 +1534,9 @@ class WasmModuleBuilder { ...@@ -1534,9 +1534,9 @@ class WasmModuleBuilder {
this.exports.push({name: name, kind: kExternalMemory, index: 0}); this.exports.push({name: name, kind: kExternalMemory, index: 0});
} }
// {offset} is an initializer expression. // {offset} is a constant expression.
// If {type} is undefined, then {elements} are function indices. Otherwise, // If {type} is undefined, then {elements} are function indices. Otherwise,
// they are initializer expressions. // they are constant expressions.
addActiveElementSegment(table, offset, elements, type) { addActiveElementSegment(table, offset, elements, type) {
checkExpr(offset); checkExpr(offset);
if (type != undefined) { if (type != undefined) {
...@@ -1548,7 +1548,7 @@ class WasmModuleBuilder { ...@@ -1548,7 +1548,7 @@ class WasmModuleBuilder {
} }
// If {type} is undefined, then {elements} are function indices. Otherwise, // If {type} is undefined, then {elements} are function indices. Otherwise,
// they are initializer expressions. // they are constant expressions.
addPassiveElementSegment(elements, type) { addPassiveElementSegment(elements, type) {
if (type != undefined) { if (type != undefined) {
for (let element of elements) checkExpr(element); for (let element of elements) checkExpr(element);
...@@ -1559,7 +1559,7 @@ class WasmModuleBuilder { ...@@ -1559,7 +1559,7 @@ class WasmModuleBuilder {
} }
// If {type} is undefined, then {elements} are function indices. Otherwise, // If {type} is undefined, then {elements} are function indices. Otherwise,
// they are initializer expressions. // they are constant expressions.
addDeclarativeElementSegment(elements, type) { addDeclarativeElementSegment(elements, type) {
if (type != undefined) { if (type != undefined) {
for (let element of elements) checkExpr(element); for (let element of elements) checkExpr(element);
......
...@@ -510,7 +510,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -510,7 +510,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
}; };
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
no_initializer, no_initializer,
"expected 1 elements on the stack for init. expression, found 0"); "expected 1 elements on the stack for constant expression, found 0");
static const byte too_many_initializers_no_end[] = { static const byte too_many_initializers_no_end[] = {
SECTION(Global, // -- SECTION(Global, // --
...@@ -521,7 +521,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -521,7 +521,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
WASM_I32V_1(43)) // another value is too much WASM_I32V_1(43)) // another value is too much
}; };
EXPECT_FAILURE_WITH_MSG(too_many_initializers_no_end, EXPECT_FAILURE_WITH_MSG(too_many_initializers_no_end,
"Initializer expression is missing 'end'"); "constant expression is missing 'end'");
static const byte too_many_initializers[] = { static const byte too_many_initializers[] = {
SECTION(Global, // -- SECTION(Global, // --
...@@ -533,7 +533,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -533,7 +533,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
kExprEnd)}; kExprEnd)};
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
too_many_initializers, too_many_initializers,
"expected 1 elements on the stack for init. expression, found 2"); "expected 1 elements on the stack for constant expression, found 2");
static const byte missing_end_opcode[] = { static const byte missing_end_opcode[] = {
SECTION(Global, // -- SECTION(Global, // --
...@@ -543,7 +543,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -543,7 +543,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
WASM_I32V_1(42)) // init value WASM_I32V_1(42)) // init value
}; };
EXPECT_FAILURE_WITH_MSG(missing_end_opcode, EXPECT_FAILURE_WITH_MSG(missing_end_opcode,
"Initializer expression is missing 'end'"); "constant expression is missing 'end'");
static const byte referencing_out_of_bounds_global[] = { static const byte referencing_out_of_bounds_global[] = {
SECTION(Global, ENTRY_COUNT(1), // -- SECTION(Global, ENTRY_COUNT(1), // --
...@@ -596,7 +596,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -596,7 +596,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
}; };
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
referencing_mutable_global, referencing_mutable_global,
"mutable globals cannot be used in initializer expressions"); "mutable globals cannot be used in constant expressions");
static const byte referencing_mutable_imported_global[] = { static const byte referencing_mutable_imported_global[] = {
SECTION(Import, ENTRY_COUNT(1), // -- SECTION(Import, ENTRY_COUNT(1), // --
...@@ -611,7 +611,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -611,7 +611,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
}; };
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
referencing_mutable_imported_global, referencing_mutable_imported_global,
"mutable globals cannot be used in initializer expressions"); "mutable globals cannot be used in constant expressions");
static const byte referencing_immutable_imported_global[] = { static const byte referencing_immutable_imported_global[] = {
SECTION(Import, ENTRY_COUNT(1), // -- SECTION(Import, ENTRY_COUNT(1), // --
...@@ -637,7 +637,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -637,7 +637,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
}; };
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
referencing_local_global, referencing_local_global,
"non-imported globals cannot be used in initializer expressions"); "non-imported globals cannot be used in constant expressions");
{ {
// But: experimental-wasm-gc should enable referencing immutable local // But: experimental-wasm-gc should enable referencing immutable local
...@@ -647,7 +647,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) { ...@@ -647,7 +647,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
// Referencing mutable glocals still invalid. // Referencing mutable glocals still invalid.
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
referencing_mutable_global, referencing_mutable_global,
"mutable globals cannot be used in initializer expressions"); "mutable globals cannot be used in constant expressions");
} }
} }
...@@ -811,7 +811,7 @@ TEST_F(WasmModuleVerifyTest, RttCanonGlobalTypeError) { ...@@ -811,7 +811,7 @@ TEST_F(WasmModuleVerifyTest, RttCanonGlobalTypeError) {
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK( EXPECT_NOT_OK(
result, result,
"type error in init. expression[0] (expected (rtt 0), got (rtt 1))"); "type error in constant expression[0] (expected (rtt 0), got (rtt 1))");
} }
TEST_F(WasmModuleVerifyTest, StructNewInitExpr) { TEST_F(WasmModuleVerifyTest, StructNewInitExpr) {
...@@ -848,7 +848,7 @@ TEST_F(WasmModuleVerifyTest, StructNewInitExpr) { ...@@ -848,7 +848,7 @@ TEST_F(WasmModuleVerifyTest, StructNewInitExpr) {
WASM_INIT_EXPR_STRUCT_NEW(0, WASM_I32V(42), WASM_RTT_CANON(0)))}; WASM_INIT_EXPR_STRUCT_NEW(0, WASM_I32V(42), WASM_RTT_CANON(0)))};
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
type_error, type_error,
"type error in init. expression[0] (expected (ref 1), got (ref 0))"); "type error in constant expression[0] (expected (ref 1), got (ref 0))");
static const byte subexpr_type_error[] = { static const byte subexpr_type_error[] = {
SECTION(Type, ENTRY_COUNT(2), // -- SECTION(Type, ENTRY_COUNT(2), // --
...@@ -902,7 +902,7 @@ TEST_F(WasmModuleVerifyTest, ArrayNewFixedInitExpr) { ...@@ -902,7 +902,7 @@ TEST_F(WasmModuleVerifyTest, ArrayNewFixedInitExpr) {
WASM_RTT_CANON(0)))}; WASM_RTT_CANON(0)))};
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
type_error, type_error,
"type error in init. expression[0] (expected (ref 1), got (ref 0))"); "type error in constant expression[0] (expected (ref 1), got (ref 0))");
static const byte subexpr_type_error[] = { static const byte subexpr_type_error[] = {
SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI64Code, true)), SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI64Code, true)),
...@@ -1208,7 +1208,7 @@ TEST_F(WasmModuleVerifyTest, TypeCanonicalization) { ...@@ -1208,7 +1208,7 @@ TEST_F(WasmModuleVerifyTest, TypeCanonicalization) {
SECTION(Global, // -- SECTION(Global, // --
ENTRY_COUNT(1), kRefCode, 0, 0, // Type, mutability ENTRY_COUNT(1), kRefCode, 0, 0, // Type, mutability
WASM_ARRAY_NEW_FIXED_STATIC(1, 1, WASM_I32V(10)), WASM_ARRAY_NEW_FIXED_STATIC(1, 1, WASM_I32V(10)),
kExprEnd) // Init. expression kExprEnd) // initial value
}; };
// Global initializer should verify as identical type in other group // Global initializer should verify as identical type in other group
...@@ -1225,13 +1225,13 @@ TEST_F(WasmModuleVerifyTest, TypeCanonicalization) { ...@@ -1225,13 +1225,13 @@ TEST_F(WasmModuleVerifyTest, TypeCanonicalization) {
SECTION(Global, // -- SECTION(Global, // --
ENTRY_COUNT(1), kRefCode, 0, 0, // Type, mutability ENTRY_COUNT(1), kRefCode, 0, 0, // Type, mutability
WASM_ARRAY_NEW_FIXED_STATIC(1, 1, WASM_I32V(10)), WASM_ARRAY_NEW_FIXED_STATIC(1, 1, WASM_I32V(10)),
kExprEnd) // Init. expression kExprEnd) // initial value
}; };
// Global initializer should not verify as type in distinct rec. group. // Global initializer should not verify as type in distinct rec. group.
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
non_identical_group, non_identical_group,
"type error in init. expression[0] (expected (ref 0), got (ref 1))"); "type error in constant expression[0] (expected (ref 0), got (ref 1))");
} }
TEST_F(WasmModuleVerifyTest, ZeroExceptions) { TEST_F(WasmModuleVerifyTest, ZeroExceptions) {
...@@ -2036,7 +2036,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionInitFuncRefTableWithExternRefNull) { ...@@ -2036,7 +2036,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionInitFuncRefTableWithExternRefNull) {
EXPECT_FAILURE_WITH_MSG( EXPECT_FAILURE_WITH_MSG(
data, data,
"type error in init. expression[0] (expected funcref, got externref)"); "type error in constant expression[0] (expected funcref, got externref)");
} }
TEST_F(WasmModuleVerifyTest, ElementSectionDontInitExternRefImportedTable) { TEST_F(WasmModuleVerifyTest, ElementSectionDontInitExternRefImportedTable) {
...@@ -2089,7 +2089,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionGlobalGetOutOfBounds) { ...@@ -2089,7 +2089,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionGlobalGetOutOfBounds) {
0x05, // Mode: Passive with expressions-as-elements 0x05, // Mode: Passive with expressions-as-elements
kFuncRefCode, // type kFuncRefCode, // type
ENTRY_COUNT(1), // element count ENTRY_COUNT(1), // element count
kExprGlobalGet, 0x00, kExprEnd)}; // init. expression kExprGlobalGet, 0x00, kExprEnd)}; // initial value
EXPECT_FAILURE_WITH_MSG(data, "Invalid global index: 0"); EXPECT_FAILURE_WITH_MSG(data, "Invalid global index: 0");
} }
...@@ -2104,8 +2104,8 @@ TEST_F(WasmModuleVerifyTest, ExtendedConstantsFail) { ...@@ -2104,8 +2104,8 @@ TEST_F(WasmModuleVerifyTest, ExtendedConstantsFail) {
// initializer // initializer
kExprGlobalGet, 0x00, kExprGlobalGet, 0x00, kExprI32Add, kExprGlobalGet, 0x00, kExprGlobalGet, 0x00, kExprI32Add,
kExprEnd)}; kExprEnd)};
EXPECT_FAILURE_WITH_MSG(data, EXPECT_FAILURE_WITH_MSG(
"opcode i32.add is not allowed in init. expressions"); data, "opcode i32.add is not allowed in constant expressions");
} }
TEST_F(WasmModuleVerifyTest, ExtendedConstantsI32) { TEST_F(WasmModuleVerifyTest, ExtendedConstantsI32) {
...@@ -2273,7 +2273,7 @@ TEST_F(WasmModuleVerifyTest, NonNullableTable) { ...@@ -2273,7 +2273,7 @@ TEST_F(WasmModuleVerifyTest, NonNullableTable) {
ENTRY_COUNT(1), // 1 table ENTRY_COUNT(1), // 1 table
kRefCode, 0, // table 0: type kRefCode, 0, // table 0: type
0, 10, // table 0: limits 0, 10, // table 0: limits
kExprRefFunc, 0, kExprEnd), // table 0: init. expression kExprRefFunc, 0, kExprEnd), // table 0: initial value
SECTION(Code, ENTRY_COUNT(1), NOP_BODY)}; SECTION(Code, ENTRY_COUNT(1), NOP_BODY)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result); EXPECT_OK(result);
......
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