Commit ceb29f7c authored by titzer's avatar titzer Committed by Commit bot

[wasm] Rename ast-decoder.* to function-body-decoder.*

Since WASM is no longer an AST :-(

R=clemensh@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2594973003
Cr-Commit-Position: refs/heads/master@{#41889}
parent 0ba82511
...@@ -1744,9 +1744,9 @@ v8_source_set("v8_base") { ...@@ -1744,9 +1744,9 @@ v8_source_set("v8_base") {
"src/version.h", "src/version.h",
"src/vm-state-inl.h", "src/vm-state-inl.h",
"src/vm-state.h", "src/vm-state.h",
"src/wasm/ast-decoder.cc",
"src/wasm/ast-decoder.h",
"src/wasm/decoder.h", "src/wasm/decoder.h",
"src/wasm/function-body-decoder.cc",
"src/wasm/function-body-decoder.h",
"src/wasm/leb-helper.h", "src/wasm/leb-helper.h",
"src/wasm/managed.h", "src/wasm/managed.h",
"src/wasm/module-decoder.cc", "src/wasm/module-decoder.cc",
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "src/factory.h" #include "src/factory.h"
#include "src/log-inl.h" #include "src/log-inl.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-opcodes.h"
...@@ -3535,7 +3535,7 @@ SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction( ...@@ -3535,7 +3535,7 @@ SourcePositionTable* WasmCompilationUnit::BuildGraphForWasmFunction(
if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) { if (index >= FLAG_trace_wasm_ast_start && index < FLAG_trace_wasm_ast_end) {
OFStream os(stdout); OFStream os(stdout);
PrintAst(isolate_->allocator(), body, os, nullptr); PrintWasmCode(isolate_->allocator(), body, os, nullptr);
} }
if (index >= FLAG_trace_wasm_text_start && index < FLAG_trace_wasm_text_end) { if (index >= FLAG_trace_wasm_text_start && index < FLAG_trace_wasm_text_end) {
OFStream os(stdout); OFStream os(stdout);
......
...@@ -1283,9 +1283,9 @@ ...@@ -1283,9 +1283,9 @@
'version.h', 'version.h',
'vm-state-inl.h', 'vm-state-inl.h',
'vm-state.h', 'vm-state.h',
'wasm/ast-decoder.cc',
'wasm/ast-decoder.h',
'wasm/decoder.h', 'wasm/decoder.h',
'wasm/function-body-decoder.cc',
'wasm/function-body-decoder.h',
'wasm/leb-helper.h', 'wasm/leb-helper.h',
'wasm/managed.h', 'wasm/managed.h',
'wasm/module-decoder.cc', 'wasm/module-decoder.cc',
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "src/handles.h" #include "src/handles.h"
#include "src/zone/zone-containers.h" #include "src/zone/zone-containers.h"
#include "src/wasm/ast-decoder.h"
#include "src/wasm/decoder.h" #include "src/wasm/decoder.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-opcodes.h"
...@@ -101,10 +101,10 @@ enum ControlKind { kControlIf, kControlBlock, kControlLoop, kControlTry }; ...@@ -101,10 +101,10 @@ enum ControlKind { kControlIf, kControlBlock, kControlLoop, kControlTry };
struct Control { struct Control {
const byte* pc; const byte* pc;
ControlKind kind; ControlKind kind;
int stack_depth; // stack height at the beginning of the construct. int stack_depth; // stack height at the beginning of the construct.
SsaEnv* end_env; // end environment for the construct. SsaEnv* end_env; // end environment for the construct.
SsaEnv* false_env; // false environment (only for if). SsaEnv* false_env; // false environment (only for if).
TryInfo* try_info; // Information used for compiling try statements. TryInfo* try_info; // Information used for compiling try statements.
int32_t previous_catch; // The previous Control (on the stack) with a catch. int32_t previous_catch; // The previous Control (on the stack) with a catch.
// Values merged into the end of this control construct. // Values merged into the end of this control construct.
...@@ -382,7 +382,7 @@ class WasmFullDecoder : public WasmDecoder { ...@@ -382,7 +382,7 @@ class WasmFullDecoder : public WasmDecoder {
bool Decode() { bool Decode() {
if (FLAG_wasm_code_fuzzer_gen_test) { if (FLAG_wasm_code_fuzzer_gen_test) {
PrintAstForDebugging(start_, end_); PrintWasmCodeForDebugging(start_, end_);
} }
base::ElapsedTimer decode_timer; base::ElapsedTimer decode_timer;
if (FLAG_trace_wasm_decode_time) { if (FLAG_trace_wasm_decode_time) {
...@@ -462,7 +462,7 @@ class WasmFullDecoder : public WasmDecoder { ...@@ -462,7 +462,7 @@ class WasmFullDecoder : public WasmDecoder {
return false; return false;
} }
bool DecodeLocalDecls(AstLocalDecls& decls) { bool DecodeLocalDecls(BodyLocalDecls& decls) {
DecodeLocalDecls(); DecodeLocalDecls();
if (failed()) return false; if (failed()) return false;
decls.decls_encoded_size = pc_offset(); decls.decls_encoded_size = pc_offset();
...@@ -1889,7 +1889,7 @@ class WasmFullDecoder : public WasmDecoder { ...@@ -1889,7 +1889,7 @@ class WasmFullDecoder : public WasmDecoder {
} }
}; };
bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, bool DecodeLocalDecls(BodyLocalDecls& decls, const byte* start,
const byte* end) { const byte* end) {
AccountingAllocator allocator; AccountingAllocator allocator;
Zone tmp(&allocator, ZONE_NAME); Zone tmp(&allocator, ZONE_NAME);
...@@ -1899,7 +1899,7 @@ bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, ...@@ -1899,7 +1899,7 @@ bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start,
} }
BytecodeIterator::BytecodeIterator(const byte* start, const byte* end, BytecodeIterator::BytecodeIterator(const byte* start, const byte* end,
AstLocalDecls* decls) BodyLocalDecls* decls)
: Decoder(start, end) { : Decoder(start, end) {
if (decls != nullptr) { if (decls != nullptr) {
if (DecodeLocalDecls(*decls, start, end)) { if (DecodeLocalDecls(*decls, start, end)) {
...@@ -1930,15 +1930,15 @@ unsigned OpcodeLength(const byte* pc, const byte* end) { ...@@ -1930,15 +1930,15 @@ unsigned OpcodeLength(const byte* pc, const byte* end) {
return decoder.OpcodeLength(pc); return decoder.OpcodeLength(pc);
} }
void PrintAstForDebugging(const byte* start, const byte* end) { void PrintWasmCodeForDebugging(const byte* start, const byte* end) {
AccountingAllocator allocator; AccountingAllocator allocator;
OFStream os(stdout); OFStream os(stdout);
PrintAst(&allocator, FunctionBodyForTesting(start, end), os, nullptr); PrintWasmCode(&allocator, FunctionBodyForTesting(start, end), os, nullptr);
} }
bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
std::ostream& os, std::ostream& os,
std::vector<std::tuple<uint32_t, int, int>>* offset_table) { std::vector<std::tuple<uint32_t, int, int>>* offset_table) {
Zone zone(allocator, ZONE_NAME); Zone zone(allocator, ZONE_NAME);
WasmFullDecoder decoder(&zone, nullptr, body); WasmFullDecoder decoder(&zone, nullptr, body);
int line_nr = 0; int line_nr = 0;
...@@ -1950,7 +1950,7 @@ bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, ...@@ -1950,7 +1950,7 @@ bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body,
} }
// Print the local declarations. // Print the local declarations.
AstLocalDecls decls(&zone); BodyLocalDecls decls(&zone);
BytecodeIterator i(body.start, body.end, &decls); BytecodeIterator i(body.start, body.end, &decls);
if (body.start != i.pc() && !FLAG_wasm_code_fuzzer_gen_test) { if (body.start != i.pc() && !FLAG_wasm_code_fuzzer_gen_test) {
os << "// locals: "; os << "// locals: ";
...@@ -2048,7 +2048,7 @@ bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, ...@@ -2048,7 +2048,7 @@ bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body,
} }
default: default:
break; break;
} }
os << std::endl; os << std::endl;
++line_nr; ++line_nr;
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef V8_WASM_AST_DECODER_H_ #ifndef V8_WASM_FUNCTION_BODY_DECODER_H_
#define V8_WASM_AST_DECODER_H_ #define V8_WASM_FUNCTION_BODY_DECODER_H_
#include <iterator> #include <iterator>
...@@ -336,12 +336,12 @@ V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator, ...@@ -336,12 +336,12 @@ V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
FunctionBody& body); FunctionBody& body);
DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
FunctionBody& body); FunctionBody& body);
bool PrintAst(AccountingAllocator* allocator, const FunctionBody& body, bool PrintWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
std::ostream& os, std::ostream& os,
std::vector<std::tuple<uint32_t, int, int>>* offset_table); std::vector<std::tuple<uint32_t, int, int>>* offset_table);
// A simplified form of AST printing, e.g. from a debugger. // A simplified form of AST printing, e.g. from a debugger.
void PrintAstForDebugging(const byte* start, const byte* end); void PrintWasmCodeForDebugging(const byte* start, const byte* end);
inline DecodeResult VerifyWasmCode(AccountingAllocator* allocator, inline DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
ModuleEnv* module, FunctionSig* sig, ModuleEnv* module, FunctionSig* sig,
...@@ -358,7 +358,7 @@ inline DecodeResult BuildTFGraph(AccountingAllocator* allocator, ...@@ -358,7 +358,7 @@ inline DecodeResult BuildTFGraph(AccountingAllocator* allocator,
return BuildTFGraph(allocator, builder, body); return BuildTFGraph(allocator, builder, body);
} }
struct AstLocalDecls { struct BodyLocalDecls {
// The size of the encoded declarations. // The size of the encoded declarations.
uint32_t decls_encoded_size; // size of encoded declarations uint32_t decls_encoded_size; // size of encoded declarations
...@@ -369,12 +369,12 @@ struct AstLocalDecls { ...@@ -369,12 +369,12 @@ struct AstLocalDecls {
ZoneVector<std::pair<LocalType, uint32_t>> local_types; ZoneVector<std::pair<LocalType, uint32_t>> local_types;
// Constructor initializes the vector. // Constructor initializes the vector.
explicit AstLocalDecls(Zone* zone) explicit BodyLocalDecls(Zone* zone)
: decls_encoded_size(0), total_local_count(0), local_types(zone) {} : decls_encoded_size(0), total_local_count(0), local_types(zone) {}
}; };
V8_EXPORT_PRIVATE bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, V8_EXPORT_PRIVATE bool DecodeLocalDecls(BodyLocalDecls& decls,
const byte* end); const byte* start, const byte* end);
V8_EXPORT_PRIVATE BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, V8_EXPORT_PRIVATE BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone,
size_t num_locals, size_t num_locals,
const byte* start, const byte* start,
...@@ -444,7 +444,7 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) { ...@@ -444,7 +444,7 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
// assume the bytecode starts with local declarations and decode them. // assume the bytecode starts with local declarations and decode them.
// Otherwise, do not decode local decls. // Otherwise, do not decode local decls.
BytecodeIterator(const byte* start, const byte* end, BytecodeIterator(const byte* start, const byte* end,
AstLocalDecls* decls = nullptr); BodyLocalDecls* decls = nullptr);
base::iterator_range<opcode_iterator> opcodes() { base::iterator_range<opcode_iterator> opcodes() {
return base::iterator_range<opcode_iterator>(opcode_iterator(pc_, end_), return base::iterator_range<opcode_iterator>(opcode_iterator(pc_, end_),
...@@ -476,4 +476,4 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) { ...@@ -476,4 +476,4 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
#endif // V8_WASM_AST_DECODER_H_ #endif // V8_WASM_FUNCTION_BODY_DECODER_H_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define V8_WASM_MODULE_DECODER_H_ #define V8_WASM_MODULE_DECODER_H_
#include "src/globals.h" #include "src/globals.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-result.h" #include "src/wasm/wasm-result.h"
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include "src/wasm/wasm-interpreter.h" #include "src/wasm/wasm-interpreter.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/wasm/ast-decoder.h"
#include "src/wasm/decoder.h" #include "src/wasm/decoder.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-external-refs.h" #include "src/wasm/wasm-external-refs.h"
#include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
...@@ -721,7 +721,7 @@ class ControlTransfers : public ZoneObject { ...@@ -721,7 +721,7 @@ class ControlTransfers : public ZoneObject {
public: public:
ControlTransferMap map_; ControlTransferMap map_;
ControlTransfers(Zone* zone, AstLocalDecls* locals, const byte* start, ControlTransfers(Zone* zone, BodyLocalDecls* locals, const byte* start,
const byte* end) const byte* end)
: map_(zone) { : map_(zone) {
// Represents a control flow label. // Represents a control flow label.
...@@ -872,7 +872,7 @@ class ControlTransfers : public ZoneObject { ...@@ -872,7 +872,7 @@ class ControlTransfers : public ZoneObject {
// Code and metadata needed to execute a function. // Code and metadata needed to execute a function.
struct InterpreterCode { struct InterpreterCode {
const WasmFunction* function; // wasm function const WasmFunction* function; // wasm function
AstLocalDecls locals; // local declarations BodyLocalDecls locals; // local declarations
const byte* orig_start; // start of original code const byte* orig_start; // start of original code
const byte* orig_end; // end of original code const byte* orig_end; // end of original code
byte* start; // start of (maybe altered) code byte* start; // start of (maybe altered) code
...@@ -938,7 +938,7 @@ class CodeMap { ...@@ -938,7 +938,7 @@ class CodeMap {
int AddFunction(const WasmFunction* function, const byte* code_start, int AddFunction(const WasmFunction* function, const byte* code_start,
const byte* code_end) { const byte* code_end) {
InterpreterCode code = { InterpreterCode code = {
function, AstLocalDecls(zone_), code_start, function, BodyLocalDecls(zone_), code_start,
code_end, const_cast<byte*>(code_start), const_cast<byte*>(code_end), code_end, const_cast<byte*>(code_start), const_cast<byte*>(code_end),
nullptr}; nullptr};
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "src/v8.h" #include "src/v8.h"
#include "src/zone/zone-containers.h" #include "src/zone/zone-containers.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/leb-helper.h" #include "src/wasm/leb-helper.h"
#include "src/wasm/wasm-macro-gen.h" #include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module-builder.h"
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "src/snapshot/snapshot.h" #include "src/snapshot/snapshot.h"
#include "src/v8.h" #include "src/v8.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/module-decoder.h" #include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-js.h" #include "src/wasm/wasm-js.h"
#include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-limits.h"
......
...@@ -795,7 +795,7 @@ bool WasmCompiledModule::GetPossibleBreakpoints( ...@@ -795,7 +795,7 @@ bool WasmCompiledModule::GetPossibleBreakpoints(
WasmFunction& func = functions[func_idx]; WasmFunction& func = functions[func_idx];
if (func.code_start_offset == func.code_end_offset) continue; if (func.code_start_offset == func.code_end_offset) continue;
AstLocalDecls locals(&tmp); BodyLocalDecls locals(&tmp);
BytecodeIterator iterator(module_start + func.code_start_offset, BytecodeIterator iterator(module_start + func.code_start_offset,
module_start + func.code_end_offset, &locals); module_start + func.code_end_offset, &locals);
DCHECK_LT(0u, locals.decls_encoded_size); DCHECK_LT(0u, locals.decls_encoded_size);
......
...@@ -27,7 +27,7 @@ enum LocalTypeCode { ...@@ -27,7 +27,7 @@ enum LocalTypeCode {
// Type code for multi-value block types. // Type code for multi-value block types.
static const uint8_t kMultivalBlock = 0x41; static const uint8_t kMultivalBlock = 0x41;
// We reuse the internal machine type to represent WebAssembly AST types. // We reuse the internal machine type to represent WebAssembly types.
// A typedef improves readability without adding a whole new type system. // A typedef improves readability without adding a whole new type system.
typedef MachineRepresentation LocalType; typedef MachineRepresentation LocalType;
const LocalType kAstStmt = MachineRepresentation::kNone; const LocalType kAstStmt = MachineRepresentation::kNone;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "src/debug/interface-types.h" #include "src/debug/interface-types.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/vector.h" #include "src/vector.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-opcodes.h"
#include "src/zone/zone.h" #include "src/zone/zone.h"
...@@ -168,7 +168,7 @@ void wasm::PrintWasmText(const WasmModule *module, ...@@ -168,7 +168,7 @@ void wasm::PrintWasmText(const WasmModule *module,
++line_nr; ++line_nr;
// Print the local declarations. // Print the local declarations.
AstLocalDecls decls(&zone); BodyLocalDecls decls(&zone);
Vector<const byte> func_bytes = wire_bytes.module_bytes.SubVector( Vector<const byte> func_bytes = wire_bytes.module_bytes.SubVector(
fun->code_start_offset, fun->code_end_offset); fun->code_start_offset, fun->code_end_offset);
BytecodeIterator i(func_bytes.begin(), func_bytes.end(), &decls); BytecodeIterator i(func_bytes.begin(), func_bytes.end(), &decls);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "src/compiler/pipeline.h" #include "src/compiler/pipeline.h"
#include "src/compiler/wasm-compiler.h" #include "src/compiler/wasm-compiler.h"
#include "src/compiler/zone-stats.h" #include "src/compiler/zone-stats.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-external-refs.h" #include "src/wasm/wasm-external-refs.h"
#include "src/wasm/wasm-interpreter.h" #include "src/wasm/wasm-interpreter.h"
#include "src/wasm/wasm-js.h" #include "src/wasm/wasm-js.h"
......
...@@ -130,9 +130,9 @@ v8_executable("unittests") { ...@@ -130,9 +130,9 @@ v8_executable("unittests") {
"unicode-unittest.cc", "unicode-unittest.cc",
"value-serializer-unittest.cc", "value-serializer-unittest.cc",
"wasm/asm-types-unittest.cc", "wasm/asm-types-unittest.cc",
"wasm/ast-decoder-unittest.cc",
"wasm/control-transfer-unittest.cc", "wasm/control-transfer-unittest.cc",
"wasm/decoder-unittest.cc", "wasm/decoder-unittest.cc",
"wasm/function-body-decoder-unittest.cc",
"wasm/leb-helper-unittest.cc", "wasm/leb-helper-unittest.cc",
"wasm/loop-assignment-analysis-unittest.cc", "wasm/loop-assignment-analysis-unittest.cc",
"wasm/module-decoder-unittest.cc", "wasm/module-decoder-unittest.cc",
......
...@@ -130,9 +130,9 @@ ...@@ -130,9 +130,9 @@
'zone/segmentpool-unittest.cc', 'zone/segmentpool-unittest.cc',
'zone/zone-chunk-list-unittest.cc', 'zone/zone-chunk-list-unittest.cc',
'wasm/asm-types-unittest.cc', 'wasm/asm-types-unittest.cc',
'wasm/ast-decoder-unittest.cc',
'wasm/control-transfer-unittest.cc', 'wasm/control-transfer-unittest.cc',
'wasm/decoder-unittest.cc', 'wasm/decoder-unittest.cc',
'wasm/function-body-decoder-unittest.cc',
'wasm/leb-helper-unittest.cc', 'wasm/leb-helper-unittest.cc',
'wasm/loop-assignment-analysis-unittest.cc', 'wasm/loop-assignment-analysis-unittest.cc',
'wasm/module-decoder-unittest.cc', 'wasm/module-decoder-unittest.cc',
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "src/objects.h" #include "src/objects.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/signature-map.h" #include "src/wasm/signature-map.h"
#include "src/wasm/wasm-macro-gen.h" #include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
...@@ -83,11 +83,11 @@ static const WasmOpcode kInt32BinopOpcodes[] = { ...@@ -83,11 +83,11 @@ static const WasmOpcode kInt32BinopOpcodes[] = {
static bool old_eh_flag; static bool old_eh_flag;
class AstDecoderTest : public TestWithZone { class FunctionBodyDecoderTest : public TestWithZone {
public: public:
typedef std::pair<uint32_t, LocalType> LocalsDecl; typedef std::pair<uint32_t, LocalType> LocalsDecl;
AstDecoderTest() : module(nullptr), local_decls(zone()) {} FunctionBodyDecoderTest() : module(nullptr), local_decls(zone()) {}
static void SetUpTestCase() { old_eh_flag = FLAG_wasm_eh_prototype; } static void SetUpTestCase() { old_eh_flag = FLAG_wasm_eh_prototype; }
...@@ -182,7 +182,7 @@ class AstDecoderTest : public TestWithZone { ...@@ -182,7 +182,7 @@ class AstDecoderTest : public TestWithZone {
} }
}; };
TEST_F(AstDecoderTest, Int8Const) { TEST_F(FunctionBodyDecoderTest, Int8Const) {
byte code[] = {kExprI8Const, 0}; byte code[] = {kExprI8Const, 0};
for (int i = -128; i < 128; i++) { for (int i = -128; i < 128; i++) {
code[1] = static_cast<byte>(i); code[1] = static_cast<byte>(i);
...@@ -190,27 +190,27 @@ TEST_F(AstDecoderTest, Int8Const) { ...@@ -190,27 +190,27 @@ TEST_F(AstDecoderTest, Int8Const) {
} }
} }
TEST_F(AstDecoderTest, EmptyFunction) { TEST_F(FunctionBodyDecoderTest, EmptyFunction) {
byte code[] = {0}; byte code[] = {0};
Verify(kSuccess, sigs.v_v(), code, code); Verify(kSuccess, sigs.v_v(), code, code);
Verify(kError, sigs.i_i(), code, code); Verify(kError, sigs.i_i(), code, code);
} }
TEST_F(AstDecoderTest, IncompleteIf1) { TEST_F(FunctionBodyDecoderTest, IncompleteIf1) {
byte code[] = {kExprIf}; byte code[] = {kExprIf};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, Int8Const_fallthru) { TEST_F(FunctionBodyDecoderTest, Int8Const_fallthru) {
EXPECT_VERIFIES(i_i, WASM_I32V_1(0)); EXPECT_VERIFIES(i_i, WASM_I32V_1(0));
} }
TEST_F(AstDecoderTest, Int8Const_fallthru2) { TEST_F(FunctionBodyDecoderTest, Int8Const_fallthru2) {
EXPECT_FAILURE(i_i, WASM_I32V_1(0), WASM_I32V_1(1)); EXPECT_FAILURE(i_i, WASM_I32V_1(0), WASM_I32V_1(1));
} }
TEST_F(AstDecoderTest, Int32Const) { TEST_F(FunctionBodyDecoderTest, Int32Const) {
const int kInc = 4498211; const int kInc = 4498211;
for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) {
// TODO(binji): expand test for other sized int32s; 1 through 5 bytes. // TODO(binji): expand test for other sized int32s; 1 through 5 bytes.
...@@ -219,7 +219,7 @@ TEST_F(AstDecoderTest, Int32Const) { ...@@ -219,7 +219,7 @@ TEST_F(AstDecoderTest, Int32Const) {
} }
} }
TEST_F(AstDecoderTest, Int64Const) { TEST_F(FunctionBodyDecoderTest, Int64Const) {
const int kInc = 4498211; const int kInc = 4498211;
for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) { for (int32_t i = kMinInt; i < kMaxInt - kInc; i = i + kInc) {
byte code[] = {WASM_I64V((static_cast<int64_t>(i) << 32) | i)}; byte code[] = {WASM_I64V((static_cast<int64_t>(i) << 32) | i)};
...@@ -227,7 +227,7 @@ TEST_F(AstDecoderTest, Int64Const) { ...@@ -227,7 +227,7 @@ TEST_F(AstDecoderTest, Int64Const) {
} }
} }
TEST_F(AstDecoderTest, Float32Const) { TEST_F(FunctionBodyDecoderTest, Float32Const) {
byte code[] = {kExprF32Const, 0, 0, 0, 0}; byte code[] = {kExprF32Const, 0, 0, 0, 0};
float* ptr = reinterpret_cast<float*>(code + 1); float* ptr = reinterpret_cast<float*>(code + 1);
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
...@@ -236,7 +236,7 @@ TEST_F(AstDecoderTest, Float32Const) { ...@@ -236,7 +236,7 @@ TEST_F(AstDecoderTest, Float32Const) {
} }
} }
TEST_F(AstDecoderTest, Float64Const) { TEST_F(FunctionBodyDecoderTest, Float64Const) {
byte code[] = {kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0}; byte code[] = {kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0};
double* ptr = reinterpret_cast<double*>(code + 1); double* ptr = reinterpret_cast<double*>(code + 1);
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
...@@ -245,7 +245,7 @@ TEST_F(AstDecoderTest, Float64Const) { ...@@ -245,7 +245,7 @@ TEST_F(AstDecoderTest, Float64Const) {
} }
} }
TEST_F(AstDecoderTest, Int32Const_off_end) { TEST_F(FunctionBodyDecoderTest, Int32Const_off_end) {
byte code[] = {kExprI32Const, 0xaa, 0xbb, 0xcc, 0x44}; byte code[] = {kExprI32Const, 0xaa, 0xbb, 0xcc, 0x44};
for (int size = 1; size <= 4; size++) { for (int size = 1; size <= 4; size++) {
...@@ -253,21 +253,21 @@ TEST_F(AstDecoderTest, Int32Const_off_end) { ...@@ -253,21 +253,21 @@ TEST_F(AstDecoderTest, Int32Const_off_end) {
} }
} }
TEST_F(AstDecoderTest, GetLocal0_param) { TEST_F(FunctionBodyDecoderTest, GetLocal0_param) {
EXPECT_VERIFIES_C(i_i, kCodeGetLocal0); EXPECT_VERIFIES_C(i_i, kCodeGetLocal0);
} }
TEST_F(AstDecoderTest, GetLocal0_local) { TEST_F(FunctionBodyDecoderTest, GetLocal0_local) {
AddLocals(kAstI32, 1); AddLocals(kAstI32, 1);
EXPECT_VERIFIES_C(i_v, kCodeGetLocal0); EXPECT_VERIFIES_C(i_v, kCodeGetLocal0);
} }
TEST_F(AstDecoderTest, TooManyLocals) { TEST_F(FunctionBodyDecoderTest, TooManyLocals) {
AddLocals(kAstI32, 4034986500); AddLocals(kAstI32, 4034986500);
EXPECT_FAILURE_C(i_v, kCodeGetLocal0); EXPECT_FAILURE_C(i_v, kCodeGetLocal0);
} }
TEST_F(AstDecoderTest, GetLocal0_param_n) { TEST_F(FunctionBodyDecoderTest, GetLocal0_param_n) {
FunctionSig* array[] = {sigs.i_i(), sigs.i_ii(), sigs.i_iii()}; FunctionSig* array[] = {sigs.i_i(), sigs.i_ii(), sigs.i_iii()};
for (size_t i = 0; i < arraysize(array); i++) { for (size_t i = 0; i < arraysize(array); i++) {
...@@ -275,7 +275,7 @@ TEST_F(AstDecoderTest, GetLocal0_param_n) { ...@@ -275,7 +275,7 @@ TEST_F(AstDecoderTest, GetLocal0_param_n) {
} }
} }
TEST_F(AstDecoderTest, GetLocalN_local) { TEST_F(FunctionBodyDecoderTest, GetLocalN_local) {
for (byte i = 1; i < 8; i++) { for (byte i = 1; i < 8; i++) {
AddLocals(kAstI32, 1); AddLocals(kAstI32, 1);
for (byte j = 0; j < i; j++) { for (byte j = 0; j < i; j++) {
...@@ -285,35 +285,35 @@ TEST_F(AstDecoderTest, GetLocalN_local) { ...@@ -285,35 +285,35 @@ TEST_F(AstDecoderTest, GetLocalN_local) {
} }
} }
TEST_F(AstDecoderTest, GetLocal0_fail_no_params) { TEST_F(FunctionBodyDecoderTest, GetLocal0_fail_no_params) {
EXPECT_FAILURE_C(i_v, kCodeGetLocal0); EXPECT_FAILURE_C(i_v, kCodeGetLocal0);
} }
TEST_F(AstDecoderTest, GetLocal1_fail_no_locals) { TEST_F(FunctionBodyDecoderTest, GetLocal1_fail_no_locals) {
EXPECT_FAILURE_C(i_i, kCodeGetLocal1); EXPECT_FAILURE_C(i_i, kCodeGetLocal1);
} }
TEST_F(AstDecoderTest, GetLocal_off_end) { TEST_F(FunctionBodyDecoderTest, GetLocal_off_end) {
static const byte code[] = {kExprGetLocal}; static const byte code[] = {kExprGetLocal};
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, NumLocalBelowLimit) { TEST_F(FunctionBodyDecoderTest, NumLocalBelowLimit) {
AddLocals(kAstI32, kMaxNumWasmLocals - 1); AddLocals(kAstI32, kMaxNumWasmLocals - 1);
EXPECT_VERIFIES(v_v, WASM_NOP); EXPECT_VERIFIES(v_v, WASM_NOP);
} }
TEST_F(AstDecoderTest, NumLocalAtLimit) { TEST_F(FunctionBodyDecoderTest, NumLocalAtLimit) {
AddLocals(kAstI32, kMaxNumWasmLocals); AddLocals(kAstI32, kMaxNumWasmLocals);
EXPECT_VERIFIES(v_v, WASM_NOP); EXPECT_VERIFIES(v_v, WASM_NOP);
} }
TEST_F(AstDecoderTest, NumLocalAboveLimit) { TEST_F(FunctionBodyDecoderTest, NumLocalAboveLimit) {
AddLocals(kAstI32, kMaxNumWasmLocals + 1); AddLocals(kAstI32, kMaxNumWasmLocals + 1);
EXPECT_FAILURE(v_v, WASM_NOP); EXPECT_FAILURE(v_v, WASM_NOP);
} }
TEST_F(AstDecoderTest, GetLocal_varint) { TEST_F(FunctionBodyDecoderTest, GetLocal_varint) {
const int kMaxLocals = kMaxNumWasmLocals - 1; const int kMaxLocals = kMaxNumWasmLocals - 1;
AddLocals(kAstI32, kMaxLocals); AddLocals(kAstI32, kMaxLocals);
...@@ -334,7 +334,7 @@ TEST_F(AstDecoderTest, GetLocal_varint) { ...@@ -334,7 +334,7 @@ TEST_F(AstDecoderTest, GetLocal_varint) {
EXPECT_FAILURE(i_v, kExprGetLocal, U32V_4(kMaxLocals + 1)); EXPECT_FAILURE(i_v, kExprGetLocal, U32V_4(kMaxLocals + 1));
} }
TEST_F(AstDecoderTest, GetLocal_toomany) { TEST_F(FunctionBodyDecoderTest, GetLocal_toomany) {
AddLocals(kAstI32, kMaxNumWasmLocals - 100); AddLocals(kAstI32, kMaxNumWasmLocals - 100);
AddLocals(kAstI32, 100); AddLocals(kAstI32, 100);
...@@ -342,7 +342,7 @@ TEST_F(AstDecoderTest, GetLocal_toomany) { ...@@ -342,7 +342,7 @@ TEST_F(AstDecoderTest, GetLocal_toomany) {
EXPECT_FAILURE(i_i, kExprGetLocal, U32V_1(66)); EXPECT_FAILURE(i_i, kExprGetLocal, U32V_1(66));
} }
TEST_F(AstDecoderTest, Binops_off_end) { TEST_F(FunctionBodyDecoderTest, Binops_off_end) {
byte code1[] = {0}; // [opcode] byte code1[] = {0}; // [opcode]
for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) {
code1[0] = kInt32BinopOpcodes[i]; code1[0] = kInt32BinopOpcodes[i];
...@@ -363,46 +363,46 @@ TEST_F(AstDecoderTest, Binops_off_end) { ...@@ -363,46 +363,46 @@ TEST_F(AstDecoderTest, Binops_off_end) {
} }
} }
TEST_F(AstDecoderTest, BinopsAcrossBlock1) { TEST_F(FunctionBodyDecoderTest, BinopsAcrossBlock1) {
static const byte code[] = {WASM_ZERO, kExprBlock, WASM_ZERO, kExprI32Add, static const byte code[] = {WASM_ZERO, kExprBlock, WASM_ZERO, kExprI32Add,
kExprEnd}; kExprEnd};
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, BinopsAcrossBlock2) { TEST_F(FunctionBodyDecoderTest, BinopsAcrossBlock2) {
static const byte code[] = {WASM_ZERO, WASM_ZERO, kExprBlock, kExprI32Add, static const byte code[] = {WASM_ZERO, WASM_ZERO, kExprBlock, kExprI32Add,
kExprEnd}; kExprEnd};
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, BinopsAcrossBlock3) { TEST_F(FunctionBodyDecoderTest, BinopsAcrossBlock3) {
static const byte code[] = {WASM_ZERO, WASM_ZERO, kExprIf, kExprI32Add, static const byte code[] = {WASM_ZERO, WASM_ZERO, kExprIf, kExprI32Add,
kExprElse, kExprI32Add, kExprEnd}; kExprElse, kExprI32Add, kExprEnd};
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, Nop) { TEST_F(FunctionBodyDecoderTest, Nop) {
static const byte code[] = {kExprNop}; static const byte code[] = {kExprNop};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
} }
TEST_F(AstDecoderTest, SetLocal0_void) { TEST_F(FunctionBodyDecoderTest, SetLocal0_void) {
EXPECT_FAILURE(i_i, WASM_SET_LOCAL(0, WASM_ZERO)); EXPECT_FAILURE(i_i, WASM_SET_LOCAL(0, WASM_ZERO));
} }
TEST_F(AstDecoderTest, SetLocal0_param) { TEST_F(FunctionBodyDecoderTest, SetLocal0_param) {
EXPECT_FAILURE_C(i_i, kCodeSetLocal0); EXPECT_FAILURE_C(i_i, kCodeSetLocal0);
EXPECT_FAILURE_C(f_ff, kCodeSetLocal0); EXPECT_FAILURE_C(f_ff, kCodeSetLocal0);
EXPECT_FAILURE_C(d_dd, kCodeSetLocal0); EXPECT_FAILURE_C(d_dd, kCodeSetLocal0);
} }
TEST_F(AstDecoderTest, TeeLocal0_param) { TEST_F(FunctionBodyDecoderTest, TeeLocal0_param) {
EXPECT_VERIFIES_C(i_i, kCodeTeeLocal0); EXPECT_VERIFIES_C(i_i, kCodeTeeLocal0);
EXPECT_FAILURE_C(f_ff, kCodeTeeLocal0); EXPECT_FAILURE_C(f_ff, kCodeTeeLocal0);
EXPECT_FAILURE_C(d_dd, kCodeTeeLocal0); EXPECT_FAILURE_C(d_dd, kCodeTeeLocal0);
} }
TEST_F(AstDecoderTest, SetLocal0_local) { TEST_F(FunctionBodyDecoderTest, SetLocal0_local) {
EXPECT_FAILURE_C(i_v, kCodeSetLocal0); EXPECT_FAILURE_C(i_v, kCodeSetLocal0);
EXPECT_FAILURE_C(v_v, kCodeSetLocal0); EXPECT_FAILURE_C(v_v, kCodeSetLocal0);
AddLocals(kAstI32, 1); AddLocals(kAstI32, 1);
...@@ -410,13 +410,13 @@ TEST_F(AstDecoderTest, SetLocal0_local) { ...@@ -410,13 +410,13 @@ TEST_F(AstDecoderTest, SetLocal0_local) {
EXPECT_VERIFIES_C(v_v, kCodeSetLocal0); EXPECT_VERIFIES_C(v_v, kCodeSetLocal0);
} }
TEST_F(AstDecoderTest, TeeLocal0_local) { TEST_F(FunctionBodyDecoderTest, TeeLocal0_local) {
EXPECT_FAILURE_C(i_v, kCodeTeeLocal0); EXPECT_FAILURE_C(i_v, kCodeTeeLocal0);
AddLocals(kAstI32, 1); AddLocals(kAstI32, 1);
EXPECT_VERIFIES_C(i_v, kCodeTeeLocal0); EXPECT_VERIFIES_C(i_v, kCodeTeeLocal0);
} }
TEST_F(AstDecoderTest, TeeLocalN_local) { TEST_F(FunctionBodyDecoderTest, TeeLocalN_local) {
for (byte i = 1; i < 8; i++) { for (byte i = 1; i < 8; i++) {
AddLocals(kAstI32, 1); AddLocals(kAstI32, 1);
for (byte j = 0; j < i; j++) { for (byte j = 0; j < i; j++) {
...@@ -426,7 +426,7 @@ TEST_F(AstDecoderTest, TeeLocalN_local) { ...@@ -426,7 +426,7 @@ TEST_F(AstDecoderTest, TeeLocalN_local) {
} }
} }
TEST_F(AstDecoderTest, BlockN) { TEST_F(FunctionBodyDecoderTest, BlockN) {
const int kMaxSize = 200; const int kMaxSize = 200;
byte buffer[kMaxSize + 3]; byte buffer[kMaxSize + 3];
...@@ -441,33 +441,33 @@ TEST_F(AstDecoderTest, BlockN) { ...@@ -441,33 +441,33 @@ TEST_F(AstDecoderTest, BlockN) {
#define WASM_EMPTY_BLOCK kExprBlock, kLocalVoid, kExprEnd #define WASM_EMPTY_BLOCK kExprBlock, kLocalVoid, kExprEnd
TEST_F(AstDecoderTest, Block0) { TEST_F(FunctionBodyDecoderTest, Block0) {
static const byte code[] = {WASM_EMPTY_BLOCK}; static const byte code[] = {WASM_EMPTY_BLOCK};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, Block0_fallthru1) { TEST_F(FunctionBodyDecoderTest, Block0_fallthru1) {
static const byte code[] = {WASM_BLOCK(WASM_EMPTY_BLOCK)}; static const byte code[] = {WASM_BLOCK(WASM_EMPTY_BLOCK)};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, Block0Block0) { TEST_F(FunctionBodyDecoderTest, Block0Block0) {
static const byte code[] = {WASM_EMPTY_BLOCK, WASM_EMPTY_BLOCK}; static const byte code[] = {WASM_EMPTY_BLOCK, WASM_EMPTY_BLOCK};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, Block0_end) { TEST_F(FunctionBodyDecoderTest, Block0_end) {
EXPECT_VERIFIES(v_v, WASM_EMPTY_BLOCK, kExprEnd); EXPECT_VERIFIES(v_v, WASM_EMPTY_BLOCK, kExprEnd);
} }
TEST_F(AstDecoderTest, Block0_end_end) { TEST_F(FunctionBodyDecoderTest, Block0_end_end) {
EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd, kExprEnd); EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd, kExprEnd);
} }
TEST_F(AstDecoderTest, Block1) { TEST_F(FunctionBodyDecoderTest, Block1) {
byte code[] = {WASM_BLOCK_I(WASM_GET_LOCAL(0))}; byte code[] = {WASM_BLOCK_I(WASM_GET_LOCAL(0))};
EXPECT_VERIFIES_C(i_i, code); EXPECT_VERIFIES_C(i_i, code);
EXPECT_FAILURE_C(v_i, code); EXPECT_FAILURE_C(v_i, code);
...@@ -476,7 +476,7 @@ TEST_F(AstDecoderTest, Block1) { ...@@ -476,7 +476,7 @@ TEST_F(AstDecoderTest, Block1) {
EXPECT_FAILURE_C(i_d, code); EXPECT_FAILURE_C(i_d, code);
} }
TEST_F(AstDecoderTest, Block1_i) { TEST_F(FunctionBodyDecoderTest, Block1_i) {
byte code[] = {WASM_BLOCK_I(WASM_ZERO)}; byte code[] = {WASM_BLOCK_I(WASM_ZERO)};
EXPECT_VERIFIES_C(i_i, code); EXPECT_VERIFIES_C(i_i, code);
EXPECT_FAILURE_C(f_ff, code); EXPECT_FAILURE_C(f_ff, code);
...@@ -484,7 +484,7 @@ TEST_F(AstDecoderTest, Block1_i) { ...@@ -484,7 +484,7 @@ TEST_F(AstDecoderTest, Block1_i) {
EXPECT_FAILURE_C(l_ll, code); EXPECT_FAILURE_C(l_ll, code);
} }
TEST_F(AstDecoderTest, Block1_f) { TEST_F(FunctionBodyDecoderTest, Block1_f) {
byte code[] = {WASM_BLOCK_F(WASM_F32(0))}; byte code[] = {WASM_BLOCK_F(WASM_F32(0))};
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
EXPECT_VERIFIES_C(f_ff, code); EXPECT_VERIFIES_C(f_ff, code);
...@@ -492,23 +492,23 @@ TEST_F(AstDecoderTest, Block1_f) { ...@@ -492,23 +492,23 @@ TEST_F(AstDecoderTest, Block1_f) {
EXPECT_FAILURE_C(l_ll, code); EXPECT_FAILURE_C(l_ll, code);
} }
TEST_F(AstDecoderTest, Block1_continue) { TEST_F(FunctionBodyDecoderTest, Block1_continue) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0)));
} }
TEST_F(AstDecoderTest, Block1_br) { TEST_F(FunctionBodyDecoderTest, Block1_br) {
EXPECT_VERIFIES(v_v, B1(WASM_BR(0))); EXPECT_VERIFIES(v_v, B1(WASM_BR(0)));
EXPECT_VERIFIES(v_v, B1(WASM_BR(1))); EXPECT_VERIFIES(v_v, B1(WASM_BR(1)));
EXPECT_FAILURE(v_v, B1(WASM_BR(2))); EXPECT_FAILURE(v_v, B1(WASM_BR(2)));
} }
TEST_F(AstDecoderTest, Block2_br) { TEST_F(FunctionBodyDecoderTest, Block2_br) {
EXPECT_VERIFIES(v_v, B2(WASM_NOP, WASM_BR(0))); EXPECT_VERIFIES(v_v, B2(WASM_NOP, WASM_BR(0)));
EXPECT_VERIFIES(v_v, B2(WASM_BR(0), WASM_NOP)); EXPECT_VERIFIES(v_v, B2(WASM_BR(0), WASM_NOP));
EXPECT_VERIFIES(v_v, B2(WASM_BR(0), WASM_BR(0))); EXPECT_VERIFIES(v_v, B2(WASM_BR(0), WASM_BR(0)));
} }
TEST_F(AstDecoderTest, Block2) { TEST_F(FunctionBodyDecoderTest, Block2) {
EXPECT_FAILURE(i_i, WASM_BLOCK(WASM_NOP, WASM_NOP)); EXPECT_FAILURE(i_i, WASM_BLOCK(WASM_NOP, WASM_NOP));
EXPECT_FAILURE(i_i, WASM_BLOCK_I(WASM_NOP, WASM_NOP)); EXPECT_FAILURE(i_i, WASM_BLOCK_I(WASM_NOP, WASM_NOP));
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_NOP, WASM_ZERO)); EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_NOP, WASM_ZERO));
...@@ -516,25 +516,25 @@ TEST_F(AstDecoderTest, Block2) { ...@@ -516,25 +516,25 @@ TEST_F(AstDecoderTest, Block2) {
EXPECT_FAILURE(i_i, WASM_BLOCK_I(WASM_ZERO, WASM_ZERO)); EXPECT_FAILURE(i_i, WASM_BLOCK_I(WASM_ZERO, WASM_ZERO));
} }
TEST_F(AstDecoderTest, Block2b) { TEST_F(FunctionBodyDecoderTest, Block2b) {
byte code[] = {WASM_BLOCK_I(WASM_SET_LOCAL(0, WASM_ZERO), WASM_ZERO)}; byte code[] = {WASM_BLOCK_I(WASM_SET_LOCAL(0, WASM_ZERO), WASM_ZERO)};
EXPECT_VERIFIES_C(i_i, code); EXPECT_VERIFIES_C(i_i, code);
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(f_ff, code); EXPECT_FAILURE_C(f_ff, code);
} }
TEST_F(AstDecoderTest, Block2_fallthru) { TEST_F(FunctionBodyDecoderTest, Block2_fallthru) {
EXPECT_VERIFIES( EXPECT_VERIFIES(
i_i, B2(WASM_SET_LOCAL(0, WASM_ZERO), WASM_SET_LOCAL(0, WASM_ZERO)), i_i, B2(WASM_SET_LOCAL(0, WASM_ZERO), WASM_SET_LOCAL(0, WASM_ZERO)),
WASM_I8(23)); WASM_I8(23));
} }
TEST_F(AstDecoderTest, Block3) { TEST_F(FunctionBodyDecoderTest, Block3) {
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_SET_LOCAL(0, WASM_ZERO), EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_SET_LOCAL(0, WASM_ZERO),
WASM_SET_LOCAL(0, WASM_ZERO), WASM_I8(11))); WASM_SET_LOCAL(0, WASM_ZERO), WASM_I8(11)));
} }
TEST_F(AstDecoderTest, Block5) { TEST_F(FunctionBodyDecoderTest, Block5) {
EXPECT_FAILURE(v_i, WASM_BLOCK(WASM_ZERO)); EXPECT_FAILURE(v_i, WASM_BLOCK(WASM_ZERO));
EXPECT_FAILURE(v_i, WASM_BLOCK(WASM_ZERO, WASM_ZERO)); EXPECT_FAILURE(v_i, WASM_BLOCK(WASM_ZERO, WASM_ZERO));
...@@ -547,14 +547,14 @@ TEST_F(AstDecoderTest, Block5) { ...@@ -547,14 +547,14 @@ TEST_F(AstDecoderTest, Block5) {
v_i, WASM_BLOCK(WASM_ZERO, WASM_ZERO, WASM_ZERO, WASM_ZERO, WASM_ZERO)); v_i, WASM_BLOCK(WASM_ZERO, WASM_ZERO, WASM_ZERO, WASM_ZERO, WASM_ZERO));
} }
TEST_F(AstDecoderTest, BlockType) { TEST_F(FunctionBodyDecoderTest, BlockType) {
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(l_l, WASM_BLOCK_L(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(l_l, WASM_BLOCK_L(WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(f_f, WASM_BLOCK_F(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(f_f, WASM_BLOCK_F(WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(d_d, WASM_BLOCK_D(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(d_d, WASM_BLOCK_D(WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, BlockType_fail) { TEST_F(FunctionBodyDecoderTest, BlockType_fail) {
EXPECT_FAILURE(i_i, WASM_BLOCK_L(WASM_I64V_1(0))); EXPECT_FAILURE(i_i, WASM_BLOCK_L(WASM_I64V_1(0)));
EXPECT_FAILURE(i_i, WASM_BLOCK_F(WASM_F32(0.0))); EXPECT_FAILURE(i_i, WASM_BLOCK_F(WASM_F32(0.0)));
EXPECT_FAILURE(i_i, WASM_BLOCK_D(WASM_F64(1.1))); EXPECT_FAILURE(i_i, WASM_BLOCK_D(WASM_F64(1.1)));
...@@ -572,14 +572,14 @@ TEST_F(AstDecoderTest, BlockType_fail) { ...@@ -572,14 +572,14 @@ TEST_F(AstDecoderTest, BlockType_fail) {
EXPECT_FAILURE(d_dd, WASM_BLOCK_F(WASM_F32(0.0))); EXPECT_FAILURE(d_dd, WASM_BLOCK_F(WASM_F32(0.0)));
} }
TEST_F(AstDecoderTest, BlockF32) { TEST_F(FunctionBodyDecoderTest, BlockF32) {
static const byte code[] = {WASM_BLOCK_F(kExprF32Const, 0, 0, 0, 0)}; static const byte code[] = {WASM_BLOCK_F(kExprF32Const, 0, 0, 0, 0)};
EXPECT_VERIFIES_C(f_ff, code); EXPECT_VERIFIES_C(f_ff, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
EXPECT_FAILURE_C(d_dd, code); EXPECT_FAILURE_C(d_dd, code);
} }
TEST_F(AstDecoderTest, BlockN_off_end) { TEST_F(FunctionBodyDecoderTest, BlockN_off_end) {
byte code[] = {WASM_BLOCK(kExprNop, kExprNop, kExprNop, kExprNop)}; byte code[] = {WASM_BLOCK(kExprNop, kExprNop, kExprNop, kExprNop)};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
for (size_t i = 1; i < arraysize(code); i++) { for (size_t i = 1; i < arraysize(code); i++) {
...@@ -587,94 +587,94 @@ TEST_F(AstDecoderTest, BlockN_off_end) { ...@@ -587,94 +587,94 @@ TEST_F(AstDecoderTest, BlockN_off_end) {
} }
} }
TEST_F(AstDecoderTest, Block2_continue) { TEST_F(FunctionBodyDecoderTest, Block2_continue) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_BR(0))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_BR(0)));
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_BR(1))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_BR(1)));
EXPECT_FAILURE(v_v, WASM_LOOP(WASM_NOP, WASM_BR(2))); EXPECT_FAILURE(v_v, WASM_LOOP(WASM_NOP, WASM_BR(2)));
} }
TEST_F(AstDecoderTest, Block3_continue) { TEST_F(FunctionBodyDecoderTest, Block3_continue) {
EXPECT_VERIFIES(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(0)))); EXPECT_VERIFIES(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(0))));
EXPECT_VERIFIES(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(1)))); EXPECT_VERIFIES(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(1))));
EXPECT_VERIFIES(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(2)))); EXPECT_VERIFIES(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(2))));
EXPECT_FAILURE(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(3)))); EXPECT_FAILURE(v_v, B1(WASM_LOOP(WASM_NOP, WASM_BR(3))));
} }
TEST_F(AstDecoderTest, NestedBlock_return) { TEST_F(FunctionBodyDecoderTest, NestedBlock_return) {
EXPECT_VERIFIES(i_i, B1(B1(WASM_RETURN1(WASM_ZERO)))); EXPECT_VERIFIES(i_i, B1(B1(WASM_RETURN1(WASM_ZERO))));
} }
TEST_F(AstDecoderTest, BlockBrBinop) { TEST_F(FunctionBodyDecoderTest, BlockBrBinop) {
EXPECT_VERIFIES( EXPECT_VERIFIES(
i_i, WASM_I32_AND(WASM_BLOCK_I(WASM_BRV(0, WASM_I8(1))), WASM_I8(2))); i_i, WASM_I32_AND(WASM_BLOCK_I(WASM_BRV(0, WASM_I8(1))), WASM_I8(2)));
} }
TEST_F(AstDecoderTest, If_empty1) { TEST_F(FunctionBodyDecoderTest, If_empty1) {
EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, kExprEnd); EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, kExprEnd);
} }
TEST_F(AstDecoderTest, If_empty2) { TEST_F(FunctionBodyDecoderTest, If_empty2) {
EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, kExprElse, kExprEnd); EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, kExprElse, kExprEnd);
} }
TEST_F(AstDecoderTest, If_empty3) { TEST_F(FunctionBodyDecoderTest, If_empty3) {
EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, WASM_NOP, kExprElse, kExprEnd); EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, WASM_NOP, kExprElse, kExprEnd);
EXPECT_FAILURE(v_v, WASM_ZERO, WASM_IF_OP, WASM_ZERO, kExprElse, kExprEnd); EXPECT_FAILURE(v_v, WASM_ZERO, WASM_IF_OP, WASM_ZERO, kExprElse, kExprEnd);
} }
TEST_F(AstDecoderTest, If_empty4) { TEST_F(FunctionBodyDecoderTest, If_empty4) {
EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, kExprElse, WASM_NOP, kExprEnd); EXPECT_VERIFIES(v_v, WASM_ZERO, WASM_IF_OP, kExprElse, WASM_NOP, kExprEnd);
EXPECT_FAILURE(v_v, WASM_ZERO, WASM_IF_OP, kExprElse, WASM_ZERO, kExprEnd); EXPECT_FAILURE(v_v, WASM_ZERO, WASM_IF_OP, kExprElse, WASM_ZERO, kExprEnd);
} }
TEST_F(AstDecoderTest, If_empty_stack) { TEST_F(FunctionBodyDecoderTest, If_empty_stack) {
byte code[] = {kExprIf}; byte code[] = {kExprIf};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, If_incomplete1) { TEST_F(FunctionBodyDecoderTest, If_incomplete1) {
byte code[] = {kExprI8Const, 0, kExprIf}; byte code[] = {kExprI8Const, 0, kExprIf};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, If_incomplete2) { TEST_F(FunctionBodyDecoderTest, If_incomplete2) {
byte code[] = {kExprI8Const, 0, kExprIf, kExprNop}; byte code[] = {kExprI8Const, 0, kExprIf, kExprNop};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, If_else_else) { TEST_F(FunctionBodyDecoderTest, If_else_else) {
byte code[] = {kExprI8Const, 0, WASM_IF_OP, kExprElse, kExprElse, kExprEnd}; byte code[] = {kExprI8Const, 0, WASM_IF_OP, kExprElse, kExprElse, kExprEnd};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, IfEmpty) { TEST_F(FunctionBodyDecoderTest, IfEmpty) {
EXPECT_VERIFIES(v_i, kExprGetLocal, 0, WASM_IF_OP, kExprEnd); EXPECT_VERIFIES(v_i, kExprGetLocal, 0, WASM_IF_OP, kExprEnd);
} }
TEST_F(AstDecoderTest, IfSet) { TEST_F(FunctionBodyDecoderTest, IfSet) {
EXPECT_VERIFIES(v_i, EXPECT_VERIFIES(v_i,
WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_ZERO))); WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_ZERO)));
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0),
WASM_SET_LOCAL(0, WASM_ZERO), WASM_NOP)); WASM_SET_LOCAL(0, WASM_ZERO), WASM_NOP));
} }
TEST_F(AstDecoderTest, IfElseEmpty) { TEST_F(FunctionBodyDecoderTest, IfElseEmpty) {
EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), WASM_IF_OP, kExprElse, kExprEnd); EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), WASM_IF_OP, kExprElse, kExprEnd);
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP));
} }
TEST_F(AstDecoderTest, IfElseUnreachable1) { TEST_F(FunctionBodyDecoderTest, IfElseUnreachable1) {
EXPECT_VERIFIES(i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_UNREACHABLE, EXPECT_VERIFIES(i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_UNREACHABLE,
WASM_GET_LOCAL(0))); WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), EXPECT_VERIFIES(i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0),
WASM_UNREACHABLE)); WASM_UNREACHABLE));
} }
TEST_F(AstDecoderTest, IfElseUnreachable2) { TEST_F(FunctionBodyDecoderTest, IfElseUnreachable2) {
static const byte code[] = { static const byte code[] = {
WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_UNREACHABLE, WASM_GET_LOCAL(0))}; WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_UNREACHABLE, WASM_GET_LOCAL(0))};
...@@ -690,148 +690,150 @@ TEST_F(AstDecoderTest, IfElseUnreachable2) { ...@@ -690,148 +690,150 @@ TEST_F(AstDecoderTest, IfElseUnreachable2) {
} }
} }
TEST_F(AstDecoderTest, IfBreak) { TEST_F(FunctionBodyDecoderTest, IfBreak) {
EXPECT_VERIFIES(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_BR(0))); EXPECT_VERIFIES(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_BR(0)));
EXPECT_VERIFIES(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_BR(1))); EXPECT_VERIFIES(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_BR(1)));
EXPECT_FAILURE(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_BR(2))); EXPECT_FAILURE(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_BR(2)));
} }
TEST_F(AstDecoderTest, IfElseBreak) { TEST_F(FunctionBodyDecoderTest, IfElseBreak) {
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_BR(0))); EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_BR(0)));
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_BR(1))); EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_BR(1)));
EXPECT_FAILURE(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_BR(2))); EXPECT_FAILURE(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_BR(2)));
} }
TEST_F(AstDecoderTest, Block_else) { TEST_F(FunctionBodyDecoderTest, Block_else) {
byte code[] = {kExprI8Const, 0, kExprBlock, kExprElse, kExprEnd}; byte code[] = {kExprI8Const, 0, kExprBlock, kExprElse, kExprEnd};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, IfNop) { TEST_F(FunctionBodyDecoderTest, IfNop) {
EXPECT_VERIFIES(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_NOP)); EXPECT_VERIFIES(v_i, WASM_IF(WASM_GET_LOCAL(0), WASM_NOP));
} }
TEST_F(AstDecoderTest, IfNopElseNop) { TEST_F(FunctionBodyDecoderTest, IfNopElseNop) {
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP)); EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_NOP, WASM_NOP));
} }
TEST_F(AstDecoderTest, If_end_end) { TEST_F(FunctionBodyDecoderTest, If_end_end) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd, kExprEnd}; static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprEnd, kExprEnd};
EXPECT_VERIFIES_C(v_i, code); EXPECT_VERIFIES_C(v_i, code);
} }
TEST_F(AstDecoderTest, If_end_end_end) { TEST_F(FunctionBodyDecoderTest, If_end_end_end) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP,
kExprEnd, kExprEnd, kExprEnd}; kExprEnd, kExprEnd, kExprEnd};
EXPECT_FAILURE_C(v_i, code); EXPECT_FAILURE_C(v_i, code);
} }
TEST_F(AstDecoderTest, If_falloff1) { TEST_F(FunctionBodyDecoderTest, If_falloff1) {
static const byte code[] = {kExprGetLocal, 0, kExprIf}; static const byte code[] = {kExprGetLocal, 0, kExprIf};
EXPECT_FAILURE_C(v_i, code); EXPECT_FAILURE_C(v_i, code);
} }
TEST_F(AstDecoderTest, If_falloff2) { TEST_F(FunctionBodyDecoderTest, If_falloff2) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP}; static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP};
EXPECT_FAILURE_C(v_i, code); EXPECT_FAILURE_C(v_i, code);
} }
TEST_F(AstDecoderTest, IfElse_falloff) { TEST_F(FunctionBodyDecoderTest, IfElse_falloff) {
static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprNop, static const byte code[] = {kExprGetLocal, 0, WASM_IF_OP, kExprNop,
kExprElse}; kExprElse};
EXPECT_FAILURE_C(v_i, code); EXPECT_FAILURE_C(v_i, code);
} }
TEST_F(AstDecoderTest, IfElseNop) { TEST_F(FunctionBodyDecoderTest, IfElseNop) {
EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), EXPECT_VERIFIES(v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0),
WASM_SET_LOCAL(0, WASM_ZERO), WASM_NOP)); WASM_SET_LOCAL(0, WASM_ZERO), WASM_NOP));
} }
TEST_F(AstDecoderTest, IfBlock1) { TEST_F(FunctionBodyDecoderTest, IfBlock1) {
EXPECT_VERIFIES( EXPECT_VERIFIES(
v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), B1(WASM_SET_LOCAL(0, WASM_ZERO)), v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), B1(WASM_SET_LOCAL(0, WASM_ZERO)),
WASM_NOP)); WASM_NOP));
} }
TEST_F(AstDecoderTest, IfBlock1b) { TEST_F(FunctionBodyDecoderTest, IfBlock1b) {
EXPECT_VERIFIES(v_i, EXPECT_VERIFIES(v_i,
WASM_IF(WASM_GET_LOCAL(0), B1(WASM_SET_LOCAL(0, WASM_ZERO)))); WASM_IF(WASM_GET_LOCAL(0), B1(WASM_SET_LOCAL(0, WASM_ZERO))));
} }
TEST_F(AstDecoderTest, IfBlock2a) { TEST_F(FunctionBodyDecoderTest, IfBlock2a) {
EXPECT_VERIFIES(v_i, EXPECT_VERIFIES(v_i,
WASM_IF(WASM_GET_LOCAL(0), B2(WASM_SET_LOCAL(0, WASM_ZERO), WASM_IF(WASM_GET_LOCAL(0), B2(WASM_SET_LOCAL(0, WASM_ZERO),
WASM_SET_LOCAL(0, WASM_ZERO)))); WASM_SET_LOCAL(0, WASM_ZERO))));
} }
TEST_F(AstDecoderTest, IfBlock2b) { TEST_F(FunctionBodyDecoderTest, IfBlock2b) {
EXPECT_VERIFIES( EXPECT_VERIFIES(
v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), B2(WASM_SET_LOCAL(0, WASM_ZERO), v_i, WASM_IF_ELSE(WASM_GET_LOCAL(0), B2(WASM_SET_LOCAL(0, WASM_ZERO),
WASM_SET_LOCAL(0, WASM_ZERO)), WASM_SET_LOCAL(0, WASM_ZERO)),
WASM_NOP)); WASM_NOP));
} }
TEST_F(AstDecoderTest, IfElseSet) { TEST_F(FunctionBodyDecoderTest, IfElseSet) {
EXPECT_VERIFIES(v_i, EXPECT_VERIFIES(v_i,
WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_ZERO), WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_ZERO),
WASM_SET_LOCAL(0, WASM_I8(1)))); WASM_SET_LOCAL(0, WASM_I8(1))));
} }
TEST_F(AstDecoderTest, Loop0) { EXPECT_VERIFIES(v_v, WASM_LOOP_OP, kExprEnd); } TEST_F(FunctionBodyDecoderTest, Loop0) {
EXPECT_VERIFIES(v_v, WASM_LOOP_OP, kExprEnd);
}
TEST_F(AstDecoderTest, Loop1) { TEST_F(FunctionBodyDecoderTest, Loop1) {
static const byte code[] = {WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO))}; static const byte code[] = {WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO))};
EXPECT_VERIFIES_C(v_i, code); EXPECT_VERIFIES_C(v_i, code);
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(f_ff, code); EXPECT_FAILURE_C(f_ff, code);
} }
TEST_F(AstDecoderTest, Loop2) { TEST_F(FunctionBodyDecoderTest, Loop2) {
EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO), EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO),
WASM_SET_LOCAL(0, WASM_ZERO))); WASM_SET_LOCAL(0, WASM_ZERO)));
} }
TEST_F(AstDecoderTest, Loop1_continue) { TEST_F(FunctionBodyDecoderTest, Loop1_continue) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0)));
} }
TEST_F(AstDecoderTest, Loop1_break) { TEST_F(FunctionBodyDecoderTest, Loop1_break) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(1))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(1)));
} }
TEST_F(AstDecoderTest, Loop2_continue) { TEST_F(FunctionBodyDecoderTest, Loop2_continue) {
EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO), WASM_BR(0))); EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO), WASM_BR(0)));
} }
TEST_F(AstDecoderTest, Loop2_break) { TEST_F(FunctionBodyDecoderTest, Loop2_break) {
EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO), WASM_BR(1))); EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO), WASM_BR(1)));
} }
TEST_F(AstDecoderTest, InfiniteLoop) { TEST_F(FunctionBodyDecoderTest, InfiniteLoop) {
EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0))); EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0)));
EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BRV(1, WASM_ZERO))); EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BRV(1, WASM_ZERO)));
} }
TEST_F(AstDecoderTest, Loop2_unreachable) { TEST_F(FunctionBodyDecoderTest, Loop2_unreachable) {
EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0), WASM_NOP)); EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0), WASM_NOP));
} }
TEST_F(AstDecoderTest, LoopType) { TEST_F(FunctionBodyDecoderTest, LoopType) {
EXPECT_VERIFIES(i_i, WASM_LOOP_I(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(i_i, WASM_LOOP_I(WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(l_l, WASM_LOOP_L(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(l_l, WASM_LOOP_L(WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(f_f, WASM_LOOP_F(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(f_f, WASM_LOOP_F(WASM_GET_LOCAL(0)));
EXPECT_VERIFIES(d_d, WASM_LOOP_D(WASM_GET_LOCAL(0))); EXPECT_VERIFIES(d_d, WASM_LOOP_D(WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, LoopType_void) { TEST_F(FunctionBodyDecoderTest, LoopType_void) {
EXPECT_FAILURE(v_v, WASM_LOOP_I(WASM_ZERO)); EXPECT_FAILURE(v_v, WASM_LOOP_I(WASM_ZERO));
EXPECT_FAILURE(v_v, WASM_LOOP_L(WASM_I64V_1(0))); EXPECT_FAILURE(v_v, WASM_LOOP_L(WASM_I64V_1(0)));
EXPECT_FAILURE(v_v, WASM_LOOP_F(WASM_F32(0.0))); EXPECT_FAILURE(v_v, WASM_LOOP_F(WASM_F32(0.0)));
EXPECT_FAILURE(v_v, WASM_LOOP_D(WASM_F64(1.1))); EXPECT_FAILURE(v_v, WASM_LOOP_D(WASM_F64(1.1)));
} }
TEST_F(AstDecoderTest, LoopType_fail) { TEST_F(FunctionBodyDecoderTest, LoopType_fail) {
EXPECT_FAILURE(i_i, WASM_LOOP_L(WASM_I64V_1(0))); EXPECT_FAILURE(i_i, WASM_LOOP_L(WASM_I64V_1(0)));
EXPECT_FAILURE(i_i, WASM_LOOP_F(WASM_F32(0.0))); EXPECT_FAILURE(i_i, WASM_LOOP_F(WASM_F32(0.0)));
EXPECT_FAILURE(i_i, WASM_LOOP_D(WASM_F64(1.1))); EXPECT_FAILURE(i_i, WASM_LOOP_D(WASM_F64(1.1)));
...@@ -849,21 +851,21 @@ TEST_F(AstDecoderTest, LoopType_fail) { ...@@ -849,21 +851,21 @@ TEST_F(AstDecoderTest, LoopType_fail) {
EXPECT_FAILURE(d_dd, WASM_LOOP_F(WASM_F32(0.0))); EXPECT_FAILURE(d_dd, WASM_LOOP_F(WASM_F32(0.0)));
} }
TEST_F(AstDecoderTest, ReturnVoid1) { TEST_F(FunctionBodyDecoderTest, ReturnVoid1) {
static const byte code[] = {kExprNop}; static const byte code[] = {kExprNop};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
EXPECT_FAILURE_C(i_f, code); EXPECT_FAILURE_C(i_f, code);
} }
TEST_F(AstDecoderTest, ReturnVoid2) { TEST_F(FunctionBodyDecoderTest, ReturnVoid2) {
static const byte code[] = {WASM_BLOCK(WASM_BR(0))}; static const byte code[] = {WASM_BLOCK(WASM_BR(0))};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
EXPECT_FAILURE_C(i_f, code); EXPECT_FAILURE_C(i_f, code);
} }
TEST_F(AstDecoderTest, ReturnVoid3) { TEST_F(FunctionBodyDecoderTest, ReturnVoid3) {
EXPECT_FAILURE(v_v, kExprI8Const, 0); EXPECT_FAILURE(v_v, kExprI8Const, 0);
EXPECT_FAILURE(v_v, kExprI32Const, 0); EXPECT_FAILURE(v_v, kExprI32Const, 0);
EXPECT_FAILURE(v_v, kExprI64Const, 0); EXPECT_FAILURE(v_v, kExprI64Const, 0);
...@@ -873,7 +875,7 @@ TEST_F(AstDecoderTest, ReturnVoid3) { ...@@ -873,7 +875,7 @@ TEST_F(AstDecoderTest, ReturnVoid3) {
EXPECT_FAILURE(v_i, kExprGetLocal, 0); EXPECT_FAILURE(v_i, kExprGetLocal, 0);
} }
TEST_F(AstDecoderTest, Unreachable1) { TEST_F(FunctionBodyDecoderTest, Unreachable1) {
EXPECT_VERIFIES(v_v, kExprUnreachable); EXPECT_VERIFIES(v_v, kExprUnreachable);
EXPECT_VERIFIES(v_v, kExprUnreachable, kExprUnreachable); EXPECT_VERIFIES(v_v, kExprUnreachable, kExprUnreachable);
EXPECT_VERIFIES(v_v, B2(WASM_UNREACHABLE, WASM_ZERO)); EXPECT_VERIFIES(v_v, B2(WASM_UNREACHABLE, WASM_ZERO));
...@@ -882,18 +884,18 @@ TEST_F(AstDecoderTest, Unreachable1) { ...@@ -882,18 +884,18 @@ TEST_F(AstDecoderTest, Unreachable1) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0), WASM_ZERO)); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0), WASM_ZERO));
} }
TEST_F(AstDecoderTest, Unreachable_binop) { TEST_F(FunctionBodyDecoderTest, Unreachable_binop) {
EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_ZERO, WASM_UNREACHABLE)); EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_ZERO, WASM_UNREACHABLE));
EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_UNREACHABLE, WASM_ZERO)); EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_UNREACHABLE, WASM_ZERO));
} }
TEST_F(AstDecoderTest, Unreachable_select) { TEST_F(FunctionBodyDecoderTest, Unreachable_select) {
EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_UNREACHABLE, WASM_ZERO, WASM_ZERO)); EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_UNREACHABLE, WASM_ZERO, WASM_ZERO));
EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_ZERO, WASM_UNREACHABLE, WASM_ZERO)); EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_ZERO, WASM_UNREACHABLE, WASM_ZERO));
EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_ZERO, WASM_ZERO, WASM_UNREACHABLE)); EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_ZERO, WASM_ZERO, WASM_UNREACHABLE));
} }
TEST_F(AstDecoderTest, If1) { TEST_F(FunctionBodyDecoderTest, If1) {
EXPECT_VERIFIES(i_i, EXPECT_VERIFIES(i_i,
WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I8(9), WASM_I8(8))); WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I8(9), WASM_I8(8)));
EXPECT_VERIFIES( EXPECT_VERIFIES(
...@@ -902,7 +904,7 @@ TEST_F(AstDecoderTest, If1) { ...@@ -902,7 +904,7 @@ TEST_F(AstDecoderTest, If1) {
i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_I8(8))); i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_I8(8)));
} }
TEST_F(AstDecoderTest, If_off_end) { TEST_F(FunctionBodyDecoderTest, If_off_end) {
static const byte kCode[] = { static const byte kCode[] = {
WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))}; WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))};
for (size_t len = 3; len < arraysize(kCode); len++) { for (size_t len = 3; len < arraysize(kCode); len++) {
...@@ -910,7 +912,7 @@ TEST_F(AstDecoderTest, If_off_end) { ...@@ -910,7 +912,7 @@ TEST_F(AstDecoderTest, If_off_end) {
} }
} }
TEST_F(AstDecoderTest, If_type1) { TEST_F(FunctionBodyDecoderTest, If_type1) {
// float|double ? 1 : 2 // float|double ? 1 : 2
static const byte kCode[] = { static const byte kCode[] = {
WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I8(0), WASM_I8(2))}; WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I8(0), WASM_I8(2))};
...@@ -919,7 +921,7 @@ TEST_F(AstDecoderTest, If_type1) { ...@@ -919,7 +921,7 @@ TEST_F(AstDecoderTest, If_type1) {
EXPECT_FAILURE_C(i_d, kCode); EXPECT_FAILURE_C(i_d, kCode);
} }
TEST_F(AstDecoderTest, If_type2) { TEST_F(FunctionBodyDecoderTest, If_type2) {
// 1 ? float|double : 2 // 1 ? float|double : 2
static const byte kCode[] = { static const byte kCode[] = {
WASM_IF_ELSE_I(WASM_I8(1), WASM_GET_LOCAL(0), WASM_I8(1))}; WASM_IF_ELSE_I(WASM_I8(1), WASM_GET_LOCAL(0), WASM_I8(1))};
...@@ -928,7 +930,7 @@ TEST_F(AstDecoderTest, If_type2) { ...@@ -928,7 +930,7 @@ TEST_F(AstDecoderTest, If_type2) {
EXPECT_FAILURE_C(i_d, kCode); EXPECT_FAILURE_C(i_d, kCode);
} }
TEST_F(AstDecoderTest, If_type3) { TEST_F(FunctionBodyDecoderTest, If_type3) {
// stmt ? 0 : 1 // stmt ? 0 : 1
static const byte kCode[] = { static const byte kCode[] = {
WASM_IF_ELSE_I(WASM_NOP, WASM_I8(0), WASM_I8(1))}; WASM_IF_ELSE_I(WASM_NOP, WASM_I8(0), WASM_I8(1))};
...@@ -937,7 +939,7 @@ TEST_F(AstDecoderTest, If_type3) { ...@@ -937,7 +939,7 @@ TEST_F(AstDecoderTest, If_type3) {
EXPECT_FAILURE_C(i_d, kCode); EXPECT_FAILURE_C(i_d, kCode);
} }
TEST_F(AstDecoderTest, If_type4) { TEST_F(FunctionBodyDecoderTest, If_type4) {
// 0 ? stmt : 1 // 0 ? stmt : 1
static const byte kCode[] = { static const byte kCode[] = {
WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_NOP, WASM_I8(1))}; WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_NOP, WASM_I8(1))};
...@@ -946,7 +948,7 @@ TEST_F(AstDecoderTest, If_type4) { ...@@ -946,7 +948,7 @@ TEST_F(AstDecoderTest, If_type4) {
EXPECT_FAILURE_C(i_d, kCode); EXPECT_FAILURE_C(i_d, kCode);
} }
TEST_F(AstDecoderTest, If_type5) { TEST_F(FunctionBodyDecoderTest, If_type5) {
// 0 ? 1 : stmt // 0 ? 1 : stmt
static const byte kCode[] = {WASM_IF_ELSE_I(WASM_ZERO, WASM_I8(1), WASM_NOP)}; static const byte kCode[] = {WASM_IF_ELSE_I(WASM_ZERO, WASM_I8(1), WASM_NOP)};
EXPECT_FAILURE_C(i_i, kCode); EXPECT_FAILURE_C(i_i, kCode);
...@@ -954,11 +956,11 @@ TEST_F(AstDecoderTest, If_type5) { ...@@ -954,11 +956,11 @@ TEST_F(AstDecoderTest, If_type5) {
EXPECT_FAILURE_C(i_d, kCode); EXPECT_FAILURE_C(i_d, kCode);
} }
TEST_F(AstDecoderTest, Int64Local_param) { TEST_F(FunctionBodyDecoderTest, Int64Local_param) {
EXPECT_VERIFIES_C(l_l, kCodeGetLocal0); EXPECT_VERIFIES_C(l_l, kCodeGetLocal0);
} }
TEST_F(AstDecoderTest, Int64Locals) { TEST_F(FunctionBodyDecoderTest, Int64Locals) {
for (byte i = 1; i < 8; i++) { for (byte i = 1; i < 8; i++) {
AddLocals(kAstI64, 1); AddLocals(kAstI64, 1);
for (byte j = 0; j < i; j++) { for (byte j = 0; j < i; j++) {
...@@ -967,7 +969,7 @@ TEST_F(AstDecoderTest, Int64Locals) { ...@@ -967,7 +969,7 @@ TEST_F(AstDecoderTest, Int64Locals) {
} }
} }
TEST_F(AstDecoderTest, Int32Binops) { TEST_F(FunctionBodyDecoderTest, Int32Binops) {
TestBinop(kExprI32Add, sigs.i_ii()); TestBinop(kExprI32Add, sigs.i_ii());
TestBinop(kExprI32Sub, sigs.i_ii()); TestBinop(kExprI32Sub, sigs.i_ii());
TestBinop(kExprI32Mul, sigs.i_ii()); TestBinop(kExprI32Mul, sigs.i_ii());
...@@ -988,7 +990,7 @@ TEST_F(AstDecoderTest, Int32Binops) { ...@@ -988,7 +990,7 @@ TEST_F(AstDecoderTest, Int32Binops) {
TestBinop(kExprI32LeU, sigs.i_ii()); TestBinop(kExprI32LeU, sigs.i_ii());
} }
TEST_F(AstDecoderTest, DoubleBinops) { TEST_F(FunctionBodyDecoderTest, DoubleBinops) {
TestBinop(kExprF64Add, sigs.d_dd()); TestBinop(kExprF64Add, sigs.d_dd());
TestBinop(kExprF64Sub, sigs.d_dd()); TestBinop(kExprF64Sub, sigs.d_dd());
TestBinop(kExprF64Mul, sigs.d_dd()); TestBinop(kExprF64Mul, sigs.d_dd());
...@@ -999,7 +1001,7 @@ TEST_F(AstDecoderTest, DoubleBinops) { ...@@ -999,7 +1001,7 @@ TEST_F(AstDecoderTest, DoubleBinops) {
TestBinop(kExprF64Le, sigs.i_dd()); TestBinop(kExprF64Le, sigs.i_dd());
} }
TEST_F(AstDecoderTest, FloatBinops) { TEST_F(FunctionBodyDecoderTest, FloatBinops) {
TestBinop(kExprF32Add, sigs.f_ff()); TestBinop(kExprF32Add, sigs.f_ff());
TestBinop(kExprF32Sub, sigs.f_ff()); TestBinop(kExprF32Sub, sigs.f_ff());
TestBinop(kExprF32Mul, sigs.f_ff()); TestBinop(kExprF32Mul, sigs.f_ff());
...@@ -1010,7 +1012,7 @@ TEST_F(AstDecoderTest, FloatBinops) { ...@@ -1010,7 +1012,7 @@ TEST_F(AstDecoderTest, FloatBinops) {
TestBinop(kExprF32Le, sigs.i_ff()); TestBinop(kExprF32Le, sigs.i_ff());
} }
TEST_F(AstDecoderTest, TypeConversions) { TEST_F(FunctionBodyDecoderTest, TypeConversions) {
TestUnop(kExprI32SConvertF32, kAstI32, kAstF32); TestUnop(kExprI32SConvertF32, kAstI32, kAstF32);
TestUnop(kExprI32SConvertF64, kAstI32, kAstF64); TestUnop(kExprI32SConvertF64, kAstI32, kAstF64);
TestUnop(kExprI32UConvertF32, kAstI32, kAstF32); TestUnop(kExprI32UConvertF32, kAstI32, kAstF32);
...@@ -1023,7 +1025,7 @@ TEST_F(AstDecoderTest, TypeConversions) { ...@@ -1023,7 +1025,7 @@ TEST_F(AstDecoderTest, TypeConversions) {
TestUnop(kExprF32ConvertF64, kAstF32, kAstF64); TestUnop(kExprF32ConvertF64, kAstF32, kAstF64);
} }
TEST_F(AstDecoderTest, MacrosStmt) { TEST_F(FunctionBodyDecoderTest, MacrosStmt) {
EXPECT_VERIFIES(v_i, WASM_SET_LOCAL(0, WASM_I32V_3(87348))); EXPECT_VERIFIES(v_i, WASM_SET_LOCAL(0, WASM_I32V_3(87348)));
EXPECT_VERIFIES( EXPECT_VERIFIES(
v_i, WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40))); v_i, WASM_STORE_MEM(MachineType::Int32(), WASM_I8(24), WASM_I8(40)));
...@@ -1035,18 +1037,18 @@ TEST_F(AstDecoderTest, MacrosStmt) { ...@@ -1035,18 +1037,18 @@ TEST_F(AstDecoderTest, MacrosStmt) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0)));
} }
TEST_F(AstDecoderTest, MacrosContinue) { TEST_F(FunctionBodyDecoderTest, MacrosContinue) {
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_CONTINUE(0))); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_CONTINUE(0)));
} }
TEST_F(AstDecoderTest, MacrosVariadic) { TEST_F(FunctionBodyDecoderTest, MacrosVariadic) {
EXPECT_VERIFIES(v_v, B2(WASM_NOP, WASM_NOP)); EXPECT_VERIFIES(v_v, B2(WASM_NOP, WASM_NOP));
EXPECT_VERIFIES(v_v, B3(WASM_NOP, WASM_NOP, WASM_NOP)); EXPECT_VERIFIES(v_v, B3(WASM_NOP, WASM_NOP, WASM_NOP));
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_NOP)); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_NOP));
EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_NOP, WASM_NOP)); EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_NOP, WASM_NOP, WASM_NOP));
} }
TEST_F(AstDecoderTest, MacrosNestedBlocks) { TEST_F(FunctionBodyDecoderTest, MacrosNestedBlocks) {
EXPECT_VERIFIES(v_v, B2(WASM_NOP, B2(WASM_NOP, WASM_NOP))); EXPECT_VERIFIES(v_v, B2(WASM_NOP, B2(WASM_NOP, WASM_NOP)));
EXPECT_VERIFIES(v_v, B3(WASM_NOP, // -- EXPECT_VERIFIES(v_v, B3(WASM_NOP, // --
B2(WASM_NOP, WASM_NOP), // -- B2(WASM_NOP, WASM_NOP), // --
...@@ -1054,7 +1056,7 @@ TEST_F(AstDecoderTest, MacrosNestedBlocks) { ...@@ -1054,7 +1056,7 @@ TEST_F(AstDecoderTest, MacrosNestedBlocks) {
EXPECT_VERIFIES(v_v, B1(B1(B2(WASM_NOP, WASM_NOP)))); EXPECT_VERIFIES(v_v, B1(B1(B2(WASM_NOP, WASM_NOP))));
} }
TEST_F(AstDecoderTest, MultipleReturn) { TEST_F(FunctionBodyDecoderTest, MultipleReturn) {
static LocalType kIntTypes5[] = {kAstI32, kAstI32, kAstI32, kAstI32, kAstI32}; static LocalType kIntTypes5[] = {kAstI32, kAstI32, kAstI32, kAstI32, kAstI32};
FunctionSig sig_ii_v(2, 0, kIntTypes5); FunctionSig sig_ii_v(2, 0, kIntTypes5);
EXPECT_VERIFIES_S(&sig_ii_v, WASM_RETURNN(2, WASM_ZERO, WASM_ONE)); EXPECT_VERIFIES_S(&sig_ii_v, WASM_RETURNN(2, WASM_ZERO, WASM_ONE));
...@@ -1066,7 +1068,7 @@ TEST_F(AstDecoderTest, MultipleReturn) { ...@@ -1066,7 +1068,7 @@ TEST_F(AstDecoderTest, MultipleReturn) {
EXPECT_FAILURE_S(&sig_iii_v, WASM_RETURNN(2, WASM_ZERO, WASM_ONE)); EXPECT_FAILURE_S(&sig_iii_v, WASM_RETURNN(2, WASM_ZERO, WASM_ONE));
} }
TEST_F(AstDecoderTest, MultipleReturn_fallthru) { TEST_F(FunctionBodyDecoderTest, MultipleReturn_fallthru) {
static LocalType kIntTypes5[] = {kAstI32, kAstI32, kAstI32, kAstI32, kAstI32}; static LocalType kIntTypes5[] = {kAstI32, kAstI32, kAstI32, kAstI32, kAstI32};
FunctionSig sig_ii_v(2, 0, kIntTypes5); FunctionSig sig_ii_v(2, 0, kIntTypes5);
...@@ -1078,7 +1080,7 @@ TEST_F(AstDecoderTest, MultipleReturn_fallthru) { ...@@ -1078,7 +1080,7 @@ TEST_F(AstDecoderTest, MultipleReturn_fallthru) {
EXPECT_FAILURE_S(&sig_iii_v, WASM_ZERO, WASM_ONE); EXPECT_FAILURE_S(&sig_iii_v, WASM_ZERO, WASM_ONE);
} }
TEST_F(AstDecoderTest, MacrosInt32) { TEST_F(FunctionBodyDecoderTest, MacrosInt32) {
EXPECT_VERIFIES(i_i, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_I8(12))); EXPECT_VERIFIES(i_i, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_I8(12)));
EXPECT_VERIFIES(i_i, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(13))); EXPECT_VERIFIES(i_i, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(13)));
EXPECT_VERIFIES(i_i, WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_I8(14))); EXPECT_VERIFIES(i_i, WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_I8(14)));
...@@ -1108,7 +1110,7 @@ TEST_F(AstDecoderTest, MacrosInt32) { ...@@ -1108,7 +1110,7 @@ TEST_F(AstDecoderTest, MacrosInt32) {
EXPECT_VERIFIES(i_i, WASM_I32_GEU(WASM_GET_LOCAL(0), WASM_I8(29))); EXPECT_VERIFIES(i_i, WASM_I32_GEU(WASM_GET_LOCAL(0), WASM_I8(29)));
} }
TEST_F(AstDecoderTest, MacrosInt64) { TEST_F(FunctionBodyDecoderTest, MacrosInt64) {
EXPECT_VERIFIES(l_ll, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64V_1(12))); EXPECT_VERIFIES(l_ll, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_I64V_1(12)));
EXPECT_VERIFIES(l_ll, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64V_1(13))); EXPECT_VERIFIES(l_ll, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_I64V_1(13)));
EXPECT_VERIFIES(l_ll, WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64V_1(14))); EXPECT_VERIFIES(l_ll, WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_I64V_1(14)));
...@@ -1140,7 +1142,7 @@ TEST_F(AstDecoderTest, MacrosInt64) { ...@@ -1140,7 +1142,7 @@ TEST_F(AstDecoderTest, MacrosInt64) {
EXPECT_VERIFIES(i_ll, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64V_1(25))); EXPECT_VERIFIES(i_ll, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_I64V_1(25)));
} }
TEST_F(AstDecoderTest, AllSimpleExpressions) { TEST_F(FunctionBodyDecoderTest, AllSimpleExpressions) {
// Test all simple expressions which are described by a signature. // Test all simple expressions which are described by a signature.
#define DECODE_TEST(name, opcode, sig) \ #define DECODE_TEST(name, opcode, sig) \
{ \ { \
...@@ -1157,13 +1159,13 @@ TEST_F(AstDecoderTest, AllSimpleExpressions) { ...@@ -1157,13 +1159,13 @@ TEST_F(AstDecoderTest, AllSimpleExpressions) {
#undef DECODE_TEST #undef DECODE_TEST
} }
TEST_F(AstDecoderTest, MemorySize) { TEST_F(FunctionBodyDecoderTest, MemorySize) {
byte code[] = {kExprMemorySize, 0}; byte code[] = {kExprMemorySize, 0};
EXPECT_VERIFIES_C(i_i, code); EXPECT_VERIFIES_C(i_i, code);
EXPECT_FAILURE_C(f_ff, code); EXPECT_FAILURE_C(f_ff, code);
} }
TEST_F(AstDecoderTest, LoadMemOffset) { TEST_F(FunctionBodyDecoderTest, LoadMemOffset) {
for (int offset = 0; offset < 128; offset += 7) { for (int offset = 0; offset < 128; offset += 7) {
byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT, byte code[] = {kExprI8Const, 0, kExprI32LoadMem, ZERO_ALIGNMENT,
static_cast<byte>(offset)}; static_cast<byte>(offset)};
...@@ -1171,7 +1173,7 @@ TEST_F(AstDecoderTest, LoadMemOffset) { ...@@ -1171,7 +1173,7 @@ TEST_F(AstDecoderTest, LoadMemOffset) {
} }
} }
TEST_F(AstDecoderTest, LoadMemAlignment) { TEST_F(FunctionBodyDecoderTest, LoadMemAlignment) {
struct { struct {
WasmOpcode instruction; WasmOpcode instruction;
uint32_t maximum_aligment; uint32_t maximum_aligment;
...@@ -1205,7 +1207,7 @@ TEST_F(AstDecoderTest, LoadMemAlignment) { ...@@ -1205,7 +1207,7 @@ TEST_F(AstDecoderTest, LoadMemAlignment) {
} }
} }
TEST_F(AstDecoderTest, StoreMemOffset) { TEST_F(FunctionBodyDecoderTest, StoreMemOffset) {
for (int offset = 0; offset < 128; offset += 7) { for (int offset = 0; offset < 128; offset += 7) {
byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset, byte code[] = {WASM_STORE_MEM_OFFSET(MachineType::Int32(), offset,
WASM_ZERO, WASM_ZERO)}; WASM_ZERO, WASM_ZERO)};
...@@ -1213,7 +1215,7 @@ TEST_F(AstDecoderTest, StoreMemOffset) { ...@@ -1213,7 +1215,7 @@ TEST_F(AstDecoderTest, StoreMemOffset) {
} }
} }
TEST_F(AstDecoderTest, StoreMemOffset_void) { TEST_F(FunctionBodyDecoderTest, StoreMemOffset_void) {
EXPECT_FAILURE(i_i, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 0, WASM_ZERO, EXPECT_FAILURE(i_i, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 0, WASM_ZERO,
WASM_ZERO)); WASM_ZERO));
} }
...@@ -1228,7 +1230,7 @@ TEST_F(AstDecoderTest, StoreMemOffset_void) { ...@@ -1228,7 +1230,7 @@ TEST_F(AstDecoderTest, StoreMemOffset_void) {
#define VARINT3(x) BYTE0(x) | 0x80, BYTE1(x) | 0x80, BYTE2(x) #define VARINT3(x) BYTE0(x) | 0x80, BYTE1(x) | 0x80, BYTE2(x)
#define VARINT4(x) BYTE0(x) | 0x80, BYTE1(x) | 0x80, BYTE2(x) | 0x80, BYTE3(x) #define VARINT4(x) BYTE0(x) | 0x80, BYTE1(x) | 0x80, BYTE2(x) | 0x80, BYTE3(x)
TEST_F(AstDecoderTest, LoadMemOffset_varint) { TEST_F(FunctionBodyDecoderTest, LoadMemOffset_varint) {
EXPECT_VERIFIES(i_i, WASM_ZERO, kExprI32LoadMem, ZERO_ALIGNMENT, EXPECT_VERIFIES(i_i, WASM_ZERO, kExprI32LoadMem, ZERO_ALIGNMENT,
VARINT1(0x45)); VARINT1(0x45));
EXPECT_VERIFIES(i_i, WASM_ZERO, kExprI32LoadMem, ZERO_ALIGNMENT, EXPECT_VERIFIES(i_i, WASM_ZERO, kExprI32LoadMem, ZERO_ALIGNMENT,
...@@ -1239,7 +1241,7 @@ TEST_F(AstDecoderTest, LoadMemOffset_varint) { ...@@ -1239,7 +1241,7 @@ TEST_F(AstDecoderTest, LoadMemOffset_varint) {
VARINT4(0x36666667)); VARINT4(0x36666667));
} }
TEST_F(AstDecoderTest, StoreMemOffset_varint) { TEST_F(FunctionBodyDecoderTest, StoreMemOffset_varint) {
EXPECT_VERIFIES(v_i, WASM_ZERO, WASM_ZERO, kExprI32StoreMem, ZERO_ALIGNMENT, EXPECT_VERIFIES(v_i, WASM_ZERO, WASM_ZERO, kExprI32StoreMem, ZERO_ALIGNMENT,
VARINT1(0x33)); VARINT1(0x33));
EXPECT_VERIFIES(v_i, WASM_ZERO, WASM_ZERO, kExprI32StoreMem, ZERO_ALIGNMENT, EXPECT_VERIFIES(v_i, WASM_ZERO, WASM_ZERO, kExprI32StoreMem, ZERO_ALIGNMENT,
...@@ -1250,7 +1252,7 @@ TEST_F(AstDecoderTest, StoreMemOffset_varint) { ...@@ -1250,7 +1252,7 @@ TEST_F(AstDecoderTest, StoreMemOffset_varint) {
VARINT4(0x44444444)); VARINT4(0x44444444));
} }
TEST_F(AstDecoderTest, AllLoadMemCombinations) { TEST_F(FunctionBodyDecoderTest, AllLoadMemCombinations) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType local_type = kLocalTypes[i]; LocalType local_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(machineTypes); j++) { for (size_t j = 0; j < arraysize(machineTypes); j++) {
...@@ -1266,7 +1268,7 @@ TEST_F(AstDecoderTest, AllLoadMemCombinations) { ...@@ -1266,7 +1268,7 @@ TEST_F(AstDecoderTest, AllLoadMemCombinations) {
} }
} }
TEST_F(AstDecoderTest, AllStoreMemCombinations) { TEST_F(FunctionBodyDecoderTest, AllStoreMemCombinations) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType local_type = kLocalTypes[i]; LocalType local_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(machineTypes); j++) { for (size_t j = 0; j < arraysize(machineTypes); j++) {
...@@ -1330,7 +1332,7 @@ class TestModuleEnv : public ModuleEnv { ...@@ -1330,7 +1332,7 @@ class TestModuleEnv : public ModuleEnv {
}; };
} // namespace } // namespace
TEST_F(AstDecoderTest, SimpleCalls) { TEST_F(FunctionBodyDecoderTest, SimpleCalls) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1344,7 +1346,7 @@ TEST_F(AstDecoderTest, SimpleCalls) { ...@@ -1344,7 +1346,7 @@ TEST_F(AstDecoderTest, SimpleCalls) {
EXPECT_VERIFIES_S(sig, WASM_CALL_FUNCTION(2, WASM_I8(37), WASM_I8(77))); EXPECT_VERIFIES_S(sig, WASM_CALL_FUNCTION(2, WASM_I8(37), WASM_I8(77)));
} }
TEST_F(AstDecoderTest, CallsWithTooFewArguments) { TEST_F(FunctionBodyDecoderTest, CallsWithTooFewArguments) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1358,7 +1360,7 @@ TEST_F(AstDecoderTest, CallsWithTooFewArguments) { ...@@ -1358,7 +1360,7 @@ TEST_F(AstDecoderTest, CallsWithTooFewArguments) {
EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(2, WASM_GET_LOCAL(0))); EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(2, WASM_GET_LOCAL(0)));
} }
TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) { TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs2) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1370,7 +1372,7 @@ TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) { ...@@ -1370,7 +1372,7 @@ TEST_F(AstDecoderTest, CallsWithMismatchedSigs2) {
EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(0, WASM_F64(17.1))); EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(0, WASM_F64(17.1)));
} }
TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) { TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs3) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1388,7 +1390,7 @@ TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) { ...@@ -1388,7 +1390,7 @@ TEST_F(AstDecoderTest, CallsWithMismatchedSigs3) {
EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(1, WASM_F32(17.6))); EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(1, WASM_F32(17.6)));
} }
TEST_F(AstDecoderTest, MultiReturn) { TEST_F(FunctionBodyDecoderTest, MultiReturn) {
FLAG_wasm_mv_prototype = true; FLAG_wasm_mv_prototype = true;
LocalType storage[] = {kAstI32, kAstI32}; LocalType storage[] = {kAstI32, kAstI32};
FunctionSig sig_ii_v(2, 0, storage); FunctionSig sig_ii_v(2, 0, storage);
...@@ -1404,7 +1406,7 @@ TEST_F(AstDecoderTest, MultiReturn) { ...@@ -1404,7 +1406,7 @@ TEST_F(AstDecoderTest, MultiReturn) {
EXPECT_VERIFIES(v_v, WASM_CALL_FUNCTION0(1), kExprCallFunction, 0); EXPECT_VERIFIES(v_v, WASM_CALL_FUNCTION0(1), kExprCallFunction, 0);
} }
TEST_F(AstDecoderTest, MultiReturnType) { TEST_F(FunctionBodyDecoderTest, MultiReturnType) {
FLAG_wasm_mv_prototype = true; FLAG_wasm_mv_prototype = true;
for (size_t a = 0; a < arraysize(kLocalTypes); a++) { for (size_t a = 0; a < arraysize(kLocalTypes); a++) {
for (size_t b = 0; b < arraysize(kLocalTypes); b++) { for (size_t b = 0; b < arraysize(kLocalTypes); b++) {
...@@ -1432,7 +1434,7 @@ TEST_F(AstDecoderTest, MultiReturnType) { ...@@ -1432,7 +1434,7 @@ TEST_F(AstDecoderTest, MultiReturnType) {
} }
} }
TEST_F(AstDecoderTest, SimpleIndirectCalls) { TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module_env.InitializeFunctionTable(); module_env.InitializeFunctionTable();
...@@ -1448,7 +1450,7 @@ TEST_F(AstDecoderTest, SimpleIndirectCalls) { ...@@ -1448,7 +1450,7 @@ TEST_F(AstDecoderTest, SimpleIndirectCalls) {
sig, WASM_CALL_INDIRECT2(f2, WASM_ZERO, WASM_I8(32), WASM_I8(72))); sig, WASM_CALL_INDIRECT2(f2, WASM_ZERO, WASM_I8(32), WASM_I8(72)));
} }
TEST_F(AstDecoderTest, IndirectCallsOutOfBounds) { TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module_env.InitializeFunctionTable(); module_env.InitializeFunctionTable();
...@@ -1465,7 +1467,7 @@ TEST_F(AstDecoderTest, IndirectCallsOutOfBounds) { ...@@ -1465,7 +1467,7 @@ TEST_F(AstDecoderTest, IndirectCallsOutOfBounds) {
EXPECT_FAILURE_S(sig, WASM_CALL_INDIRECT1(2, WASM_ZERO, WASM_I8(27))); EXPECT_FAILURE_S(sig, WASM_CALL_INDIRECT1(2, WASM_ZERO, WASM_I8(27)));
} }
TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { TEST_F(FunctionBodyDecoderTest, IndirectCallsWithMismatchedSigs3) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module_env.InitializeFunctionTable(); module_env.InitializeFunctionTable();
...@@ -1488,7 +1490,7 @@ TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) { ...@@ -1488,7 +1490,7 @@ TEST_F(AstDecoderTest, IndirectCallsWithMismatchedSigs3) {
EXPECT_FAILURE_S(sig, WASM_CALL_INDIRECT1(f1, WASM_ZERO, WASM_F32(17.6))); EXPECT_FAILURE_S(sig, WASM_CALL_INDIRECT1(f1, WASM_ZERO, WASM_F32(17.6)));
} }
TEST_F(AstDecoderTest, IndirectCallsWithoutTableCrash) { TEST_F(FunctionBodyDecoderTest, IndirectCallsWithoutTableCrash) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1503,7 +1505,7 @@ TEST_F(AstDecoderTest, IndirectCallsWithoutTableCrash) { ...@@ -1503,7 +1505,7 @@ TEST_F(AstDecoderTest, IndirectCallsWithoutTableCrash) {
sig, WASM_CALL_INDIRECT2(f2, WASM_ZERO, WASM_I8(32), WASM_I8(72))); sig, WASM_CALL_INDIRECT2(f2, WASM_ZERO, WASM_I8(32), WASM_I8(72)));
} }
TEST_F(AstDecoderTest, SimpleImportCalls) { TEST_F(FunctionBodyDecoderTest, SimpleImportCalls) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1517,7 +1519,7 @@ TEST_F(AstDecoderTest, SimpleImportCalls) { ...@@ -1517,7 +1519,7 @@ TEST_F(AstDecoderTest, SimpleImportCalls) {
EXPECT_VERIFIES_S(sig, WASM_CALL_FUNCTION(f2, WASM_I8(32), WASM_I8(72))); EXPECT_VERIFIES_S(sig, WASM_CALL_FUNCTION(f2, WASM_I8(32), WASM_I8(72)));
} }
TEST_F(AstDecoderTest, ImportCallsWithMismatchedSigs3) { TEST_F(FunctionBodyDecoderTest, ImportCallsWithMismatchedSigs3) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1537,7 +1539,7 @@ TEST_F(AstDecoderTest, ImportCallsWithMismatchedSigs3) { ...@@ -1537,7 +1539,7 @@ TEST_F(AstDecoderTest, ImportCallsWithMismatchedSigs3) {
EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(f1, WASM_F32(17.6))); EXPECT_FAILURE_S(sig, WASM_CALL_FUNCTION(f1, WASM_F32(17.6)));
} }
TEST_F(AstDecoderTest, Int32Globals) { TEST_F(FunctionBodyDecoderTest, Int32Globals) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1549,7 +1551,7 @@ TEST_F(AstDecoderTest, Int32Globals) { ...@@ -1549,7 +1551,7 @@ TEST_F(AstDecoderTest, Int32Globals) {
EXPECT_VERIFIES_S(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)), WASM_ZERO); EXPECT_VERIFIES_S(sig, WASM_SET_GLOBAL(0, WASM_GET_LOCAL(0)), WASM_ZERO);
} }
TEST_F(AstDecoderTest, ImmutableGlobal) { TEST_F(FunctionBodyDecoderTest, ImmutableGlobal) {
FunctionSig* sig = sigs.v_v(); FunctionSig* sig = sigs.v_v();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1561,7 +1563,7 @@ TEST_F(AstDecoderTest, ImmutableGlobal) { ...@@ -1561,7 +1563,7 @@ TEST_F(AstDecoderTest, ImmutableGlobal) {
EXPECT_FAILURE_S(sig, WASM_SET_GLOBAL(g1, WASM_ZERO)); EXPECT_FAILURE_S(sig, WASM_SET_GLOBAL(g1, WASM_ZERO));
} }
TEST_F(AstDecoderTest, Int32Globals_fail) { TEST_F(FunctionBodyDecoderTest, Int32Globals_fail) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1582,7 +1584,7 @@ TEST_F(AstDecoderTest, Int32Globals_fail) { ...@@ -1582,7 +1584,7 @@ TEST_F(AstDecoderTest, Int32Globals_fail) {
EXPECT_FAILURE_S(sig, WASM_SET_GLOBAL(3, WASM_GET_LOCAL(0)), WASM_ZERO); EXPECT_FAILURE_S(sig, WASM_SET_GLOBAL(3, WASM_GET_LOCAL(0)), WASM_ZERO);
} }
TEST_F(AstDecoderTest, Int64Globals) { TEST_F(FunctionBodyDecoderTest, Int64Globals) {
FunctionSig* sig = sigs.l_l(); FunctionSig* sig = sigs.l_l();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1599,7 +1601,7 @@ TEST_F(AstDecoderTest, Int64Globals) { ...@@ -1599,7 +1601,7 @@ TEST_F(AstDecoderTest, Int64Globals) {
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
} }
TEST_F(AstDecoderTest, Float32Globals) { TEST_F(FunctionBodyDecoderTest, Float32Globals) {
FunctionSig* sig = sigs.f_ff(); FunctionSig* sig = sigs.f_ff();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1611,7 +1613,7 @@ TEST_F(AstDecoderTest, Float32Globals) { ...@@ -1611,7 +1613,7 @@ TEST_F(AstDecoderTest, Float32Globals) {
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
} }
TEST_F(AstDecoderTest, Float64Globals) { TEST_F(FunctionBodyDecoderTest, Float64Globals) {
FunctionSig* sig = sigs.d_dd(); FunctionSig* sig = sigs.d_dd();
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1623,7 +1625,7 @@ TEST_F(AstDecoderTest, Float64Globals) { ...@@ -1623,7 +1625,7 @@ TEST_F(AstDecoderTest, Float64Globals) {
WASM_GET_LOCAL(0)); WASM_GET_LOCAL(0));
} }
TEST_F(AstDecoderTest, AllGetGlobalCombinations) { TEST_F(FunctionBodyDecoderTest, AllGetGlobalCombinations) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType local_type = kLocalTypes[i]; LocalType local_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
...@@ -1641,7 +1643,7 @@ TEST_F(AstDecoderTest, AllGetGlobalCombinations) { ...@@ -1641,7 +1643,7 @@ TEST_F(AstDecoderTest, AllGetGlobalCombinations) {
} }
} }
TEST_F(AstDecoderTest, AllSetGlobalCombinations) { TEST_F(FunctionBodyDecoderTest, AllSetGlobalCombinations) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType local_type = kLocalTypes[i]; LocalType local_type = kLocalTypes[i];
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
...@@ -1659,7 +1661,7 @@ TEST_F(AstDecoderTest, AllSetGlobalCombinations) { ...@@ -1659,7 +1661,7 @@ TEST_F(AstDecoderTest, AllSetGlobalCombinations) {
} }
} }
TEST_F(AstDecoderTest, WasmGrowMemory) { TEST_F(FunctionBodyDecoderTest, WasmGrowMemory) {
TestModuleEnv module_env; TestModuleEnv module_env;
module = &module_env; module = &module_env;
...@@ -1668,7 +1670,7 @@ TEST_F(AstDecoderTest, WasmGrowMemory) { ...@@ -1668,7 +1670,7 @@ TEST_F(AstDecoderTest, WasmGrowMemory) {
EXPECT_FAILURE_C(i_d, code); EXPECT_FAILURE_C(i_d, code);
} }
TEST_F(AstDecoderTest, AsmJsGrowMemory) { TEST_F(FunctionBodyDecoderTest, AsmJsGrowMemory) {
TestModuleEnv module_env(kAsmJsOrigin); TestModuleEnv module_env(kAsmJsOrigin);
module = &module_env; module = &module_env;
...@@ -1676,7 +1678,7 @@ TEST_F(AstDecoderTest, AsmJsGrowMemory) { ...@@ -1676,7 +1678,7 @@ TEST_F(AstDecoderTest, AsmJsGrowMemory) {
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, AsmJsBinOpsCheckOrigin) { TEST_F(FunctionBodyDecoderTest, AsmJsBinOpsCheckOrigin) {
LocalType float32int32float32[] = {kAstF32, kAstI32, kAstF32}; LocalType float32int32float32[] = {kAstF32, kAstI32, kAstF32};
FunctionSig sig_f_if(1, 2, float32int32float32); FunctionSig sig_f_if(1, 2, float32int32float32);
LocalType float64int32float64[] = {kAstF64, kAstI32, kAstF64}; LocalType float64int32float64[] = {kAstF64, kAstI32, kAstF64};
...@@ -1718,7 +1720,7 @@ TEST_F(AstDecoderTest, AsmJsBinOpsCheckOrigin) { ...@@ -1718,7 +1720,7 @@ TEST_F(AstDecoderTest, AsmJsBinOpsCheckOrigin) {
} }
} }
TEST_F(AstDecoderTest, AsmJsUnOpsCheckOrigin) { TEST_F(FunctionBodyDecoderTest, AsmJsUnOpsCheckOrigin) {
LocalType float32int32[] = {kAstF32, kAstI32}; LocalType float32int32[] = {kAstF32, kAstI32};
FunctionSig sig_f_i(1, 1, float32int32); FunctionSig sig_f_i(1, 1, float32int32);
LocalType float64int32[] = {kAstF64, kAstI32}; LocalType float64int32[] = {kAstF64, kAstI32};
...@@ -1763,14 +1765,14 @@ TEST_F(AstDecoderTest, AsmJsUnOpsCheckOrigin) { ...@@ -1763,14 +1765,14 @@ TEST_F(AstDecoderTest, AsmJsUnOpsCheckOrigin) {
} }
} }
TEST_F(AstDecoderTest, BreakEnd) { TEST_F(FunctionBodyDecoderTest, BreakEnd) {
EXPECT_VERIFIES( EXPECT_VERIFIES(
i_i, WASM_BLOCK_I(WASM_I32_ADD(WASM_BRV(0, WASM_ZERO), WASM_ZERO))); i_i, WASM_BLOCK_I(WASM_I32_ADD(WASM_BRV(0, WASM_ZERO), WASM_ZERO)));
EXPECT_VERIFIES( EXPECT_VERIFIES(
i_i, WASM_BLOCK_I(WASM_I32_ADD(WASM_ZERO, WASM_BRV(0, WASM_ZERO)))); i_i, WASM_BLOCK_I(WASM_I32_ADD(WASM_ZERO, WASM_BRV(0, WASM_ZERO))));
} }
TEST_F(AstDecoderTest, BreakIfBinop) { TEST_F(FunctionBodyDecoderTest, BreakIfBinop) {
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_I32_ADD( EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_I32_ADD(
WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO), WASM_ZERO))); WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO), WASM_ZERO)));
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_I32_ADD( EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_I32_ADD(
...@@ -1780,7 +1782,7 @@ TEST_F(AstDecoderTest, BreakIfBinop) { ...@@ -1780,7 +1782,7 @@ TEST_F(AstDecoderTest, BreakIfBinop) {
WASM_BLOCK_F(WASM_F32_ABS(WASM_BRV_IF(0, WASM_F32(0.0f), WASM_ZERO)))); WASM_BLOCK_F(WASM_F32_ABS(WASM_BRV_IF(0, WASM_F32(0.0f), WASM_ZERO))));
} }
TEST_F(AstDecoderTest, BreakIfBinop_fail) { TEST_F(FunctionBodyDecoderTest, BreakIfBinop_fail) {
EXPECT_FAILURE_S( EXPECT_FAILURE_S(
sigs.f_ff(), sigs.f_ff(),
WASM_BLOCK_F(WASM_F32_ABS(WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO)))); WASM_BLOCK_F(WASM_F32_ABS(WASM_BRV_IF(0, WASM_ZERO, WASM_ZERO))));
...@@ -1789,7 +1791,7 @@ TEST_F(AstDecoderTest, BreakIfBinop_fail) { ...@@ -1789,7 +1791,7 @@ TEST_F(AstDecoderTest, BreakIfBinop_fail) {
WASM_BLOCK_I(WASM_F32_ABS(WASM_BRV_IF(0, WASM_F32(0.0f), WASM_ZERO)))); WASM_BLOCK_I(WASM_F32_ABS(WASM_BRV_IF(0, WASM_F32(0.0f), WASM_ZERO))));
} }
TEST_F(AstDecoderTest, BreakNesting1) { TEST_F(FunctionBodyDecoderTest, BreakNesting1) {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
// (block[2] (loop[2] (if (get p) break[N]) (set p 1)) p) // (block[2] (loop[2] (if (get p) break[N]) (set p 1)) p)
byte code[] = {WASM_BLOCK_I( byte code[] = {WASM_BLOCK_I(
...@@ -1804,7 +1806,7 @@ TEST_F(AstDecoderTest, BreakNesting1) { ...@@ -1804,7 +1806,7 @@ TEST_F(AstDecoderTest, BreakNesting1) {
} }
} }
TEST_F(AstDecoderTest, BreakNesting2) { TEST_F(FunctionBodyDecoderTest, BreakNesting2) {
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
byte code[] = {B1(WASM_LOOP(WASM_IF(WASM_ZERO, WASM_BR(i)), WASM_NOP))}; byte code[] = {B1(WASM_LOOP(WASM_IF(WASM_ZERO, WASM_BR(i)), WASM_NOP))};
if (i <= 3) { if (i <= 3) {
...@@ -1815,7 +1817,7 @@ TEST_F(AstDecoderTest, BreakNesting2) { ...@@ -1815,7 +1817,7 @@ TEST_F(AstDecoderTest, BreakNesting2) {
} }
} }
TEST_F(AstDecoderTest, BreakNesting3) { TEST_F(FunctionBodyDecoderTest, BreakNesting3) {
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
// (block[1] (loop[1] (block[1] (if 0 break[N]) // (block[1] (loop[1] (block[1] (if 0 break[N])
byte code[] = { byte code[] = {
...@@ -1828,7 +1830,7 @@ TEST_F(AstDecoderTest, BreakNesting3) { ...@@ -1828,7 +1830,7 @@ TEST_F(AstDecoderTest, BreakNesting3) {
} }
} }
TEST_F(AstDecoderTest, BreaksWithMultipleTypes) { TEST_F(FunctionBodyDecoderTest, BreaksWithMultipleTypes) {
EXPECT_FAILURE(i_i, B2(WASM_BRV_IF_ZERO(0, WASM_I8(7)), WASM_F32(7.7))); EXPECT_FAILURE(i_i, B2(WASM_BRV_IF_ZERO(0, WASM_I8(7)), WASM_F32(7.7)));
EXPECT_FAILURE(i_i, B2(WASM_BRV_IF_ZERO(0, WASM_I8(7)), EXPECT_FAILURE(i_i, B2(WASM_BRV_IF_ZERO(0, WASM_I8(7)),
...@@ -1841,7 +1843,7 @@ TEST_F(AstDecoderTest, BreaksWithMultipleTypes) { ...@@ -1841,7 +1843,7 @@ TEST_F(AstDecoderTest, BreaksWithMultipleTypes) {
WASM_BRV_IF_ZERO(0, WASM_I8(11)))); WASM_BRV_IF_ZERO(0, WASM_I8(11))));
} }
TEST_F(AstDecoderTest, BreakNesting_6_levels) { TEST_F(FunctionBodyDecoderTest, BreakNesting_6_levels) {
for (int mask = 0; mask < 64; mask++) { for (int mask = 0; mask < 64; mask++) {
for (int i = 0; i < 14; i++) { for (int i = 0; i < 14; i++) {
byte code[] = {WASM_BLOCK(WASM_BLOCK( byte code[] = {WASM_BLOCK(WASM_BLOCK(
...@@ -1867,7 +1869,7 @@ TEST_F(AstDecoderTest, BreakNesting_6_levels) { ...@@ -1867,7 +1869,7 @@ TEST_F(AstDecoderTest, BreakNesting_6_levels) {
} }
} }
TEST_F(AstDecoderTest, Break_TypeCheck) { TEST_F(FunctionBodyDecoderTest, Break_TypeCheck) {
FunctionSig* sigarray[] = {sigs.i_i(), sigs.l_l(), sigs.f_ff(), sigs.d_dd()}; FunctionSig* sigarray[] = {sigs.i_i(), sigs.l_l(), sigs.f_ff(), sigs.d_dd()};
for (size_t i = 0; i < arraysize(sigarray); i++) { for (size_t i = 0; i < arraysize(sigarray); i++) {
FunctionSig* sig = sigarray[i]; FunctionSig* sig = sigarray[i];
...@@ -1888,7 +1890,7 @@ TEST_F(AstDecoderTest, Break_TypeCheck) { ...@@ -1888,7 +1890,7 @@ TEST_F(AstDecoderTest, Break_TypeCheck) {
WASM_F64(1.2))); WASM_F64(1.2)));
} }
TEST_F(AstDecoderTest, Break_TypeCheckAll1) { TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll1) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]}; LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
...@@ -1906,7 +1908,7 @@ TEST_F(AstDecoderTest, Break_TypeCheckAll1) { ...@@ -1906,7 +1908,7 @@ TEST_F(AstDecoderTest, Break_TypeCheckAll1) {
} }
} }
TEST_F(AstDecoderTest, Break_TypeCheckAll2) { TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll2) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]}; LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
...@@ -1924,7 +1926,7 @@ TEST_F(AstDecoderTest, Break_TypeCheckAll2) { ...@@ -1924,7 +1926,7 @@ TEST_F(AstDecoderTest, Break_TypeCheckAll2) {
} }
} }
TEST_F(AstDecoderTest, Break_TypeCheckAll3) { TEST_F(FunctionBodyDecoderTest, Break_TypeCheckAll3) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]}; LocalType storage[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
...@@ -1942,7 +1944,7 @@ TEST_F(AstDecoderTest, Break_TypeCheckAll3) { ...@@ -1942,7 +1944,7 @@ TEST_F(AstDecoderTest, Break_TypeCheckAll3) {
} }
} }
TEST_F(AstDecoderTest, Break_Unify) { TEST_F(FunctionBodyDecoderTest, Break_Unify) {
for (int which = 0; which < 2; which++) { for (int which = 0; which < 2; which++) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType type = kLocalTypes[i]; LocalType type = kLocalTypes[i];
...@@ -1962,7 +1964,7 @@ TEST_F(AstDecoderTest, Break_Unify) { ...@@ -1962,7 +1964,7 @@ TEST_F(AstDecoderTest, Break_Unify) {
} }
} }
TEST_F(AstDecoderTest, BreakIf_cond_type) { TEST_F(FunctionBodyDecoderTest, BreakIf_cond_type) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalType types[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]}; LocalType types[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j]};
...@@ -1979,7 +1981,7 @@ TEST_F(AstDecoderTest, BreakIf_cond_type) { ...@@ -1979,7 +1981,7 @@ TEST_F(AstDecoderTest, BreakIf_cond_type) {
} }
} }
TEST_F(AstDecoderTest, BreakIf_val_type) { TEST_F(FunctionBodyDecoderTest, BreakIf_val_type) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
for (size_t j = 0; j < arraysize(kLocalTypes); j++) { for (size_t j = 0; j < arraysize(kLocalTypes); j++) {
LocalType types[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j], LocalType types[] = {kLocalTypes[i], kLocalTypes[i], kLocalTypes[j],
...@@ -1998,7 +2000,7 @@ TEST_F(AstDecoderTest, BreakIf_val_type) { ...@@ -1998,7 +2000,7 @@ TEST_F(AstDecoderTest, BreakIf_val_type) {
} }
} }
TEST_F(AstDecoderTest, BreakIf_Unify) { TEST_F(FunctionBodyDecoderTest, BreakIf_Unify) {
for (int which = 0; which < 2; which++) { for (int which = 0; which < 2; which++) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType type = kLocalTypes[i]; LocalType type = kLocalTypes[i];
...@@ -2016,29 +2018,29 @@ TEST_F(AstDecoderTest, BreakIf_Unify) { ...@@ -2016,29 +2018,29 @@ TEST_F(AstDecoderTest, BreakIf_Unify) {
} }
} }
TEST_F(AstDecoderTest, BrTable0) { TEST_F(FunctionBodyDecoderTest, BrTable0) {
static byte code[] = {kExprBrTable, 0, BR_TARGET(0)}; static byte code[] = {kExprBrTable, 0, BR_TARGET(0)};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
} }
TEST_F(AstDecoderTest, BrTable0b) { TEST_F(FunctionBodyDecoderTest, BrTable0b) {
static byte code[] = {kExprI32Const, 11, kExprBrTable, 0, BR_TARGET(0)}; static byte code[] = {kExprI32Const, 11, kExprBrTable, 0, BR_TARGET(0)};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, BrTable0c) { TEST_F(FunctionBodyDecoderTest, BrTable0c) {
static byte code[] = {kExprI32Const, 11, kExprBrTable, 0, BR_TARGET(1)}; static byte code[] = {kExprI32Const, 11, kExprBrTable, 0, BR_TARGET(1)};
EXPECT_FAILURE_C(v_v, code); EXPECT_FAILURE_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
} }
TEST_F(AstDecoderTest, BrTable1a) { TEST_F(FunctionBodyDecoderTest, BrTable1a) {
static byte code[] = {B1(WASM_BR_TABLE(WASM_I8(67), 0, BR_TARGET(0)))}; static byte code[] = {B1(WASM_BR_TABLE(WASM_I8(67), 0, BR_TARGET(0)))};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
} }
TEST_F(AstDecoderTest, BrTable1b) { TEST_F(FunctionBodyDecoderTest, BrTable1b) {
static byte code[] = {B1(WASM_BR_TABLE(WASM_ZERO, 0, BR_TARGET(0)))}; static byte code[] = {B1(WASM_BR_TABLE(WASM_ZERO, 0, BR_TARGET(0)))};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
EXPECT_FAILURE_C(i_i, code); EXPECT_FAILURE_C(i_i, code);
...@@ -2046,26 +2048,26 @@ TEST_F(AstDecoderTest, BrTable1b) { ...@@ -2046,26 +2048,26 @@ TEST_F(AstDecoderTest, BrTable1b) {
EXPECT_FAILURE_C(d_dd, code); EXPECT_FAILURE_C(d_dd, code);
} }
TEST_F(AstDecoderTest, BrTable2a) { TEST_F(FunctionBodyDecoderTest, BrTable2a) {
static byte code[] = { static byte code[] = {
B1(WASM_BR_TABLE(WASM_I8(67), 1, BR_TARGET(0), BR_TARGET(0)))}; B1(WASM_BR_TABLE(WASM_I8(67), 1, BR_TARGET(0), BR_TARGET(0)))};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
} }
TEST_F(AstDecoderTest, BrTable2b) { TEST_F(FunctionBodyDecoderTest, BrTable2b) {
static byte code[] = {WASM_BLOCK( static byte code[] = {WASM_BLOCK(
WASM_BLOCK(WASM_BR_TABLE(WASM_I8(67), 1, BR_TARGET(0), BR_TARGET(1))))}; WASM_BLOCK(WASM_BR_TABLE(WASM_I8(67), 1, BR_TARGET(0), BR_TARGET(1))))};
EXPECT_VERIFIES_C(v_v, code); EXPECT_VERIFIES_C(v_v, code);
} }
TEST_F(AstDecoderTest, BrTable_off_end) { TEST_F(FunctionBodyDecoderTest, BrTable_off_end) {
static byte code[] = {B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0)))}; static byte code[] = {B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0)))};
for (size_t len = 1; len < sizeof(code); len++) { for (size_t len = 1; len < sizeof(code); len++) {
Verify(kError, sigs.i_i(), code, code + len); Verify(kError, sigs.i_i(), code, code + len);
} }
} }
TEST_F(AstDecoderTest, BrTable_invalid_br1) { TEST_F(FunctionBodyDecoderTest, BrTable_invalid_br1) {
for (int depth = 0; depth < 4; depth++) { for (int depth = 0; depth < 4; depth++) {
byte code[] = {B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(depth)))}; byte code[] = {B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(depth)))};
if (depth <= 1) { if (depth <= 1) {
...@@ -2076,7 +2078,7 @@ TEST_F(AstDecoderTest, BrTable_invalid_br1) { ...@@ -2076,7 +2078,7 @@ TEST_F(AstDecoderTest, BrTable_invalid_br1) {
} }
} }
TEST_F(AstDecoderTest, BrTable_invalid_br2) { TEST_F(FunctionBodyDecoderTest, BrTable_invalid_br2) {
for (int depth = 0; depth < 7; depth++) { for (int depth = 0; depth < 7; depth++) {
byte code[] = { byte code[] = {
WASM_LOOP(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(depth)))}; WASM_LOOP(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(depth)))};
...@@ -2088,40 +2090,40 @@ TEST_F(AstDecoderTest, BrTable_invalid_br2) { ...@@ -2088,40 +2090,40 @@ TEST_F(AstDecoderTest, BrTable_invalid_br2) {
} }
} }
TEST_F(AstDecoderTest, Brv1) { TEST_F(FunctionBodyDecoderTest, Brv1) {
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV(0, WASM_ZERO))); EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV(0, WASM_ZERO)));
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_LOOP(WASM_BRV(2, WASM_ZERO)))); EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_LOOP(WASM_BRV(2, WASM_ZERO))));
} }
TEST_F(AstDecoderTest, Brv1_type) { TEST_F(FunctionBodyDecoderTest, Brv1_type) {
EXPECT_VERIFIES(i_ii, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(i_ii, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
EXPECT_VERIFIES(l_ll, WASM_BLOCK_L(WASM_BRV(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(l_ll, WASM_BLOCK_L(WASM_BRV(0, WASM_GET_LOCAL(0))));
EXPECT_VERIFIES(f_ff, WASM_BLOCK_F(WASM_BRV(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(f_ff, WASM_BLOCK_F(WASM_BRV(0, WASM_GET_LOCAL(0))));
EXPECT_VERIFIES(d_dd, WASM_BLOCK_D(WASM_BRV(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(d_dd, WASM_BLOCK_D(WASM_BRV(0, WASM_GET_LOCAL(0))));
} }
TEST_F(AstDecoderTest, Brv1_type_n) { TEST_F(FunctionBodyDecoderTest, Brv1_type_n) {
EXPECT_FAILURE(i_f, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); EXPECT_FAILURE(i_f, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
EXPECT_FAILURE(i_d, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); EXPECT_FAILURE(i_d, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
} }
TEST_F(AstDecoderTest, BrvIf1) { TEST_F(FunctionBodyDecoderTest, BrvIf1) {
EXPECT_VERIFIES(i_v, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_ZERO))); EXPECT_VERIFIES(i_v, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_ZERO)));
} }
TEST_F(AstDecoderTest, BrvIf1_type) { TEST_F(FunctionBodyDecoderTest, BrvIf1_type) {
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0))));
EXPECT_VERIFIES(l_l, WASM_BLOCK_L(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(l_l, WASM_BLOCK_L(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0))));
EXPECT_VERIFIES(f_ff, WASM_BLOCK_F(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(f_ff, WASM_BLOCK_F(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0))));
EXPECT_VERIFIES(d_dd, WASM_BLOCK_D(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)))); EXPECT_VERIFIES(d_dd, WASM_BLOCK_D(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0))));
} }
TEST_F(AstDecoderTest, BrvIf1_type_n) { TEST_F(FunctionBodyDecoderTest, BrvIf1_type_n) {
EXPECT_FAILURE(i_f, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)))); EXPECT_FAILURE(i_f, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0))));
EXPECT_FAILURE(i_d, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0)))); EXPECT_FAILURE(i_d, WASM_BLOCK_I(WASM_BRV_IF_ZERO(0, WASM_GET_LOCAL(0))));
} }
TEST_F(AstDecoderTest, Select) { TEST_F(FunctionBodyDecoderTest, Select) {
EXPECT_VERIFIES(i_i, EXPECT_VERIFIES(i_i,
WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)); WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO));
EXPECT_VERIFIES(f_ff, WASM_SELECT(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO)); EXPECT_VERIFIES(f_ff, WASM_SELECT(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO));
...@@ -2129,7 +2131,7 @@ TEST_F(AstDecoderTest, Select) { ...@@ -2129,7 +2131,7 @@ TEST_F(AstDecoderTest, Select) {
EXPECT_VERIFIES(l_l, WASM_SELECT(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)); EXPECT_VERIFIES(l_l, WASM_SELECT(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO));
} }
TEST_F(AstDecoderTest, Select_fail1) { TEST_F(FunctionBodyDecoderTest, Select_fail1) {
EXPECT_FAILURE( EXPECT_FAILURE(
i_i, WASM_SELECT(WASM_F32(0.0), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); i_i, WASM_SELECT(WASM_F32(0.0), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
EXPECT_FAILURE( EXPECT_FAILURE(
...@@ -2138,7 +2140,7 @@ TEST_F(AstDecoderTest, Select_fail1) { ...@@ -2138,7 +2140,7 @@ TEST_F(AstDecoderTest, Select_fail1) {
i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_F32(0.0))); i_i, WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_F32(0.0)));
} }
TEST_F(AstDecoderTest, Select_fail2) { TEST_F(FunctionBodyDecoderTest, Select_fail2) {
for (size_t i = 0; i < arraysize(kLocalTypes); i++) { for (size_t i = 0; i < arraysize(kLocalTypes); i++) {
LocalType type = kLocalTypes[i]; LocalType type = kLocalTypes[i];
if (type == kAstI32) continue; if (type == kAstI32) continue;
...@@ -2160,7 +2162,7 @@ TEST_F(AstDecoderTest, Select_fail2) { ...@@ -2160,7 +2162,7 @@ TEST_F(AstDecoderTest, Select_fail2) {
} }
} }
TEST_F(AstDecoderTest, Select_TypeCheck) { TEST_F(FunctionBodyDecoderTest, Select_TypeCheck) {
EXPECT_FAILURE( EXPECT_FAILURE(
i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); i_i, WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
...@@ -2171,7 +2173,7 @@ TEST_F(AstDecoderTest, Select_TypeCheck) { ...@@ -2171,7 +2173,7 @@ TEST_F(AstDecoderTest, Select_TypeCheck) {
WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64V_1(0))); WASM_SELECT(WASM_F32(9.9), WASM_GET_LOCAL(0), WASM_I64V_1(0)));
} }
TEST_F(AstDecoderTest, Throw) { TEST_F(FunctionBodyDecoderTest, Throw) {
FLAG_wasm_eh_prototype = true; FLAG_wasm_eh_prototype = true;
EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow); EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow);
...@@ -2184,7 +2186,7 @@ TEST_F(AstDecoderTest, Throw) { ...@@ -2184,7 +2186,7 @@ TEST_F(AstDecoderTest, Throw) {
#define WASM_CATCH(local) kExprCatch, static_cast<byte>(local) #define WASM_CATCH(local) kExprCatch, static_cast<byte>(local)
TEST_F(AstDecoderTest, TryCatch) { TEST_F(FunctionBodyDecoderTest, TryCatch) {
FLAG_wasm_eh_prototype = true; FLAG_wasm_eh_prototype = true;
EXPECT_VERIFIES(v_i, WASM_TRY_OP, WASM_CATCH(0), kExprEnd); EXPECT_VERIFIES(v_i, WASM_TRY_OP, WASM_CATCH(0), kExprEnd);
...@@ -2198,21 +2200,21 @@ TEST_F(AstDecoderTest, TryCatch) { ...@@ -2198,21 +2200,21 @@ TEST_F(AstDecoderTest, TryCatch) {
EXPECT_FAILURE(v_i, WASM_TRY_OP, WASM_CATCH(0), WASM_CATCH(0), kExprEnd); EXPECT_FAILURE(v_i, WASM_TRY_OP, WASM_CATCH(0), WASM_CATCH(0), kExprEnd);
} }
TEST_F(AstDecoderTest, MultiValBlock1) { TEST_F(FunctionBodyDecoderTest, MultiValBlock1) {
FLAG_wasm_mv_prototype = true; FLAG_wasm_mv_prototype = true;
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1)), WASM_GET_LOCAL(1)),
kExprI32Add); kExprI32Add);
} }
TEST_F(AstDecoderTest, MultiValBlock2) { TEST_F(FunctionBodyDecoderTest, MultiValBlock2) {
FLAG_wasm_mv_prototype = true; FLAG_wasm_mv_prototype = true;
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1)), WASM_GET_LOCAL(1)),
WASM_I32_ADD(WASM_NOP, WASM_NOP)); WASM_I32_ADD(WASM_NOP, WASM_NOP));
} }
TEST_F(AstDecoderTest, MultiValBlockBr1) { TEST_F(FunctionBodyDecoderTest, MultiValBlockBr1) {
FLAG_wasm_mv_prototype = true; FLAG_wasm_mv_prototype = true;
EXPECT_FAILURE(i_ii, EXPECT_FAILURE(i_ii,
WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_BR(0)), WASM_BLOCK_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), WASM_BR(0)),
...@@ -2222,7 +2224,7 @@ TEST_F(AstDecoderTest, MultiValBlockBr1) { ...@@ -2222,7 +2224,7 @@ TEST_F(AstDecoderTest, MultiValBlockBr1) {
kExprI32Add); kExprI32Add);
} }
TEST_F(AstDecoderTest, MultiValIf1) { TEST_F(FunctionBodyDecoderTest, MultiValIf1) {
FLAG_wasm_mv_prototype = true; FLAG_wasm_mv_prototype = true;
EXPECT_FAILURE( EXPECT_FAILURE(
i_ii, WASM_IF_ELSE_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0), i_ii, WASM_IF_ELSE_TT(kAstI32, kAstI32, WASM_GET_LOCAL(0),
...@@ -2555,7 +2557,7 @@ class LocalDeclDecoderTest : public TestWithZone { ...@@ -2555,7 +2557,7 @@ class LocalDeclDecoderTest : public TestWithZone {
return pos; return pos;
} }
LocalTypeMap Expand(AstLocalDecls& decls) { LocalTypeMap Expand(BodyLocalDecls& decls) {
ZoneVector<LocalType> map(zone()); ZoneVector<LocalType> map(zone());
for (auto p : decls.local_types) { for (auto p : decls.local_types) {
map.insert(map.end(), p.second, p.first); map.insert(map.end(), p.second, p.first);
...@@ -2565,14 +2567,14 @@ class LocalDeclDecoderTest : public TestWithZone { ...@@ -2565,14 +2567,14 @@ class LocalDeclDecoderTest : public TestWithZone {
}; };
TEST_F(LocalDeclDecoderTest, EmptyLocals) { TEST_F(LocalDeclDecoderTest, EmptyLocals) {
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
bool result = DecodeLocalDecls(decls, nullptr, nullptr); bool result = DecodeLocalDecls(decls, nullptr, nullptr);
EXPECT_FALSE(result); EXPECT_FALSE(result);
} }
TEST_F(LocalDeclDecoderTest, NoLocals) { TEST_F(LocalDeclDecoderTest, NoLocals) {
static const byte data[] = {0}; static const byte data[] = {0};
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
bool result = DecodeLocalDecls(decls, data, data + sizeof(data)); bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(0u, decls.total_local_count); EXPECT_EQ(0u, decls.total_local_count);
...@@ -2583,7 +2585,7 @@ TEST_F(LocalDeclDecoderTest, OneLocal) { ...@@ -2583,7 +2585,7 @@ TEST_F(LocalDeclDecoderTest, OneLocal) {
LocalType type = kLocalTypes[i]; LocalType type = kLocalTypes[i];
const byte data[] = { const byte data[] = {
1, 1, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(type))}; 1, 1, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(type))};
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
bool result = DecodeLocalDecls(decls, data, data + sizeof(data)); bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(1u, decls.total_local_count); EXPECT_EQ(1u, decls.total_local_count);
...@@ -2599,7 +2601,7 @@ TEST_F(LocalDeclDecoderTest, FiveLocals) { ...@@ -2599,7 +2601,7 @@ TEST_F(LocalDeclDecoderTest, FiveLocals) {
LocalType type = kLocalTypes[i]; LocalType type = kLocalTypes[i];
const byte data[] = { const byte data[] = {
1, 5, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(type))}; 1, 5, static_cast<byte>(WasmOpcodes::LocalTypeCodeFor(type))};
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
bool result = DecodeLocalDecls(decls, data, data + sizeof(data)); bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(sizeof(data), decls.decls_encoded_size); EXPECT_EQ(sizeof(data), decls.decls_encoded_size);
...@@ -2618,7 +2620,7 @@ TEST_F(LocalDeclDecoderTest, MixedLocals) { ...@@ -2618,7 +2620,7 @@ TEST_F(LocalDeclDecoderTest, MixedLocals) {
for (byte d = 0; d < 3; d++) { for (byte d = 0; d < 3; d++) {
const byte data[] = {4, a, kLocalI32, b, kLocalI64, const byte data[] = {4, a, kLocalI32, b, kLocalI64,
c, kLocalF32, d, kLocalF64}; c, kLocalF32, d, kLocalF64};
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
bool result = DecodeLocalDecls(decls, data, data + sizeof(data)); bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(sizeof(data), decls.decls_encoded_size); EXPECT_EQ(sizeof(data), decls.decls_encoded_size);
...@@ -2649,7 +2651,7 @@ TEST_F(LocalDeclDecoderTest, UseEncoder) { ...@@ -2649,7 +2651,7 @@ TEST_F(LocalDeclDecoderTest, UseEncoder) {
local_decls.AddLocals(212, kAstI64); local_decls.AddLocals(212, kAstI64);
local_decls.Prepend(zone(), &data, &end); local_decls.Prepend(zone(), &data, &end);
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
bool result = DecodeLocalDecls(decls, data, end); bool result = DecodeLocalDecls(decls, data, end);
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(5u + 1337u + 212u, decls.total_local_count); EXPECT_EQ(5u + 1337u + 212u, decls.total_local_count);
...@@ -2719,9 +2721,9 @@ TEST_F(BytecodeIteratorTest, ForeachOffset) { ...@@ -2719,9 +2721,9 @@ TEST_F(BytecodeIteratorTest, ForeachOffset) {
EXPECT_EQ(6, count); EXPECT_EQ(6, count);
} }
TEST_F(BytecodeIteratorTest, WithAstDecls) { TEST_F(BytecodeIteratorTest, WithLocalDecls) {
byte code[] = {1, 1, kLocalI32, WASM_I8(9), WASM_I8(11)}; byte code[] = {1, 1, kLocalI32, WASM_I8(9), WASM_I8(11)};
AstLocalDecls decls(zone()); BodyLocalDecls decls(zone());
BytecodeIterator iter(code, code + sizeof(code), &decls); BytecodeIterator iter(code, code + sizeof(code), &decls);
EXPECT_EQ(3u, decls.decls_encoded_size); EXPECT_EQ(3u, decls.decls_encoded_size);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "src/bit-vector.h" #include "src/bit-vector.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-macro-gen.h" #include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "src/v8.h" #include "src/v8.h"
#include "src/wasm/ast-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module-builder.h"
#include "test/common/wasm/test-signatures.h" #include "test/common/wasm/test-signatures.h"
......
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