Commit 7bd99ccf authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Parsing] Fix RCS tracing for deciding if preparsing is tracking variables.

With FLAG_preparser_scope_analysis enabled we now always track
unresolved variables in the preparser. Fix the logic for deciding on
the correct RCS tracing category to be based on what the preparser does.

Change-Id: If691d51e6a2c09e554e4d96c10c37060cc7cca96
Reviewed-on: https://chromium-review.googlesource.com/1193303Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55460}
parent 38e7b9b8
...@@ -2670,19 +2670,16 @@ FunctionLiteral* Parser::ParseFunctionLiteral( ...@@ -2670,19 +2670,16 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
} }
if (V8_UNLIKELY(FLAG_runtime_stats)) { if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (should_preparse) { if (should_preparse) {
RuntimeCallCounterId counter_id = const RuntimeCallCounterId counters[2][2] = {
parsing_on_main_thread_ {RuntimeCallCounterId::kPreParseBackgroundNoVariableResolution,
? RuntimeCallCounterId::kPreParseWithVariableResolution RuntimeCallCounterId::kPreParseNoVariableResolution},
: RuntimeCallCounterId:: {RuntimeCallCounterId::kPreParseBackgroundWithVariableResolution,
kPreParseBackgroundWithVariableResolution; RuntimeCallCounterId::kPreParseWithVariableResolution}};
if (is_top_level) {
counter_id = parsing_on_main_thread_
? RuntimeCallCounterId::kPreParseNoVariableResolution
: RuntimeCallCounterId::
kPreParseBackgroundNoVariableResolution;
}
if (runtime_call_stats_) { if (runtime_call_stats_) {
runtime_call_stats_->CorrectCurrentCounterId(counter_id); bool tracked_variables = PreParser::ShouldTrackUnresolvedVariables(
is_lazy_top_level_function);
runtime_call_stats_->CorrectCurrentCounterId(
counters[tracked_variables][parsing_on_main_thread_]);
} }
} }
} }
......
...@@ -123,19 +123,21 @@ PreParser::PreParseResult PreParser::PreParseFunction( ...@@ -123,19 +123,21 @@ PreParser::PreParseResult PreParser::PreParseFunction(
int script_id) { int script_id) {
DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type()); DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type());
use_counts_ = use_counts; use_counts_ = use_counts;
DCHECK(!track_unresolved_variables_);
track_unresolved_variables_ = is_inner_function;
set_script_id(script_id); set_script_id(script_id);
#ifdef DEBUG #ifdef DEBUG
function_scope->set_is_being_lazily_parsed(true); function_scope->set_is_being_lazily_parsed(true);
#endif #endif
DCHECK(!track_unresolved_variables_);
track_unresolved_variables_ =
ShouldTrackUnresolvedVariables(is_inner_function);
// Start collecting data for a new function which might contain skippable // Start collecting data for a new function which might contain skippable
// functions. // functions.
std::unique_ptr<ProducedPreParsedScopeData::DataGatheringScope> std::unique_ptr<ProducedPreParsedScopeData::DataGatheringScope>
produced_preparsed_scope_data_scope; produced_preparsed_scope_data_scope;
if (FLAG_preparser_scope_analysis && !IsArrowFunction(kind)) { if (FLAG_preparser_scope_analysis && !IsArrowFunction(kind)) {
track_unresolved_variables_ = true; DCHECK(track_unresolved_variables_);
produced_preparsed_scope_data_scope.reset( produced_preparsed_scope_data_scope.reset(
new ProducedPreParsedScopeData::DataGatheringScope(function_scope, new ProducedPreParsedScopeData::DataGatheringScope(function_scope,
this)); this));
......
...@@ -979,6 +979,10 @@ class PreParser : public ParserBase<PreParser> { ...@@ -979,6 +979,10 @@ class PreParser : public ParserBase<PreParser> {
ProducedPreParsedScopeData** produced_preparser_scope_data, ProducedPreParsedScopeData** produced_preparser_scope_data,
int script_id); int script_id);
V8_INLINE static bool ShouldTrackUnresolvedVariables(bool is_inner_function) {
return FLAG_preparser_scope_analysis || is_inner_function;
}
ProducedPreParsedScopeData* produced_preparsed_scope_data() const { ProducedPreParsedScopeData* produced_preparsed_scope_data() const {
return produced_preparsed_scope_data_; return produced_preparsed_scope_data_;
} }
......
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