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(
}
if (V8_UNLIKELY(FLAG_runtime_stats)) {
if (should_preparse) {
RuntimeCallCounterId counter_id =
parsing_on_main_thread_
? RuntimeCallCounterId::kPreParseWithVariableResolution
: RuntimeCallCounterId::
kPreParseBackgroundWithVariableResolution;
if (is_top_level) {
counter_id = parsing_on_main_thread_
? RuntimeCallCounterId::kPreParseNoVariableResolution
: RuntimeCallCounterId::
kPreParseBackgroundNoVariableResolution;
}
const RuntimeCallCounterId counters[2][2] = {
{RuntimeCallCounterId::kPreParseBackgroundNoVariableResolution,
RuntimeCallCounterId::kPreParseNoVariableResolution},
{RuntimeCallCounterId::kPreParseBackgroundWithVariableResolution,
RuntimeCallCounterId::kPreParseWithVariableResolution}};
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(
int script_id) {
DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type());
use_counts_ = use_counts;
DCHECK(!track_unresolved_variables_);
track_unresolved_variables_ = is_inner_function;
set_script_id(script_id);
#ifdef DEBUG
function_scope->set_is_being_lazily_parsed(true);
#endif
DCHECK(!track_unresolved_variables_);
track_unresolved_variables_ =
ShouldTrackUnresolvedVariables(is_inner_function);
// Start collecting data for a new function which might contain skippable
// functions.
std::unique_ptr<ProducedPreParsedScopeData::DataGatheringScope>
produced_preparsed_scope_data_scope;
if (FLAG_preparser_scope_analysis && !IsArrowFunction(kind)) {
track_unresolved_variables_ = true;
DCHECK(track_unresolved_variables_);
produced_preparsed_scope_data_scope.reset(
new ProducedPreParsedScopeData::DataGatheringScope(function_scope,
this));
......
......@@ -979,6 +979,10 @@ class PreParser : public ParserBase<PreParser> {
ProducedPreParsedScopeData** produced_preparser_scope_data,
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 {
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