Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: runtime/lib/timeline.cc

Issue 1554623003: Don't conflate Timeline serialized json with event type (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/timeline.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/timeline.cc
diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc
index 8410f1bb5074f9f018cc829ba1283ba608c9d48d..f81ce4d3aa711bce09f9904362ab8edcd8fdaeca 100644
--- a/runtime/lib/timeline.cc
+++ b/runtime/lib/timeline.cc
@@ -58,7 +58,13 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) {
OSThread* os_thread = thread->os_thread();
ASSERT(os_thread != NULL);
int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id());
-
+ // Convert phase to a C string and perform a sanity check.
+ const char* phase_string = phase.ToCString();
+ ASSERT(phase_string != NULL);
+ ASSERT((phase_string[0] == 'n') ||
+ (phase_string[0] == 'b') ||
+ (phase_string[0] == 'e'));
+ ASSERT(phase_string[1] == '\0');
char* json = OS::SCreate(zone,
"{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 ","
"\"ts\":%" Pd64 ",\"ph\":\"%s\",\"id\":%" Pd64 ", \"args\":%s}",
@@ -67,7 +73,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) {
tid,
pid,
start.AsInt64Value(),
- phase.ToCString(),
+ phase_string,
id.AsInt64Value(),
args.ToCString());
siva 2015/12/30 20:21:26 Can this json initialization stuff be moved down b
Cutch 2015/12/30 20:48:14 Good suggestion. Done here and elsewhere.
@@ -76,9 +82,21 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) {
// Stream was turned off.
return Object::null();
}
+ switch (phase_string[0]) {
+ case 'n':
+ event->AsyncInstant("", id.AsInt64Value(), start.AsInt64Value());
+ break;
+ case 'b':
+ event->AsyncBegin("", id.AsInt64Value(), start.AsInt64Value());
+ break;
+ case 'e':
+ event->AsyncEnd("", id.AsInt64Value(), start.AsInt64Value());
+ break;
+ default:
+ UNREACHABLE();
+ }
// json was allocated in the zone and a copy will be stored in event.
- event->SerializedJSON(json, start.AsInt64Value(), id.AsInt64Value());
- event->Complete();
+ event->CompleteWithPreSerializedJSON(json);
return Object::null();
}
@@ -123,10 +141,9 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) {
// Stream was turned off.
return Object::null();
}
+ event->Duration("", start.AsInt64Value(), end.AsInt64Value());
// json was allocated in the zone and a copy will be stored in event.
- event->SerializedJSON(json, start.AsInt64Value(), end.AsInt64Value());
- event->SetSerializedJSONIsDuration(true);
- event->Complete();
+ event->CompleteWithPreSerializedJSON(json);
return Object::null();
}
@@ -168,9 +185,9 @@ DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) {
// Stream was turned off.
return Object::null();
}
+ event->Instant("", start.AsInt64Value());
// json was allocated in the zone and a copy will be stored in event.
- event->SerializedJSON(json, start.AsInt64Value(), 0);
- event->Complete();
+ event->CompleteWithPreSerializedJSON(json);
return Object::null();
}
« no previous file with comments | « no previous file | runtime/vm/timeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698