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 virtual Isolate* GetIsolate() const { return isolate_; } |
52 | 52 |
53 private: | 53 private: |
54 Isolate* isolate_; | 54 Isolate* isolate_; |
55 }; | 55 }; |
56 | 56 |
57 | 57 |
58 IsolateMessageHandler::IsolateMessageHandler(Isolate* isolate) | 58 IsolateMessageHandler::IsolateMessageHandler(Isolate* isolate) |
59 : isolate_(isolate) { | 59 : isolate_(isolate) { |
60 } | 60 } |
61 | 61 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 result->set_api_state(state); | 229 result->set_api_state(state); |
230 | 230 |
231 // 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 |
232 // main thread. | 232 // main thread. |
233 // 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 |
234 // main thread. | 234 // main thread. |
235 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); | 235 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); |
236 result->set_main_port(PortMap::CreatePort(result->message_handler())); | 236 result->set_main_port(PortMap::CreatePort(result->message_handler())); |
237 result->BuildName(name_prefix); | 237 result->BuildName(name_prefix); |
238 | 238 |
239 // Signal isolate creation event. | |
240 Debugger::SignalIsolateEvent(Debugger::kIsolateCreated); | |
241 | |
242 result->debugger_ = new Debugger(); | 239 result->debugger_ = new Debugger(); |
243 result->debugger_->Initialize(result); | 240 result->debugger_->Initialize(result); |
244 if (FLAG_trace_isolates) { | 241 if (FLAG_trace_isolates) { |
245 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { | 242 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { |
246 OS::Print("[+] Starting isolate:\n" | 243 OS::Print("[+] Starting isolate:\n" |
247 "\tisolate: %s\n", result->name()); | 244 "\tisolate: %s\n", result->name()); |
248 } | 245 } |
249 } | 246 } |
250 return result; | 247 return result; |
251 } | 248 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 406 |
410 // Clean up debugger resources. Shutting down the debugger | 407 // Clean up debugger resources. Shutting down the debugger |
411 // requires a handle zone. We must set up a temporary zone because | 408 // requires a handle zone. We must set up a temporary zone because |
412 // Isolate::Shutdown is called without a zone. | 409 // Isolate::Shutdown is called without a zone. |
413 { | 410 { |
414 Zone zone(this); | 411 Zone zone(this); |
415 HandleScope handle_scope(this); | 412 HandleScope handle_scope(this); |
416 debugger_->Shutdown(); | 413 debugger_->Shutdown(); |
417 } | 414 } |
418 | 415 |
419 // Signal isolate shutdown event. | |
420 Debugger::SignalIsolateEvent(Debugger::kIsolateShutdown); | |
421 | |
422 // Close all the ports owned by this isolate. | 416 // Close all the ports owned by this isolate. |
423 PortMap::ClosePorts(message_handler()); | 417 PortMap::ClosePorts(message_handler()); |
424 | 418 |
425 // Fail fast if anybody tries to post any more messsages to this isolate. | 419 // Fail fast if anybody tries to post any more messsages to this isolate. |
426 delete message_handler(); | 420 delete message_handler(); |
427 set_message_handler(NULL); | 421 set_message_handler(NULL); |
428 | 422 |
429 // Finalize any weak persistent handles with a non-null referent. | 423 // Finalize any weak persistent handles with a non-null referent. |
430 FinalizeWeakPersistentHandlesVisitor visitor; | 424 FinalizeWeakPersistentHandlesVisitor visitor; |
431 api_state()->weak_persistent_handles().VisitHandles(&visitor); | 425 api_state()->weak_persistent_handles().VisitHandles(&visitor); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 493 |
500 | 494 |
501 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 495 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
502 bool visit_prologue_weak_handles) { | 496 bool visit_prologue_weak_handles) { |
503 if (api_state() != NULL) { | 497 if (api_state() != NULL) { |
504 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 498 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
505 } | 499 } |
506 } | 500 } |
507 | 501 |
508 } // namespace dart | 502 } // namespace dart |
OLD | NEW |