| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/json.h" | 9 #include "platform/json.h" |
| 10 #include "lib/mirrors.h" | 10 #include "lib/mirrors.h" |
| 11 #include "vm/code_observers.h" | 11 #include "vm/code_observers.h" |
| 12 #include "vm/compiler_stats.h" | 12 #include "vm/compiler_stats.h" |
| 13 #include "vm/coverage.h" | 13 #include "vm/coverage.h" |
| 14 #include "vm/dart_api_state.h" | 14 #include "vm/dart_api_state.h" |
| 15 #include "vm/dart_entry.h" | 15 #include "vm/dart_entry.h" |
| 16 #include "vm/debugger.h" | 16 #include "vm/debugger.h" |
| 17 #include "vm/deopt_instructions.h" | 17 #include "vm/deopt_instructions.h" |
| 18 #include "vm/heap.h" | 18 #include "vm/heap.h" |
| 19 #include "vm/heap_histogram.h" | 19 #include "vm/heap_histogram.h" |
| 20 #include "vm/message_handler.h" | 20 #include "vm/message_handler.h" |
| 21 #include "vm/object_id_ring.h" | 21 #include "vm/object_id_ring.h" |
| 22 #include "vm/object_store.h" | 22 #include "vm/object_store.h" |
| 23 #include "vm/parser.h" | 23 #include "vm/parser.h" |
| 24 #include "vm/port.h" | 24 #include "vm/port.h" |
| 25 #include "vm/profiler.h" | 25 #include "vm/profiler.h" |
| 26 #include "vm/reusable_handles.h" | 26 #include "vm/reusable_handles.h" |
| 27 #include "vm/service.h" | 27 #include "vm/service.h" |
| 28 #include "vm/signal_handler.h" | |
| 29 #include "vm/simulator.h" | 28 #include "vm/simulator.h" |
| 30 #include "vm/stack_frame.h" | 29 #include "vm/stack_frame.h" |
| 31 #include "vm/stub_code.h" | 30 #include "vm/stub_code.h" |
| 32 #include "vm/symbols.h" | 31 #include "vm/symbols.h" |
| 33 #include "vm/thread.h" | 32 #include "vm/thread.h" |
| 34 #include "vm/timer.h" | 33 #include "vm/timer.h" |
| 35 #include "vm/visitor.h" | 34 #include "vm/visitor.h" |
| 36 | 35 |
| 37 | 36 |
| 38 namespace dart { | 37 namespace dart { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 #endif | 332 #endif |
| 334 delete mutex_; | 333 delete mutex_; |
| 335 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. | 334 mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. |
| 336 delete message_handler_; | 335 delete message_handler_; |
| 337 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. | 336 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
| 338 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. | 337 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. |
| 339 delete object_histogram_; | 338 delete object_histogram_; |
| 340 } | 339 } |
| 341 | 340 |
| 342 void Isolate::SetCurrent(Isolate* current) { | 341 void Isolate::SetCurrent(Isolate* current) { |
| 343 ScopedSignalBlocker ssb; | |
| 344 Isolate* old_isolate = Current(); | 342 Isolate* old_isolate = Current(); |
| 345 if (old_isolate != NULL) { | 343 if (old_isolate != NULL) { |
| 346 ProfilerManager::DescheduleIsolate(old_isolate); | 344 ProfilerManager::DescheduleIsolate(old_isolate); |
| 347 } | 345 } |
| 348 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); | 346 Thread::SetThreadLocal(isolate_key, reinterpret_cast<uword>(current)); |
| 349 if (current != NULL) { | 347 if (current != NULL) { |
| 350 ProfilerManager::ScheduleIsolate(current); | 348 ProfilerManager::ScheduleIsolate(current); |
| 351 } | 349 } |
| 352 } | 350 } |
| 353 | 351 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 ASSERT(this == Isolate::Current()); | 695 ASSERT(this == Isolate::Current()); |
| 698 ASSERT(top_resource() == NULL); | 696 ASSERT(top_resource() == NULL); |
| 699 ASSERT((heap_ == NULL) || heap_->Verify()); | 697 ASSERT((heap_ == NULL) || heap_->Verify()); |
| 700 | 698 |
| 701 // Create an area where we do have a zone and a handle scope so that we can | 699 // Create an area where we do have a zone and a handle scope so that we can |
| 702 // call VM functions while tearing this isolate down. | 700 // call VM functions while tearing this isolate down. |
| 703 { | 701 { |
| 704 StackZone stack_zone(this); | 702 StackZone stack_zone(this); |
| 705 HandleScope handle_scope(this); | 703 HandleScope handle_scope(this); |
| 706 | 704 |
| 707 ScopedSignalBlocker ssb; | |
| 708 | |
| 709 ProfilerManager::DescheduleIsolate(this); | |
| 710 | |
| 711 | |
| 712 if (FLAG_print_object_histogram) { | 705 if (FLAG_print_object_histogram) { |
| 713 heap()->CollectAllGarbage(); | 706 heap()->CollectAllGarbage(); |
| 714 object_histogram()->Print(); | 707 object_histogram()->Print(); |
| 715 } | 708 } |
| 716 | 709 |
| 717 // Clean up debugger resources. | 710 // Clean up debugger resources. |
| 718 debugger()->Shutdown(); | 711 debugger()->Shutdown(); |
| 719 | 712 |
| 720 // Close all the ports owned by this isolate. | 713 // Close all the ports owned by this isolate. |
| 721 PortMap::ClosePorts(message_handler()); | 714 PortMap::ClosePorts(message_handler()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 743 megamorphic_cache_table()->PrintSizes(); | 736 megamorphic_cache_table()->PrintSizes(); |
| 744 Symbols::DumpStats(); | 737 Symbols::DumpStats(); |
| 745 OS::Print("[-] Stopping isolate:\n" | 738 OS::Print("[-] Stopping isolate:\n" |
| 746 "\tisolate: %s\n", name()); | 739 "\tisolate: %s\n", name()); |
| 747 } | 740 } |
| 748 } | 741 } |
| 749 | 742 |
| 750 // TODO(5411455): For now just make sure there are no current isolates | 743 // TODO(5411455): For now just make sure there are no current isolates |
| 751 // as we are shutting down the isolate. | 744 // as we are shutting down the isolate. |
| 752 SetCurrent(NULL); | 745 SetCurrent(NULL); |
| 746 ProfilerManager::DescheduleIsolate(this); |
| 753 ProfilerManager::ShutdownIsolateForProfiling(this); | 747 ProfilerManager::ShutdownIsolateForProfiling(this); |
| 754 } | 748 } |
| 755 | 749 |
| 756 | 750 |
| 757 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 751 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
| 758 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | 752 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; |
| 759 Dart_IsolateUnhandledExceptionCallback | 753 Dart_IsolateUnhandledExceptionCallback |
| 760 Isolate::unhandled_exception_callback_ = NULL; | 754 Isolate::unhandled_exception_callback_ = NULL; |
| 761 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 755 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
| 762 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 756 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 return func.raw(); | 1119 return func.raw(); |
| 1126 } | 1120 } |
| 1127 | 1121 |
| 1128 | 1122 |
| 1129 void IsolateSpawnState::Cleanup() { | 1123 void IsolateSpawnState::Cleanup() { |
| 1130 SwitchIsolateScope switch_scope(isolate()); | 1124 SwitchIsolateScope switch_scope(isolate()); |
| 1131 Dart::ShutdownIsolate(); | 1125 Dart::ShutdownIsolate(); |
| 1132 } | 1126 } |
| 1133 | 1127 |
| 1134 } // namespace dart | 1128 } // namespace dart |
| OLD | NEW |