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

Unified Diff: runtime/lib/timeline.cc

Issue 1412183008: Redo TimelineTask API (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/lib/timeline.dart » ('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 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
« no previous file with comments | « no previous file | runtime/lib/timeline.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698