| Index: src/wasm/module-decoder.cc
|
| diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
|
| index 7503e4070b06f491c44c5d4cd11c2eb3cba5e489..904db736db231bac8c5e2d92c64410319d5dc8ff 100644
|
| --- a/src/wasm/module-decoder.cc
|
| +++ b/src/wasm/module-decoder.cc
|
| @@ -1214,11 +1214,13 @@ class ModuleDecoder : public Decoder {
|
| }
|
| };
|
|
|
| -ModuleResult DecodeWasmModuleInternal(Isolate* isolate,
|
| - const byte* module_start,
|
| - const byte* module_end,
|
| - bool verify_functions,
|
| - ModuleOrigin origin, bool is_sync) {
|
| +ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start,
|
| + const byte* module_end, bool verify_functions,
|
| + ModuleOrigin origin, Counters* counters,
|
| + bool is_sync) {
|
| + TimedHistogramScope wasm_decode_module_time_scope(
|
| + IsWasm(origin) ? counters->wasm_decode_wasm_module_time()
|
| + : counters->wasm_decode_asm_module_time());
|
| size_t size = module_end - module_start;
|
| if (module_start > module_end) return ModuleResult::Error("start > end");
|
| if (size >= kV8MaxWasmModuleSize)
|
| @@ -1227,8 +1229,8 @@ ModuleResult DecodeWasmModuleInternal(Isolate* isolate,
|
| if (is_sync) {
|
| // TODO(karlschimpf): Make this work when asynchronous.
|
| // https://bugs.chromium.org/p/v8/issues/detail?id=6361
|
| - (IsWasm(origin) ? isolate->counters()->wasm_wasm_module_size_bytes()
|
| - : isolate->counters()->wasm_asm_module_size_bytes())
|
| + (IsWasm(origin) ? counters->wasm_wasm_module_size_bytes()
|
| + : counters->wasm_asm_module_size_bytes())
|
| ->AddSample(static_cast<int>(size));
|
| }
|
| // Signatures are stored in zone memory, which have the same lifetime
|
| @@ -1242,9 +1244,8 @@ ModuleResult DecodeWasmModuleInternal(Isolate* isolate,
|
| if (is_sync && result.ok()) {
|
| // TODO(karlschimpf): Make this work when asynchronous.
|
| // https://bugs.chromium.org/p/v8/issues/detail?id=6361
|
| - (IsWasm(origin)
|
| - ? isolate->counters()->wasm_decode_wasm_module_peak_memory_bytes()
|
| - : isolate->counters()->wasm_decode_asm_module_peak_memory_bytes())
|
| + (IsWasm(origin) ? counters->wasm_decode_wasm_module_peak_memory_bytes()
|
| + : counters->wasm_decode_asm_module_peak_memory_bytes())
|
| ->AddSample(
|
| static_cast<int>(result.val->signature_zone->allocation_size()));
|
| }
|
| @@ -1253,20 +1254,19 @@ ModuleResult DecodeWasmModuleInternal(Isolate* isolate,
|
|
|
| } // namespace
|
|
|
| -ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start,
|
| - const byte* module_end, bool verify_functions,
|
| - ModuleOrigin origin, bool is_sync) {
|
| - if (is_sync) {
|
| - // TODO(karlschimpf): Make this work when asynchronous.
|
| - // https://bugs.chromium.org/p/v8/issues/detail?id=6361
|
| - HistogramTimerScope wasm_decode_module_time_scope(
|
| - IsWasm(origin) ? isolate->counters()->wasm_decode_wasm_module_time()
|
| - : isolate->counters()->wasm_decode_asm_module_time());
|
| - return DecodeWasmModuleInternal(isolate, module_start, module_end,
|
| - verify_functions, origin, true);
|
| - }
|
| - return DecodeWasmModuleInternal(isolate, module_start, module_end,
|
| - verify_functions, origin, false);
|
| +ModuleResult SyncDecodeWasmModule(Isolate* isolate, const byte* module_start,
|
| + const byte* module_end, bool verify_functions,
|
| + ModuleOrigin origin) {
|
| + return DecodeWasmModule(isolate, module_start, module_end, verify_functions,
|
| + origin, isolate->counters(), true);
|
| +}
|
| +
|
| +ModuleResult AsyncDecodeWasmModule(Isolate* isolate, const byte* module_start,
|
| + const byte* module_end,
|
| + bool verify_functions, ModuleOrigin origin,
|
| + const std::shared_ptr<Counters>& counters) {
|
| + return DecodeWasmModule(isolate, module_start, module_end, verify_functions,
|
| + origin, counters.get(), false);
|
| }
|
|
|
| FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start,
|
| @@ -1283,12 +1283,19 @@ WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end) {
|
|
|
| namespace {
|
|
|
| -FunctionResult DecodeWasmFunctionInternal(Isolate* isolate, Zone* zone,
|
| - ModuleBytesEnv* module_env,
|
| - const byte* function_start,
|
| - const byte* function_end,
|
| - bool is_sync) {
|
| +FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone,
|
| + ModuleBytesEnv* module_env,
|
| + const byte* function_start,
|
| + const byte* function_end, Counters* counters,
|
| + bool is_sync) {
|
| size_t size = function_end - function_start;
|
| + bool is_wasm = module_env->module_env.is_wasm();
|
| + (is_wasm ? counters->wasm_wasm_function_size_bytes()
|
| + : counters->wasm_asm_function_size_bytes())
|
| + ->AddSample(static_cast<int>(size));
|
| + TimedHistogramScope wasm_decode_function_time_scope(
|
| + is_wasm ? counters->wasm_decode_wasm_function_time()
|
| + : counters->wasm_decode_asm_function_time());
|
| if (function_start > function_end)
|
| return FunctionResult::Error("start > end");
|
| if (size > kV8MaxWasmFunctionSize)
|
| @@ -1297,8 +1304,8 @@ FunctionResult DecodeWasmFunctionInternal(Isolate* isolate, Zone* zone,
|
| // TODO(karlschimpf): Make this work when asynchronous.
|
| // https://bugs.chromium.org/p/v8/issues/detail?id=6361
|
| bool is_wasm = module_env->module_env.is_wasm();
|
| - (is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
|
| - : isolate->counters()->wasm_asm_function_size_bytes())
|
| + (is_wasm ? counters->wasm_wasm_function_size_bytes()
|
| + : counters->wasm_asm_function_size_bytes())
|
| ->AddSample(static_cast<int>(size));
|
| }
|
| ModuleDecoder decoder(function_start, function_end, kWasmOrigin);
|
| @@ -1307,27 +1314,20 @@ FunctionResult DecodeWasmFunctionInternal(Isolate* isolate, Zone* zone,
|
| }
|
|
|
| } // namespace
|
| +FunctionResult SyncDecodeWasmFunction(Isolate* isolate, Zone* zone,
|
| + ModuleBytesEnv* module_env,
|
| + const byte* function_start,
|
| + const byte* function_end) {
|
| + return DecodeWasmFunction(isolate, zone, module_env, function_start,
|
| + function_end, isolate->counters(), true);
|
| +}
|
|
|
| -FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone,
|
| - ModuleBytesEnv* module_env,
|
| - const byte* function_start,
|
| - const byte* function_end, bool is_sync) {
|
| - if (is_sync) {
|
| - // TODO(karlschimpf): Make this work when asynchronous.
|
| - // https://bugs.chromium.org/p/v8/issues/detail?id=6361
|
| - size_t size = function_end - function_start;
|
| - bool is_wasm = module_env->module_env.is_wasm();
|
| - (is_wasm ? isolate->counters()->wasm_wasm_function_size_bytes()
|
| - : isolate->counters()->wasm_asm_function_size_bytes())
|
| - ->AddSample(static_cast<int>(size));
|
| - HistogramTimerScope wasm_decode_function_time_scope(
|
| - is_wasm ? isolate->counters()->wasm_decode_wasm_function_time()
|
| - : isolate->counters()->wasm_decode_asm_function_time());
|
| - return DecodeWasmFunctionInternal(isolate, zone, module_env, function_start,
|
| - function_end, true);
|
| - }
|
| - return DecodeWasmFunctionInternal(isolate, zone, module_env, function_start,
|
| - function_end, false);
|
| +FunctionResult AsyncDecodeWasmFunction(
|
| + Isolate* isolate, Zone* zone, ModuleBytesEnv* module_env,
|
| + const byte* function_start, const byte* function_end,
|
| + const std::shared_ptr<Counters>& counters) {
|
| + return DecodeWasmFunction(isolate, zone, module_env, function_start,
|
| + function_end, counters.get(), false);
|
| }
|
|
|
| AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* tables_start,
|
|
|