Chromium Code Reviews| Index: runtime/lib/timeline.cc |
| diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc |
| index ce4b43f6d24e7bd2e70ab4055fb4234b73178d40..fa58864520b95d545419ea2f56515efe8362382a 100644 |
| --- a/runtime/lib/timeline.cc |
| +++ b/runtime/lib/timeline.cc |
| @@ -116,11 +116,6 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| if (!FLAG_support_timeline) { |
| return Object::null(); |
| } |
| - GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| - GET_NON_NULL_NATIVE_ARGUMENT(Integer, start_cpu, arguments->NativeArgAt(1)); |
| - GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); |
| - GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); |
| - GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4)); |
| TimelineEventRecorder* recorder = Timeline::recorder(); |
| if (recorder == NULL) { |
| @@ -133,18 +128,32 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| return Object::null(); |
| } |
| + GET_NON_NULL_NATIVE_ARGUMENT(Integer, s, arguments->NativeArgAt(0)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(Integer, s_cpu, arguments->NativeArgAt(1)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4)); |
| + const int64_t start = s.AsInt64Value(); |
| + const int64_t start_cpu = s_cpu.AsInt64Value(); |
| 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(); |
| +#if defined(HOST_OS_FUCHSIA) |
| + event->Duration(strdup(name.ToCString()), start, end, start_cpu, end_cpu); |
| + event->set_owns_label(true); |
| + event->SetNumArguments(1); |
| + event->CopyArgument(0, "args", args.ToCString()); |
| + event->Complete(); |
| +#else |
|
siva
2017/07/20 16:36:31
Do you think we need a OS abstraction around this
zra
2017/07/20 16:57:04
There are probably going to be more pieces because
|
| + GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); |
| + const int64_t duration = end - start; |
| + const int64_t duration_cpu = end_cpu - start_cpu; |
| + const int64_t pid = OS::ProcessId(); |
| OSThread* os_thread = thread->os_thread(); |
| ASSERT(os_thread != NULL); |
| - int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id()); |
| + const int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id()); |
| char* json = NULL; |
| - if ((start_cpu.AsInt64Value() != -1) && (end_cpu != -1)) { |
| + if ((start_cpu != -1) && (end_cpu != -1)) { |
| json = OS::SCreate( |
| zone, |
| "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 |
| @@ -152,7 +161,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 |
| "," |
| "\"tdur\":%" Pd64 ",\"args\":%s}", |
| - name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(), |
| + name.ToCString(), category.ToCString(), tid, pid, start, |
| duration, duration_cpu, args.ToCString()); |
| } else { |
| json = OS::SCreate( |
| @@ -160,16 +169,16 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 |
| "," |
| "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}", |
| - name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(), |
| + name.ToCString(), category.ToCString(), tid, pid, start, |
| duration, args.ToCString()); |
| } |
| ASSERT(json != NULL); |
| - event->Duration("", start.AsInt64Value(), end, start_cpu.AsInt64Value(), |
| - end_cpu); |
| + event->Duration("", start, end, start_cpu, end_cpu); |
| // json was allocated in the zone and a copy will be stored in event. |
| event->CompleteWithPreSerializedJSON(json); |
| -#endif |
| +#endif // !defined(HOST_OS_FUCHSIA) |
| +#endif // !defined(PRODUCT) |
| return Object::null(); |
| } |