Commit 8f4e8c0a authored by Wiktor Garbacz's avatar Wiktor Garbacz Committed by Commit Bot

Fix runtime_call_stats for background parsing.

BUG=v8:6093

Change-Id: I365fbd7c3f33e2de47e0a84ee3ea631b4ffa6d35
Reviewed-on: https://chromium-review.googlesource.com/488243Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarDaniel Vogelheim <vogelheim@chromium.org>
Commit-Queue: Wiktor Garbacz <wiktorg@google.com>
Cr-Commit-Position: refs/heads/master@{#45013}
parent c2f4498f
......@@ -2470,6 +2470,7 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
source->parser->ReportErrors(isolate, script);
}
source->parser->UpdateStatistics(isolate, script);
source->info->UpdateStatisticsAfterBackgroundParse(isolate);
i::DeferredHandleScope deferred_handle_scope(isolate);
{
......
......@@ -37,6 +37,9 @@ BackgroundParsingTask::BackgroundParsingTask(
info->set_unicode_cache(&source_->unicode_cache);
info->set_compile_options(options);
info->set_allow_lazy_parsing();
if (V8_UNLIKELY(FLAG_runtime_call_stats)) {
info->set_runtime_call_stats(new (info->zone()) RuntimeCallStats());
}
source_->info->set_cached_data(&script_data_);
// Parser needs to stay alive for finalizing the parsing on the main
......
......@@ -90,6 +90,10 @@ CompilerDispatcherJob::CompilerDispatcherJob(
parse_info_->set_language_mode(language_mode);
parse_info_->set_function_literal_id(function_literal_id);
parse_info_->set_ast_string_constants(ast_string_constants);
if (V8_UNLIKELY(FLAG_runtime_call_stats)) {
parse_info_->set_runtime_call_stats(new (parse_info_->zone())
RuntimeCallStats());
}
parse_info_->set_native(native);
parse_info_->set_module(module);
......@@ -266,6 +270,10 @@ void CompilerDispatcherJob::PrepareToParseOnMainThread() {
parse_info_->set_unicode_cache(unicode_cache_.get());
parse_info_->set_language_mode(shared_->language_mode());
parse_info_->set_function_literal_id(shared_->function_literal_id());
if (V8_UNLIKELY(FLAG_runtime_call_stats)) {
parse_info_->set_runtime_call_stats(new (parse_info_->zone())
RuntimeCallStats());
}
parser_.reset(new Parser(parse_info_.get()));
MaybeHandle<ScopeInfo> outer_scope_info;
......@@ -334,6 +342,7 @@ bool CompilerDispatcherJob::FinalizeParsingOnMainThread() {
status_ = CompileJobStatus::kReadyToAnalyze;
}
parser_->UpdateStatistics(isolate_, script);
parse_info_->UpdateStatisticsAfterBackgroundParse(isolate_);
DeferredHandleScope scope(isolate_);
{
......
......@@ -164,6 +164,20 @@ void ParseInfo::InitFromIsolate(Isolate* isolate) {
set_ast_string_constants(isolate->ast_string_constants());
}
void ParseInfo::UpdateStatisticsAfterBackgroundParse(Isolate* isolate) {
// Copy over the counters from the background thread to the main counters on
// the isolate.
RuntimeCallStats* main_call_stats = isolate->counters()->runtime_call_stats();
if (FLAG_runtime_stats ==
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE) {
DCHECK_NE(main_call_stats, runtime_call_stats());
DCHECK_NOT_NULL(main_call_stats);
DCHECK_NOT_NULL(runtime_call_stats());
main_call_stats->Add(runtime_call_stats());
}
set_runtime_call_stats(main_call_stats);
}
#ifdef DEBUG
bool ParseInfo::script_is_native() const {
return script_->type() == Script::TYPE_NATIVE;
......
......@@ -243,6 +243,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
}
}
void UpdateStatisticsAfterBackgroundParse(Isolate* isolate);
#ifdef DEBUG
bool script_is_native() const;
#endif // DEBUG
......
......@@ -3499,13 +3499,6 @@ void Parser::UpdateStatistics(Isolate* isolate, Handle<Script> script) {
}
isolate->counters()->total_preparse_skipped()->Increment(
total_preparse_skipped_);
if (!parsing_on_main_thread_ &&
FLAG_runtime_stats ==
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE) {
// Copy over the counters from the background thread to the main counters on
// the isolate.
isolate->counters()->runtime_call_stats()->Add(runtime_call_stats_);
}
}
void Parser::ParseOnBackground(ParseInfo* info) {
......@@ -3522,10 +3515,6 @@ void Parser::ParseOnBackground(ParseInfo* info) {
compile_options_ = ScriptCompiler::kNoCompileOptions;
}
}
if (FLAG_runtime_stats) {
// Create separate runtime stats for background parsing.
runtime_call_stats_ = new (zone()) RuntimeCallStats();
}
std::unique_ptr<Utf16CharacterStream> stream;
Utf16CharacterStream* stream_ptr;
......
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