Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index 92822d477aacff987d06f3f74fd987e57232f069..232cc757e5c274340e938ea5ce5b4b4257fe6d4a 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -586,7 +586,8 @@ Expression* Parser::NewV8Intrinsic(const AstRawString* name, |
Parser::Parser(ParseInfo* info) |
: ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(), |
- info->extension(), info->ast_value_factory()), |
+ info->extension(), info->ast_value_factory(), |
+ info->isolate()->counters()->runtime_call_stats()), |
scanner_(info->unicode_cache()), |
reusable_preparser_(nullptr), |
original_scope_(nullptr), |
@@ -670,7 +671,9 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { |
// called in the main thread. |
DCHECK(parsing_on_main_thread_); |
- RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::ParseProgram); |
+ RuntimeCallTimerScope runtime_timer( |
+ runtime_call_stats_, info->is_eval() ? &RuntimeCallStats::ParseEval |
+ : &RuntimeCallStats::ParseProgram); |
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseProgram"); |
Handle<String> source(String::cast(info->script()->source())); |
isolate->counters()->total_parse_size()->Increment(source->length()); |
@@ -833,7 +836,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info) { |
// It's OK to use the Isolate & counters here, since this function is only |
// called in the main thread. |
DCHECK(parsing_on_main_thread_); |
- RuntimeCallTimerScope runtime_timer(isolate, |
+ RuntimeCallTimerScope runtime_timer(runtime_call_stats_, |
&RuntimeCallStats::ParseFunction); |
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseFunction"); |
Handle<String> source(String::cast(info->script()->source())); |
@@ -2580,6 +2583,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral( |
bool is_lazy_top_level_function = |
can_preparse && impl()->AllowsLazyParsingWithoutUnresolvedVariables(); |
+ RuntimeCallTimerScope runtime_timer(runtime_call_stats_, |
+ &RuntimeCallStats::ParseFunctionLiteral); |
+ |
// Determine whether we can still lazy parse the inner function. |
// The preconditions are: |
// - Lazy compilation has to be enabled. |
@@ -2697,6 +2703,13 @@ FunctionLiteral* Parser::ParseFunctionLiteral( |
: (use_temp_zone ? "Preparse resolution" : "Full parse"), |
scope->start_position(), scope->end_position(), |
function_name->byte_length(), function_name->raw_data()); |
+ if (is_lazy_top_level_function) { |
+ CHANGE_CURRENT_RUNTIME_COUNTER(runtime_call_stats_, |
+ PreParseNoVariableResolution); |
+ } else if (use_temp_zone) { |
+ CHANGE_CURRENT_RUNTIME_COUNTER(runtime_call_stats_, |
+ PreParseWithVariableResolution); |
+ } |
} |
// Validate function name. We can do this only after parsing the function, |
@@ -3291,8 +3304,8 @@ PreParser::PreParseResult Parser::ParseFunctionWithPreParser( |
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse"); |
if (reusable_preparser_ == NULL) { |
- reusable_preparser_ = |
- new PreParser(zone(), &scanner_, ast_value_factory(), stack_limit_); |
+ reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), |
+ runtime_call_stats_, stack_limit_); |
reusable_preparser_->set_allow_lazy(true); |
#define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); |
SET_ALLOW(natives); |
@@ -3810,6 +3823,11 @@ void Parser::ParseOnBackground(ParseInfo* info) { |
ParserLogger logger; |
if (produce_cached_parse_data()) log_ = &logger; |
+ RuntimeCallStats* default_runtime_call_stats = runtime_call_stats_; |
+ if (FLAG_runtime_call_stats) { |
lpy
2016/11/09 16:47:42
How about using FLAG_runtime_stats here? I prefer
Camillo Bruni
2016/11/10 10:49:40
done.
|
+ // Create separate runtime stats for background parsing. |
+ runtime_call_stats_ = new (zone()) RuntimeCallStats(); |
+ } |
std::unique_ptr<Utf16CharacterStream> stream; |
Utf16CharacterStream* stream_ptr; |
@@ -3849,6 +3867,13 @@ void Parser::ParseOnBackground(ParseInfo* info) { |
if (result != NULL) *info->cached_data() = logger.GetScriptData(); |
log_ = NULL; |
} |
+ if (FLAG_runtime_call_stats) { |
lpy
2016/11/09 16:47:42
Same here.
Camillo Bruni
2016/11/10 10:49:40
done.
|
+ // Copy over the counters from the background thread to the main counters on |
+ // the isolate. |
+ // TODO(cbruni,lpy): properly attach the runtime stats to the trace for |
+ // background parsing. |
+ default_runtime_call_stats->Add(runtime_call_stats_); |
+ } |
} |
Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) { |