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/thread.h" | 5 #include "vm/thread.h" |
6 | 6 |
7 #include "vm/compiler_stats.h" | 7 #include "vm/compiler_stats.h" |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 DECLARE_FLAG(bool, trace_service_verbose); | 31 DECLARE_FLAG(bool, trace_service_verbose); |
32 | 32 |
33 | 33 |
34 Thread::~Thread() { | 34 Thread::~Thread() { |
35 // We should cleanly exit any isolate before destruction. | 35 // We should cleanly exit any isolate before destruction. |
36 ASSERT(isolate_ == NULL); | 36 ASSERT(isolate_ == NULL); |
37 if (compiler_stats_ != NULL) { | 37 if (compiler_stats_ != NULL) { |
38 delete compiler_stats_; | 38 delete compiler_stats_; |
39 compiler_stats_ = NULL; | 39 compiler_stats_ = NULL; |
40 } | 40 } |
41 // All zone allocated memory should be free by this point. | |
42 ASSERT(current_thread_memory_ == 0); | |
43 // There should be no top api scopes at this point. | 41 // There should be no top api scopes at this point. |
44 ASSERT(api_top_scope() == NULL); | 42 ASSERT(api_top_scope() == NULL); |
45 // Delete the resusable api scope if there is one. | 43 // Delete the resusable api scope if there is one. |
46 if (api_reusable_scope_) { | 44 if (api_reusable_scope_) { |
47 delete api_reusable_scope_; | 45 delete api_reusable_scope_; |
48 api_reusable_scope_ = NULL; | 46 api_reusable_scope_ = NULL; |
49 } | 47 } |
50 delete thread_lock_; | 48 delete thread_lock_; |
51 thread_lock_ = NULL; | 49 thread_lock_ = NULL; |
52 } | 50 } |
(...skipping 16 matching lines...) Expand all Loading... |
69 isolate_(NULL), | 67 isolate_(NULL), |
70 heap_(NULL), | 68 heap_(NULL), |
71 top_exit_frame_info_(0), | 69 top_exit_frame_info_(0), |
72 store_buffer_block_(NULL), | 70 store_buffer_block_(NULL), |
73 vm_tag_(0), | 71 vm_tag_(0), |
74 task_kind_(kUnknownTask), | 72 task_kind_(kUnknownTask), |
75 dart_stream_(NULL), | 73 dart_stream_(NULL), |
76 os_thread_(NULL), | 74 os_thread_(NULL), |
77 thread_lock_(new Monitor()), | 75 thread_lock_(new Monitor()), |
78 zone_(NULL), | 76 zone_(NULL), |
79 current_thread_memory_(0), | |
80 memory_high_watermark_(0), | |
81 api_reusable_scope_(NULL), | 77 api_reusable_scope_(NULL), |
82 api_top_scope_(NULL), | 78 api_top_scope_(NULL), |
83 top_resource_(NULL), | 79 top_resource_(NULL), |
84 long_jump_base_(NULL), | 80 long_jump_base_(NULL), |
85 no_callback_scope_depth_(0), | 81 no_callback_scope_depth_(0), |
86 #if defined(DEBUG) | 82 #if defined(DEBUG) |
87 top_handle_scope_(NULL), | 83 top_handle_scope_(NULL), |
88 no_handle_scope_depth_(0), | 84 no_handle_scope_depth_(0), |
89 no_safepoint_scope_depth_(0), | 85 no_safepoint_scope_depth_(0), |
90 #endif | 86 #endif |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 206 |
211 | 207 |
212 #ifndef PRODUCT | 208 #ifndef PRODUCT |
213 // Collect information about each individual zone associated with this thread. | 209 // Collect information about each individual zone associated with this thread. |
214 void Thread::PrintJSON(JSONStream* stream) const { | 210 void Thread::PrintJSON(JSONStream* stream) const { |
215 JSONObject jsobj(stream); | 211 JSONObject jsobj(stream); |
216 jsobj.AddProperty("type", "_Thread"); | 212 jsobj.AddProperty("type", "_Thread"); |
217 jsobj.AddPropertyF("id", "threads/%" Pd "", | 213 jsobj.AddPropertyF("id", "threads/%" Pd "", |
218 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); | 214 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); |
219 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); | 215 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); |
220 jsobj.AddPropertyF("_memoryHighWatermark", "%u", memory_high_watermark_); | |
221 Zone* zone = zone_; | 216 Zone* zone = zone_; |
222 { | 217 { |
223 JSONArray zone_info_array(&jsobj, "zones"); | 218 JSONArray zone_info_array(&jsobj, "zones"); |
224 zone = zone_; | 219 zone = zone_; |
225 while (zone != NULL) { | 220 while (zone != NULL) { |
226 zone_info_array.AddValue(zone); | 221 zone_info_array.AddValue(zone); |
227 zone = zone->previous(); | 222 zone = zone->previous(); |
228 } | 223 } |
229 } | 224 } |
230 } | 225 } |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 | 839 |
845 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 840 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
846 if (thread() != NULL) { | 841 if (thread() != NULL) { |
847 OSThread* os_thread = thread()->os_thread(); | 842 OSThread* os_thread = thread()->os_thread(); |
848 ASSERT(os_thread != NULL); | 843 ASSERT(os_thread != NULL); |
849 os_thread->EnableThreadInterrupts(); | 844 os_thread->EnableThreadInterrupts(); |
850 } | 845 } |
851 } | 846 } |
852 | 847 |
853 } // namespace dart | 848 } // namespace dart |
OLD | NEW |