Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 | 1284 |
| 1285 DART_EXPORT Dart_Handle Dart_DebugName() { | 1285 DART_EXPORT Dart_Handle Dart_DebugName() { |
| 1286 DARTSCOPE(Thread::Current()); | 1286 DARTSCOPE(Thread::Current()); |
| 1287 Isolate* I = T->isolate(); | 1287 Isolate* I = T->isolate(); |
| 1288 return Api::NewHandle(T, String::New(I->name())); | 1288 return Api::NewHandle(T, String::New(I->name())); |
| 1289 } | 1289 } |
| 1290 | 1290 |
| 1291 | 1291 |
| 1292 DART_EXPORT bool Dart_RegisterEmbedderThread(const char* name) { | |
| 1293 OSThread* os_thread = OSThread::Current(); | |
| 1294 if (os_thread == NULL) { | |
| 1295 os_thread = new OSThread(); | |
| 1296 OSThread::SetCurrent(os_thread); | |
| 1297 os_thread->set_name(name); | |
| 1298 } | |
| 1299 return true; | |
| 1300 } | |
| 1301 | |
| 1292 | 1302 |
| 1293 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate) { | 1303 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate) { |
| 1294 CHECK_NO_ISOLATE(Isolate::Current()); | 1304 CHECK_NO_ISOLATE(Isolate::Current()); |
| 1295 // TODO(16615): Validate isolate parameter. | 1305 // TODO(16615): Validate isolate parameter. |
| 1296 Isolate* iso = reinterpret_cast<Isolate*>(isolate); | 1306 Isolate* iso = reinterpret_cast<Isolate*>(isolate); |
| 1297 if (iso->HasMutatorThread()) { | 1307 if (iso->HasMutatorThread()) { |
| 1298 FATAL("Multiple mutators within one isolate is not supported."); | 1308 FATAL("Multiple mutators within one isolate is not supported."); |
| 1299 } | 1309 } |
| 1300 Thread::EnterIsolate(iso); | 1310 Thread::EnterIsolate(iso); |
| 1301 } | 1311 } |
| (...skipping 4419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5721 Timeline::ReclaimCachedBlocksFromThreads(); | 5731 Timeline::ReclaimCachedBlocksFromThreads(); |
| 5722 JSONStream js; | 5732 JSONStream js; |
| 5723 IsolateTimelineEventFilter filter(isolate->main_port()); | 5733 IsolateTimelineEventFilter filter(isolate->main_port()); |
| 5724 timeline_recorder->PrintTraceEvent(&js, &filter); | 5734 timeline_recorder->PrintTraceEvent(&js, &filter); |
| 5725 return StreamTraceEvents(consumer, user_data, &js); | 5735 return StreamTraceEvents(consumer, user_data, &js); |
| 5726 } | 5736 } |
| 5727 | 5737 |
| 5728 | 5738 |
| 5729 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, | 5739 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, |
| 5730 void* user_data) { | 5740 void* user_data) { |
| 5741 // To support various embedders, it must be possible to call this function | |
| 5742 // from a thread for which we have not entered an Isolate and set up a Thread | |
| 5743 // TLS object. Therefore, a Zone may not be available, a StackZone cannot be | |
| 5744 // created, and no ZoneAllocated objects can be allocated. | |
| 5731 if (consumer == NULL) { | 5745 if (consumer == NULL) { |
| 5732 return false; | 5746 return false; |
| 5733 } | 5747 } |
| 5734 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5748 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5735 if (timeline_recorder == NULL) { | 5749 if (timeline_recorder == NULL) { |
| 5736 // Nothing has been recorded. | 5750 // Nothing has been recorded. |
| 5737 return false; | 5751 return false; |
| 5738 } | 5752 } |
| 5739 Thread* T = Thread::Current(); | |
| 5740 StackZone zone(T); | |
| 5741 Timeline::ReclaimCachedBlocksFromThreads(); | 5753 Timeline::ReclaimCachedBlocksFromThreads(); |
|
Ivan Posva
2015/12/01 05:08:42
Please add a test that does request a timeline tra
zra
2015/12/01 16:55:13
Done.
| |
| 5742 JSONStream js; | 5754 JSONStream js; |
| 5743 TimelineEventFilter filter; | 5755 TimelineEventFilter filter; |
| 5744 timeline_recorder->PrintTraceEvent(&js, &filter); | 5756 timeline_recorder->PrintTraceEvent(&js, &filter); |
| 5745 return StreamTraceEvents(consumer, user_data, &js); | 5757 return StreamTraceEvents(consumer, user_data, &js); |
| 5746 } | 5758 } |
| 5747 | 5759 |
| 5748 | 5760 |
| 5749 DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label, | 5761 DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label, |
| 5750 int64_t start_micros, | 5762 int64_t start_micros, |
| 5751 int64_t end_micros) { | 5763 int64_t end_micros) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5918 ApiReallocate); | 5930 ApiReallocate); |
| 5919 writer.WriteFullSnapshot(); | 5931 writer.WriteFullSnapshot(); |
| 5920 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 5932 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 5921 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 5933 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 5922 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 5934 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
| 5923 | 5935 |
| 5924 return Api::Success(); | 5936 return Api::Success(); |
| 5925 } | 5937 } |
| 5926 | 5938 |
| 5927 } // namespace dart | 5939 } // namespace dart |
| OLD | NEW |