| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 Dart_MessageNotifyCallback callback = isolate_->message_notify_callback(); | 76 Dart_MessageNotifyCallback callback = isolate_->message_notify_callback(); |
| 77 if (callback) { | 77 if (callback) { |
| 78 // Allow the embedder to handle message notification. | 78 // Allow the embedder to handle message notification. |
| 79 (*callback)(Api::CastIsolate(isolate_)); | 79 (*callback)(Api::CastIsolate(isolate_)); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 bool IsolateMessageHandler::HandleMessage(Message* message) { | 84 bool IsolateMessageHandler::HandleMessage(Message* message) { |
| 85 StartIsolateScope start_scope(isolate_); | 85 StartIsolateScope start_scope(isolate_); |
| 86 Zone zone(isolate_); | 86 StackZone zone(isolate_); |
| 87 HandleScope handle_scope(isolate_); | 87 HandleScope handle_scope(isolate_); |
| 88 | 88 |
| 89 // Parse the message. | 89 // Parse the message. |
| 90 SnapshotReader reader(message->data(), message->len(), | 90 SnapshotReader reader(message->data(), message->len(), |
| 91 Snapshot::kMessage, Isolate::Current()); | 91 Snapshot::kMessage, Isolate::Current()); |
| 92 const Object& msg_obj = Object::Handle(reader.ReadObject()); | 92 const Object& msg_obj = Object::Handle(reader.ReadObject()); |
| 93 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { | 93 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { |
| 94 // TODO(turnidge): We need to decide what an isolate does with | 94 // TODO(turnidge): We need to decide what an isolate does with |
| 95 // malformed messages. If they (eventually) come from a remote | 95 // malformed messages. If they (eventually) come from a remote |
| 96 // machine, then it might make sense to drop the message entirely. | 96 // machine, then it might make sense to drop the message entirely. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 function ^= class_functions.At(j); | 347 function ^= class_functions.At(j); |
| 348 if (function.usage_counter() > 0) { | 348 if (function.usage_counter() > 0) { |
| 349 functions->Add(&function); | 349 functions->Add(&function); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 void Isolate::PrintInvokedFunctions() { | 355 void Isolate::PrintInvokedFunctions() { |
| 356 ASSERT(this == Isolate::Current()); | 356 ASSERT(this == Isolate::Current()); |
| 357 Zone zone(this); | 357 StackZone zone(this); |
| 358 HandleScope handle_scope(this); | 358 HandleScope handle_scope(this); |
| 359 const GrowableObjectArray& libraries = | 359 const GrowableObjectArray& libraries = |
| 360 GrowableObjectArray::Handle(object_store()->libraries()); | 360 GrowableObjectArray::Handle(object_store()->libraries()); |
| 361 Library& library = Library::Handle(); | 361 Library& library = Library::Handle(); |
| 362 GrowableArray<const Function*> invoked_functions; | 362 GrowableArray<const Function*> invoked_functions; |
| 363 for (int i = 0; i < libraries.Length(); i++) { | 363 for (int i = 0; i < libraries.Length(); i++) { |
| 364 library ^= libraries.At(i); | 364 library ^= libraries.At(i); |
| 365 Class& cls = Class::Handle(); | 365 Class& cls = Class::Handle(); |
| 366 ClassDictionaryIterator iter(library); | 366 ClassDictionaryIterator iter(library); |
| 367 while (iter.HasNext()) { | 367 while (iter.HasNext()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 void Isolate::Shutdown() { | 402 void Isolate::Shutdown() { |
| 403 ASSERT(this == Isolate::Current()); | 403 ASSERT(this == Isolate::Current()); |
| 404 ASSERT(top_resource() == NULL); | 404 ASSERT(top_resource() == NULL); |
| 405 ASSERT((heap_ == NULL) || heap_->Verify()); | 405 ASSERT((heap_ == NULL) || heap_->Verify()); |
| 406 | 406 |
| 407 // Clean up debugger resources. Shutting down the debugger | 407 // Clean up debugger resources. Shutting down the debugger |
| 408 // 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 |
| 409 // Isolate::Shutdown is called without a zone. | 409 // Isolate::Shutdown is called without a zone. |
| 410 { | 410 { |
| 411 Zone zone(this); | 411 StackZone zone(this); |
| 412 HandleScope handle_scope(this); | 412 HandleScope handle_scope(this); |
| 413 debugger_->Shutdown(); | 413 debugger_->Shutdown(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 // Close all the ports owned by this isolate. | 416 // Close all the ports owned by this isolate. |
| 417 PortMap::ClosePorts(message_handler()); | 417 PortMap::ClosePorts(message_handler()); |
| 418 | 418 |
| 419 // 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. |
| 420 delete message_handler(); | 420 delete message_handler(); |
| 421 set_message_handler(NULL); | 421 set_message_handler(NULL); |
| 422 | 422 |
| 423 // Finalize any weak persistent handles with a non-null referent. | 423 // Finalize any weak persistent handles with a non-null referent. |
| 424 FinalizeWeakPersistentHandlesVisitor visitor; | 424 FinalizeWeakPersistentHandlesVisitor visitor; |
| 425 api_state()->weak_persistent_handles().VisitHandles(&visitor); | 425 api_state()->weak_persistent_handles().VisitHandles(&visitor); |
| 426 | 426 |
| 427 // Dump all accumalated timer data for the isolate. | 427 // Dump all accumalated timer data for the isolate. |
| 428 timer_list_.ReportTimers(); | 428 timer_list_.ReportTimers(); |
| 429 if (FLAG_report_usage_count) { | 429 if (FLAG_report_usage_count) { |
| 430 PrintInvokedFunctions(); | 430 PrintInvokedFunctions(); |
| 431 } | 431 } |
| 432 CompilerStats::Print(); | 432 CompilerStats::Print(); |
| 433 if (FLAG_generate_gdb_symbols) { | 433 if (FLAG_generate_gdb_symbols) { |
| 434 DebugInfo::UnregisterAllSections(); | 434 DebugInfo::UnregisterAllSections(); |
| 435 } | 435 } |
| 436 if (FLAG_trace_isolates) { | 436 if (FLAG_trace_isolates) { |
| 437 Zone zone(this); | 437 StackZone zone(this); |
| 438 HandleScope handle_scope(this); | 438 HandleScope handle_scope(this); |
| 439 OS::Print("Number of symbols added = %"Pd"\n", Symbols::Size(this)); | 439 OS::Print("Number of symbols added = %"Pd"\n", Symbols::Size(this)); |
| 440 OS::Print("[-] Stopping isolate:\n" | 440 OS::Print("[-] Stopping isolate:\n" |
| 441 "\tisolate: %s\n", name()); | 441 "\tisolate: %s\n", name()); |
| 442 } | 442 } |
| 443 // TODO(5411455): For now just make sure there are no current isolates | 443 // TODO(5411455): For now just make sure there are no current isolates |
| 444 // as we are shutting down the isolate. | 444 // as we are shutting down the isolate. |
| 445 SetCurrent(NULL); | 445 SetCurrent(NULL); |
| 446 } | 446 } |
| 447 | 447 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 | 494 |
| 495 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 495 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
| 496 bool visit_prologue_weak_handles) { | 496 bool visit_prologue_weak_handles) { |
| 497 if (api_state() != NULL) { | 497 if (api_state() != NULL) { |
| 498 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 498 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace dart | 502 } // namespace dart |
| OLD | NEW |