From 6eccbd4c70fb31a788e6a93ee2a163bb7dc6d06b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 11 Sep 2016 18:56:58 -0700 Subject: validate in debug mode in passRunner --- src/passes/pass.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 437b023bc..712331562 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -18,6 +18,7 @@ #include #include +#include namespace wasm { @@ -132,10 +133,9 @@ void PassRunner::addDefaultGlobalOptimizationPasses() { void PassRunner::run() { if (debug) { // for debug logging purposes, run each pass in full before running the other - std::chrono::high_resolution_clock::time_point beforeEverything; + auto totalTime = std::chrono::duration(0); size_t padding = 0; std::cerr << "[PassRunner] running passes..." << std::endl; - beforeEverything = std::chrono::high_resolution_clock::now(); for (auto pass : passes) { padding = std::max(padding, pass->name.size()); } @@ -158,10 +158,19 @@ void PassRunner::run() { auto after = std::chrono::high_resolution_clock::now(); std::chrono::duration diff = after - before; std::cerr << diff.count() << " seconds." << std::endl; + totalTime += diff; +#if 0 + // validate, ignoring the time + std::cerr << "[PassRunner] (validating)\n"; + if (!WasmValidator().validate(*wasm)) { + std::cerr << "last pass (" << pass->name << ") broke validation\n"; + abort(); + } +#endif } - auto after = std::chrono::high_resolution_clock::now(); - std::chrono::duration diff = after - beforeEverything; - std::cerr << "[PassRunner] passes took " << diff.count() << " seconds." << std::endl; + std::cerr << "[PassRunner] passes took " << totalTime.count() << " seconds." << std::endl; + // validate + assert(WasmValidator().validate(*wasm)); } else { // non-debug normal mode, run them in an optimal manner - for locality it is better // to run as many passes as possible on a single function before moving to the next -- cgit v1.2.3