Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2864583004: Only turn on UMA WASM metric when synchronous. (Closed)
Patch Set: Again, merge updated master. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/wasm/module-decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/assembler-inl.h" 9 #include "src/assembler-inl.h"
10 #include "src/base/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
(...skipping 3919 matching lines...) Expand 10 before | Expand all | Expand 10 after
3930 DCHECK(name_len > 0 && name_len < name_vector.length()); 3930 DCHECK(name_len > 0 && name_len < name_vector.length());
3931 3931
3932 char* index_name = zone->NewArray<char>(name_len); 3932 char* index_name = zone->NewArray<char>(name_len);
3933 memcpy(index_name, name_vector.start(), name_len); 3933 memcpy(index_name, name_vector.start(), name_len);
3934 return Vector<const char>(index_name, name_len); 3934 return Vector<const char>(index_name, name_len);
3935 } 3935 }
3936 } // namespace 3936 } // namespace
3937 3937
3938 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, 3938 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
3939 wasm::ModuleBytesEnv* module_env, 3939 wasm::ModuleBytesEnv* module_env,
3940 const wasm::WasmFunction* function) 3940 const wasm::WasmFunction* function,
3941 bool is_sync)
3941 : WasmCompilationUnit( 3942 : WasmCompilationUnit(
3942 isolate, &module_env->module_env, 3943 isolate, &module_env->module_env,
3943 wasm::FunctionBody{ 3944 wasm::FunctionBody{
3944 function->sig, module_env->wire_bytes.start(), 3945 function->sig, module_env->wire_bytes.start(),
3945 module_env->wire_bytes.start() + function->code_start_offset, 3946 module_env->wire_bytes.start() + function->code_start_offset,
3946 module_env->wire_bytes.start() + function->code_end_offset}, 3947 module_env->wire_bytes.start() + function->code_end_offset},
3947 module_env->wire_bytes.GetNameOrNull(function), 3948 module_env->wire_bytes.GetNameOrNull(function), function->func_index,
3948 function->func_index) {} 3949 is_sync) {}
3949 3950
3950 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, 3951 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
3951 wasm::ModuleEnv* module_env, 3952 wasm::ModuleEnv* module_env,
3952 wasm::FunctionBody body, 3953 wasm::FunctionBody body,
3953 wasm::WasmName name, int index) 3954 wasm::WasmName name, int index,
3955 bool is_sync)
3954 : isolate_(isolate), 3956 : isolate_(isolate),
3955 module_env_(module_env), 3957 module_env_(module_env),
3956 func_body_(body), 3958 func_body_(body),
3957 func_name_(name), 3959 func_name_(name),
3960 is_sync_(is_sync),
3958 graph_zone_(new Zone(isolate->allocator(), ZONE_NAME)), 3961 graph_zone_(new Zone(isolate->allocator(), ZONE_NAME)),
3959 jsgraph_(new (graph_zone()) JSGraph( 3962 jsgraph_(new (graph_zone()) JSGraph(
3960 isolate, new (graph_zone()) Graph(graph_zone()), 3963 isolate, new (graph_zone()) Graph(graph_zone()),
3961 new (graph_zone()) CommonOperatorBuilder(graph_zone()), nullptr, 3964 new (graph_zone()) CommonOperatorBuilder(graph_zone()), nullptr,
3962 nullptr, 3965 nullptr,
3963 new (graph_zone()) MachineOperatorBuilder( 3966 new (graph_zone()) MachineOperatorBuilder(
3964 graph_zone(), MachineType::PointerRepresentation(), 3967 graph_zone(), MachineType::PointerRepresentation(),
3965 InstructionSelector::SupportedMachineOperatorFlags(), 3968 InstructionSelector::SupportedMachineOperatorFlags(),
3966 InstructionSelector::AlignmentRequirements()))), 3969 InstructionSelector::AlignmentRequirements()))),
3967 compilation_zone_(isolate->allocator(), ZONE_NAME), 3970 compilation_zone_(isolate->allocator(), ZONE_NAME),
3968 info_(GetDebugName(&compilation_zone_, name, index), isolate, 3971 info_(GetDebugName(&compilation_zone_, name, index), isolate,
3969 &compilation_zone_, Code::ComputeFlags(Code::WASM_FUNCTION)), 3972 &compilation_zone_, Code::ComputeFlags(Code::WASM_FUNCTION)),
3970 func_index_(index), 3973 func_index_(index),
3971 protected_instructions_(&compilation_zone_) {} 3974 protected_instructions_(&compilation_zone_) {}
3972 3975
3973 void WasmCompilationUnit::InitializeHandles() { 3976 void WasmCompilationUnit::InitializeHandles() {
3974 // Create and cache this node in the main thread, which contains a handle to 3977 // Create and cache this node in the main thread, which contains a handle to
3975 // the code object of the c-entry stub. 3978 // the code object of the c-entry stub.
3976 jsgraph_->CEntryStubConstant(1); 3979 jsgraph_->CEntryStubConstant(1);
3977 DCHECK(!handles_initialized_); 3980 DCHECK(!handles_initialized_);
3978 #if DEBUG 3981 #if DEBUG
3979 handles_initialized_ = true; 3982 handles_initialized_ = true;
3980 #endif // DEBUG 3983 #endif // DEBUG
3981 } 3984 }
3982 3985
3983 void WasmCompilationUnit::ExecuteCompilation() { 3986 void WasmCompilationUnit::ExecuteCompilation() {
3984 DCHECK(handles_initialized_); 3987 DCHECK(handles_initialized_);
3985 // TODO(ahaas): The counters are not thread-safe at the moment. 3988 if (is_sync_) {
3986 // HistogramTimerScope wasm_compile_function_time_scope( 3989 // TODO(karlschimpf): Make this work when asynchronous.
3987 // isolate_->counters()->wasm_compile_function_time()); 3990 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
3991 HistogramTimerScope wasm_compile_function_time_scope(
3992 isolate_->counters()->wasm_compile_function_time());
3993 ExecuteCompilationInternal();
3994 return;
3995 }
3996 ExecuteCompilationInternal();
3997 }
3998
3999 void WasmCompilationUnit::ExecuteCompilationInternal() {
3988 if (FLAG_trace_wasm_compiler) { 4000 if (FLAG_trace_wasm_compiler) {
3989 if (func_name_.start() != nullptr) { 4001 if (func_name_.start() != nullptr) {
3990 PrintF("Compiling WASM function %d:'%.*s'\n\n", func_index(), 4002 PrintF("Compiling WASM function %d:'%.*s'\n\n", func_index(),
3991 func_name_.length(), func_name_.start()); 4003 func_name_.length(), func_name_.start());
3992 } else { 4004 } else {
3993 PrintF("Compiling WASM function %d:<unnamed>\n\n", func_index()); 4005 PrintF("Compiling WASM function %d:<unnamed>\n\n", func_index());
3994 } 4006 }
3995 } 4007 }
3996 4008
3997 double decode_ms = 0; 4009 double decode_ms = 0;
(...skipping 18 matching lines...) Expand all
4016 &compilation_zone_, func_body_.sig); 4028 &compilation_zone_, func_body_.sig);
4017 if (jsgraph_->machine()->Is32()) { 4029 if (jsgraph_->machine()->Is32()) {
4018 descriptor = 4030 descriptor =
4019 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); 4031 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor);
4020 } 4032 }
4021 job_.reset(Pipeline::NewWasmCompilationJob( 4033 job_.reset(Pipeline::NewWasmCompilationJob(
4022 &info_, jsgraph_, descriptor, source_positions, &protected_instructions_, 4034 &info_, jsgraph_, descriptor, source_positions, &protected_instructions_,
4023 !module_env_->module->is_wasm())); 4035 !module_env_->module->is_wasm()));
4024 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; 4036 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED;
4025 // TODO(bradnelson): Improve histogram handling of size_t. 4037 // TODO(bradnelson): Improve histogram handling of size_t.
4026 // TODO(ahaas): The counters are not thread-safe at the moment. 4038 if (is_sync_)
4027 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() 4039 // TODO(karlschimpf): Make this work when asynchronous.
4028 // ->AddSample( 4040 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
4029 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); 4041 isolate_->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
4042 static_cast<int>(jsgraph_->graph()->zone()->allocation_size()));
4030 4043
4031 if (FLAG_trace_wasm_decode_time) { 4044 if (FLAG_trace_wasm_decode_time) {
4032 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); 4045 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF();
4033 PrintF( 4046 PrintF(
4034 "wasm-compilation phase 1 ok: %u bytes, %0.3f ms decode, %zu nodes, " 4047 "wasm-compilation phase 1 ok: %u bytes, %0.3f ms decode, %zu nodes, "
4035 "%0.3f ms pipeline\n", 4048 "%0.3f ms pipeline\n",
4036 static_cast<unsigned>(func_body_.end - func_body_.start), decode_ms, 4049 static_cast<unsigned>(func_body_.end - func_body_.start), decode_ms,
4037 node_count, pipeline_ms); 4050 node_count, pipeline_ms);
4038 } 4051 }
4039 } 4052 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) { 4102 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) {
4090 WasmCompilationUnit unit(isolate, module_env, function); 4103 WasmCompilationUnit unit(isolate, module_env, function);
4091 unit.InitializeHandles(); 4104 unit.InitializeHandles();
4092 unit.ExecuteCompilation(); 4105 unit.ExecuteCompilation();
4093 return unit.FinishCompilation(thrower); 4106 return unit.FinishCompilation(thrower);
4094 } 4107 }
4095 4108
4096 } // namespace compiler 4109 } // namespace compiler
4097 } // namespace internal 4110 } // namespace internal
4098 } // namespace v8 4111 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/wasm/module-decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698