| 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" |
| 11 #include "vm/os.h" | 11 #include "vm/os.h" |
| 12 #include "vm/timeline.h" | 12 #include "vm/timeline.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 // Native implementations for the dart:developer library. | 16 // Native implementations for the dart:developer library. |
| 17 | 17 |
| 18 DEFINE_NATIVE_ENTRY(Timeline_getIsolateNum, 0) { | 18 DEFINE_NATIVE_ENTRY(Timeline_getIsolateNum, 0) { |
| 19 return Integer::New(static_cast<int64_t>(isolate->main_port()), | 19 return Integer::New(static_cast<int64_t>(isolate->main_port()), |
| 20 Heap::kOld, | 20 Heap::kOld, |
| 21 true); | 21 true); |
| 22 } | 22 } |
| 23 | 23 |
| 24 | 24 |
| 25 DEFINE_NATIVE_ENTRY(Timeline_getNextAsyncId, 0) { | 25 DEFINE_NATIVE_ENTRY(Timeline_getNextAsyncId, 0) { |
| 26 if (!FLAG_support_timeline) { |
| 27 return Integer::New(0); |
| 28 } |
| 26 TimelineEventRecorder* recorder = Timeline::recorder(); | 29 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 27 if (recorder == NULL) { | 30 if (recorder == NULL) { |
| 28 return Integer::New(0); | 31 return Integer::New(0); |
| 29 } | 32 } |
| 30 return Integer::New(recorder->GetNextAsyncId()); | 33 return Integer::New(recorder->GetNextAsyncId()); |
| 31 } | 34 } |
| 32 | 35 |
| 33 | 36 |
| 34 DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0) { | 37 DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0) { |
| 35 return Integer::New(OS::GetCurrentMonotonicMicros(), Heap::kNew, true); | 38 return Integer::New(OS::GetCurrentMonotonicMicros(), Heap::kNew, true); |
| 36 } | 39 } |
| 37 | 40 |
| 38 | 41 |
| 39 DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { | 42 DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
| 43 if (!FLAG_support_timeline) { |
| 44 return Object::null(); |
| 45 } |
| 40 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); | 46 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| 41 GET_NON_NULL_NATIVE_ARGUMENT(Integer, id, arguments->NativeArgAt(1)); | 47 GET_NON_NULL_NATIVE_ARGUMENT(Integer, id, arguments->NativeArgAt(1)); |
| 42 GET_NON_NULL_NATIVE_ARGUMENT(String, phase, arguments->NativeArgAt(2)); | 48 GET_NON_NULL_NATIVE_ARGUMENT(String, phase, arguments->NativeArgAt(2)); |
| 43 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(3)); | 49 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(3)); |
| 44 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(4)); | 50 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(4)); |
| 45 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(5)); | 51 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(5)); |
| 46 | 52 |
| 47 TimelineEventRecorder* recorder = Timeline::recorder(); | 53 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 48 if (recorder == NULL) { | 54 if (recorder == NULL) { |
| 49 return Object::null(); | 55 return Object::null(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 99 } |
| 94 | 100 |
| 95 // json was allocated in the zone and a copy will be stored in event. | 101 // json was allocated in the zone and a copy will be stored in event. |
| 96 event->CompleteWithPreSerializedJSON(json); | 102 event->CompleteWithPreSerializedJSON(json); |
| 97 | 103 |
| 98 return Object::null(); | 104 return Object::null(); |
| 99 } | 105 } |
| 100 | 106 |
| 101 | 107 |
| 102 DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { | 108 DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| 109 if (!FLAG_support_timeline) { |
| 110 return Object::null(); |
| 111 } |
| 103 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); | 112 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| 104 GET_NON_NULL_NATIVE_ARGUMENT(Integer, end, arguments->NativeArgAt(1)); | 113 GET_NON_NULL_NATIVE_ARGUMENT(Integer, end, arguments->NativeArgAt(1)); |
| 105 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); | 114 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); |
| 106 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); | 115 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3)); |
| 107 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4)); | 116 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4)); |
| 108 | 117 |
| 109 TimelineEventRecorder* recorder = Timeline::recorder(); | 118 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 110 if (recorder == NULL) { | 119 if (recorder == NULL) { |
| 111 return Object::null(); | 120 return Object::null(); |
| 112 } | 121 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 136 | 145 |
| 137 event->Duration("", start.AsInt64Value(), end.AsInt64Value()); | 146 event->Duration("", start.AsInt64Value(), end.AsInt64Value()); |
| 138 // json was allocated in the zone and a copy will be stored in event. | 147 // json was allocated in the zone and a copy will be stored in event. |
| 139 event->CompleteWithPreSerializedJSON(json); | 148 event->CompleteWithPreSerializedJSON(json); |
| 140 | 149 |
| 141 return Object::null(); | 150 return Object::null(); |
| 142 } | 151 } |
| 143 | 152 |
| 144 | 153 |
| 145 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { | 154 DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { |
| 155 if (!FLAG_support_timeline) { |
| 156 return Object::null(); |
| 157 } |
| 146 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); | 158 GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); |
| 147 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); | 159 GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); |
| 148 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); | 160 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); |
| 149 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(3)); | 161 GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(3)); |
| 150 | 162 |
| 151 TimelineEventRecorder* recorder = Timeline::recorder(); | 163 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 152 if (recorder == NULL) { | 164 if (recorder == NULL) { |
| 153 return Object::null(); | 165 return Object::null(); |
| 154 } | 166 } |
| 155 | 167 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 args.ToCString()); | 187 args.ToCString()); |
| 176 | 188 |
| 177 event->Instant("", start.AsInt64Value()); | 189 event->Instant("", start.AsInt64Value()); |
| 178 // json was allocated in the zone and a copy will be stored in event. | 190 // json was allocated in the zone and a copy will be stored in event. |
| 179 event->CompleteWithPreSerializedJSON(json); | 191 event->CompleteWithPreSerializedJSON(json); |
| 180 | 192 |
| 181 return Object::null(); | 193 return Object::null(); |
| 182 } | 194 } |
| 183 | 195 |
| 184 } // namespace dart | 196 } // namespace dart |
| OLD | NEW |