Commit 98728e58 authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm] Inline VerifyWasmCodeWithStats

This removes the need to pass Counters into the function body decoder
by making timing happen in the callers.

R=mstarzinger@chromium.org

Change-Id: I05c8d2c85b1c315150cbf9e9b3f68efa03114b75
Reviewed-on: https://chromium-review.googlesource.com/1156700
Commit-Queue: Ben Titzer <titzer@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54842}
parent baa055c7
...@@ -844,18 +844,6 @@ DecodeResult VerifyWasmCode(AccountingAllocator* allocator, ...@@ -844,18 +844,6 @@ DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
return decoder.toResult(nullptr); return decoder.toResult(nullptr);
} }
DecodeResult VerifyWasmCodeWithStats(AccountingAllocator* allocator,
const wasm::WasmModule* module,
FunctionBody& body, ModuleOrigin origin,
Counters* counters) {
CHECK_LE(0, body.end - body.start);
auto time_counter = origin == kWasmOrigin
? counters->wasm_decode_wasm_function_time()
: counters->wasm_decode_asm_function_time();
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
return VerifyWasmCode(allocator, module, body);
}
DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
FunctionBody& body, FunctionBody& body,
compiler::NodeOriginTable* node_origins) { compiler::NodeOriginTable* node_origins) {
......
...@@ -17,7 +17,6 @@ namespace v8 { ...@@ -17,7 +17,6 @@ namespace v8 {
namespace internal { namespace internal {
class BitVector; // forward declaration class BitVector; // forward declaration
class Counters;
namespace compiler { // external declarations from compiler. namespace compiler { // external declarations from compiler.
class NodeOriginTable; class NodeOriginTable;
...@@ -28,7 +27,6 @@ namespace wasm { ...@@ -28,7 +27,6 @@ namespace wasm {
typedef compiler::WasmGraphBuilder TFBuilder; typedef compiler::WasmGraphBuilder TFBuilder;
struct WasmModule; // forward declaration of module interface. struct WasmModule; // forward declaration of module interface.
enum ModuleOrigin : uint8_t;
// A wrapper around the signature and bytes of a function. // A wrapper around the signature and bytes of a function.
struct FunctionBody { struct FunctionBody {
...@@ -43,27 +41,20 @@ struct FunctionBody { ...@@ -43,27 +41,20 @@ struct FunctionBody {
}; };
V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator, V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
const wasm::WasmModule* module, const WasmModule* module,
FunctionBody& body); FunctionBody& body);
// Note: If run in the background thread, must follow protocol using
// isolate::async_counters() to guarantee usability of counters argument.
DecodeResult VerifyWasmCodeWithStats(AccountingAllocator* allocator,
const wasm::WasmModule* module,
FunctionBody& body, ModuleOrigin origin,
Counters* counters);
DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
FunctionBody& body, FunctionBody& body,
compiler::NodeOriginTable* node_origins); compiler::NodeOriginTable* node_origins);
enum PrintLocals { kPrintLocals, kOmitLocals }; enum PrintLocals { kPrintLocals, kOmitLocals };
V8_EXPORT_PRIVATE V8_EXPORT_PRIVATE
bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body, bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
const wasm::WasmModule* module, PrintLocals print_locals); const WasmModule* module, PrintLocals print_locals);
V8_EXPORT_PRIVATE V8_EXPORT_PRIVATE
bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body, bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
const wasm::WasmModule* module, PrintLocals print_locals, const WasmModule* module, PrintLocals print_locals,
std::ostream& out, std::ostream& out,
std::vector<int>* line_numbers = nullptr); std::vector<int>* line_numbers = nullptr);
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class Counters;
namespace compiler { namespace compiler {
class TurbofanWasmCompilationUnit; class TurbofanWasmCompilationUnit;
} // namespace compiler } // namespace compiler
......
...@@ -686,9 +686,15 @@ void ValidateSequentially(Isolate* isolate, NativeModule* native_module, ...@@ -686,9 +686,15 @@ void ValidateSequentially(Isolate* isolate, NativeModule* native_module,
const byte* base = wire_bytes.start(); const byte* base = wire_bytes.start();
FunctionBody body{func.sig, func.code.offset(), base + func.code.offset(), FunctionBody body{func.sig, func.code.offset(), base + func.code.offset(),
base + func.code.end_offset()}; base + func.code.end_offset()};
DecodeResult result = VerifyWasmCodeWithStats( DecodeResult result;
isolate->allocator(), module, body, module->origin, {
isolate->async_counters().get()); auto time_counter =
SELECT_WASM_COUNTER(isolate->async_counters(), module->origin,
wasm_decode, function_time);
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
result = VerifyWasmCode(isolate->allocator(), module, body);
}
if (result.failed()) { if (result.failed()) {
TruncatedUserString<> name(wire_bytes.GetName(&func, module)); TruncatedUserString<> name(wire_bytes.GetName(&func, module));
thrower->CompileError("Compiling function #%d:%.*s failed: %s @+%u", i, thrower->CompileError("Compiling function #%d:%.*s failed: %s @+%u", i,
......
...@@ -1046,8 +1046,16 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1046,8 +1046,16 @@ class ModuleDecoderImpl : public Decoder {
function->sig, function->code.offset(), function->sig, function->code.offset(),
start_ + GetBufferRelativeOffset(function->code.offset()), start_ + GetBufferRelativeOffset(function->code.offset()),
start_ + GetBufferRelativeOffset(function->code.end_offset())}; start_ + GetBufferRelativeOffset(function->code.end_offset())};
DecodeResult result = VerifyWasmCodeWithStats(allocator, module, body,
origin_, GetCounters()); DecodeResult result;
{
auto time_counter = SELECT_WASM_COUNTER(GetCounters(), origin_,
wasm_decode, function_time);
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
result = VerifyWasmCode(allocator, module, body);
}
if (result.failed()) { if (result.failed()) {
// Wrap the error message from the function decoder. // Wrap the error message from the function decoder.
std::ostringstream wrapped; std::ostringstream wrapped;
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class Counters;
namespace wasm { namespace wasm {
struct ModuleEnv; struct ModuleEnv;
......
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