Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit fe9f30c

Browse files
yuanhuihuicommit-bot@chromium.org
authored andcommitted
[timeline] support vm events available to systrace
more detail: dart-lang/sdk#39757 Signed-off-by: yuanhuihui <gityuan@gmail.com> Bug: dart-lang/sdk#39757 Change-Id: I6174500796289ffcfb7a53d3f897c5d7f82932ae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128200 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
1 parent a5caa52 commit fe9f30c

File tree

14 files changed

+73
-132
lines changed

14 files changed

+73
-132
lines changed

runtime/vm/class_finalizer.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,11 +1121,11 @@ void ClassFinalizer::FinalizeClass(const Class& cls) {
11211121
}
11221122

11231123
#if defined(SUPPORT_TIMELINE)
1124-
TimelineDurationScope tds(thread, Timeline::GetCompilerStream(),
1125-
"FinalizeClass");
1126-
if (tds.enabled()) {
1127-
tds.SetNumArguments(1);
1128-
tds.CopyArgument(0, "class", cls.ToCString());
1124+
TimelineBeginEndScope tbes(thread, Timeline::GetCompilerStream(),
1125+
"FinalizeClass");
1126+
if (tbes.enabled()) {
1127+
tbes.SetNumArguments(1);
1128+
tbes.CopyArgument(0, "class", cls.ToCString());
11291129
}
11301130
#endif // defined(SUPPORT_TIMELINE)
11311131

@@ -1464,7 +1464,7 @@ void ClassFinalizer::SortClasses() {
14641464

14651465
RemapClassIds(old_to_new_cid);
14661466
delete[] old_to_new_cid;
1467-
RehashTypes(); // Types use cid's as part of their hashes.
1467+
RehashTypes(); // Types use cid's as part of their hashes.
14681468
I->RehashConstants(); // Const objects use cid's as part of their hashes.
14691469
}
14701470

runtime/vm/compiler/frontend/bytecode_reader.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,13 +3300,13 @@ RawError* BytecodeReader::ReadFunctionBytecode(Thread* thread,
33003300
VMTagScope tagScope(thread, VMTag::kLoadBytecodeTagId);
33013301

33023302
#if defined(SUPPORT_TIMELINE)
3303-
TimelineDurationScope tds(thread, Timeline::GetCompilerStream(),
3304-
"BytecodeReader::ReadFunctionBytecode");
3303+
TimelineBeginEndScope tbes(thread, Timeline::GetCompilerStream(),
3304+
"BytecodeReader::ReadFunctionBytecode");
33053305
// This increases bytecode reading time by ~7%, so only keep it around for
33063306
// debugging.
33073307
#if defined(DEBUG)
3308-
tds.SetNumArguments(1);
3309-
tds.CopyArgument(0, "Function", function.ToQualifiedCString());
3308+
tbes.SetNumArguments(1);
3309+
tbes.CopyArgument(0, "Function", function.ToQualifiedCString());
33103310
#endif // defined(DEBUG)
33113311
#endif // !defined(SUPPORT_TIMELINE)
33123312

runtime/vm/dart.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
199199
Zone::Init();
200200
#if defined(SUPPORT_TIMELINE)
201201
Timeline::Init();
202-
TimelineDurationScope tds(Timeline::GetVMStream(), "Dart::Init");
202+
TimelineBeginEndScope tbes(Timeline::GetVMStream(), "Dart::Init");
203203
#endif
204204
Isolate::InitVM();
205205
IsolateGroup::Init();
@@ -263,7 +263,7 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
263263
SubtypeTestCache::Init();
264264
if (vm_isolate_snapshot != NULL) {
265265
#if defined(SUPPORT_TIMELINE)
266-
TimelineDurationScope tds(Timeline::GetVMStream(), "ReadVMSnapshot");
266+
TimelineBeginEndScope tbes(Timeline::GetVMStream(), "ReadVMSnapshot");
267267
#endif
268268
ASSERT(snapshot != nullptr);
269269
vm_snapshot_kind_ = snapshot->kind();
@@ -307,10 +307,10 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
307307

308308
Object::FinishInit(vm_isolate_);
309309
#if defined(SUPPORT_TIMELINE)
310-
if (tds.enabled()) {
311-
tds.SetNumArguments(2);
312-
tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
313-
tds.FormatArgument(
310+
if (tbes.enabled()) {
311+
tbes.SetNumArguments(2);
312+
tbes.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
313+
tbes.FormatArgument(
314314
1, "heapSize", "%" Pd64,
315315
vm_isolate_->heap()->UsedInWords(Heap::kOld) * kWordSize);
316316
}
@@ -356,7 +356,7 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
356356
#endif
357357
{
358358
#if defined(SUPPORT_TIMELINE)
359-
TimelineDurationScope tds(Timeline::GetVMStream(), "FinalizeVMIsolate");
359+
TimelineBeginEndScope tbes(Timeline::GetVMStream(), "FinalizeVMIsolate");
360360
#endif
361361
Object::FinalizeVMIsolate(vm_isolate_);
362362
}
@@ -644,10 +644,10 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_data,
644644
Thread* T = Thread::Current();
645645
Isolate* I = T->isolate();
646646
#if defined(SUPPORT_TIMELINE)
647-
TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
648-
"InitializeIsolate");
649-
tds.SetNumArguments(1);
650-
tds.CopyArgument(0, "isolateName", I->name());
647+
TimelineBeginEndScope tbes(T, Timeline::GetIsolateStream(),
648+
"InitializeIsolate");
649+
tbes.SetNumArguments(1);
650+
tbes.CopyArgument(0, "isolateName", I->name());
651651
#endif
652652
ASSERT(I != NULL);
653653
StackZone zone(T);
@@ -662,8 +662,8 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_data,
662662
if ((snapshot_data != NULL) && kernel_buffer == NULL) {
663663
// Read the snapshot and setup the initial state.
664664
#if defined(SUPPORT_TIMELINE)
665-
TimelineDurationScope tds(T, Timeline::GetIsolateStream(),
666-
"ReadIsolateSnapshot");
665+
TimelineBeginEndScope tbes(T, Timeline::GetIsolateStream(),
666+
"ReadIsolateSnapshot");
667667
#endif
668668
// TODO(turnidge): Remove once length is not part of the snapshot.
669669
const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_data);
@@ -690,11 +690,11 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_data,
690690
ReversePcLookupCache::BuildAndAttachToIsolate(I);
691691

692692
#if defined(SUPPORT_TIMELINE)
693-
if (tds.enabled()) {
694-
tds.SetNumArguments(2);
695-
tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
696-
tds.FormatArgument(1, "heapSize", "%" Pd64,
697-
I->heap()->UsedInWords(Heap::kOld) * kWordSize);
693+
if (tbes.enabled()) {
694+
tbes.SetNumArguments(2);
695+
tbes.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length());
696+
tbes.FormatArgument(1, "heapSize", "%" Pd64,
697+
I->heap()->UsedInWords(Heap::kOld) * kWordSize);
698698
}
699699
#endif // !defined(PRODUCT)
700700
if (FLAG_trace_isolates) {

runtime/vm/dart_api_impl.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,8 +1450,7 @@ DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port,
14501450
intptr_t response_length;
14511451
bool success = Dart_InvokeVMServiceMethod(
14521452
reinterpret_cast<uint8_t*>(method), method_length,
1453-
reinterpret_cast<uint8_t**>(&response), &response_length,
1454-
error);
1453+
reinterpret_cast<uint8_t**>(&response), &response_length, error);
14551454
free(response);
14561455
return success;
14571456
#endif
@@ -6189,8 +6188,8 @@ Dart_CreateAppAOTSnapshotAsElf(Dart_StreamingWriteCallback callback,
61896188
DARTSCOPE(Thread::Current());
61906189
API_TIMELINE_DURATION(T);
61916190

6192-
NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(),
6193-
"WriteAppAOTSnapshot"));
6191+
NOT_IN_PRODUCT(TimelineBeginEndScope tbes2(T, Timeline::GetIsolateStream(),
6192+
"WriteAppAOTSnapshot"));
61946193

61956194
uint8_t* vm_snapshot_data_buffer = nullptr;
61966195
uint8_t* vm_snapshot_instructions_buffer = nullptr;

runtime/vm/dart_api_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ const char* CanonicalFunction(const char* func);
106106

107107
#ifdef SUPPORT_TIMELINE
108108
#define API_TIMELINE_DURATION(thread) \
109-
TimelineDurationScope api_tds(thread, Timeline::GetAPIStream(), CURRENT_FUNC)
109+
TimelineBeginEndScope api_tbes(thread, Timeline::GetAPIStream(), CURRENT_FUNC)
110110
#define API_TIMELINE_DURATION_BASIC(thread) \
111111
API_TIMELINE_DURATION(thread); \
112-
api_tds.SetNumArguments(1); \
113-
api_tds.CopyArgument(0, "mode", "basic");
112+
api_tbes.SetNumArguments(1); \
113+
api_tbes.CopyArgument(0, "mode", "basic");
114114

115115
#define API_TIMELINE_BEGIN_END(thread) \
116116
TimelineBeginEndScope api_tbes(thread, Timeline::GetAPIStream(), CURRENT_FUNC)

runtime/vm/heap/heap.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ void Heap::EvacuateNewSpace(Thread* thread, GCReason reason) {
476476
new_space_.Evacuate();
477477
RecordAfterGC(kScavenge);
478478
PrintStats();
479-
NOT_IN_PRODUCT(PrintStatsToTimeline(&tds, reason));
479+
NOT_IN_PRODUCT(PrintStatsToTimeline(&tbes, reason));
480480
EndNewSpaceGC();
481481
}
482482
}
@@ -499,7 +499,7 @@ void Heap::CollectNewSpaceGarbage(Thread* thread, GCReason reason) {
499499
new_space_.Scavenge();
500500
RecordAfterGC(kScavenge);
501501
PrintStats();
502-
NOT_IN_PRODUCT(PrintStatsToTimeline(&tds, reason));
502+
NOT_IN_PRODUCT(PrintStatsToTimeline(&tbes, reason));
503503
EndNewSpaceGC();
504504
}
505505
if (reason == kNewSpace) {
@@ -535,7 +535,7 @@ void Heap::CollectOldSpaceGarbage(Thread* thread,
535535
old_space_.CollectGarbage(type == kMarkCompact, true /* finish */);
536536
RecordAfterGC(type);
537537
PrintStats();
538-
NOT_IN_PRODUCT(PrintStatsToTimeline(&tds, reason));
538+
NOT_IN_PRODUCT(PrintStatsToTimeline(&tbes, reason));
539539
// Some Code objects may have been collected so invalidate handler cache.
540540
thread->isolate()->handler_info_cache()->Clear();
541541
thread->isolate()->catch_entry_moves_cache()->Clear();

runtime/vm/heap/pages.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ void PageSpace::CollectGarbage(bool compact, bool finalize) {
10011001
return; // Barrier not implemented.
10021002
#else
10031003
if (!enable_concurrent_mark()) return; // Disabled.
1004-
if (FLAG_marker_tasks == 0) return; // Disabled.
1004+
if (FLAG_marker_tasks == 0) return; // Disabled.
10051005
#endif
10061006
}
10071007

@@ -1530,16 +1530,16 @@ void PageSpaceController::RecordUpdate(SpaceUsage before,
15301530
const char* reason) {
15311531
#if defined(SUPPORT_TIMELINE)
15321532
TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "UpdateGrowthLimit");
1533-
tds.SetNumArguments(5);
1534-
tds.CopyArgument(0, "Reason", reason);
1535-
tds.FormatArgument(1, "Before.CombinedCapacity (kB)", "%" Pd "",
1536-
RoundWordsToKB(before.CombinedCapacityInWords()));
1537-
tds.FormatArgument(2, "After.CombinedCapacity (kB)", "%" Pd "",
1538-
RoundWordsToKB(after.CombinedCapacityInWords()));
1539-
tds.FormatArgument(3, "Threshold (kB)", "%" Pd "",
1540-
RoundWordsToKB(gc_threshold_in_words_));
1541-
tds.FormatArgument(4, "Idle Threshold (kB)", "%" Pd "",
1542-
RoundWordsToKB(idle_gc_threshold_in_words_));
1533+
tbes.SetNumArguments(5);
1534+
tbes.CopyArgument(0, "Reason", reason);
1535+
tbes.FormatArgument(1, "Before.CombinedCapacity (kB)", "%" Pd "",
1536+
RoundWordsToKB(before.CombinedCapacityInWords()));
1537+
tbes.FormatArgument(2, "After.CombinedCapacity (kB)", "%" Pd "",
1538+
RoundWordsToKB(after.CombinedCapacityInWords()));
1539+
tbes.FormatArgument(3, "Threshold (kB)", "%" Pd "",
1540+
RoundWordsToKB(gc_threshold_in_words_));
1541+
tbes.FormatArgument(4, "Idle Threshold (kB)", "%" Pd "",
1542+
RoundWordsToKB(idle_gc_threshold_in_words_));
15431543
#endif
15441544

15451545
if (FLAG_log_growth) {

runtime/vm/isolate.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,11 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage(
861861
Zone* zone = stack_zone.GetZone();
862862
HandleScope handle_scope(thread);
863863
#if defined(SUPPORT_TIMELINE)
864-
TimelineDurationScope tds(
864+
TimelineBeginEndScope tbes(
865865
thread, Timeline::GetIsolateStream(),
866866
message->IsOOB() ? "HandleOOBMessage" : "HandleMessage");
867-
tds.SetNumArguments(1);
868-
tds.CopyArgument(0, "isolateName", I->name());
867+
tbes.SetNumArguments(1);
868+
tbes.CopyArgument(0, "isolateName", I->name());
869869
#endif
870870

871871
// If the message is in band we lookup the handler to dispatch to. If the
@@ -979,8 +979,8 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage(
979979
// the Timeline due to absence of this argument. We still send them in
980980
// order to maintain the original behavior of the full timeline and allow
981981
// the developer to download complete dump files.
982-
tds.SetNumArguments(2);
983-
tds.CopyArgument(1, "mode", "basic");
982+
tbes.SetNumArguments(2);
983+
tbes.CopyArgument(1, "mode", "basic");
984984
}
985985
#endif
986986
const Object& result =
@@ -2362,7 +2362,6 @@ void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor,
23622362
}
23632363
#endif // !defined(DART_PRECOMPILED_RUNTIME)
23642364

2365-
23662365
VisitStackPointers(visitor, validate_frames);
23672366
}
23682367

runtime/vm/isolate_reload.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ DECLARE_FLAG(bool, trace_deoptimization);
6262
#define Z zone_
6363

6464
#define TIMELINE_SCOPE(name) \
65-
TimelineDurationScope tds##name(Thread::Current(), \
66-
Timeline::GetIsolateStream(), #name)
65+
TimelineBeginEndScope tbes##name(Thread::Current(), \
66+
Timeline::GetIsolateStream(), #name)
6767

6868
// The ObjectLocator is used for collecting instances that
6969
// needs to be morphed.

runtime/vm/kernel_isolate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class RunKernelTask : public ThreadPool::Task {
7070
virtual void Run() {
7171
ASSERT(Isolate::Current() == NULL);
7272
#ifdef SUPPORT_TIMELINE
73-
TimelineDurationScope tds(Timeline::GetVMStream(), "KernelIsolateStartup");
73+
TimelineBeginEndScope tbes(Timeline::GetVMStream(), "KernelIsolateStartup");
7474
#endif // SUPPORT_TIMELINE
7575
char* error = NULL;
7676
Isolate* isolate = NULL;

0 commit comments

Comments
 (0)