OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/code_index_table.h" | 9 #include "vm/code_index_table.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 | 78 |
79 #if defined(DEBUG) | 79 #if defined(DEBUG) |
80 void IsolateMessageHandler::CheckAccess() { | 80 void IsolateMessageHandler::CheckAccess() { |
81 ASSERT(isolate_ == Isolate::Current()); | 81 ASSERT(isolate_ == Isolate::Current()); |
82 } | 82 } |
83 #endif | 83 #endif |
84 | 84 |
85 | 85 |
| 86 #if defined(DEBUG) |
| 87 // static |
| 88 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { |
| 89 ASSERT(isolate == Isolate::Current()); |
| 90 } |
| 91 #endif |
| 92 |
| 93 |
86 Isolate::Isolate() | 94 Isolate::Isolate() |
87 : store_buffer_(), | 95 : store_buffer_(), |
88 message_notify_callback_(NULL), | 96 message_notify_callback_(NULL), |
89 name_(NULL), | 97 name_(NULL), |
90 main_port_(0), | 98 main_port_(0), |
91 heap_(NULL), | 99 heap_(NULL), |
92 object_store_(NULL), | 100 object_store_(NULL), |
93 top_resource_(NULL), | |
94 top_context_(Context::null()), | 101 top_context_(Context::null()), |
95 current_zone_(NULL), | |
96 #if defined(DEBUG) | 102 #if defined(DEBUG) |
97 no_gc_scope_depth_(0), | 103 no_gc_scope_depth_(0), |
98 no_handle_scope_depth_(0), | 104 no_handle_scope_depth_(0), |
99 top_handle_scope_(NULL), | 105 top_handle_scope_(NULL), |
100 #endif | 106 #endif |
101 random_seed_(Random::kDefaultRandomSeed), | 107 random_seed_(Random::kDefaultRandomSeed), |
102 top_exit_frame_info_(0), | 108 top_exit_frame_info_(0), |
103 init_callback_data_(NULL), | 109 init_callback_data_(NULL), |
104 library_tag_handler_(NULL), | 110 library_tag_handler_(NULL), |
105 api_state_(NULL), | 111 api_state_(NULL), |
106 stub_code_(NULL), | 112 stub_code_(NULL), |
107 code_index_table_(NULL), | 113 code_index_table_(NULL), |
108 debugger_(NULL), | 114 debugger_(NULL), |
109 long_jump_base_(NULL), | 115 long_jump_base_(NULL), |
110 timer_list_(), | 116 timer_list_(), |
111 ast_node_id_(AstNode::kNoId), | 117 ast_node_id_(AstNode::kNoId), |
112 mutex_(new Mutex()), | 118 mutex_(new Mutex()), |
113 stack_limit_(0), | 119 stack_limit_(0), |
114 saved_stack_limit_(0) { | 120 saved_stack_limit_(0) { |
115 } | 121 } |
116 | 122 |
117 | 123 |
118 Isolate::~Isolate() { | 124 Isolate::~Isolate() { |
119 delete [] name_; | 125 delete [] name_; |
120 delete heap_; | 126 delete heap_; |
121 delete object_store_; | 127 delete object_store_; |
122 // Do not delete stack resources: top_resource_ and current_zone_. | |
123 delete api_state_; | 128 delete api_state_; |
124 delete stub_code_; | 129 delete stub_code_; |
125 delete code_index_table_; | 130 delete code_index_table_; |
126 delete debugger_; | 131 delete debugger_; |
127 delete mutex_; | 132 delete mutex_; |
128 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. | 133 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. |
129 delete message_handler_; | 134 delete message_handler_; |
130 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. | 135 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
131 } | 136 } |
132 | 137 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 for (int i = 0; i < invoked_functions.length(); i++) { | 306 for (int i = 0; i < invoked_functions.length(); i++) { |
302 OS::Print("%10d x %s\n", | 307 OS::Print("%10d x %s\n", |
303 invoked_functions[i]->usage_counter(), | 308 invoked_functions[i]->usage_counter(), |
304 invoked_functions[i]->ToFullyQualifiedCString()); | 309 invoked_functions[i]->ToFullyQualifiedCString()); |
305 } | 310 } |
306 } | 311 } |
307 | 312 |
308 | 313 |
309 void Isolate::Shutdown() { | 314 void Isolate::Shutdown() { |
310 ASSERT(this == Isolate::Current()); | 315 ASSERT(this == Isolate::Current()); |
311 ASSERT(top_resource_ == NULL); | 316 ASSERT(top_resource() == NULL); |
312 ASSERT((heap_ == NULL) || heap_->Verify()); | 317 ASSERT((heap_ == NULL) || heap_->Verify()); |
313 | 318 |
314 // Clean up debugger resources. Shutting down the debugger | 319 // Clean up debugger resources. Shutting down the debugger |
315 // requires a handle zone. We must set up a temporary zone because | 320 // requires a handle zone. We must set up a temporary zone because |
316 // Isolate::Shutdown is called without a zone. | 321 // Isolate::Shutdown is called without a zone. |
317 { | 322 { |
318 Zone zone(this); | 323 Zone zone(this); |
319 HandleScope handle_scope(this); | 324 HandleScope handle_scope(this); |
320 debugger_->Shutdown(); | 325 debugger_->Shutdown(); |
321 } | 326 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 477 |
473 | 478 |
474 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 479 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
475 bool visit_prologue_weak_handles) { | 480 bool visit_prologue_weak_handles) { |
476 if (api_state() != NULL) { | 481 if (api_state() != NULL) { |
477 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 482 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
478 } | 483 } |
479 } | 484 } |
480 | 485 |
481 } // namespace dart | 486 } // namespace dart |
OLD | NEW |