Index: runtime/lib/timeline.cc |
diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc |
index 06c3ba7c0cc6ea9cc207ecc39b2ddf40b9308fbc..a26c847cf74b6ba3f50e20eeda39851a73f256f2 100644 |
--- a/runtime/lib/timeline.cc |
+++ b/runtime/lib/timeline.cc |
@@ -126,4 +126,46 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
return Object::null(); |
} |
+ |
+DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { |
+ GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
+ GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); |
+ GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); |
+ GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(3)); |
+ |
+ TimelineEventRecorder* recorder = Timeline::recorder(); |
+ if (recorder == NULL) { |
+ return Object::null(); |
+ } |
+ |
+ if (!isolate->GetDartStream()->Enabled()) { |
+ // Dart stream is not enabled for this isolate, do nothing. |
+ return Object::null(); |
+ } |
+ |
+ int64_t pid = OS::ProcessId(); |
+ int64_t tid = OSThread::ThreadIdToIntPtr(OSThread::GetCurrentThreadTraceId()); |
+ |
+ 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()); |
+ |
+ TimelineEvent* event = isolate->GetDartStream()->StartEvent(); |
+ if (event == NULL) { |
+ // Stream was turned off. |
+ return Object::null(); |
+ } |
+ // json was allocated in the zone and a copy will be stored in event. |
+ event->SerializedJSON(json); |
+ event->Complete(); |
+ |
+ return Object::null(); |
+} |
+ |
} // namespace dart |