| 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 "lib/mirrors.h" | 9 #include "lib/mirrors.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 const char* name() const; | 42 const char* name() const; |
| 43 void MessageNotify(Message::Priority priority); | 43 void MessageNotify(Message::Priority priority); |
| 44 bool HandleMessage(Message* message); | 44 bool HandleMessage(Message* message); |
| 45 | 45 |
| 46 #if defined(DEBUG) | 46 #if defined(DEBUG) |
| 47 // Check that it is safe to access this handler. | 47 // Check that it is safe to access this handler. |
| 48 void CheckAccess(); | 48 void CheckAccess(); |
| 49 #endif | 49 #endif |
| 50 bool IsCurrentIsolate() const; | 50 bool IsCurrentIsolate() const; |
| 51 Isolate* GetIsolate() const { return isolate_; } |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 Isolate* isolate_; | 54 Isolate* isolate_; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 | 57 |
| 57 IsolateMessageHandler::IsolateMessageHandler(Isolate* isolate) | 58 IsolateMessageHandler::IsolateMessageHandler(Isolate* isolate) |
| 58 : isolate_(isolate) { | 59 : isolate_(isolate) { |
| 59 } | 60 } |
| 60 | 61 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 result->set_api_state(state); | 229 result->set_api_state(state); |
| 229 | 230 |
| 230 // Initialize stack top and limit in case we are running the isolate in the | 231 // Initialize stack top and limit in case we are running the isolate in the |
| 231 // main thread. | 232 // main thread. |
| 232 // TODO(5411455): Need to figure out how to set the stack limit for the | 233 // TODO(5411455): Need to figure out how to set the stack limit for the |
| 233 // main thread. | 234 // main thread. |
| 234 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); | 235 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); |
| 235 result->set_main_port(PortMap::CreatePort(result->message_handler())); | 236 result->set_main_port(PortMap::CreatePort(result->message_handler())); |
| 236 result->BuildName(name_prefix); | 237 result->BuildName(name_prefix); |
| 237 | 238 |
| 239 // Signal isolate creation event. |
| 240 Debugger::SignalIsolateEvent(Debugger::kIsolateCreated); |
| 241 |
| 238 result->debugger_ = new Debugger(); | 242 result->debugger_ = new Debugger(); |
| 239 result->debugger_->Initialize(result); | 243 result->debugger_->Initialize(result); |
| 240 if (FLAG_trace_isolates) { | 244 if (FLAG_trace_isolates) { |
| 241 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { | 245 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { |
| 242 OS::Print("[+] Starting isolate:\n" | 246 OS::Print("[+] Starting isolate:\n" |
| 243 "\tisolate: %s\n", result->name()); | 247 "\tisolate: %s\n", result->name()); |
| 244 } | 248 } |
| 245 } | 249 } |
| 246 return result; | 250 return result; |
| 247 } | 251 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 409 |
| 406 // Clean up debugger resources. Shutting down the debugger | 410 // Clean up debugger resources. Shutting down the debugger |
| 407 // requires a handle zone. We must set up a temporary zone because | 411 // requires a handle zone. We must set up a temporary zone because |
| 408 // Isolate::Shutdown is called without a zone. | 412 // Isolate::Shutdown is called without a zone. |
| 409 { | 413 { |
| 410 Zone zone(this); | 414 Zone zone(this); |
| 411 HandleScope handle_scope(this); | 415 HandleScope handle_scope(this); |
| 412 debugger_->Shutdown(); | 416 debugger_->Shutdown(); |
| 413 } | 417 } |
| 414 | 418 |
| 419 // Signal isolate shutdown event. |
| 420 Debugger::SignalIsolateEvent(Debugger::kIsolateShutdown); |
| 421 |
| 415 // Close all the ports owned by this isolate. | 422 // Close all the ports owned by this isolate. |
| 416 PortMap::ClosePorts(message_handler()); | 423 PortMap::ClosePorts(message_handler()); |
| 417 | 424 |
| 418 // Fail fast if anybody tries to post any more messsages to this isolate. | 425 // Fail fast if anybody tries to post any more messsages to this isolate. |
| 419 delete message_handler(); | 426 delete message_handler(); |
| 420 set_message_handler(NULL); | 427 set_message_handler(NULL); |
| 421 | 428 |
| 422 // Finalize any weak persistent handles with a non-null referent. | 429 // Finalize any weak persistent handles with a non-null referent. |
| 423 FinalizeWeakPersistentHandlesVisitor visitor; | 430 FinalizeWeakPersistentHandlesVisitor visitor; |
| 424 api_state()->weak_persistent_handles().VisitHandles(&visitor); | 431 api_state()->weak_persistent_handles().VisitHandles(&visitor); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 499 |
| 493 | 500 |
| 494 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 501 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
| 495 bool visit_prologue_weak_handles) { | 502 bool visit_prologue_weak_handles) { |
| 496 if (api_state() != NULL) { | 503 if (api_state() != NULL) { |
| 497 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 504 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
| 498 } | 505 } |
| 499 } | 506 } |
| 500 | 507 |
| 501 } // namespace dart | 508 } // namespace dart |
| OLD | NEW |