| 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 5755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5766 Isolate* isolate = Isolate::Current(); | 5766 Isolate* isolate = Isolate::Current(); |
| 5767 CHECK_ISOLATE(isolate); | 5767 CHECK_ISOLATE(isolate); |
| 5768 if (consumer == NULL) { | 5768 if (consumer == NULL) { |
| 5769 return false; | 5769 return false; |
| 5770 } | 5770 } |
| 5771 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5771 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5772 if (timeline_recorder == NULL) { | 5772 if (timeline_recorder == NULL) { |
| 5773 // Nothing has been recorded. | 5773 // Nothing has been recorded. |
| 5774 return false; | 5774 return false; |
| 5775 } | 5775 } |
| 5776 // Suspend execution of other threads while serializing to JSON. | 5776 // Reclaim all blocks cached by isolate. |
| 5777 isolate->thread_registry()->SafepointThreads(); | 5777 Timeline::ReclaimIsolateBlocks(); |
| 5778 // TODO(johnmccutchan): Reclaim open blocks from isolate so we have a complete | |
| 5779 // timeline. | |
| 5780 JSONStream js; | 5778 JSONStream js; |
| 5781 IsolateTimelineEventFilter filter(isolate); | 5779 IsolateTimelineEventFilter filter(isolate); |
| 5782 timeline_recorder->PrintJSON(&js, &filter); | 5780 timeline_recorder->PrintJSON(&js, &filter); |
| 5783 // Resume execution of other threads. | |
| 5784 isolate->thread_registry()->ResumeAllThreads(); | |
| 5785 | 5781 |
| 5786 // Copy output. | 5782 // Copy output. |
| 5787 char* output = NULL; | 5783 char* output = NULL; |
| 5788 intptr_t output_length = 0; | 5784 intptr_t output_length = 0; |
| 5789 js.Steal(const_cast<const char**>(&output), &output_length); | 5785 js.Steal(const_cast<const char**>(&output), &output_length); |
| 5790 if (output != NULL) { | 5786 if (output != NULL) { |
| 5791 // Add one for the '\0' character. | 5787 // Add one for the '\0' character. |
| 5792 output_length++; | 5788 output_length++; |
| 5793 } | 5789 } |
| 5794 StreamToConsumer(consumer, user_data, output, output_length); | 5790 StreamToConsumer(consumer, user_data, output, output_length); |
| 5795 | 5791 |
| 5796 // We stole the JSONStream's output buffer, free it. | 5792 // We stole the JSONStream's output buffer, free it. |
| 5797 free(output); | 5793 free(output); |
| 5798 return true; | 5794 return true; |
| 5799 } | 5795 } |
| 5800 | 5796 |
| 5801 | 5797 |
| 5802 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, | 5798 DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, |
| 5803 void* user_data) { | 5799 void* user_data) { |
| 5804 if (consumer == NULL) { | 5800 if (consumer == NULL) { |
| 5805 return false; | 5801 return false; |
| 5806 } | 5802 } |
| 5807 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); | 5803 TimelineEventRecorder* timeline_recorder = Timeline::recorder(); |
| 5808 if (timeline_recorder == NULL) { | 5804 if (timeline_recorder == NULL) { |
| 5809 // Nothing has been recorded. | 5805 // Nothing has been recorded. |
| 5810 return false; | 5806 return false; |
| 5811 } | 5807 } |
| 5812 | 5808 |
| 5813 // TODO(johnmccutchan): Reclaim all open blocks from the system so we have | 5809 // Reclaim all blocks cached in the system. |
| 5814 // a complete timeline. | 5810 Timeline::ReclaimAllBlocks(); |
| 5815 JSONStream js; | 5811 JSONStream js; |
| 5816 TimelineEventFilter filter; | 5812 TimelineEventFilter filter; |
| 5817 timeline_recorder->PrintJSON(&js, &filter); | 5813 timeline_recorder->PrintJSON(&js, &filter); |
| 5818 | 5814 |
| 5819 // Copy output. | 5815 // Copy output. |
| 5820 char* output = NULL; | 5816 char* output = NULL; |
| 5821 intptr_t output_length = 0; | 5817 intptr_t output_length = 0; |
| 5822 js.Steal(const_cast<const char**>(&output), &output_length); | 5818 js.Steal(const_cast<const char**>(&output), &output_length); |
| 5823 if (output != NULL) { | 5819 if (output != NULL) { |
| 5824 // Add one for the '\0' character. | 5820 // Add one for the '\0' character. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6001 ApiReallocate); | 5997 ApiReallocate); |
| 6002 writer.WriteFullSnapshot(); | 5998 writer.WriteFullSnapshot(); |
| 6003 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 5999 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
| 6004 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6000 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
| 6005 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); | 6001 *instructions_snapshot_size = writer.InstructionsSnapshotSize(); |
| 6006 | 6002 |
| 6007 return Api::Success(); | 6003 return Api::Success(); |
| 6008 } | 6004 } |
| 6009 | 6005 |
| 6010 } // namespace dart | 6006 } // namespace dart |
| OLD | NEW |