| 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 5836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5847 } | 5847 } |
| 5848 | 5848 |
| 5849 | 5849 |
| 5850 DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer, | 5850 DART_EXPORT bool Dart_TimelineGetTrace(Dart_StreamConsumer consumer, |
| 5851 void* user_data) { | 5851 void* user_data) { |
| 5852 Isolate* isolate = Isolate::Current(); | 5852 Isolate* isolate = Isolate::Current(); |
| 5853 CHECK_ISOLATE(isolate); | 5853 CHECK_ISOLATE(isolate); |
| 5854 if (consumer == NULL) { | 5854 if (consumer == NULL) { |
| 5855 return false; | 5855 return false; |
| 5856 } | 5856 } |
| 5857 TimelineEventRecorder* timeline_recorder = isolate->timeline_event_recorder(); | 5857 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5858 if (timeline_recorder == NULL) { | 5858 if (timeline_recorder == NULL) { |
| 5859 // Nothing has been recorded. | 5859 // Nothing has been recorded. |
| 5860 return false; | 5860 return false; |
| 5861 } | 5861 } |
| 5862 // Suspend execution of other threads while serializing to JSON. | 5862 // Suspend execution of other threads while serializing to JSON. |
| 5863 isolate->thread_registry()->SafepointThreads(); | 5863 isolate->thread_registry()->SafepointThreads(); |
| 5864 JSONStream js; | 5864 JSONStream js; |
| 5865 timeline_recorder->PrintJSON(&js); | 5865 IsolateTimelineEventFilter filter(isolate); |
| 5866 timeline_recorder->PrintJSON(&js, &filter); |
| 5866 // Resume execution of other threads. | 5867 // Resume execution of other threads. |
| 5867 isolate->thread_registry()->ResumeAllThreads(); | 5868 isolate->thread_registry()->ResumeAllThreads(); |
| 5868 | 5869 |
| 5869 // Copy output. | 5870 // Copy output. |
| 5870 char* output = NULL; | 5871 char* output = NULL; |
| 5871 intptr_t output_length = 0; | 5872 intptr_t output_length = 0; |
| 5872 js.Steal(const_cast<const char**>(&output), &output_length); | 5873 js.Steal(const_cast<const char**>(&output), &output_length); |
| 5873 if (output != NULL) { | 5874 if (output != NULL) { |
| 5874 // Add one for the '\0' character. | 5875 // Add one for the '\0' character. |
| 5875 output_length++; | 5876 output_length++; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5968 RETURN_NULL_ERROR(label); | 5969 RETURN_NULL_ERROR(label); |
| 5969 } | 5970 } |
| 5970 if (async_id == NULL) { | 5971 if (async_id == NULL) { |
| 5971 RETURN_NULL_ERROR(async_id); | 5972 RETURN_NULL_ERROR(async_id); |
| 5972 } | 5973 } |
| 5973 *async_id = -1; | 5974 *async_id = -1; |
| 5974 TimelineStream* stream = isolate->GetEmbedderStream(); | 5975 TimelineStream* stream = isolate->GetEmbedderStream(); |
| 5975 ASSERT(stream != NULL); | 5976 ASSERT(stream != NULL); |
| 5976 TimelineEvent* event = stream->StartEvent(); | 5977 TimelineEvent* event = stream->StartEvent(); |
| 5977 if (event != NULL) { | 5978 if (event != NULL) { |
| 5978 *async_id = event->AsyncBegin(label); | 5979 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 5980 ASSERT(recorder != NULL); |
| 5981 *async_id = recorder->GetNextAsyncId(); |
| 5982 event->AsyncBegin(label, *async_id); |
| 5979 event->Complete(); | 5983 event->Complete(); |
| 5980 } | 5984 } |
| 5981 return Api::Success(); | 5985 return Api::Success(); |
| 5982 } | 5986 } |
| 5983 | 5987 |
| 5984 | 5988 |
| 5985 DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label, | 5989 DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label, |
| 5986 int64_t async_id) { | 5990 int64_t async_id) { |
| 5987 if (async_id < 0) { | 5991 if (async_id < 0) { |
| 5988 return Api::Success(); | 5992 return Api::Success(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6017 ASSERT(stream != NULL); | 6021 ASSERT(stream != NULL); |
| 6018 TimelineEvent* event = stream->StartEvent(); | 6022 TimelineEvent* event = stream->StartEvent(); |
| 6019 if (event != NULL) { | 6023 if (event != NULL) { |
| 6020 event->AsyncEnd(label, async_id); | 6024 event->AsyncEnd(label, async_id); |
| 6021 event->Complete(); | 6025 event->Complete(); |
| 6022 } | 6026 } |
| 6023 return Api::Success(); | 6027 return Api::Success(); |
| 6024 } | 6028 } |
| 6025 | 6029 |
| 6026 } // namespace dart | 6030 } // namespace dart |
| OLD | NEW |