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

Side by Side Diff: runtime/lib/timeline.cc

Issue 2984603002: Special-case Timeline.{start,finish}Sync for Fuchsia (Closed)
Patch Set: . Created 3 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/lib/timeline.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 default: 104 default:
105 UNREACHABLE(); 105 UNREACHABLE();
106 } 106 }
107 107
108 // json was allocated in the zone and a copy will be stored in event. 108 // json was allocated in the zone and a copy will be stored in event.
109 event->CompleteWithPreSerializedJSON(json); 109 event->CompleteWithPreSerializedJSON(json);
110 #endif 110 #endif
111 return Object::null(); 111 return Object::null();
112 } 112 }
113 113
114 DEFINE_NATIVE_ENTRY(Timeline_reportBeginEvent, 1) {
115 #if !defined(PRODUCT) && defined(HOST_OS_FUCHSIA)
116 if (!FLAG_support_timeline) {
117 return Object::null();
118 }
119 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(0));
120
121 TimelineEventRecorder* recorder = Timeline::recorder();
122 if (recorder == NULL) {
123 return Object::null();
124 }
125
126 TimelineEvent* event = Timeline::GetDartStream()->StartEvent();
127 if (event == NULL) {
128 // Stream was turned off.
129 return Object::null();
130 }
131
132 event->Begin(strdup(name.ToCString()));
133 event->set_owns_label(true);
134 event->Complete();
135 #endif // !PRODUCT
136 return Object::null();
137 }
138
114 DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { 139 DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) {
115 #ifndef PRODUCT 140 #ifndef PRODUCT
116 if (!FLAG_support_timeline) { 141 if (!FLAG_support_timeline) {
117 return Object::null(); 142 return Object::null();
118 } 143 }
119 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0));
120 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start_cpu, arguments->NativeArgAt(1));
121 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2));
122 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3));
123 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4));
124 144
125 TimelineEventRecorder* recorder = Timeline::recorder(); 145 TimelineEventRecorder* recorder = Timeline::recorder();
126 if (recorder == NULL) { 146 if (recorder == NULL) {
127 return Object::null(); 147 return Object::null();
128 } 148 }
129 149
130 TimelineEvent* event = Timeline::GetDartStream()->StartEvent(); 150 TimelineEvent* event = Timeline::GetDartStream()->StartEvent();
131 if (event == NULL) { 151 if (event == NULL) {
132 // Stream was turned off. 152 // Stream was turned off.
133 return Object::null(); 153 return Object::null();
134 } 154 }
135 155
156 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3));
157 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4));
158 #if defined(HOST_OS_FUCHSIA)
konkers 2017/07/19 22:11:20 This is not strictly necessary. It does, however,
159 event->End(strdup(name.ToCString()));
160 event->set_owns_label(true);
161 event->SetNumArguments(1);
162 event->CopyArgument(0, "args", args.ToCString());
163 event->Complete();
164 #else
165 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0));
166 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start_cpu, arguments->NativeArgAt(1));
167 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2));
168
136 const int64_t end = OS::GetCurrentMonotonicMicros(); 169 const int64_t end = OS::GetCurrentMonotonicMicros();
137 const int64_t end_cpu = OS::GetCurrentThreadCPUMicros(); 170 const int64_t end_cpu = OS::GetCurrentThreadCPUMicros();
138 const int64_t duration = end - start.AsInt64Value(); 171 const int64_t duration = end - start.AsInt64Value();
139 const int64_t duration_cpu = end_cpu - start_cpu.AsInt64Value(); 172 const int64_t duration_cpu = end_cpu - start_cpu.AsInt64Value();
140 int64_t pid = OS::ProcessId(); 173 int64_t pid = OS::ProcessId();
141 OSThread* os_thread = thread->os_thread(); 174 OSThread* os_thread = thread->os_thread();
142 ASSERT(os_thread != NULL); 175 ASSERT(os_thread != NULL);
143 int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id()); 176 int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id());
144 177
145 char* json = NULL; 178 char* json = NULL;
(...skipping 16 matching lines...) Expand all
162 "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}", 195 "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}",
163 name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(), 196 name.ToCString(), category.ToCString(), tid, pid, start.AsInt64Value(),
164 duration, args.ToCString()); 197 duration, args.ToCString());
165 } 198 }
166 ASSERT(json != NULL); 199 ASSERT(json != NULL);
167 200
168 event->Duration("", start.AsInt64Value(), end, start_cpu.AsInt64Value(), 201 event->Duration("", start.AsInt64Value(), end, start_cpu.AsInt64Value(),
169 end_cpu); 202 end_cpu);
170 // json was allocated in the zone and a copy will be stored in event. 203 // json was allocated in the zone and a copy will be stored in event.
171 event->CompleteWithPreSerializedJSON(json); 204 event->CompleteWithPreSerializedJSON(json);
172 #endif 205 #endif // defined(HOST_OS_FUCHSIA)
206 #endif // !defined(PRODUCT)
173 return Object::null(); 207 return Object::null();
174 } 208 }
175 209
176 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { 210 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) {
177 #ifndef PRODUCT 211 #ifndef PRODUCT
178 if (!FLAG_support_timeline) { 212 if (!FLAG_support_timeline) {
179 return Object::null(); 213 return Object::null();
180 } 214 }
181 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); 215 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0));
182 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); 216 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1));
(...skipping 25 matching lines...) Expand all
208 start.AsInt64Value(), args.ToCString()); 242 start.AsInt64Value(), args.ToCString());
209 243
210 event->Instant("", start.AsInt64Value()); 244 event->Instant("", start.AsInt64Value());
211 // json was allocated in the zone and a copy will be stored in event. 245 // json was allocated in the zone and a copy will be stored in event.
212 event->CompleteWithPreSerializedJSON(json); 246 event->CompleteWithPreSerializedJSON(json);
213 #endif 247 #endif
214 return Object::null(); 248 return Object::null();
215 } 249 }
216 250
217 } // namespace dart 251 } // namespace dart
OLDNEW
« 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