Index: test/cctest/wasm/wasm-run-utils.h |
diff --git a/test/cctest/wasm/wasm-run-utils.h b/test/cctest/wasm/wasm-run-utils.h |
index a9f70deadf5725e5b9bd21f98279bb277b53819d..4eba4a4d43876544d866f48a6c8074cfba35d817 100644 |
--- a/test/cctest/wasm/wasm-run-utils.h |
+++ b/test/cctest/wasm/wasm-run-utils.h |
@@ -52,10 +52,16 @@ enum WasmExecutionMode { kExecuteInterpreted, kExecuteCompiled }; |
#define WASM_RUNNER_MAX_NUM_PARAMETERS 4 |
#define WASM_WRAPPER_RETURN_VALUE 8754 |
-#define BUILD(r, ...) \ |
- do { \ |
- byte code[] = {__VA_ARGS__}; \ |
- r.Build(code, code + arraysize(code)); \ |
+#define BUILD(r, ...) \ |
+ do { \ |
+ byte code[] = {__VA_ARGS__}; \ |
+ r.Build(code, code + arraysize(code), false); \ |
+ } while (false) |
+ |
+#define BUILD_FAIL(r, ...) \ |
+ do { \ |
+ byte code[] = {__VA_ARGS__}; \ |
+ r.Build(code, code + arraysize(code), true); \ |
} while (false) |
namespace { |
@@ -228,9 +234,11 @@ class TestingModule : public ModuleEnv { |
instance->function_code[index] = code; |
} |
- void AddIndirectFunctionTable(uint16_t* functions, uint32_t table_size) { |
- module_.function_tables.push_back( |
- {table_size, table_size, std::vector<uint16_t>()}); |
+ void AddIndirectFunctionTable(FunctionSig* sig, uint32_t table, |
+ uint16_t* functions, uint32_t table_size) { |
+ module_.function_tables.push_back({!module_.function_tables.size(), sig, |
+ table, table_size, table_size, |
+ std::vector<uint16_t>()}); |
for (uint32_t i = 0; i < table_size; ++i) { |
module_.function_tables.back().values.push_back(functions[i]); |
} |
@@ -278,11 +286,11 @@ class TestingModule : public ModuleEnv { |
inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, |
FunctionSig* sig, |
SourcePositionTable* source_position_table, |
- const byte* start, const byte* end) { |
+ const byte* start, const byte* end, bool fail) { |
compiler::WasmGraphBuilder builder(zone, jsgraph, sig, source_position_table); |
DecodeResult result = |
BuildTFGraph(zone->allocator(), &builder, module, sig, start, end); |
- if (result.failed()) { |
+ if ((result.failed() && !fail) || (!result.failed() && fail)) { |
ptrdiff_t pc = result.error_pc - result.start; |
ptrdiff_t pt = result.error_pt - result.start; |
std::ostringstream str; |
@@ -291,6 +299,7 @@ inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, |
str << ", msg = " << result.error_msg.get(); |
FATAL(str.str().c_str()); |
} |
+ if (result.failed()) return; |
builder.Int64LoweringForTesting(); |
if (FLAG_trace_turbo_graph) { |
OFStream os(stdout); |
@@ -521,12 +530,12 @@ class WasmFunctionCompiler : public HandleAndZoneScope, |
CallDescriptor* descriptor() { return descriptor_; } |
uint32_t function_index() { return function_->func_index; } |
- void Build(const byte* start, const byte* end) { |
+ void Build(const byte* start, const byte* end, bool fail) { |
// Build the TurboFan graph. |
local_decls.Prepend(main_zone(), &start, &end); |
TestBuildingGraph(main_zone(), &jsgraph, testing_module_, sig, |
- &source_position_table_, start, end); |
- if (interpreter_) { |
+ &source_position_table_, start, end, fail); |
+ if (!fail && interpreter_) { |
// Add the code to the interpreter. |
CHECK(interpreter_->SetFunctionCodeForTesting(function_, start, end)); |
} |
@@ -648,12 +657,12 @@ class WasmRunner { |
// Builds a graph from the given Wasm code and generates the machine |
// code and call wrapper for that graph. This method must not be called |
// more than once. |
- void Build(const byte* start, const byte* end) { |
+ void Build(const byte* start, const byte* end, bool fail) { |
CHECK(!compiled_); |
compiled_ = true; |
- compiler_.Build(start, end); |
+ compiler_.Build(start, end, fail); |
- if (!interpret()) { |
+ if (!interpret() && !fail) { |
// Compile machine code and install it into the module. |
Handle<Code> code = compiler_.Compile(); |