Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 if (!isolate->GetDartStream()->Enabled()) { | 52 if (!isolate->GetDartStream()->Enabled()) { |
| 53 // Dart stream is not enabled for this isolate, do nothing. | 53 // Dart stream is not enabled for this isolate, do nothing. |
| 54 return Object::null(); | 54 return Object::null(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 int64_t pid = OS::ProcessId(); | 57 int64_t pid = OS::ProcessId(); |
| 58 OSThread* os_thread = thread->os_thread(); | 58 OSThread* os_thread = thread->os_thread(); |
| 59 ASSERT(os_thread != NULL); | 59 ASSERT(os_thread != NULL); |
| 60 int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id()); | 60 int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id()); |
| 61 | 61 // Convert phase to a C string and perform a sanity check. |
| 62 const char* phase_string = phase.ToCString(); | |
| 63 ASSERT(phase_string != NULL); | |
| 64 ASSERT((phase_string[0] == 'n') || | |
| 65 (phase_string[0] == 'b') || | |
| 66 (phase_string[0] == 'e')); | |
| 67 ASSERT(phase_string[1] == '\0'); | |
| 62 char* json = OS::SCreate(zone, | 68 char* json = OS::SCreate(zone, |
| 63 "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 "," | 69 "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 "," |
| 64 "\"ts\":%" Pd64 ",\"ph\":\"%s\",\"id\":%" Pd64 ", \"args\":%s}", | 70 "\"ts\":%" Pd64 ",\"ph\":\"%s\",\"id\":%" Pd64 ", \"args\":%s}", |
| 65 name.ToCString(), | 71 name.ToCString(), |
| 66 category.ToCString(), | 72 category.ToCString(), |
| 67 tid, | 73 tid, |
| 68 pid, | 74 pid, |
| 69 start.AsInt64Value(), | 75 start.AsInt64Value(), |
| 70 phase.ToCString(), | 76 phase_string, |
| 71 id.AsInt64Value(), | 77 id.AsInt64Value(), |
| 72 args.ToCString()); | 78 args.ToCString()); |
|
siva
2015/12/30 20:21:26
Can this json initialization stuff be moved down b
Cutch
2015/12/30 20:48:14
Good suggestion. Done here and elsewhere.
| |
| 73 | 79 |
| 74 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); | 80 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); |
| 75 if (event == NULL) { | 81 if (event == NULL) { |
| 76 // Stream was turned off. | 82 // Stream was turned off. |
| 77 return Object::null(); | 83 return Object::null(); |
| 78 } | 84 } |
| 85 switch (phase_string[0]) { | |
| 86 case 'n': | |
| 87 event->AsyncInstant("", id.AsInt64Value(), start.AsInt64Value()); | |
| 88 break; | |
| 89 case 'b': | |
| 90 event->AsyncBegin("", id.AsInt64Value(), start.AsInt64Value()); | |
| 91 break; | |
| 92 case 'e': | |
| 93 event->AsyncEnd("", id.AsInt64Value(), start.AsInt64Value()); | |
| 94 break; | |
| 95 default: | |
| 96 UNREACHABLE(); | |
| 97 } | |
| 79 // json was allocated in the zone and a copy will be stored in event. | 98 // json was allocated in the zone and a copy will be stored in event. |
| 80 event->SerializedJSON(json, start.AsInt64Value(), id.AsInt64Value()); | 99 event->CompleteWithPreSerializedJSON(json); |
| 81 event->Complete(); | |
| 82 | 100 |
| 83 return Object::null(); | 101 return Object::null(); |
| 84 } | 102 } |
| 85 | 103 |
| 86 | 104 |
| 87 DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { | 105 DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| 88 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); | 106 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| 89 GET_NON_NULL_NATIVE_ARGUMENT(Integer, end, arguments->NativeArgAt(1)); | 107 GET_NON_NULL_NATIVE_ARGUMENT(Integer, end, arguments->NativeArgAt(1)); |
| 90 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); | 108 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); |
| 91 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); | 109 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 116 pid, | 134 pid, |
| 117 start.AsInt64Value(), | 135 start.AsInt64Value(), |
| 118 duration, | 136 duration, |
| 119 args.ToCString()); | 137 args.ToCString()); |
| 120 | 138 |
| 121 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); | 139 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); |
| 122 if (event == NULL) { | 140 if (event == NULL) { |
| 123 // Stream was turned off. | 141 // Stream was turned off. |
| 124 return Object::null(); | 142 return Object::null(); |
| 125 } | 143 } |
| 144 event->Duration("", start.AsInt64Value(), end.AsInt64Value()); | |
| 126 // json was allocated in the zone and a copy will be stored in event. | 145 // json was allocated in the zone and a copy will be stored in event. |
| 127 event->SerializedJSON(json, start.AsInt64Value(), end.AsInt64Value()); | 146 event->CompleteWithPreSerializedJSON(json); |
| 128 event->SetSerializedJSONIsDuration(true); | |
| 129 event->Complete(); | |
| 130 | 147 |
| 131 return Object::null(); | 148 return Object::null(); |
| 132 } | 149 } |
| 133 | 150 |
| 134 | 151 |
| 135 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { | 152 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { |
| 136 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); | 153 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| 137 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); | 154 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); |
| 138 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); | 155 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); |
| 139 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(3)); | 156 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(3)); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 161 tid, | 178 tid, |
| 162 pid, | 179 pid, |
| 163 start.AsInt64Value(), | 180 start.AsInt64Value(), |
| 164 args.ToCString()); | 181 args.ToCString()); |
| 165 | 182 |
| 166 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); | 183 TimelineEvent* event = isolate->GetDartStream()->StartEvent(); |
| 167 if (event == NULL) { | 184 if (event == NULL) { |
| 168 // Stream was turned off. | 185 // Stream was turned off. |
| 169 return Object::null(); | 186 return Object::null(); |
| 170 } | 187 } |
| 188 event->Instant("", start.AsInt64Value()); | |
| 171 // json was allocated in the zone and a copy will be stored in event. | 189 // json was allocated in the zone and a copy will be stored in event. |
| 172 event->SerializedJSON(json, start.AsInt64Value(), 0); | 190 event->CompleteWithPreSerializedJSON(json); |
| 173 event->Complete(); | |
| 174 | 191 |
| 175 return Object::null(); | 192 return Object::null(); |
| 176 } | 193 } |
| 177 | 194 |
| 178 } // namespace dart | 195 } // namespace dart |
| OLD | NEW |