| Index: runtime/lib/timeline.cc
|
| diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc
|
| index ce4b43f6d24e7bd2e70ab4055fb4234b73178d40..f90ff71dc1ada014132152bdc5cdd1254b5c9831 100644
|
| --- a/runtime/lib/timeline.cc
|
| +++ b/runtime/lib/timeline.cc
|
| @@ -73,40 +73,10 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) {
|
| return Object::null();
|
| }
|
|
|
| - int64_t pid = OS::ProcessId();
|
| - 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}",
|
| - name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(),
|
| - phase_string, id.AsInt64Value(), args.ToCString());
|
| -
|
| - 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->CompleteWithPreSerializedJSON(json);
|
| + DartTimelineEventHelpers::ReportTaskEvent(
|
| + thread, zone, event, start.AsInt64Value(), id.AsInt64Value(),
|
| + phase.ToCString(), category.ToCString(), name.ToCString(),
|
| + args.ToCString());
|
| #endif
|
| return Object::null();
|
| }
|
| @@ -133,43 +103,10 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) {
|
| return Object::null();
|
| }
|
|
|
| - const int64_t end = OS::GetCurrentMonotonicMicros();
|
| - const int64_t end_cpu = OS::GetCurrentThreadCPUMicros();
|
| - const int64_t duration = end - start.AsInt64Value();
|
| - const int64_t duration_cpu = end_cpu - start_cpu.AsInt64Value();
|
| - int64_t pid = OS::ProcessId();
|
| - OSThread* os_thread = thread->os_thread();
|
| - ASSERT(os_thread != NULL);
|
| - int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id());
|
| -
|
| - char* json = NULL;
|
| -
|
| - if ((start_cpu.AsInt64Value() != -1) && (end_cpu != -1)) {
|
| - json = OS::SCreate(
|
| - zone,
|
| - "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64
|
| - ","
|
| - "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64
|
| - ","
|
| - "\"tdur\":%" Pd64 ",\"args\":%s}",
|
| - name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(),
|
| - duration, duration_cpu, args.ToCString());
|
| - } else {
|
| - json = OS::SCreate(
|
| - zone,
|
| - "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64
|
| - ","
|
| - "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}",
|
| - name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(),
|
| - duration, args.ToCString());
|
| - }
|
| - ASSERT(json != NULL);
|
| -
|
| - event->Duration("", start.AsInt64Value(), end, start_cpu.AsInt64Value(),
|
| - end_cpu);
|
| - // json was allocated in the zone and a copy will be stored in event.
|
| - event->CompleteWithPreSerializedJSON(json);
|
| -#endif
|
| + DartTimelineEventHelpers::ReportCompleteEvent(
|
| + thread, zone, event, start.AsInt64Value(), start_cpu.AsInt64Value(),
|
| + category.ToCString(), name.ToCString(), args.ToCString());
|
| +#endif // !defined(PRODUCT)
|
| return Object::null();
|
| }
|
|
|
| @@ -194,22 +131,9 @@ DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) {
|
| return Object::null();
|
| }
|
|
|
| - int64_t pid = OS::ProcessId();
|
| - OSThread* os_thread = thread->os_thread();
|
| - ASSERT(os_thread != NULL);
|
| - int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id());
|
| -
|
| - char* json = OS::SCreate(zone,
|
| - "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64
|
| - ",\"pid\":%" Pd64
|
| - ","
|
| - "\"ts\":%" Pd64 ",\"ph\":\"I\",\"args\":%s}",
|
| - name.ToCString(), category.ToCString(), tid, pid,
|
| - start.AsInt64Value(), args.ToCString());
|
| -
|
| - event->Instant("", start.AsInt64Value());
|
| - // json was allocated in the zone and a copy will be stored in event.
|
| - event->CompleteWithPreSerializedJSON(json);
|
| + DartTimelineEventHelpers::ReportInstantEvent(
|
| + thread, zone, event, start.AsInt64Value(), category.ToCString(),
|
| + name.ToCString(), args.ToCString());
|
| #endif
|
| return Object::null();
|
| }
|
|
|