OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/native_entry.h" | 9 #include "vm/native_entry.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Stream was turned off. | 119 // Stream was turned off. |
120 return Object::null(); | 120 return Object::null(); |
121 } | 121 } |
122 // json was allocated in the zone and a copy will be stored in event. | 122 // json was allocated in the zone and a copy will be stored in event. |
123 event->SerializedJSON(json); | 123 event->SerializedJSON(json); |
124 event->Complete(); | 124 event->Complete(); |
125 | 125 |
126 return Object::null(); | 126 return Object::null(); |
127 } | 127 } |
128 | 128 |
| 129 |
| 130 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { |
| 131 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| 132 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); |
| 133 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); |
| 134 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(3)); |
| 135 |
| 136 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 137 if (recorder == NULL) { |
| 138 return Object::null(); |
| 139 } |
| 140 |
| 141 if (!isolate->GetDartStream()->Enabled()) { |
| 142 // Dart stream is not enabled for this isolate, do nothing. |
| 143 return Object::null(); |
| 144 } |
| 145 |
| 146 int64_t pid = OS::ProcessId(); |
| 147 int64_t tid = OSThread::ThreadIdToIntPtr(OSThread::GetCurrentThreadTraceId()); |
| 148 |
| 149 char* json = OS::SCreate(zone, |
| 150 "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 "," |
| 151 "\"ts\":%" Pd64 ",\"ph\":\"I\",\"args\":%s}", |
| 152 name.ToCString(), |
| 153 category.ToCString(), |
| 154 tid, |
| 155 pid, |
| 156 start.AsInt64Value(), |
| 157 args.ToCString()); |
| 158 |
| 159 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); |
| 160 if (event == NULL) { |
| 161 // Stream was turned off. |
| 162 return Object::null(); |
| 163 } |
| 164 // json was allocated in the zone and a copy will be stored in event. |
| 165 event->SerializedJSON(json); |
| 166 event->Complete(); |
| 167 |
| 168 return Object::null(); |
| 169 } |
| 170 |
129 } // namespace dart | 171 } // namespace dart |
OLD | NEW |