From 63aa1f1bdd6297ca8b710d652f91c89b94ad1e3a Mon Sep 17 00:00:00 2001 From: Peter Marshall Date: Tue, 4 Sep 2018 15:48:15 +0200 Subject: [PATCH] deps: backport detailed line info for CPU profiler [cpu-profiler] Add flag to always generate accurate line info. https://chromium.googlesource.com/v8/v8/+/ 56baf56790de439b3f69e887e94beb3b301ed77c [cpu-profiler] Turn on detailed line info for optimized code https://chromium.googlesource.com/v8/v8/+/ 84894ce6d2af7feb9e1f5574409355120887326c [cpu-profiler] Separate the flags for generating extra line information https://chromium.googlesource.com/v8/v8/+/ 30ff6719db441cc7ef220d449970cc169067e256 PR-URL: https://github.com/nodejs/node/pull/22688 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- common.gypi | 2 +- deps/v8/src/flag-definitions.h | 3 +++ deps/v8/src/isolate.cc | 4 ++++ deps/v8/src/isolate.h | 2 ++ deps/v8/src/optimized-compilation-info.cc | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common.gypi b/common.gypi index 594b43df3cc89c..65a3ff119103d3 100644 --- a/common.gypi +++ b/common.gypi @@ -29,7 +29,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.8', + 'v8_embedder_string': '-node.9', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/flag-definitions.h b/deps/v8/src/flag-definitions.h index 052869f3081ed6..4d5aa6f8854658 100644 --- a/deps/v8/src/flag-definitions.h +++ b/deps/v8/src/flag-definitions.h @@ -1243,6 +1243,9 @@ DEFINE_BOOL(log_function_events, false, DEFINE_BOOL(prof, false, "Log statistical profiling information (implies --log-code).") +DEFINE_BOOL(detailed_line_info, true, + "Always generate detailed line information for CPU profiling.") + #if defined(ANDROID) // Phones and tablets have processors that are much slower than desktop // and laptop computers for which current heuristics are tuned. diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc index b0a970305e9d4d..b33b713672a6d4 100644 --- a/deps/v8/src/isolate.cc +++ b/deps/v8/src/isolate.cc @@ -3247,6 +3247,10 @@ bool Isolate::use_optimizer() { !is_precise_count_code_coverage() && !is_block_count_code_coverage(); } +bool Isolate::NeedsDetailedOptimizedCodeLineInfo() const { + return NeedsSourcePositionsForProfiling() || FLAG_detailed_line_info; +} + bool Isolate::NeedsSourcePositionsForProfiling() const { return FLAG_trace_deopt || FLAG_trace_turbo || FLAG_trace_turbo_graph || FLAG_turbo_profiling || FLAG_perf_prof || is_profiling() || diff --git a/deps/v8/src/isolate.h b/deps/v8/src/isolate.h index 09aaf996849017..d94c0fde147f50 100644 --- a/deps/v8/src/isolate.h +++ b/deps/v8/src/isolate.h @@ -1044,6 +1044,8 @@ class Isolate : private HiddenFactory { bool NeedsSourcePositionsForProfiling() const; + bool NeedsDetailedOptimizedCodeLineInfo() const; + bool is_best_effort_code_coverage() const { return code_coverage_mode() == debug::Coverage::kBestEffort; } diff --git a/deps/v8/src/optimized-compilation-info.cc b/deps/v8/src/optimized-compilation-info.cc index 09b8a0edeae734..77730919f14dc2 100644 --- a/deps/v8/src/optimized-compilation-info.cc +++ b/deps/v8/src/optimized-compilation-info.cc @@ -38,7 +38,7 @@ OptimizedCompilationInfo::OptimizedCompilationInfo( // Collect source positions for optimized code when profiling or if debugger // is active, to be able to get more precise source positions at the price of // more memory consumption. - if (isolate->NeedsSourcePositionsForProfiling()) { + if (isolate->NeedsDetailedOptimizedCodeLineInfo()) { MarkAsSourcePositionsEnabled(); }