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

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

Issue 2929853003: Fix use of history timers in background threads. (Closed)
Patch Set: Merge with master Created 3 years, 6 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
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 3925 matching lines...) Expand 10 before | Expand all | Expand 10 after
3936 DCHECK(name_len > 0 && name_len < name_vector.length()); 3936 DCHECK(name_len > 0 && name_len < name_vector.length());
3937 3937
3938 char* index_name = zone->NewArray<char>(name_len); 3938 char* index_name = zone->NewArray<char>(name_len);
3939 memcpy(index_name, name_vector.start(), name_len); 3939 memcpy(index_name, name_vector.start(), name_len);
3940 return Vector<const char>(index_name, name_len); 3940 return Vector<const char>(index_name, name_len);
3941 } 3941 }
3942 } // namespace 3942 } // namespace
3943 3943
3944 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, 3944 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
3945 wasm::ModuleBytesEnv* module_env, 3945 wasm::ModuleBytesEnv* module_env,
3946 const wasm::WasmFunction* function, 3946 const wasm::WasmFunction* function)
3947 bool is_sync)
3948 : WasmCompilationUnit( 3947 : WasmCompilationUnit(
3949 isolate, &module_env->module_env, 3948 isolate, &module_env->module_env,
3950 wasm::FunctionBody{ 3949 wasm::FunctionBody{
3951 function->sig, module_env->wire_bytes.start(), 3950 function->sig, module_env->wire_bytes.start(),
3952 module_env->wire_bytes.start() + function->code.offset(), 3951 module_env->wire_bytes.start() + function->code.offset(),
3953 module_env->wire_bytes.start() + function->code.end_offset()}, 3952 module_env->wire_bytes.start() + function->code.end_offset()},
3954 module_env->wire_bytes.GetNameOrNull(function), function->func_index, 3953 module_env->wire_bytes.GetNameOrNull(function),
3955 is_sync) {} 3954 function->func_index) {}
3956 3955
3957 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, 3956 WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate,
3958 wasm::ModuleEnv* module_env, 3957 wasm::ModuleEnv* module_env,
3959 wasm::FunctionBody body, 3958 wasm::FunctionBody body,
3960 wasm::WasmName name, int index, 3959 wasm::WasmName name, int index)
3961 bool is_sync)
3962 : isolate_(isolate), 3960 : isolate_(isolate),
3963 module_env_(module_env), 3961 module_env_(module_env),
3964 func_body_(body), 3962 func_body_(body),
3965 func_name_(name), 3963 func_name_(name),
3966 is_sync_(is_sync),
3967 centry_stub_(CEntryStub(isolate, 1).GetCode()), 3964 centry_stub_(CEntryStub(isolate, 1).GetCode()),
3968 func_index_(index) {} 3965 func_index_(index) {}
3969 3966
3970 void WasmCompilationUnit::ExecuteCompilation() { 3967 void WasmCompilationUnit::ExecuteCompilation() {
3971 if (is_sync_) { 3968 HistogramTimerScope wasm_compile_function_time_scope(
3972 // TODO(karlschimpf): Make this work when asynchronous. 3969 isolate_->counters()->wasm_compile_function_time());
3973 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
3974 HistogramTimerScope wasm_compile_function_time_scope(
3975 isolate_->counters()->wasm_compile_function_time());
3976 }
3977 ExecuteCompilationInternal(); 3970 ExecuteCompilationInternal();
3978 // Record the memory cost this unit places on the system until 3971 // Record the memory cost this unit places on the system until
3979 // it is finalized. That may be "0" in error cases. 3972 // it is finalized. That may be "0" in error cases.
3980 if (job_) { 3973 if (job_) {
3981 size_t cost = job_->AllocatedMemory(); 3974 size_t cost = job_->AllocatedMemory();
3982 set_memory_cost(cost); 3975 set_memory_cost(cost);
3983 } 3976 }
3984 } 3977 }
3985 3978
3986 void WasmCompilationUnit::ExecuteCompilationInternal() { 3979 void WasmCompilationUnit::ExecuteCompilationInternal() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 GetDebugName(compilation_zone_.get(), func_name_, func_index_), isolate_, 4023 GetDebugName(compilation_zone_.get(), func_name_, func_index_), isolate_,
4031 compilation_zone_.get(), Code::ComputeFlags(Code::WASM_FUNCTION))); 4024 compilation_zone_.get(), Code::ComputeFlags(Code::WASM_FUNCTION)));
4032 ZoneVector<trap_handler::ProtectedInstructionData> protected_instructions( 4025 ZoneVector<trap_handler::ProtectedInstructionData> protected_instructions(
4033 compilation_zone_.get()); 4026 compilation_zone_.get());
4034 4027
4035 job_.reset(Pipeline::NewWasmCompilationJob( 4028 job_.reset(Pipeline::NewWasmCompilationJob(
4036 info_.get(), jsgraph_, descriptor, source_positions, 4029 info_.get(), jsgraph_, descriptor, source_positions,
4037 &protected_instructions, !module_env_->module->is_wasm())); 4030 &protected_instructions, !module_env_->module->is_wasm()));
4038 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; 4031 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED;
4039 // TODO(bradnelson): Improve histogram handling of size_t. 4032 // TODO(bradnelson): Improve histogram handling of size_t.
4040 if (is_sync_) 4033 isolate_->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
4041 // TODO(karlschimpf): Make this work when asynchronous. 4034 static_cast<int>(jsgraph_->graph()->zone()->allocation_size()));
4042 // https://bugs.chromium.org/p/v8/issues/detail?id=6361
4043 isolate_->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
4044 static_cast<int>(jsgraph_->graph()->zone()->allocation_size()));
4045 4035
4046 if (FLAG_trace_wasm_decode_time) { 4036 if (FLAG_trace_wasm_decode_time) {
4047 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); 4037 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF();
4048 PrintF( 4038 PrintF(
4049 "wasm-compilation phase 1 ok: %u bytes, %0.3f ms decode, %zu nodes, " 4039 "wasm-compilation phase 1 ok: %u bytes, %0.3f ms decode, %zu nodes, "
4050 "%0.3f ms pipeline\n", 4040 "%0.3f ms pipeline\n",
4051 static_cast<unsigned>(func_body_.end - func_body_.start), decode_ms, 4041 static_cast<unsigned>(func_body_.end - func_body_.start), decode_ms,
4052 node_count, pipeline_ms); 4042 node_count, pipeline_ms);
4053 } 4043 }
4054 // The graph zone is about to get out of scope. Avoid invalid references. 4044 // The graph zone is about to get out of scope. Avoid invalid references.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4105 wasm::ErrorThrower* thrower, Isolate* isolate, 4095 wasm::ErrorThrower* thrower, Isolate* isolate,
4106 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) { 4096 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) {
4107 WasmCompilationUnit unit(isolate, module_env, function); 4097 WasmCompilationUnit unit(isolate, module_env, function);
4108 unit.ExecuteCompilation(); 4098 unit.ExecuteCompilation();
4109 return unit.FinishCompilation(thrower); 4099 return unit.FinishCompilation(thrower);
4110 } 4100 }
4111 4101
4112 } // namespace compiler 4102 } // namespace compiler
4113 } // namespace internal 4103 } // namespace internal
4114 } // namespace v8 4104 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/counters.h » ('j') | src/counters.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698