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); |
41 // There should be no top api scopes at this point. | 43 // There should be no top api scopes at this point. |
42 ASSERT(api_top_scope() == NULL); | 44 ASSERT(api_top_scope() == NULL); |
43 // Delete the resusable api scope if there is one. | 45 // Delete the resusable api scope if there is one. |
44 if (api_reusable_scope_) { | 46 if (api_reusable_scope_) { |
45 delete api_reusable_scope_; | 47 delete api_reusable_scope_; |
46 api_reusable_scope_ = NULL; | 48 api_reusable_scope_ = NULL; |
47 } | 49 } |
48 delete thread_lock_; | 50 delete thread_lock_; |
49 thread_lock_ = NULL; | 51 thread_lock_ = NULL; |
50 } | 52 } |
(...skipping 16 matching lines...) Expand all Loading... |
67 isolate_(NULL), | 69 isolate_(NULL), |
68 heap_(NULL), | 70 heap_(NULL), |
69 top_exit_frame_info_(0), | 71 top_exit_frame_info_(0), |
70 store_buffer_block_(NULL), | 72 store_buffer_block_(NULL), |
71 vm_tag_(0), | 73 vm_tag_(0), |
72 task_kind_(kUnknownTask), | 74 task_kind_(kUnknownTask), |
73 dart_stream_(NULL), | 75 dart_stream_(NULL), |
74 os_thread_(NULL), | 76 os_thread_(NULL), |
75 thread_lock_(new Monitor()), | 77 thread_lock_(new Monitor()), |
76 zone_(NULL), | 78 zone_(NULL), |
| 79 current_thread_memory_(0), |
| 80 memory_high_watermark_(0), |
77 api_reusable_scope_(NULL), | 81 api_reusable_scope_(NULL), |
78 api_top_scope_(NULL), | 82 api_top_scope_(NULL), |
79 top_resource_(NULL), | 83 top_resource_(NULL), |
80 long_jump_base_(NULL), | 84 long_jump_base_(NULL), |
81 no_callback_scope_depth_(0), | 85 no_callback_scope_depth_(0), |
82 #if defined(DEBUG) | 86 #if defined(DEBUG) |
83 top_handle_scope_(NULL), | 87 top_handle_scope_(NULL), |
84 no_handle_scope_depth_(0), | 88 no_handle_scope_depth_(0), |
85 no_safepoint_scope_depth_(0), | 89 no_safepoint_scope_depth_(0), |
86 #endif | 90 #endif |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 210 |
207 | 211 |
208 #ifndef PRODUCT | 212 #ifndef PRODUCT |
209 // Collect information about each individual zone associated with this thread. | 213 // Collect information about each individual zone associated with this thread. |
210 void Thread::PrintJSON(JSONStream* stream) const { | 214 void Thread::PrintJSON(JSONStream* stream) const { |
211 JSONObject jsobj(stream); | 215 JSONObject jsobj(stream); |
212 jsobj.AddProperty("type", "_Thread"); | 216 jsobj.AddProperty("type", "_Thread"); |
213 jsobj.AddPropertyF("id", "threads/%" Pd "", | 217 jsobj.AddPropertyF("id", "threads/%" Pd "", |
214 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); | 218 OSThread::ThreadIdToIntPtr(os_thread()->trace_id())); |
215 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); | 219 jsobj.AddProperty("kind", TaskKindToCString(task_kind())); |
| 220 jsobj.AddPropertyF("_memoryHighWatermark", "%" Pu "", memory_high_watermark_); |
216 Zone* zone = zone_; | 221 Zone* zone = zone_; |
217 { | 222 { |
218 JSONArray zone_info_array(&jsobj, "zones"); | 223 JSONArray zone_info_array(&jsobj, "zones"); |
219 zone = zone_; | 224 zone = zone_; |
220 while (zone != NULL) { | 225 while (zone != NULL) { |
221 zone_info_array.AddValue(zone); | 226 zone_info_array.AddValue(zone); |
222 zone = zone->previous(); | 227 zone = zone->previous(); |
223 } | 228 } |
224 } | 229 } |
225 } | 230 } |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 820 |
816 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 821 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
817 if (thread() != NULL) { | 822 if (thread() != NULL) { |
818 OSThread* os_thread = thread()->os_thread(); | 823 OSThread* os_thread = thread()->os_thread(); |
819 ASSERT(os_thread != NULL); | 824 ASSERT(os_thread != NULL); |
820 os_thread->EnableThreadInterrupts(); | 825 os_thread->EnableThreadInterrupts(); |
821 } | 826 } |
822 } | 827 } |
823 | 828 |
824 } // namespace dart | 829 } // namespace dart |
OLD | NEW |