Commit 6ef1551e authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Parser] Move background parsing runtime-call-stack logging.

This moves the logging of the RCS event for background parsing tasks out
of the parser and performs it at the end of the background parsing task.
This is necessary in order to log background compile RCS events which happen
after parsing.

BUG=v8:5203

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ie216eeade0279d8243818a8eb59309969775823c
Reviewed-on: https://chromium-review.googlesource.com/776669Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49483}
parent a76fe168
......@@ -2609,7 +2609,7 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
source->info->set_script(script);
source->parser->UpdateStatistics(isolate, script);
source->info->UpdateStatisticsAfterBackgroundParse(isolate);
source->info->UpdateBackgroundParseStatisticsOnMainThread(isolate);
source->parser->HandleSourceURLComments(isolate, script);
i::Handle<i::SharedFunctionInfo> result;
......
......@@ -283,7 +283,7 @@ void UnoptimizedCompileJob::FinalizeOnMainThread(Isolate* isolate) {
Handle<Script> script(Script::cast(shared_->script()), isolate);
parse_info_->set_script(script);
parser_->UpdateStatistics(isolate, script);
parse_info_->UpdateStatisticsAfterBackgroundParse(isolate);
parse_info_->UpdateBackgroundParseStatisticsOnMainThread(isolate);
parser_->HandleSourceURLComments(isolate, script);
{
......
......@@ -96,6 +96,8 @@ void BackgroundParsingTask::Run() {
script_data_ = nullptr;
}
source_->info->EmitBackgroundParseStatisticsOnBackgroundThread();
source_->info->set_on_background_thread(false);
source_->info->set_stack_limit(old_stack_limit);
}
......
......@@ -163,7 +163,21 @@ void ParseInfo::InitFromIsolate(Isolate* isolate) {
if (isolate->is_collecting_type_profile()) set_collect_type_profile();
}
void ParseInfo::UpdateStatisticsAfterBackgroundParse(Isolate* isolate) {
void ParseInfo::EmitBackgroundParseStatisticsOnBackgroundThread() {
// If runtime call stats was enabled by tracing, emit a trace event at the
// end of background parsing on the background thread.
if (runtime_call_stats_ &&
(FLAG_runtime_stats &
v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING)) {
auto value = v8::tracing::TracedValue::Create();
runtime_call_stats_->Dump(value.get());
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"),
"V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD,
"runtime-call-stats", std::move(value));
}
}
void ParseInfo::UpdateBackgroundParseStatisticsOnMainThread(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();
......
......@@ -241,7 +241,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
}
}
void UpdateStatisticsAfterBackgroundParse(Isolate* isolate);
void EmitBackgroundParseStatisticsOnBackgroundThread();
void UpdateBackgroundParseStatisticsOnMainThread(Isolate* isolate);
private:
// Various configuration flags for parsing.
......
......@@ -3531,15 +3531,6 @@ void Parser::ParseOnBackground(ParseInfo* info) {
if (result != nullptr) *info->cached_data() = logger.GetScriptData();
log_ = nullptr;
}
if (runtime_call_stats_ &&
(FLAG_runtime_stats &
v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING)) {
auto value = v8::tracing::TracedValue::Create();
runtime_call_stats_->Dump(value.get());
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"),
"V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD,
"runtime-call-stats", std::move(value));
}
}
Parser::TemplateLiteralState Parser::OpenTemplateLiteral(int pos) {
......
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