Index: runtime/lib/timeline.cc |
diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc |
index 32f5896c0d30995e5b970fa4d539c6cc3562ac79..06c3ba7c0cc6ea9cc207ecc39b2ddf40b9308fbc 100644 |
--- a/runtime/lib/timeline.cc |
+++ b/runtime/lib/timeline.cc |
@@ -14,8 +14,11 @@ |
namespace dart { |
// Native implementations for the dart:developer library. |
-DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0) { |
- return Integer::New(OS::GetCurrentTraceMicros(), Heap::kNew, true); |
+ |
+DEFINE_NATIVE_ENTRY(Timeline_getIsolateNum, 0) { |
+ return Integer::New(static_cast<int64_t>(isolate->main_port()), |
+ Heap::kOld, |
+ true); |
} |
@@ -28,6 +31,11 @@ DEFINE_NATIVE_ENTRY(Timeline_getNextAsyncId, 0) { |
} |
+DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0) { |
+ return Integer::New(OS::GetCurrentTraceMicros(), Heap::kNew, true); |
+} |
+ |
+ |
DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
GET_NON_NULL_NATIVE_ARGUMENT(Integer, id, arguments->NativeArgAt(1)); |
@@ -46,11 +54,10 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
return Object::null(); |
} |
- |
int64_t pid = OS::ProcessId(); |
int64_t tid = OSThread::ThreadIdToIntPtr(OSThread::GetCurrentThreadTraceId()); |
- char* event = OS::SCreate(zone, |
+ char* json = OS::SCreate(zone, |
"{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 "," |
"\"ts\":%" Pd64 ",\"ph\":\"%s\",\"id\":%" Pd64 ", \"args\":%s}", |
name.ToCString(), |
@@ -62,8 +69,14 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
id.AsInt64Value(), |
args.ToCString()); |
- // event was allocated in the zone and will be copied by AppendDartEvent. |
- recorder->AppendDartEvent(isolate, event); |
+ 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(); |
} |
@@ -90,7 +103,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
int64_t pid = OS::ProcessId(); |
int64_t tid = OSThread::ThreadIdToIntPtr(OSThread::GetCurrentThreadTraceId()); |
- char* event = OS::SCreate(zone, |
+ char* json = OS::SCreate(zone, |
"{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 "," |
"\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}", |
name.ToCString(), |
@@ -101,8 +114,14 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
duration, |
args.ToCString()); |
- // event was allocated in the zone and will be copied by AppendDartEvent. |
- recorder->AppendDartEvent(isolate, event); |
+ 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(); |
} |