Chromium Code Reviews| Index: runtime/lib/timeline.cc |
| diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc |
| index ce4b43f6d24e7bd2e70ab4055fb4234b73178d40..24c559c12e4871f0e88146274327c658024b6335 100644 |
| --- a/runtime/lib/timeline.cc |
| +++ b/runtime/lib/timeline.cc |
| @@ -111,16 +111,36 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
| return Object::null(); |
| } |
| +DEFINE_NATIVE_ENTRY(Timeline_reportBeginEvent, 1) { |
| +#if !defined(PRODUCT) && defined(HOST_OS_FUCHSIA) |
| + if (!FLAG_support_timeline) { |
| + return Object::null(); |
| + } |
| + GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0)); |
| + |
| + TimelineEventRecorder* recorder = Timeline::recorder(); |
| + if (recorder == NULL) { |
| + return Object::null(); |
| + } |
| + |
| + TimelineEvent* event = Timeline::GetDartStream()->StartEvent(); |
| + if (event == NULL) { |
| + // Stream was turned off. |
| + return Object::null(); |
| + } |
| + |
| + event->Begin(strdup(name.ToCString())); |
| + event->set_owns_label(true); |
| + event->Complete(); |
| +#endif // !PRODUCT |
| + return Object::null(); |
| +} |
| + |
| DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| #ifndef PRODUCT |
| 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,6 +153,19 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| return Object::null(); |
| } |
| + GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4)); |
| +#if defined(HOST_OS_FUCHSIA) |
|
konkers
2017/07/19 22:11:20
This is not strictly necessary. It does, however,
|
| + event->End(strdup(name.ToCString())); |
| + event->set_owns_label(true); |
| + event->SetNumArguments(1); |
| + event->CopyArgument(0, "args", args.ToCString()); |
| + event->Complete(); |
| +#else |
| + 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)); |
| + |
| const int64_t end = OS::GetCurrentMonotonicMicros(); |
| const int64_t end_cpu = OS::GetCurrentThreadCPUMicros(); |
| const int64_t duration = end - start.AsInt64Value(); |
| @@ -169,7 +202,8 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| 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(); |
| } |