| 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 5746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5757 Isolate* isolate = Isolate::Current(); | 5757 Isolate* isolate = Isolate::Current(); |
| 5758 CHECK_ISOLATE(isolate); | 5758 CHECK_ISOLATE(isolate); |
| 5759 if (consumer == NULL) { | 5759 if (consumer == NULL) { |
| 5760 return false; | 5760 return false; |
| 5761 } | 5761 } |
| 5762 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5762 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5763 if (timeline_recorder == NULL) { | 5763 if (timeline_recorder == NULL) { |
| 5764 // Nothing has been recorded. | 5764 // Nothing has been recorded. |
| 5765 return false; | 5765 return false; |
| 5766 } | 5766 } |
| 5767 // Suspend execution of other threads while serializing to JSON. | 5767 // Reclaim all blocks cached by isolate. |
| 5768 isolate->thread_registry()->SafepointThreads(); | 5768 Timeline::ReclaimIsolateBlocks(); |
| 5769 // TODO(johnmccutchan): Reclaim open blocks from isolate so we have a complete | |
| 5770 // timeline. | |
| 5771 JSONStream js; | 5769 JSONStream js; |
| 5772 IsolateTimelineEventFilter filter(isolate); | 5770 IsolateTimelineEventFilter filter(isolate); |
| 5773 timeline_recorder->PrintJSON(&js, &filter); | 5771 timeline_recorder->PrintJSON(&js, &filter); |
| 5774 // Resume execution of other threads. | |
| 5775 isolate->thread_registry()->ResumeAllThreads(); | |
| 5776 | 5772 |
| 5777 // Copy output. | 5773 // Copy output. |
| 5778 char* output = NULL; | 5774 char* output = NULL; |
| 5779 intptr_t output_length = 0; | 5775 intptr_t output_length = 0; |
| 5780 js.Steal(const_cast<const char**>(&output), &output_length); | 5776 js.Steal(const_cast<const char**>(&output), &output_length); |
| 5781 if (output != NULL) { | 5777 if (output != NULL) { |
| 5782 // Add one for the '\0' character. | 5778 // Add one for the '\0' character. |
| 5783 output_length++; | 5779 output_length++; |
| 5784 } | 5780 } |
| 5785 StreamToConsumer(consumer, user_data, output, output_length); | 5781 StreamToConsumer(consumer, user_data, output, output_length); |
| 5786 | 5782 |
| 5787 // We stole the JSONStream's output buffer, free it. | 5783 // We stole the JSONStream's output buffer, free it. |
| 5788 free(output); | 5784 free(output); |
| 5789 return true; | 5785 return true; |
| 5790 } | 5786 } |
| 5791 | 5787 |
| 5792 | 5788 |
| 5793 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, | 5789 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, |
| 5794 void* user_data) { | 5790 void* user_data) { |
| 5795 if (consumer == NULL) { | 5791 if (consumer == NULL) { |
| 5796 return false; | 5792 return false; |
| 5797 } | 5793 } |
| 5798 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5794 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5799 if (timeline_recorder == NULL) { | 5795 if (timeline_recorder == NULL) { |
| 5800 // Nothing has been recorded. | 5796 // Nothing has been recorded. |
| 5801 return false; | 5797 return false; |
| 5802 } | 5798 } |
| 5803 | 5799 |
| 5804 // TODO(johnmccutchan): Reclaim all open blocks from the system so we have | 5800 // Reclaim all blocks cached in the system. |
| 5805 // a complete timeline. | 5801 Timeline::ReclaimAllBlocks(); |
| 5806 JSONStream js; | 5802 JSONStream js; |
| 5807 TimelineEventFilter filter; | 5803 TimelineEventFilter filter; |
| 5808 timeline_recorder->PrintJSON(&js, &filter); | 5804 timeline_recorder->PrintJSON(&js, &filter); |
| 5809 | 5805 |
| 5810 // Copy output. | 5806 // Copy output. |
| 5811 char* output = NULL; | 5807 char* output = NULL; |
| 5812 intptr_t output_length = 0; | 5808 intptr_t output_length = 0; |
| 5813 js.Steal(const_cast<const char**>(&output), &output_length); | 5809 js.Steal(const_cast<const char**>(&output), &output_length); |
| 5814 if (output != NULL) { | 5810 if (output != NULL) { |
| 5815 // Add one for the '\0' character. | 5811 // Add one for the '\0' character. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5985 ApiReallocate); | 5981 ApiReallocate); |
| 5986 writer.WriteFullSnapshot(); | 5982 writer.WriteFullSnapshot(); |
| 5987 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 5983 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 5988 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 5984 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 5989 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 5985 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
| 5990 | 5986 |
| 5991 return Api::Success(); | 5987 return Api::Success(); |
| 5992 } | 5988 } |
| 5993 | 5989 |
| 5994 } // namespace dart | 5990 } // namespace dart |
| OLD | NEW |