Commit e869518f authored by Mythri A's avatar Mythri A Committed by Commit Bot

[turbofan] Set runtimestats table in piplinedata for PrepareJobs

For measuring the time spent in each phase of TurboFan we use
PipelineRunScope that adds a RuntimeCallStats scope with the correct counter.
PipelineRunScope uses the runtimestats table set on the PipelineData to
initialize the RuntimeCallStats scope. We correctly set the runtimestats on
the pipelineData when starting ExecuteJobs but don't set it on PrepareJobs.
This cl fixes it to also set runtimestats table on PrepareJobs. PrepareJobs
always run on main thread, so it should be safe to use the runtimestats table
on the isolate.

Change-Id: Ied211158a10197aabb94373967146089a48c2db0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1995386
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65737}
parent 37ccf35b
...@@ -1016,8 +1016,30 @@ PipelineCompilationJob::PipelineCompilationJob( ...@@ -1016,8 +1016,30 @@ PipelineCompilationJob::PipelineCompilationJob(
PipelineCompilationJob::~PipelineCompilationJob() { PipelineCompilationJob::~PipelineCompilationJob() {
} }
namespace {
// Ensure that the RuntimeStats table is set on the PipelineData for duration of
// the job phase and unset immediately afterwards. Each job needs to set the
// correct RuntimeCallStats table depending on whether it is running on a
// background or foreground thread.
class PipelineJobScope {
public:
PipelineJobScope(PipelineData* data, RuntimeCallStats* stats) : data_(data) {
data_->set_runtime_call_stats(stats);
}
~PipelineJobScope() { data_->set_runtime_call_stats(nullptr); }
private:
PipelineData* data_;
};
} // namespace
PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl( PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl(
Isolate* isolate) { Isolate* isolate) {
// Ensure that the RuntimeCallStats table of main thread is available for
// phases happening during PrepareJob.
PipelineJobScope scope(&data_, isolate->counters()->runtime_call_stats());
if (compilation_info()->bytecode_array()->length() > if (compilation_info()->bytecode_array()->length() >
FLAG_max_optimized_bytecode_size) { FLAG_max_optimized_bytecode_size) {
return AbortOptimization(BailoutReason::kFunctionTooBig); return AbortOptimization(BailoutReason::kFunctionTooBig);
...@@ -1093,28 +1115,11 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl( ...@@ -1093,28 +1115,11 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl(
return SUCCEEDED; return SUCCEEDED;
} }
namespace {
// Ensure that the RuntimeStats table is set on the PipelineData for duration of
// the Execute phase and unset immediately afterwards.
class PipelineExecuteJobScope {
public:
PipelineExecuteJobScope(PipelineData* data, RuntimeCallStats* stats)
: data_(data) {
data_->set_runtime_call_stats(stats);
}
~PipelineExecuteJobScope() { data_->set_runtime_call_stats(nullptr); }
private:
PipelineData* data_;
};
} // namespace
PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl( PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl(
RuntimeCallStats* stats) { RuntimeCallStats* stats) {
// Ensure that the RuntimeCallStats table is only available during execution // Ensure that the RuntimeCallStats table is only available during execution
// and not during finalization as that might be on a different thread. // and not during finalization as that might be on a different thread.
PipelineExecuteJobScope scope(&data_, stats); PipelineJobScope scope(&data_, stats);
if (compilation_info()->is_concurrent_inlining()) { if (compilation_info()->is_concurrent_inlining()) {
if (!pipeline_.CreateGraph()) { if (!pipeline_.CreateGraph()) {
return AbortOptimization(BailoutReason::kGraphBuildingFailed); return AbortOptimization(BailoutReason::kGraphBuildingFailed);
...@@ -1136,6 +1141,9 @@ PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl( ...@@ -1136,6 +1141,9 @@ PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl(
PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl( PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl(
Isolate* isolate) { Isolate* isolate) {
// Ensure that the RuntimeCallStats table of main thread is available for
// phases happening during PrepareJob.
PipelineJobScope scope(&data_, isolate->counters()->runtime_call_stats());
RuntimeCallTimerScope runtimeTimer( RuntimeCallTimerScope runtimeTimer(
isolate, RuntimeCallCounterId::kOptimizeFinalizePipelineJob); isolate, RuntimeCallCounterId::kOptimizeFinalizePipelineJob);
MaybeHandle<Code> maybe_code = pipeline_.FinalizeCode(); MaybeHandle<Code> maybe_code = pipeline_.FinalizeCode();
......
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