Commit 21d95415 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm][cleanup] Rename kLocal<type> constants -> k<type>Code

Change-Id: I7bca3ed949a5dd036c3255cc5853819312387cce
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2436330Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70190}
parent 14ec0176
...@@ -273,14 +273,14 @@ void AsmJsParser::SkipSemicolon() { ...@@ -273,14 +273,14 @@ void AsmJsParser::SkipSemicolon() {
void AsmJsParser::Begin(AsmJsScanner::token_t label) { void AsmJsParser::Begin(AsmJsScanner::token_t label) {
BareBegin(BlockKind::kRegular, label); BareBegin(BlockKind::kRegular, label);
current_function_builder_->EmitWithU8(kExprBlock, kLocalVoid); current_function_builder_->EmitWithU8(kExprBlock, kVoidCode);
} }
void AsmJsParser::Loop(AsmJsScanner::token_t label) { void AsmJsParser::Loop(AsmJsScanner::token_t label) {
BareBegin(BlockKind::kLoop, label); BareBegin(BlockKind::kLoop, label);
size_t position = scanner_.Position(); size_t position = scanner_.Position();
current_function_builder_->AddAsmWasmOffset(position, position); current_function_builder_->AddAsmWasmOffset(position, position);
current_function_builder_->EmitWithU8(kExprLoop, kLocalVoid); current_function_builder_->EmitWithU8(kExprLoop, kVoidCode);
} }
void AsmJsParser::End() { void AsmJsParser::End() {
...@@ -1055,7 +1055,7 @@ void AsmJsParser::Block() { ...@@ -1055,7 +1055,7 @@ void AsmJsParser::Block() {
bool can_break_to_block = pending_label_ != 0; bool can_break_to_block = pending_label_ != 0;
if (can_break_to_block) { if (can_break_to_block) {
BareBegin(BlockKind::kNamed, pending_label_); BareBegin(BlockKind::kNamed, pending_label_);
current_function_builder_->EmitWithU8(kExprBlock, kLocalVoid); current_function_builder_->EmitWithU8(kExprBlock, kVoidCode);
} }
pending_label_ = 0; pending_label_ = 0;
EXPECT_TOKEN('{'); EXPECT_TOKEN('{');
...@@ -1098,7 +1098,7 @@ void AsmJsParser::IfStatement() { ...@@ -1098,7 +1098,7 @@ void AsmJsParser::IfStatement() {
RECURSE(Expression(AsmType::Int())); RECURSE(Expression(AsmType::Int()));
EXPECT_TOKEN(')'); EXPECT_TOKEN(')');
BareBegin(BlockKind::kOther); BareBegin(BlockKind::kOther);
current_function_builder_->EmitWithU8(kExprIf, kLocalVoid); current_function_builder_->EmitWithU8(kExprIf, kVoidCode);
RECURSE(ValidateStatement()); RECURSE(ValidateStatement());
if (Check(TOK(else))) { if (Check(TOK(else))) {
current_function_builder_->Emit(kExprElse); current_function_builder_->Emit(kExprElse);
...@@ -1181,7 +1181,7 @@ void AsmJsParser::DoStatement() { ...@@ -1181,7 +1181,7 @@ void AsmJsParser::DoStatement() {
Loop(); Loop();
// c: block { // but treated like loop so continue works // c: block { // but treated like loop so continue works
BareBegin(BlockKind::kLoop, pending_label_); BareBegin(BlockKind::kLoop, pending_label_);
current_function_builder_->EmitWithU8(kExprBlock, kLocalVoid); current_function_builder_->EmitWithU8(kExprBlock, kVoidCode);
pending_label_ = 0; pending_label_ = 0;
EXPECT_TOKEN(TOK(do)); EXPECT_TOKEN(TOK(do));
// BODY // BODY
...@@ -1222,7 +1222,7 @@ void AsmJsParser::ForStatement() { ...@@ -1222,7 +1222,7 @@ void AsmJsParser::ForStatement() {
Loop(); Loop();
// c: block { // but treated like loop so continue works // c: block { // but treated like loop so continue works
BareBegin(BlockKind::kLoop, pending_label_); BareBegin(BlockKind::kLoop, pending_label_);
current_function_builder_->EmitWithU8(kExprBlock, kLocalVoid); current_function_builder_->EmitWithU8(kExprBlock, kVoidCode);
pending_label_ = 0; pending_label_ = 0;
if (!Peek(';')) { if (!Peek(';')) {
// if (!CONDITION) break a; // if (!CONDITION) break a;
...@@ -1322,7 +1322,7 @@ void AsmJsParser::SwitchStatement() { ...@@ -1322,7 +1322,7 @@ void AsmJsParser::SwitchStatement() {
size_t count = cases.size() + 1; size_t count = cases.size() + 1;
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {
BareBegin(BlockKind::kOther); BareBegin(BlockKind::kOther);
current_function_builder_->EmitWithU8(kExprBlock, kLocalVoid); current_function_builder_->EmitWithU8(kExprBlock, kVoidCode);
} }
int table_pos = 0; int table_pos = 0;
for (auto c : cases) { for (auto c : cases) {
...@@ -2063,7 +2063,7 @@ AsmType* AsmJsParser::ConditionalExpression() { ...@@ -2063,7 +2063,7 @@ AsmType* AsmJsParser::ConditionalExpression() {
if (!test->IsA(AsmType::Int())) { if (!test->IsA(AsmType::Int())) {
FAILn("Expected int in condition of ternary operator."); FAILn("Expected int in condition of ternary operator.");
} }
current_function_builder_->EmitWithU8(kExprIf, kLocalI32); current_function_builder_->EmitWithU8(kExprIf, kI32Code);
size_t fixup = current_function_builder_->GetPosition() - size_t fixup = current_function_builder_->GetPosition() -
1; // Assumes encoding knowledge. 1; // Assumes encoding knowledge.
AsmType* cons = nullptr; AsmType* cons = nullptr;
...@@ -2074,13 +2074,13 @@ AsmType* AsmJsParser::ConditionalExpression() { ...@@ -2074,13 +2074,13 @@ AsmType* AsmJsParser::ConditionalExpression() {
RECURSEn(alt = AssignmentExpression()); RECURSEn(alt = AssignmentExpression());
current_function_builder_->Emit(kExprEnd); current_function_builder_->Emit(kExprEnd);
if (cons->IsA(AsmType::Int()) && alt->IsA(AsmType::Int())) { if (cons->IsA(AsmType::Int()) && alt->IsA(AsmType::Int())) {
current_function_builder_->FixupByte(fixup, kLocalI32); current_function_builder_->FixupByte(fixup, kI32Code);
return AsmType::Int(); return AsmType::Int();
} else if (cons->IsA(AsmType::Double()) && alt->IsA(AsmType::Double())) { } else if (cons->IsA(AsmType::Double()) && alt->IsA(AsmType::Double())) {
current_function_builder_->FixupByte(fixup, kLocalF64); current_function_builder_->FixupByte(fixup, kF64Code);
return AsmType::Double(); return AsmType::Double();
} else if (cons->IsA(AsmType::Float()) && alt->IsA(AsmType::Float())) { } else if (cons->IsA(AsmType::Float()) && alt->IsA(AsmType::Float())) {
current_function_builder_->FixupByte(fixup, kLocalF32); current_function_builder_->FixupByte(fixup, kF32Code);
return AsmType::Float(); return AsmType::Float();
} else { } else {
FAILn("Type mismatch in ternary operator."); FAILn("Type mismatch in ternary operator.");
...@@ -2337,7 +2337,7 @@ AsmType* AsmJsParser::ValidateCall() { ...@@ -2337,7 +2337,7 @@ AsmType* AsmJsParser::ValidateCall() {
} else { } else {
current_function_builder_->Emit(kExprI32LeS); current_function_builder_->Emit(kExprI32LeS);
} }
current_function_builder_->EmitWithU8(kExprIf, kLocalI32); current_function_builder_->EmitWithU8(kExprIf, kI32Code);
current_function_builder_->EmitGetLocal(tmp_x.get()); current_function_builder_->EmitGetLocal(tmp_x.get());
current_function_builder_->Emit(kExprElse); current_function_builder_->Emit(kExprElse);
current_function_builder_->EmitGetLocal(tmp_y.get()); current_function_builder_->EmitGetLocal(tmp_y.get());
......
...@@ -150,11 +150,11 @@ HeapType read_heap_type(Decoder* decoder, const byte* pc, ...@@ -150,11 +150,11 @@ HeapType read_heap_type(Decoder* decoder, const byte* pc,
uint8_t uint_7_mask = 0x7F; uint8_t uint_7_mask = 0x7F;
uint8_t code = static_cast<ValueTypeCode>(heap_index) & uint_7_mask; uint8_t code = static_cast<ValueTypeCode>(heap_index) & uint_7_mask;
switch (code) { switch (code) {
case kLocalFuncRef: case kFuncRefCode:
case kLocalExnRef: case kExnRefCode:
case kLocalEqRef: case kEqRefCode:
case kLocalExternRef: case kExternRefCode:
case kLocalI31Ref: { case kI31RefCode: {
HeapType result = HeapType::from_code(code); HeapType result = HeapType::from_code(code);
if (!VALIDATE(enabled.contains(feature_for_heap_type(result)))) { if (!VALIDATE(enabled.contains(feature_for_heap_type(result)))) {
decoder->errorf( decoder->errorf(
...@@ -205,14 +205,14 @@ ValueType read_value_type(Decoder* decoder, const byte* pc, ...@@ -205,14 +205,14 @@ ValueType read_value_type(Decoder* decoder, const byte* pc,
} }
ValueTypeCode code = static_cast<ValueTypeCode>(val); ValueTypeCode code = static_cast<ValueTypeCode>(val);
switch (code) { switch (code) {
case kLocalFuncRef: case kFuncRefCode:
case kLocalExnRef: case kExnRefCode:
case kLocalEqRef: case kEqRefCode:
case kLocalExternRef: case kExternRefCode:
case kLocalI31Ref: { case kI31RefCode: {
HeapType heap_type = HeapType::from_code(code); HeapType heap_type = HeapType::from_code(code);
ValueType result = ValueType::Ref( ValueType result = ValueType::Ref(
heap_type, code == kLocalI31Ref ? kNonNullable : kNullable); heap_type, code == kI31RefCode ? kNonNullable : kNullable);
if (!VALIDATE(enabled.contains(feature_for_heap_type(heap_type)))) { if (!VALIDATE(enabled.contains(feature_for_heap_type(heap_type)))) {
decoder->errorf( decoder->errorf(
pc, "invalid value type '%s', enable with --experimental-wasm-%s", pc, "invalid value type '%s', enable with --experimental-wasm-%s",
...@@ -222,17 +222,17 @@ ValueType read_value_type(Decoder* decoder, const byte* pc, ...@@ -222,17 +222,17 @@ ValueType read_value_type(Decoder* decoder, const byte* pc,
} }
return result; return result;
} }
case kLocalI32: case kI32Code:
return kWasmI32; return kWasmI32;
case kLocalI64: case kI64Code:
return kWasmI64; return kWasmI64;
case kLocalF32: case kF32Code:
return kWasmF32; return kWasmF32;
case kLocalF64: case kF64Code:
return kWasmF64; return kWasmF64;
case kLocalRef: case kRefCode:
case kLocalOptRef: { case kOptRefCode: {
Nullability nullability = code == kLocalOptRef ? kNullable : kNonNullable; Nullability nullability = code == kOptRefCode ? kNullable : kNonNullable;
if (!VALIDATE(enabled.has_typed_funcref())) { if (!VALIDATE(enabled.has_typed_funcref())) {
decoder->errorf(pc, decoder->errorf(pc,
"Invalid type '(ref%s <heaptype>)', enable with " "Invalid type '(ref%s <heaptype>)', enable with "
...@@ -246,7 +246,7 @@ ValueType read_value_type(Decoder* decoder, const byte* pc, ...@@ -246,7 +246,7 @@ ValueType read_value_type(Decoder* decoder, const byte* pc,
return heap_type.is_bottom() ? kWasmBottom return heap_type.is_bottom() ? kWasmBottom
: ValueType::Ref(heap_type, nullability); : ValueType::Ref(heap_type, nullability);
} }
case kLocalRtt: { case kRttCode: {
if (!VALIDATE(enabled.has_gc())) { if (!VALIDATE(enabled.has_gc())) {
decoder->error( decoder->error(
pc, "invalid value type 'rtt', enable with --experimental-wasm-gc"); pc, "invalid value type 'rtt', enable with --experimental-wasm-gc");
...@@ -268,7 +268,7 @@ ValueType read_value_type(Decoder* decoder, const byte* pc, ...@@ -268,7 +268,7 @@ ValueType read_value_type(Decoder* decoder, const byte* pc,
return heap_type.is_bottom() ? kWasmBottom return heap_type.is_bottom() ? kWasmBottom
: ValueType::Rtt(heap_type, depth); : ValueType::Rtt(heap_type, depth);
} }
case kLocalS128: { case kS128Code: {
if (!VALIDATE(enabled.has_simd())) { if (!VALIDATE(enabled.has_simd())) {
decoder->error(pc, decoder->error(pc,
"invalid value type 's128', enable with " "invalid value type 's128', enable with "
...@@ -280,9 +280,9 @@ ValueType read_value_type(Decoder* decoder, const byte* pc, ...@@ -280,9 +280,9 @@ ValueType read_value_type(Decoder* decoder, const byte* pc,
// Although these codes are included in ValueTypeCode, they technically // Although these codes are included in ValueTypeCode, they technically
// do not correspond to value types and are only used in specific // do not correspond to value types and are only used in specific
// contexts. The caller of this function is responsible for handling them. // contexts. The caller of this function is responsible for handling them.
case kLocalVoid: case kVoidCode:
case kLocalI8: case kI8Code:
case kLocalI16: case kI16Code:
return kWasmBottom; return kWasmBottom;
} }
// Anything that doesn't match an enumeration value is an invalid type code. // Anything that doesn't match an enumeration value is an invalid type code.
...@@ -402,7 +402,7 @@ struct BlockTypeImmediate { ...@@ -402,7 +402,7 @@ struct BlockTypeImmediate {
int64_t block_type = int64_t block_type =
decoder->read_i33v<validate>(pc, &length, "block type"); decoder->read_i33v<validate>(pc, &length, "block type");
if (block_type < 0) { if (block_type < 0) {
if ((static_cast<uint8_t>(block_type) & byte{0x7f}) == kLocalVoid) return; if ((static_cast<uint8_t>(block_type) & byte{0x7f}) == kVoidCode) return;
type = value_type_reader::read_value_type<validate>(decoder, pc, &length, type = value_type_reader::read_value_type<validate>(decoder, pc, &length,
enabled); enabled);
if (!VALIDATE(type != kWasmBottom)) { if (!VALIDATE(type != kWasmBottom)) {
......
...@@ -210,7 +210,7 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body, ...@@ -210,7 +210,7 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
// TODO(7748) Update this for gc and ref types if needed // TODO(7748) Update this for gc and ref types if needed
switch (i.pc()[1]) { switch (i.pc()[1]) {
#define CASE_LOCAL_TYPE(local_name, type_name) \ #define CASE_LOCAL_TYPE(local_name, type_name) \
case kLocal##local_name: \ case k##local_name##Code: \
os << " kWasm" #type_name ","; \ os << " kWasm" #type_name ","; \
break; break;
......
...@@ -1852,10 +1852,10 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1852,10 +1852,10 @@ class ModuleDecoderImpl : public Decoder {
ValueType consume_storage_type() { ValueType consume_storage_type() {
uint8_t opcode = read_u8<kValidate>(this->pc()); uint8_t opcode = read_u8<kValidate>(this->pc());
switch (opcode) { switch (opcode) {
case kLocalI8: case kI8Code:
consume_bytes(1, "i8"); consume_bytes(1, "i8");
return kWasmI8; return kWasmI8;
case kLocalI16: case kI16Code:
consume_bytes(1, "i16"); consume_bytes(1, "i16");
return kWasmI16; return kWasmI16;
default: default:
...@@ -1872,7 +1872,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1872,7 +1872,7 @@ class ModuleDecoderImpl : public Decoder {
ValueType consume_reference_type() { ValueType consume_reference_type() {
if (!enabled_features_.has_reftypes()) { if (!enabled_features_.has_reftypes()) {
uint8_t ref_type = consume_u8("reference type"); uint8_t ref_type = consume_u8("reference type");
if (ref_type != kLocalFuncRef) { if (ref_type != kFuncRefCode) {
error(pc_ - 1, error(pc_ - 1,
"invalid table type. Consider using experimental flags."); "invalid table type. Consider using experimental flags.");
return kWasmBottom; return kWasmBottom;
......
...@@ -68,15 +68,15 @@ class HeapType { ...@@ -68,15 +68,15 @@ class HeapType {
static constexpr HeapType from_code(uint8_t code) { static constexpr HeapType from_code(uint8_t code) {
switch (code) { switch (code) {
case ValueTypeCode::kLocalFuncRef: case ValueTypeCode::kFuncRefCode:
return HeapType(kFunc); return HeapType(kFunc);
case ValueTypeCode::kLocalExternRef: case ValueTypeCode::kExternRefCode:
return HeapType(kExtern); return HeapType(kExtern);
case ValueTypeCode::kLocalEqRef: case ValueTypeCode::kEqRefCode:
return HeapType(kEq); return HeapType(kEq);
case ValueTypeCode::kLocalExnRef: case ValueTypeCode::kExnRefCode:
return HeapType(kExn); return HeapType(kExn);
case ValueTypeCode::kLocalI31Ref: case ValueTypeCode::kI31RefCode:
return HeapType(kI31); return HeapType(kI31);
default: default:
return HeapType(kBottom); return HeapType(kBottom);
...@@ -137,20 +137,20 @@ class HeapType { ...@@ -137,20 +137,20 @@ class HeapType {
// Returns the code that represents this heap type in the wasm binary format. // Returns the code that represents this heap type in the wasm binary format.
constexpr int32_t code() const { constexpr int32_t code() const {
// kLocal* codes represent the first byte of the LEB128 encoding. To get the // Type codes represent the first byte of the LEB128 encoding. To get the
// int32 represented by a code, we need to sign-extend it from 7 to 32 bits. // int32 represented by a code, we need to sign-extend it from 7 to 32 bits.
int32_t mask = 0xFFFFFF80; int32_t mask = 0xFFFFFF80;
switch (representation_) { switch (representation_) {
case kFunc: case kFunc:
return mask | kLocalFuncRef; return mask | kFuncRefCode;
case kExn: case kExn:
return mask | kLocalExnRef; return mask | kExnRefCode;
case kExtern: case kExtern:
return mask | kLocalExternRef; return mask | kExternRefCode;
case kEq: case kEq:
return mask | kLocalEqRef; return mask | kEqRefCode;
case kI31: case kI31:
return mask | kLocalI31Ref; return mask | kI31RefCode;
default: default:
return static_cast<int32_t>(representation_); return static_cast<int32_t>(representation_);
} }
...@@ -321,38 +321,38 @@ class ValueType { ...@@ -321,38 +321,38 @@ class ValueType {
// For compatibility with the reftypes and exception-handling proposals, this // For compatibility with the reftypes and exception-handling proposals, this
// function prioritizes shorthand encodings // function prioritizes shorthand encodings
// (e.g., Ref(HeapType::kFunc, kNullable).value_type_code will return // (e.g., Ref(HeapType::kFunc, kNullable).value_type_code will return
// kLocalFuncref and not kLocalOptRef). // kFuncrefCode and not kOptRefCode).
constexpr ValueTypeCode value_type_code() const { constexpr ValueTypeCode value_type_code() const {
CONSTEXPR_DCHECK(kind() != kBottom); CONSTEXPR_DCHECK(kind() != kBottom);
switch (kind()) { switch (kind()) {
case kOptRef: case kOptRef:
switch (heap_representation()) { switch (heap_representation()) {
case HeapType::kFunc: case HeapType::kFunc:
return kLocalFuncRef; return kFuncRefCode;
case HeapType::kExtern: case HeapType::kExtern:
return kLocalExternRef; return kExternRefCode;
case HeapType::kEq: case HeapType::kEq:
return kLocalEqRef; return kEqRefCode;
case HeapType::kExn: case HeapType::kExn:
return kLocalExnRef; return kExnRefCode;
default: default:
return kLocalOptRef; return kOptRefCode;
} }
case kRef: case kRef:
if (heap_representation() == HeapType::kI31) return kLocalI31Ref; if (heap_representation() == HeapType::kI31) return kI31RefCode;
return kLocalRef; return kRefCode;
case kStmt: case kStmt:
return kLocalVoid; return kVoidCode;
case kRtt: case kRtt:
return kLocalRtt; return kRttCode;
#define NUMERIC_TYPE_CASE(kind, ...) \ #define NUMERIC_TYPE_CASE(kind, ...) \
case k##kind: \ case k##kind: \
return kLocal##kind; return k##kind##Code;
FOREACH_NUMERIC_VALUE_TYPE(NUMERIC_TYPE_CASE) FOREACH_NUMERIC_VALUE_TYPE(NUMERIC_TYPE_CASE)
#undef NUMERIC_TYPE_CASE #undef NUMERIC_TYPE_CASE
case kBottom: case kBottom:
// Unreachable code // Unreachable code
return kLocalVoid; return kVoidCode;
} }
} }
......
...@@ -21,26 +21,26 @@ constexpr uint32_t kWasmVersion = 0x01; ...@@ -21,26 +21,26 @@ constexpr uint32_t kWasmVersion = 0x01;
// Binary encoding of value and heap types. // Binary encoding of value and heap types.
enum ValueTypeCode : uint8_t { enum ValueTypeCode : uint8_t {
// Current wasm types // Current wasm types
kLocalVoid = 0x40, kVoidCode = 0x40,
kLocalI32 = 0x7f, kI32Code = 0x7f,
kLocalI64 = 0x7e, kI64Code = 0x7e,
kLocalF32 = 0x7d, kF32Code = 0x7d,
kLocalF64 = 0x7c, kF64Code = 0x7c,
// Simd proposal // Simd proposal
kLocalS128 = 0x7b, kS128Code = 0x7b,
// reftypes, typed-funcref, and GC proposals // reftypes, typed-funcref, and GC proposals
kLocalI8 = 0x7a, kI8Code = 0x7a,
kLocalI16 = 0x79, kI16Code = 0x79,
kLocalFuncRef = 0x70, kFuncRefCode = 0x70,
kLocalExternRef = 0x6f, kExternRefCode = 0x6f,
// kLocalAny = 0x6e, // TODO(7748): Implement // kAnyCode = 0x6e, // TODO(7748): Implement
kLocalEqRef = 0x6d, kEqRefCode = 0x6d,
kLocalOptRef = 0x6c, kOptRefCode = 0x6c,
kLocalRef = 0x6b, kRefCode = 0x6b,
kLocalI31Ref = 0x6a, kI31RefCode = 0x6a,
kLocalRtt = 0x69, kRttCode = 0x69,
// Exception handling proposal // Exception handling proposal
kLocalExnRef = 0x68, kExnRefCode = 0x68,
}; };
// Binary encoding of other types. // Binary encoding of other types.
constexpr uint8_t kWasmFunctionTypeCode = 0x60; constexpr uint8_t kWasmFunctionTypeCode = 0x60;
......
...@@ -332,7 +332,7 @@ TEST(BrOnCast) { ...@@ -332,7 +332,7 @@ TEST(BrOnCast) {
WASM_GET_GLOBAL(rtt_index))), WASM_GET_GLOBAL(rtt_index))),
WASM_GET_LOCAL(1), WASM_GET_LOCAL(1),
// The struct is not an i31, so this branch isn't taken. // The struct is not an i31, so this branch isn't taken.
WASM_BR_ON_CAST(0, WASM_RTT_CANON(kLocalI31Ref)), WASM_BR_ON_CAST(0, WASM_RTT_CANON(kI31RefCode)),
WASM_SET_LOCAL(0, WASM_I32V(222)), // Final result. WASM_SET_LOCAL(0, WASM_I32V(222)), // Final result.
// This branch is taken. // This branch is taken.
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)), WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)),
...@@ -351,7 +351,7 @@ TEST(BrOnCast) { ...@@ -351,7 +351,7 @@ TEST(BrOnCast) {
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)), WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)),
WASM_SET_LOCAL(0, WASM_I32V(222)), // Final result. WASM_SET_LOCAL(0, WASM_I32V(222)), // Final result.
// This branch is taken. // This branch is taken.
WASM_BR_ON_CAST(0, WASM_RTT_CANON(kLocalI31Ref)), WASM_BR_ON_CAST(0, WASM_RTT_CANON(kI31RefCode)),
// Not executed due to the branch. // Not executed due to the branch.
WASM_DROP, WASM_SET_LOCAL(0, WASM_I32V(333))), WASM_DROP, WASM_SET_LOCAL(0, WASM_I32V(333))),
WASM_GET_LOCAL(0), kExprEnd}); WASM_GET_LOCAL(0), kExprEnd});
...@@ -361,7 +361,7 @@ TEST(BrOnCast) { ...@@ -361,7 +361,7 @@ TEST(BrOnCast) {
{WASM_BLOCK(WASM_SET_LOCAL(0, WASM_I32V(111)), {WASM_BLOCK(WASM_SET_LOCAL(0, WASM_I32V(111)),
WASM_GET_LOCAL(1), // Put a nullref onto the value stack. WASM_GET_LOCAL(1), // Put a nullref onto the value stack.
// Neither of these branches is taken for nullref. // Neither of these branches is taken for nullref.
WASM_BR_ON_CAST(0, WASM_RTT_CANON(kLocalI31Ref)), WASM_BR_ON_CAST(0, WASM_RTT_CANON(kI31RefCode)),
WASM_SET_LOCAL(0, WASM_I32V(222)), WASM_SET_LOCAL(0, WASM_I32V(222)),
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)), WASM_DROP, WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)), WASM_DROP,
WASM_SET_LOCAL(0, WASM_I32V(333))), // Final result. WASM_SET_LOCAL(0, WASM_I32V(333))), // Final result.
...@@ -517,7 +517,7 @@ TEST(WasmLetInstruction) { ...@@ -517,7 +517,7 @@ TEST(WasmLetInstruction) {
const byte kLetTest1 = tester.DefineFunction( const byte kLetTest1 = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_LET_1_I( {WASM_LET_1_I(
WASM_SEQ(kLocalRef, type_index), WASM_SEQ(kRefCode, type_index),
WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42), WASM_I32V(52), WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42), WASM_I32V(52),
WASM_RTT_CANON(type_index)), WASM_RTT_CANON(type_index)),
WASM_STRUCT_GET(type_index, let_field_index, WASM_STRUCT_GET(type_index, let_field_index,
...@@ -528,8 +528,8 @@ TEST(WasmLetInstruction) { ...@@ -528,8 +528,8 @@ TEST(WasmLetInstruction) {
const byte kLetTest2 = tester.DefineFunction( const byte kLetTest2 = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_LET_2_I( {WASM_LET_2_I(
kLocalI32, WASM_I32_ADD(WASM_I32V(42), WASM_I32V(-32)), kI32Code, WASM_I32_ADD(WASM_I32V(42), WASM_I32V(-32)),
WASM_SEQ(kLocalRef, type_index), WASM_SEQ(kRefCode, type_index),
WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42), WASM_I32V(52), WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42), WASM_I32V(52),
WASM_RTT_CANON(type_index)), WASM_RTT_CANON(type_index)),
WASM_I32_MUL(WASM_STRUCT_GET(type_index, let_2_field_index, WASM_I32_MUL(WASM_STRUCT_GET(type_index, let_2_field_index,
...@@ -541,7 +541,7 @@ TEST(WasmLetInstruction) { ...@@ -541,7 +541,7 @@ TEST(WasmLetInstruction) {
tester.sigs.i_i(), {kWasmI32}, tester.sigs.i_i(), {kWasmI32},
{WASM_SET_LOCAL(1, WASM_I32V(100)), {WASM_SET_LOCAL(1, WASM_I32V(100)),
WASM_LET_2_I( WASM_LET_2_I(
kLocalI32, WASM_I32V(1), kLocalI32, WASM_I32V(10), kI32Code, WASM_I32V(1), kI32Code, WASM_I32V(10),
WASM_I32_SUB(WASM_I32_ADD(WASM_GET_LOCAL(0), // 1st let-local WASM_I32_SUB(WASM_I32_ADD(WASM_GET_LOCAL(0), // 1st let-local
WASM_GET_LOCAL(2)), // Parameter WASM_GET_LOCAL(2)), // Parameter
WASM_I32_ADD(WASM_GET_LOCAL(1), // 2nd let-local WASM_I32_ADD(WASM_GET_LOCAL(1), // 2nd let-local
...@@ -553,7 +553,7 @@ TEST(WasmLetInstruction) { ...@@ -553,7 +553,7 @@ TEST(WasmLetInstruction) {
const byte kLetTestErase = tester.DefineFunction( const byte kLetTestErase = tester.DefineFunction(
tester.sigs.i_v(), {kWasmI32}, tester.sigs.i_v(), {kWasmI32},
{WASM_SET_LOCAL(let_erase_local_index, WASM_I32V(0)), {WASM_SET_LOCAL(let_erase_local_index, WASM_I32V(0)),
WASM_LET_1_V(kLocalI32, WASM_I32V(1), WASM_NOP), WASM_LET_1_V(kI32Code, WASM_I32V(1), WASM_NOP),
WASM_GET_LOCAL(let_erase_local_index), kExprEnd}); WASM_GET_LOCAL(let_erase_local_index), kExprEnd});
// The result should be 0 and not 1, as local_get(0) refers to the original // The result should be 0 and not 1, as local_get(0) refers to the original
// local. // local.
...@@ -742,15 +742,15 @@ TEST(BasicRTT) { ...@@ -742,15 +742,15 @@ TEST(BasicRTT) {
{WASM_RTT_SUB(subtype_index, WASM_RTT_CANON(type_index)), kExprEnd}); {WASM_RTT_SUB(subtype_index, WASM_RTT_CANON(type_index)), kExprEnd});
const byte kRttSubGeneric = tester.DefineFunction( const byte kRttSubGeneric = tester.DefineFunction(
&sig_t3_v, {}, &sig_t3_v, {},
{WASM_RTT_SUB(type_index, WASM_RTT_CANON(kLocalEqRef)), kExprEnd}); {WASM_RTT_SUB(type_index, WASM_RTT_CANON(kEqRefCode)), kExprEnd});
const byte kStructWithRtt = tester.DefineFunction( const byte kStructWithRtt = tester.DefineFunction(
&sig_q_v, {}, &sig_q_v, {},
{WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42), {WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42),
WASM_RTT_CANON(type_index)), WASM_RTT_CANON(type_index)),
kExprEnd}); kExprEnd});
const int kFieldIndex = 1; const int kFieldIndex = 1;
const int kLocalStructIndex = 1; // Shifted in 'let' block. const int kStructIndexCode = 1; // Shifted in 'let' block.
const int kLocalRttIndex = 0; // Let-bound, hence first local. const int kRttIndexCode = 0; // Let-bound, hence first local.
// This implements the following function: // This implements the following function:
// var local_struct: type0; // var local_struct: type0;
// let (local_rtt = rtt.sub(rtt.canon(type0), type1) in { // let (local_rtt = rtt.sub(rtt.canon(type0), type1) in {
...@@ -764,18 +764,18 @@ TEST(BasicRTT) { ...@@ -764,18 +764,18 @@ TEST(BasicRTT) {
{WASM_LET_1_I( {WASM_LET_1_I(
WASM_RTT(2, subtype_index), WASM_RTT(2, subtype_index),
WASM_RTT_SUB(subtype_index, WASM_RTT_CANON(type_index)), WASM_RTT_SUB(subtype_index, WASM_RTT_CANON(type_index)),
WASM_SET_LOCAL(kLocalStructIndex, WASM_SET_LOCAL(kStructIndexCode,
WASM_STRUCT_NEW_WITH_RTT( WASM_STRUCT_NEW_WITH_RTT(
subtype_index, WASM_I32V(11), WASM_I32V(42), subtype_index, WASM_I32V(11), WASM_I32V(42),
WASM_GET_LOCAL(kLocalRttIndex))), WASM_GET_LOCAL(kRttIndexCode))),
WASM_I32_ADD( WASM_I32_ADD(
WASM_REF_TEST(type_index, subtype_index, WASM_REF_TEST(type_index, subtype_index,
WASM_GET_LOCAL(kLocalStructIndex), WASM_GET_LOCAL(kStructIndexCode),
WASM_GET_LOCAL(kLocalRttIndex)), WASM_GET_LOCAL(kRttIndexCode)),
WASM_STRUCT_GET(subtype_index, kFieldIndex, WASM_STRUCT_GET(subtype_index, kFieldIndex,
WASM_REF_CAST(type_index, subtype_index, WASM_REF_CAST(type_index, subtype_index,
WASM_GET_LOCAL(kLocalStructIndex), WASM_GET_LOCAL(kStructIndexCode),
WASM_GET_LOCAL(kLocalRttIndex)))), WASM_GET_LOCAL(kRttIndexCode)))),
kExprEnd)}); kExprEnd)});
tester.CompileModule(); tester.CompileModule();
...@@ -866,12 +866,12 @@ TEST(FunctionRefs) { ...@@ -866,12 +866,12 @@ TEST(FunctionRefs) {
FunctionSig sig_rtt2(1, 0, &rtt2); FunctionSig sig_rtt2(1, 0, &rtt2);
const byte rtt_sub = tester.DefineFunction( const byte rtt_sub = tester.DefineFunction(
&sig_rtt2, {}, &sig_rtt2, {},
{WASM_RTT_SUB(sig_index, WASM_RTT_CANON(kLocalFuncRef)), kExprEnd}); {WASM_RTT_SUB(sig_index, WASM_RTT_CANON(kFuncRefCode)), kExprEnd});
const byte cast = tester.DefineFunction( const byte cast = tester.DefineFunction(
&sig_func, {kWasmFuncRef}, &sig_func, {kWasmFuncRef},
{WASM_SET_LOCAL(0, WASM_REF_FUNC(func_index)), {WASM_SET_LOCAL(0, WASM_REF_FUNC(func_index)),
WASM_REF_CAST(kLocalFuncRef, sig_index, WASM_GET_LOCAL(0), WASM_REF_CAST(kFuncRefCode, sig_index, WASM_GET_LOCAL(0),
WASM_RTT_CANON(sig_index)), WASM_RTT_CANON(sig_index)),
kExprEnd}); kExprEnd});
...@@ -881,7 +881,7 @@ TEST(FunctionRefs) { ...@@ -881,7 +881,7 @@ TEST(FunctionRefs) {
const byte test = tester.DefineFunction( const byte test = tester.DefineFunction(
tester.sigs.i_v(), {kWasmFuncRef}, tester.sigs.i_v(), {kWasmFuncRef},
{WASM_SET_LOCAL(0, WASM_REF_FUNC(func_index)), {WASM_SET_LOCAL(0, WASM_REF_FUNC(func_index)),
WASM_REF_TEST(kLocalFuncRef, other_sig_index, WASM_GET_LOCAL(0), WASM_REF_TEST(kFuncRefCode, other_sig_index, WASM_GET_LOCAL(0),
WASM_RTT_CANON(other_sig_index)), WASM_RTT_CANON(other_sig_index)),
kExprEnd}); kExprEnd});
...@@ -990,9 +990,9 @@ TEST(I31Casts) { ...@@ -990,9 +990,9 @@ TEST(I31Casts) {
const byte kTestAndCastSuccess = tester.DefineFunction( const byte kTestAndCastSuccess = tester.DefineFunction(
tester.sigs.i_v(), {kWasmEqRef}, tester.sigs.i_v(), {kWasmEqRef},
{WASM_SET_LOCAL(0, WASM_I31_NEW(WASM_I32V(42))), {WASM_SET_LOCAL(0, WASM_I31_NEW(WASM_I32V(42))),
WASM_I32_ADD(WASM_REF_TEST(kLocalEqRef, kLocalI31Ref, WASM_GET_LOCAL(0), WASM_I32_ADD(WASM_REF_TEST(kEqRefCode, kI31RefCode, WASM_GET_LOCAL(0),
WASM_GET_GLOBAL(i31_rtt)), WASM_GET_GLOBAL(i31_rtt)),
WASM_I31_GET_S(WASM_REF_CAST(kLocalEqRef, kLocalI31Ref, WASM_I31_GET_S(WASM_REF_CAST(kEqRefCode, kI31RefCode,
WASM_GET_LOCAL(0), WASM_GET_LOCAL(0),
WASM_GET_GLOBAL(i31_rtt)))), WASM_GET_GLOBAL(i31_rtt)))),
kExprEnd}); kExprEnd});
...@@ -1001,11 +1001,11 @@ TEST(I31Casts) { ...@@ -1001,11 +1001,11 @@ TEST(I31Casts) {
const byte kTestFalse = tester.DefineFunction( const byte kTestFalse = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_I32_ADD( {WASM_I32_ADD(
WASM_REF_TEST(kLocalEqRef, kLocalI31Ref, WASM_REF_TEST(kEqRefCode, kI31RefCode,
WASM_STRUCT_NEW_WITH_RTT(struct_type, WASM_I32V(42), WASM_STRUCT_NEW_WITH_RTT(struct_type, WASM_I32V(42),
WASM_GET_GLOBAL(struct_rtt)), WASM_GET_GLOBAL(struct_rtt)),
WASM_GET_GLOBAL(i31_rtt)), WASM_GET_GLOBAL(i31_rtt)),
WASM_REF_TEST(kLocalEqRef, struct_type, WASM_I31_NEW(WASM_I32V(23)), WASM_REF_TEST(kEqRefCode, struct_type, WASM_I31_NEW(WASM_I32V(23)),
WASM_GET_GLOBAL(struct_rtt))), WASM_GET_GLOBAL(struct_rtt))),
kExprEnd}); kExprEnd});
// Tries to cast an i31ref to a struct, which should trap. // Tries to cast an i31ref to a struct, which should trap.
...@@ -1014,7 +1014,7 @@ TEST(I31Casts) { ...@@ -1014,7 +1014,7 @@ TEST(I31Casts) {
{}, {},
{WASM_STRUCT_GET( {WASM_STRUCT_GET(
struct_type, 0, struct_type, 0,
WASM_REF_CAST(kLocalEqRef, struct_type, WASM_I31_NEW(WASM_I32V(42)), WASM_REF_CAST(kEqRefCode, struct_type, WASM_I31_NEW(WASM_I32V(42)),
WASM_GET_GLOBAL(struct_rtt))), WASM_GET_GLOBAL(struct_rtt))),
kExprEnd}); kExprEnd});
// Tries to cast a struct to i31ref, which should trap. // Tries to cast a struct to i31ref, which should trap.
...@@ -1022,7 +1022,7 @@ TEST(I31Casts) { ...@@ -1022,7 +1022,7 @@ TEST(I31Casts) {
tester.sigs.i_i(), // Argument and return value ignored tester.sigs.i_i(), // Argument and return value ignored
{}, {},
{WASM_I31_GET_S( {WASM_I31_GET_S(
WASM_REF_CAST(kLocalEqRef, kLocalI31Ref, WASM_REF_CAST(kEqRefCode, kI31RefCode,
WASM_STRUCT_NEW_WITH_RTT(struct_type, WASM_I32V(42), WASM_STRUCT_NEW_WITH_RTT(struct_type, WASM_I32V(42),
WASM_GET_GLOBAL(struct_rtt)), WASM_GET_GLOBAL(struct_rtt)),
WASM_GET_GLOBAL(i31_rtt))), WASM_GET_GLOBAL(i31_rtt))),
...@@ -1072,7 +1072,7 @@ TEST(JsAccess) { ...@@ -1072,7 +1072,7 @@ TEST(JsAccess) {
tester.DefineExportedFunction( tester.DefineExportedFunction(
"consumer", &sig_i_q, "consumer", &sig_i_q,
{WASM_STRUCT_GET(type_index, 0, {WASM_STRUCT_GET(type_index, 0,
WASM_REF_CAST(kLocalEqRef, type_index, WASM_GET_LOCAL(0), WASM_REF_CAST(kEqRefCode, type_index, WASM_GET_LOCAL(0),
WASM_RTT_CANON(type_index))), WASM_RTT_CANON(type_index))),
kExprEnd}); kExprEnd});
......
...@@ -90,7 +90,7 @@ TEST(Run_WasmBlocksN) { ...@@ -90,7 +90,7 @@ TEST(Run_WasmBlocksN) {
byte expected = static_cast<byte>(30 + nops); byte expected = static_cast<byte>(30 + nops);
memset(code, kExprNop, sizeof(code)); memset(code, kExprNop, sizeof(code));
code[0] = kExprBlock; code[0] = kExprBlock;
code[1] = kLocalI32; code[1] = kI32Code;
code[2 + nops] = kExprI32Const; code[2 + nops] = kExprI32Const;
code[2 + nops + 1] = expected; code[2 + nops + 1] = expected;
code[2 + nops + 2] = kExprEnd; code[2 + nops + 2] = kExprEnd;
...@@ -111,7 +111,7 @@ TEST(Run_WasmBlockBreakN) { ...@@ -111,7 +111,7 @@ TEST(Run_WasmBlockBreakN) {
for (int index = 0; index < nops; index++) { for (int index = 0; index < nops; index++) {
memset(code, kExprNop, sizeof(code)); memset(code, kExprNop, sizeof(code));
code[0] = kExprBlock; code[0] = kExprBlock;
code[1] = kLocalI32; code[1] = kI32Code;
code[sizeof(code) - 1] = kExprEnd; code[sizeof(code) - 1] = kExprEnd;
int expected = run++; int expected = run++;
...@@ -347,7 +347,7 @@ TEST(MemoryGrowInvalidSize) { ...@@ -347,7 +347,7 @@ TEST(MemoryGrowInvalidSize) {
TEST(ReferenceTypeLocals) { TEST(ReferenceTypeLocals) {
{ {
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter); WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_REF_IS_NULL(WASM_REF_NULL(kLocalExternRef))); BUILD(r, WASM_REF_IS_NULL(WASM_REF_NULL(kExternRefCode)));
CHECK_EQ(1, r.Call()); CHECK_EQ(1, r.Call());
} }
{ {
...@@ -360,7 +360,7 @@ TEST(ReferenceTypeLocals) { ...@@ -360,7 +360,7 @@ TEST(ReferenceTypeLocals) {
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter); WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
r.AllocateLocal(kWasmExternRef); r.AllocateLocal(kWasmExternRef);
BUILD(r, BUILD(r,
WASM_REF_IS_NULL(WASM_TEE_LOCAL(0, WASM_REF_NULL(kLocalExternRef)))); WASM_REF_IS_NULL(WASM_TEE_LOCAL(0, WASM_REF_NULL(kExternRefCode))));
CHECK_EQ(1, r.Call()); CHECK_EQ(1, r.Call());
} }
} }
......
...@@ -600,28 +600,28 @@ WASM_EXEC_TEST(IfElse_P) { ...@@ -600,28 +600,28 @@ WASM_EXEC_TEST(IfElse_P) {
WASM_EXEC_TEST(If_empty1) { WASM_EXEC_TEST(If_empty1) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprEnd, WASM_GET_LOCAL(1)); BUILD(r, WASM_GET_LOCAL(0), kExprIf, kVoidCode, kExprEnd, WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 9, i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 9, i)); }
} }
WASM_EXEC_TEST(IfElse_empty1) { WASM_EXEC_TEST(IfElse_empty1) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, kExprEnd, BUILD(r, WASM_GET_LOCAL(0), kExprIf, kVoidCode, kExprElse, kExprEnd,
WASM_GET_LOCAL(1)); WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 8, i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 8, i)); }
} }
WASM_EXEC_TEST(IfElse_empty2) { WASM_EXEC_TEST(IfElse_empty2) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, WASM_NOP, kExprElse, BUILD(r, WASM_GET_LOCAL(0), kExprIf, kVoidCode, WASM_NOP, kExprElse, kExprEnd,
kExprEnd, WASM_GET_LOCAL(1)); WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 7, i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 7, i)); }
} }
WASM_EXEC_TEST(IfElse_empty3) { WASM_EXEC_TEST(IfElse_empty3) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier);
BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, WASM_NOP, BUILD(r, WASM_GET_LOCAL(0), kExprIf, kVoidCode, kExprElse, WASM_NOP, kExprEnd,
kExprEnd, WASM_GET_LOCAL(1)); WASM_GET_LOCAL(1));
FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 6, i)); } FOR_UINT32_INPUTS(i) { CHECK_EQ(i, r.Call(i - 6, i)); }
} }
...@@ -1226,7 +1226,7 @@ WASM_EXEC_TEST(BrIfEmpty) { ...@@ -1226,7 +1226,7 @@ WASM_EXEC_TEST(BrIfEmpty) {
WASM_EXEC_TEST(Block_empty) { WASM_EXEC_TEST(Block_empty) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, kExprBlock, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0)); BUILD(r, kExprBlock, kVoidCode, kExprEnd, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
...@@ -1287,7 +1287,7 @@ WASM_EXEC_TEST(Block_If_P) { ...@@ -1287,7 +1287,7 @@ WASM_EXEC_TEST(Block_If_P) {
WASM_EXEC_TEST(Loop_empty) { WASM_EXEC_TEST(Loop_empty) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, kExprLoop, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0)); BUILD(r, kExprLoop, kVoidCode, kExprEnd, WASM_GET_LOCAL(0));
FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); } FOR_INT32_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
...@@ -1817,12 +1817,12 @@ WASM_EXEC_TEST(CheckMachIntsZero) { ...@@ -1817,12 +1817,12 @@ WASM_EXEC_TEST(CheckMachIntsZero) {
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t));
BUILD(r, // -- BUILD(r, // --
/**/ kExprLoop, kLocalVoid, // -- /**/ kExprLoop, kVoidCode, // --
/* */ kExprLocalGet, 0, // -- /* */ kExprLocalGet, 0, // --
/* */ kExprIf, kLocalVoid, // -- /* */ kExprIf, kVoidCode, // --
/* */ kExprLocalGet, 0, // -- /* */ kExprLocalGet, 0, // --
/* */ kExprI32LoadMem, 0, 0, // -- /* */ kExprI32LoadMem, 0, 0, // --
/* */ kExprIf, kLocalVoid, // -- /* */ kExprIf, kVoidCode, // --
/* */ kExprI32Const, 127, // -- /* */ kExprI32Const, 127, // --
/* */ kExprReturn, // -- /* */ kExprReturn, // --
/* */ kExprEnd, // -- /* */ kExprEnd, // --
...@@ -3374,7 +3374,7 @@ WASM_EXEC_TEST(BrToLoopWithValue) { ...@@ -3374,7 +3374,7 @@ WASM_EXEC_TEST(BrToLoopWithValue) {
// Subtracts <1> times 3 from <0> and returns the result. // Subtracts <1> times 3 from <0> and returns the result.
BUILD(r, BUILD(r,
// loop i32 // loop i32
kExprLoop, kLocalI32, kExprLoop, kI32Code,
// decrement <0> by 3. // decrement <0> by 3.
WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V_1(3))), WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V_1(3))),
// decrement <1> by 1. // decrement <1> by 1.
...@@ -3392,7 +3392,7 @@ WASM_EXEC_TEST(BrToLoopWithoutValue) { ...@@ -3392,7 +3392,7 @@ WASM_EXEC_TEST(BrToLoopWithoutValue) {
// This was broken in the interpreter, see http://crbug.com/715454 // This was broken in the interpreter, see http://crbug.com/715454
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD( BUILD(
r, kExprLoop, kLocalI32, // loop i32 r, kExprLoop, kI32Code, // loop i32
WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_ONE)), // dec <0> WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_ONE)), // dec <0>
WASM_BR_IF(0, WASM_GET_LOCAL(0)), // br_if <0> != 0 WASM_BR_IF(0, WASM_GET_LOCAL(0)), // br_if <0> != 0
kExprUnreachable, // unreachable kExprUnreachable, // unreachable
...@@ -3778,7 +3778,7 @@ TEST(Regression_1085507) { ...@@ -3778,7 +3778,7 @@ TEST(Regression_1085507) {
WasmRunner<int32_t> r(TestExecutionTier::kInterpreter); WasmRunner<int32_t> r(TestExecutionTier::kInterpreter);
TestSignatures sigs; TestSignatures sigs;
uint32_t sig_v_i = r.builder().AddSignature(sigs.v_i()); uint32_t sig_v_i = r.builder().AddSignature(sigs.v_i());
BUILD(r, WASM_I32V_1(0), kExprIf, kLocalVoid, WASM_UNREACHABLE, BUILD(r, WASM_I32V_1(0), kExprIf, kVoidCode, WASM_UNREACHABLE,
WASM_BLOCK_X(sig_v_i, kExprDrop), kExprElse, kExprEnd, WASM_I32V_1(0)); WASM_BLOCK_X(sig_v_i, kExprDrop), kExprElse, kExprEnd, WASM_I32V_1(0));
} }
......
...@@ -96,15 +96,15 @@ ...@@ -96,15 +96,15 @@
#define WASM_HEAP_TYPE(heap_type) static_cast<byte>((heap_type).code() & 0x7f) #define WASM_HEAP_TYPE(heap_type) static_cast<byte>((heap_type).code() & 0x7f)
#define WASM_REF_TYPE(type) \ #define WASM_REF_TYPE(type) \
(type).kind() == ValueType::kRef ? kLocalRef : kLocalOptRef, \ (type).kind() == ValueType::kRef ? kRefCode : kOptRefCode, \
WASM_HEAP_TYPE((type).heap_type()) WASM_HEAP_TYPE((type).heap_type())
#define WASM_BLOCK(...) kExprBlock, kLocalVoid, __VA_ARGS__, kExprEnd #define WASM_BLOCK(...) kExprBlock, kVoidCode, __VA_ARGS__, kExprEnd
#define WASM_BLOCK_I(...) kExprBlock, kLocalI32, __VA_ARGS__, kExprEnd #define WASM_BLOCK_I(...) kExprBlock, kI32Code, __VA_ARGS__, kExprEnd
#define WASM_BLOCK_L(...) kExprBlock, kLocalI64, __VA_ARGS__, kExprEnd #define WASM_BLOCK_L(...) kExprBlock, kI64Code, __VA_ARGS__, kExprEnd
#define WASM_BLOCK_F(...) kExprBlock, kLocalF32, __VA_ARGS__, kExprEnd #define WASM_BLOCK_F(...) kExprBlock, kF32Code, __VA_ARGS__, kExprEnd
#define WASM_BLOCK_D(...) kExprBlock, kLocalF64, __VA_ARGS__, kExprEnd #define WASM_BLOCK_D(...) kExprBlock, kF64Code, __VA_ARGS__, kExprEnd
#define WASM_BLOCK_T(t, ...) \ #define WASM_BLOCK_T(t, ...) \
kExprBlock, static_cast<byte>((t).value_type_code()), __VA_ARGS__, kExprEnd kExprBlock, static_cast<byte>((t).value_type_code()), __VA_ARGS__, kExprEnd
...@@ -114,13 +114,13 @@ ...@@ -114,13 +114,13 @@
#define WASM_BLOCK_X(index, ...) \ #define WASM_BLOCK_X(index, ...) \
kExprBlock, static_cast<byte>(index), __VA_ARGS__, kExprEnd kExprBlock, static_cast<byte>(index), __VA_ARGS__, kExprEnd
#define WASM_INFINITE_LOOP kExprLoop, kLocalVoid, kExprBr, DEPTH_0, kExprEnd #define WASM_INFINITE_LOOP kExprLoop, kVoidCode, kExprBr, DEPTH_0, kExprEnd
#define WASM_LOOP(...) kExprLoop, kLocalVoid, __VA_ARGS__, kExprEnd #define WASM_LOOP(...) kExprLoop, kVoidCode, __VA_ARGS__, kExprEnd
#define WASM_LOOP_I(...) kExprLoop, kLocalI32, __VA_ARGS__, kExprEnd #define WASM_LOOP_I(...) kExprLoop, kI32Code, __VA_ARGS__, kExprEnd
#define WASM_LOOP_L(...) kExprLoop, kLocalI64, __VA_ARGS__, kExprEnd #define WASM_LOOP_L(...) kExprLoop, kI64Code, __VA_ARGS__, kExprEnd
#define WASM_LOOP_F(...) kExprLoop, kLocalF32, __VA_ARGS__, kExprEnd #define WASM_LOOP_F(...) kExprLoop, kF32Code, __VA_ARGS__, kExprEnd
#define WASM_LOOP_D(...) kExprLoop, kLocalF64, __VA_ARGS__, kExprEnd #define WASM_LOOP_D(...) kExprLoop, kF64Code, __VA_ARGS__, kExprEnd
#define WASM_LOOP_T(t, ...) \ #define WASM_LOOP_T(t, ...) \
kExprLoop, static_cast<byte>((t).value_type_code()), __VA_ARGS__, kExprEnd kExprLoop, static_cast<byte>((t).value_type_code()), __VA_ARGS__, kExprEnd
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
#define WASM_LOOP_X(index, ...) \ #define WASM_LOOP_X(index, ...) \
kExprLoop, static_cast<byte>(index), __VA_ARGS__, kExprEnd kExprLoop, static_cast<byte>(index), __VA_ARGS__, kExprEnd
#define WASM_IF(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd #define WASM_IF(cond, ...) cond, kExprIf, kVoidCode, __VA_ARGS__, kExprEnd
#define WASM_IF_T(t, cond, ...) \ #define WASM_IF_T(t, cond, ...) \
cond, kExprIf, static_cast<byte>((t).value_type_code()), __VA_ARGS__, kExprEnd cond, kExprIf, static_cast<byte>((t).value_type_code()), __VA_ARGS__, kExprEnd
...@@ -142,16 +142,16 @@ ...@@ -142,16 +142,16 @@
cond, kExprIf, static_cast<byte>(index), __VA_ARGS__, kExprEnd cond, kExprIf, static_cast<byte>(index), __VA_ARGS__, kExprEnd
#define WASM_IF_ELSE(cond, tstmt, fstmt) \ #define WASM_IF_ELSE(cond, tstmt, fstmt) \
cond, kExprIf, kLocalVoid, tstmt, kExprElse, fstmt, kExprEnd cond, kExprIf, kVoidCode, tstmt, kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_I(cond, tstmt, fstmt) \ #define WASM_IF_ELSE_I(cond, tstmt, fstmt) \
cond, kExprIf, kLocalI32, tstmt, kExprElse, fstmt, kExprEnd cond, kExprIf, kI32Code, tstmt, kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_L(cond, tstmt, fstmt) \ #define WASM_IF_ELSE_L(cond, tstmt, fstmt) \
cond, kExprIf, kLocalI64, tstmt, kExprElse, fstmt, kExprEnd cond, kExprIf, kI64Code, tstmt, kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_F(cond, tstmt, fstmt) \ #define WASM_IF_ELSE_F(cond, tstmt, fstmt) \
cond, kExprIf, kLocalF32, tstmt, kExprElse, fstmt, kExprEnd cond, kExprIf, kF32Code, tstmt, kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_D(cond, tstmt, fstmt) \ #define WASM_IF_ELSE_D(cond, tstmt, fstmt) \
cond, kExprIf, kLocalF64, tstmt, kExprElse, fstmt, kExprEnd cond, kExprIf, kF64Code, tstmt, kExprElse, fstmt, kExprEnd
#define WASM_IF_ELSE_T(t, cond, tstmt, fstmt) \ #define WASM_IF_ELSE_T(t, cond, tstmt, fstmt) \
cond, kExprIf, static_cast<byte>((t).value_type_code()), tstmt, kExprElse, \ cond, kExprIf, static_cast<byte>((t).value_type_code()), tstmt, kExprElse, \
...@@ -171,17 +171,17 @@ ...@@ -171,17 +171,17 @@
#define WASM_SELECT(tval, fval, cond) tval, fval, cond, kExprSelect #define WASM_SELECT(tval, fval, cond) tval, fval, cond, kExprSelect
#define WASM_SELECT_I(tval, fval, cond) \ #define WASM_SELECT_I(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalI32 tval, fval, cond, kExprSelectWithType, U32V_1(1), kI32Code
#define WASM_SELECT_L(tval, fval, cond) \ #define WASM_SELECT_L(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalI64 tval, fval, cond, kExprSelectWithType, U32V_1(1), kI64Code
#define WASM_SELECT_F(tval, fval, cond) \ #define WASM_SELECT_F(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalF32 tval, fval, cond, kExprSelectWithType, U32V_1(1), kF32Code
#define WASM_SELECT_D(tval, fval, cond) \ #define WASM_SELECT_D(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalF64 tval, fval, cond, kExprSelectWithType, U32V_1(1), kF64Code
#define WASM_SELECT_R(tval, fval, cond) \ #define WASM_SELECT_R(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalExternRef tval, fval, cond, kExprSelectWithType, U32V_1(1), kExternRefCode
#define WASM_SELECT_A(tval, fval, cond) \ #define WASM_SELECT_A(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalFuncRef tval, fval, cond, kExprSelectWithType, U32V_1(1), kFuncRefCode
#define WASM_RETURN0 kExprReturn #define WASM_RETURN0 kExprReturn
#define WASM_RETURN1(val) val, kExprReturn #define WASM_RETURN1(val) val, kExprReturn
...@@ -502,7 +502,7 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -502,7 +502,7 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_ARRAY_LEN(typeidx, array) \ #define WASM_ARRAY_LEN(typeidx, array) \
array, WASM_GC_OP(kExprArrayLen), static_cast<byte>(typeidx) array, WASM_GC_OP(kExprArrayLen), static_cast<byte>(typeidx)
#define WASM_RTT(depth, typeidx) kLocalRtt, U32V_1(depth), U32V_1(typeidx) #define WASM_RTT(depth, typeidx) kRttCode, U32V_1(depth), U32V_1(typeidx)
#define WASM_RTT_CANON(typeidx) \ #define WASM_RTT_CANON(typeidx) \
WASM_GC_OP(kExprRttCanon), static_cast<byte>(typeidx) WASM_GC_OP(kExprRttCanon), static_cast<byte>(typeidx)
#define WASM_RTT_SUB(typeidx, supertype) \ #define WASM_RTT_SUB(typeidx, supertype) \
...@@ -530,18 +530,18 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -530,18 +530,18 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
__VA_ARGS__, func_ref, kExprReturnCallRef __VA_ARGS__, func_ref, kExprReturnCallRef
// shift locals by 1; let (locals[0]: local_type) = value in ... // shift locals by 1; let (locals[0]: local_type) = value in ...
#define WASM_LET_1_V(local_type, value, ...) \ #define WASM_LET_1_V(local_type, value, ...) \
value, kExprLet, kLocalVoid, U32V_1(1), U32V_1(1), local_type, __VA_ARGS__, \ value, kExprLet, kVoidCode, U32V_1(1), U32V_1(1), local_type, __VA_ARGS__, \
kExprEnd kExprEnd
#define WASM_LET_1_I(local_type, value, ...) \ #define WASM_LET_1_I(local_type, value, ...) \
value, kExprLet, kLocalI32, U32V_1(1), U32V_1(1), local_type, __VA_ARGS__, \ value, kExprLet, kI32Code, U32V_1(1), U32V_1(1), local_type, __VA_ARGS__, \
kExprEnd kExprEnd
// shift locals by 2; // shift locals by 2;
// let (locals[0]: local_type_1) = value_1, // let (locals[0]: local_type_1) = value_1,
// (locals[1]: local_type_2) = value_2 // (locals[1]: local_type_2) = value_2
// in ... // in ...
#define WASM_LET_2_I(local_type_1, value_1, local_type_2, value_2, ...) \ #define WASM_LET_2_I(local_type_1, value_1, local_type_2, value_2, ...) \
value_1, value_2, kExprLet, kLocalI32, U32V_1(2), U32V_1(1), local_type_1, \ value_1, value_2, kExprLet, kI32Code, U32V_1(2), U32V_1(1), local_type_1, \
U32V_1(1), local_type_2, __VA_ARGS__, kExprEnd U32V_1(1), local_type_2, __VA_ARGS__, kExprEnd
#define WASM_NOT(x) x, kExprI32Eqz #define WASM_NOT(x) x, kExprI32Eqz
...@@ -550,9 +550,9 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -550,9 +550,9 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Constructs that are composed of multiple bytecodes. // Constructs that are composed of multiple bytecodes.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define WASM_WHILE(x, y) \ #define WASM_WHILE(x, y) \
kExprLoop, kLocalVoid, x, kExprIf, kLocalVoid, y, kExprBr, DEPTH_1, \ kExprLoop, kVoidCode, x, kExprIf, kVoidCode, y, kExprBr, DEPTH_1, kExprEnd, \
kExprEnd, kExprEnd kExprEnd
#define WASM_INC_LOCAL(index) \ #define WASM_INC_LOCAL(index) \
kExprLocalGet, static_cast<byte>(index), kExprI32Const, 1, kExprI32Add, \ kExprLocalGet, static_cast<byte>(index), kExprI32Const, 1, kExprI32Add, \
kExprLocalTee, static_cast<byte>(index) kExprLocalTee, static_cast<byte>(index)
...@@ -787,7 +787,7 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -787,7 +787,7 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
val, cond, kExprBrIf, static_cast<byte>(depth) val, cond, kExprBrIf, static_cast<byte>(depth)
#define WASM_BRV_IFD(depth, val, cond) \ #define WASM_BRV_IFD(depth, val, cond) \
val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop
#define WASM_IFB(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd #define WASM_IFB(cond, ...) cond, kExprIf, kVoidCode, __VA_ARGS__, kExprEnd
#define WASM_BR_TABLEV(val, key, count, ...) \ #define WASM_BR_TABLEV(val, key, count, ...) \
val, key, kExprBrTable, U32V_1(count), __VA_ARGS__ val, key, kExprBrTable, U32V_1(count), __VA_ARGS__
......
...@@ -107,7 +107,7 @@ TEST_F(ControlTransferTest, SimpleIf) { ...@@ -107,7 +107,7 @@ TEST_F(ControlTransferTest, SimpleIf) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprEnd // @4 kExprEnd // @4
}; };
CheckTransfers(code, {{2, 2, 0, 0}}); CheckTransfers(code, {{2, 2, 0, 0}});
...@@ -118,7 +118,7 @@ TEST_F(ControlTransferTest, SimpleIf1) { ...@@ -118,7 +118,7 @@ TEST_F(ControlTransferTest, SimpleIf1) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprNop, // @4 kExprNop, // @4
kExprEnd // @5 kExprEnd // @5
}; };
...@@ -130,7 +130,7 @@ TEST_F(ControlTransferTest, SimpleIf2) { ...@@ -130,7 +130,7 @@ TEST_F(ControlTransferTest, SimpleIf2) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprNop, // @4 kExprNop, // @4
kExprNop, // @5 kExprNop, // @5
kExprEnd // @6 kExprEnd // @6
...@@ -143,7 +143,7 @@ TEST_F(ControlTransferTest, SimpleIfElse) { ...@@ -143,7 +143,7 @@ TEST_F(ControlTransferTest, SimpleIfElse) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprElse, // @4 kExprElse, // @4
kExprEnd // @5 kExprEnd // @5
}; };
...@@ -155,7 +155,7 @@ TEST_F(ControlTransferTest, SimpleIfElse_v1) { ...@@ -155,7 +155,7 @@ TEST_F(ControlTransferTest, SimpleIfElse_v1) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprI32Const, // @4 kExprI32Const, // @4
0, // @5 0, // @5
kExprElse, // @6 kExprElse, // @6
...@@ -171,7 +171,7 @@ TEST_F(ControlTransferTest, SimpleIfElse1) { ...@@ -171,7 +171,7 @@ TEST_F(ControlTransferTest, SimpleIfElse1) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprElse, // @4 kExprElse, // @4
kExprNop, // @5 kExprNop, // @5
kExprEnd // @6 kExprEnd // @6
...@@ -184,7 +184,7 @@ TEST_F(ControlTransferTest, IfBr) { ...@@ -184,7 +184,7 @@ TEST_F(ControlTransferTest, IfBr) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprBr, // @4 kExprBr, // @4
0, // @5 0, // @5
kExprEnd // @6 kExprEnd // @6
...@@ -197,7 +197,7 @@ TEST_F(ControlTransferTest, IfBrElse) { ...@@ -197,7 +197,7 @@ TEST_F(ControlTransferTest, IfBrElse) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprBr, // @4 kExprBr, // @4
0, // @5 0, // @5
kExprElse, // @6 kExprElse, // @6
...@@ -211,7 +211,7 @@ TEST_F(ControlTransferTest, IfElseBr) { ...@@ -211,7 +211,7 @@ TEST_F(ControlTransferTest, IfElseBr) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprIf, // @2 kExprIf, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprElse, // @4 kExprElse, // @4
kExprBr, // @5 kExprBr, // @5
0, // @6 0, // @6
...@@ -223,7 +223,7 @@ TEST_F(ControlTransferTest, IfElseBr) { ...@@ -223,7 +223,7 @@ TEST_F(ControlTransferTest, IfElseBr) {
TEST_F(ControlTransferTest, BlockEmpty) { TEST_F(ControlTransferTest, BlockEmpty) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprEnd // @2 kExprEnd // @2
}; };
CheckTransfers(code, {}); CheckTransfers(code, {});
...@@ -232,7 +232,7 @@ TEST_F(ControlTransferTest, BlockEmpty) { ...@@ -232,7 +232,7 @@ TEST_F(ControlTransferTest, BlockEmpty) {
TEST_F(ControlTransferTest, Br0) { TEST_F(ControlTransferTest, Br0) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBr, // @2 kExprBr, // @2
0, // @3 0, // @3
kExprEnd // @4 kExprEnd // @4
...@@ -243,7 +243,7 @@ TEST_F(ControlTransferTest, Br0) { ...@@ -243,7 +243,7 @@ TEST_F(ControlTransferTest, Br0) {
TEST_F(ControlTransferTest, Br1) { TEST_F(ControlTransferTest, Br1) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprNop, // @2 kExprNop, // @2
kExprBr, // @3 kExprBr, // @3
0, // @4 0, // @4
...@@ -255,7 +255,7 @@ TEST_F(ControlTransferTest, Br1) { ...@@ -255,7 +255,7 @@ TEST_F(ControlTransferTest, Br1) {
TEST_F(ControlTransferTest, Br_v1a) { TEST_F(ControlTransferTest, Br_v1a) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprBr, // @4 kExprBr, // @4
...@@ -268,7 +268,7 @@ TEST_F(ControlTransferTest, Br_v1a) { ...@@ -268,7 +268,7 @@ TEST_F(ControlTransferTest, Br_v1a) {
TEST_F(ControlTransferTest, Br_v1b) { TEST_F(ControlTransferTest, Br_v1b) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprBr, // @4 kExprBr, // @4
...@@ -283,7 +283,7 @@ TEST_F(ControlTransferTest, Br_v1c) { ...@@ -283,7 +283,7 @@ TEST_F(ControlTransferTest, Br_v1c) {
kExprI32Const, // @0 kExprI32Const, // @0
0, // @1 0, // @1
kExprBlock, // @2 kExprBlock, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprBr, // @4 kExprBr, // @4
0, // @5 0, // @5
kExprEnd // @6 kExprEnd // @6
...@@ -294,7 +294,7 @@ TEST_F(ControlTransferTest, Br_v1c) { ...@@ -294,7 +294,7 @@ TEST_F(ControlTransferTest, Br_v1c) {
TEST_F(ControlTransferTest, Br_v1d) { TEST_F(ControlTransferTest, Br_v1d) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalI32, // @1 kI32Code, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprBr, // @4 kExprBr, // @4
...@@ -307,7 +307,7 @@ TEST_F(ControlTransferTest, Br_v1d) { ...@@ -307,7 +307,7 @@ TEST_F(ControlTransferTest, Br_v1d) {
TEST_F(ControlTransferTest, Br2) { TEST_F(ControlTransferTest, Br2) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprNop, // @2 kExprNop, // @2
kExprNop, // @3 kExprNop, // @3
kExprBr, // @4 kExprBr, // @4
...@@ -320,7 +320,7 @@ TEST_F(ControlTransferTest, Br2) { ...@@ -320,7 +320,7 @@ TEST_F(ControlTransferTest, Br2) {
TEST_F(ControlTransferTest, Br0b) { TEST_F(ControlTransferTest, Br0b) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBr, // @2 kExprBr, // @2
0, // @3 0, // @3
kExprNop, // @4 kExprNop, // @4
...@@ -332,7 +332,7 @@ TEST_F(ControlTransferTest, Br0b) { ...@@ -332,7 +332,7 @@ TEST_F(ControlTransferTest, Br0b) {
TEST_F(ControlTransferTest, Br0c) { TEST_F(ControlTransferTest, Br0c) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBr, // @2 kExprBr, // @2
0, // @3 0, // @3
kExprNop, // @4 kExprNop, // @4
...@@ -344,46 +344,46 @@ TEST_F(ControlTransferTest, Br0c) { ...@@ -344,46 +344,46 @@ TEST_F(ControlTransferTest, Br0c) {
TEST_F(ControlTransferTest, SimpleLoop1) { TEST_F(ControlTransferTest, SimpleLoop1) {
byte code[] = { byte code[] = {
kExprLoop, // @0 kExprLoop, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBr, // @2 kExprBr, // @2
0, // @3 0, // @3
kExprEnd // @4 kExprEnd // @4
}; };
CheckTransfers(code, {{2, -2, 0, 0}}); CheckTransfers(code, {{2, -2, 0, 0}});
} }
TEST_F(ControlTransferTest, SimpleLoop2) { TEST_F(ControlTransferTest, SimpleLoop2) {
byte code[] = { byte code[] = {
kExprLoop, // @0 kExprLoop, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprNop, // @2 kExprNop, // @2
kExprBr, // @3 kExprBr, // @3
0, // @4 0, // @4
kExprEnd // @5 kExprEnd // @5
}; };
CheckTransfers(code, {{3, -3, 0, 0}}); CheckTransfers(code, {{3, -3, 0, 0}});
} }
TEST_F(ControlTransferTest, SimpleLoopExit1) { TEST_F(ControlTransferTest, SimpleLoopExit1) {
byte code[] = { byte code[] = {
kExprLoop, // @0 kExprLoop, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBr, // @2 kExprBr, // @2
1, // @3 1, // @3
kExprEnd // @4 kExprEnd // @4
}; };
CheckTransfers(code, {{2, 4, 0, 0}}); CheckTransfers(code, {{2, 4, 0, 0}});
} }
TEST_F(ControlTransferTest, SimpleLoopExit2) { TEST_F(ControlTransferTest, SimpleLoopExit2) {
byte code[] = { byte code[] = {
kExprLoop, // @0 kExprLoop, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprNop, // @2 kExprNop, // @2
kExprBr, // @3 kExprBr, // @3
1, // @4 1, // @4
kExprEnd // @5 kExprEnd // @5
}; };
CheckTransfers(code, {{3, 4, 0, 0}}); CheckTransfers(code, {{3, 4, 0, 0}});
} }
...@@ -391,7 +391,7 @@ TEST_F(ControlTransferTest, SimpleLoopExit2) { ...@@ -391,7 +391,7 @@ TEST_F(ControlTransferTest, SimpleLoopExit2) {
TEST_F(ControlTransferTest, BrTable0) { TEST_F(ControlTransferTest, BrTable0) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprBrTable, // @4 kExprBrTable, // @4
...@@ -405,7 +405,7 @@ TEST_F(ControlTransferTest, BrTable0) { ...@@ -405,7 +405,7 @@ TEST_F(ControlTransferTest, BrTable0) {
TEST_F(ControlTransferTest, BrTable0_v1a) { TEST_F(ControlTransferTest, BrTable0_v1a) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprI32Const, // @4 kExprI32Const, // @4
...@@ -421,7 +421,7 @@ TEST_F(ControlTransferTest, BrTable0_v1a) { ...@@ -421,7 +421,7 @@ TEST_F(ControlTransferTest, BrTable0_v1a) {
TEST_F(ControlTransferTest, BrTable0_v1b) { TEST_F(ControlTransferTest, BrTable0_v1b) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprI32Const, // @4 kExprI32Const, // @4
...@@ -437,7 +437,7 @@ TEST_F(ControlTransferTest, BrTable0_v1b) { ...@@ -437,7 +437,7 @@ TEST_F(ControlTransferTest, BrTable0_v1b) {
TEST_F(ControlTransferTest, BrTable1) { TEST_F(ControlTransferTest, BrTable1) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprBrTable, // @4 kExprBrTable, // @4
...@@ -452,9 +452,9 @@ TEST_F(ControlTransferTest, BrTable1) { ...@@ -452,9 +452,9 @@ TEST_F(ControlTransferTest, BrTable1) {
TEST_F(ControlTransferTest, BrTable2) { TEST_F(ControlTransferTest, BrTable2) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBlock, // @2 kExprBlock, // @2
kLocalVoid, // @3 kVoidCode, // @3
kExprI32Const, // @4 kExprI32Const, // @4
0, // @5 0, // @5
kExprBrTable, // @6 kExprBrTable, // @6
...@@ -471,11 +471,11 @@ TEST_F(ControlTransferTest, BrTable2) { ...@@ -471,11 +471,11 @@ TEST_F(ControlTransferTest, BrTable2) {
TEST_F(ControlTransferTest, BiggerSpDiffs) { TEST_F(ControlTransferTest, BiggerSpDiffs) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalI32, // @1 kI32Code, // @1
kExprI32Const, // @2 kExprI32Const, // @2
0, // @3 0, // @3
kExprBlock, // @4 kExprBlock, // @4
kLocalVoid, // @5 kVoidCode, // @5
kExprI32Const, // @6 kExprI32Const, // @6
0, // @7 0, // @7
kExprI32Const, // @8 kExprI32Const, // @8
...@@ -495,19 +495,19 @@ TEST_F(ControlTransferTest, BiggerSpDiffs) { ...@@ -495,19 +495,19 @@ TEST_F(ControlTransferTest, BiggerSpDiffs) {
TEST_F(ControlTransferTest, NoInfoForUnreachableCode) { TEST_F(ControlTransferTest, NoInfoForUnreachableCode) {
byte code[] = { byte code[] = {
kExprBlock, // @0 kExprBlock, // @0
kLocalVoid, // @1 kVoidCode, // @1
kExprBr, // @2 kExprBr, // @2
0, // @3 0, // @3
kExprBr, // @4 -- no control transfer entry! kExprBr, // @4 -- no control transfer entry!
1, // @5 1, // @5
kExprEnd, // @6 kExprEnd, // @6
kExprBlock, // @7 kExprBlock, // @7
kLocalVoid, // @8 kVoidCode, // @8
kExprUnreachable, // @9 kExprUnreachable, // @9
kExprI32Const, // @10 kExprI32Const, // @10
0, // @11 0, // @11
kExprIf, // @12 -- no control transfer entry! kExprIf, // @12 -- no control transfer entry!
kLocalVoid, // @13 kVoidCode, // @13
kExprBr, // @14 -- no control transfer entry! kExprBr, // @14 -- no control transfer entry!
0, // @15 0, // @15
kExprElse, // @16 -- no control transfer entry! kExprElse, // @16 -- no control transfer entry!
......
...@@ -38,7 +38,7 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Empty0) { ...@@ -38,7 +38,7 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Empty0) {
} }
TEST_F(WasmLoopAssignmentAnalyzerTest, Empty1) { TEST_F(WasmLoopAssignmentAnalyzerTest, Empty1) {
byte code[] = {kExprLoop, kLocalVoid, 0}; byte code[] = {kExprLoop, kVoidCode, 0};
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
BitVector* assigned = Analyze(code, code + arraysize(code)); BitVector* assigned = Analyze(code, code + arraysize(code));
for (int j = 0; j < assigned->length(); j++) { for (int j = 0; j < assigned->length(); j++) {
...@@ -176,9 +176,9 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Loop2) { ...@@ -176,9 +176,9 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, Loop2) {
} }
TEST_F(WasmLoopAssignmentAnalyzerTest, Malformed) { TEST_F(WasmLoopAssignmentAnalyzerTest, Malformed) {
byte code[] = {kExprLoop, kLocalVoid, kExprF32Neg, kExprBrTable, 0x0E, 'h', byte code[] = {kExprLoop, kVoidCode, kExprF32Neg, kExprBrTable, 0x0E, 'h',
'e', 'l', 'l', 'o', ',', ' ', 'e', 'l', 'l', 'o', ',', ' ',
'w', 'o', 'r', 'l', 'd', '!'}; 'w', 'o', 'r', 'l', 'd', '!'};
BitVector* assigned = Analyze(code, code + arraysize(code)); BitVector* assigned = Analyze(code, code + arraysize(code));
CHECK_NULL(assigned); CHECK_NULL(assigned);
} }
......
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