| 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" |  | 
| 20 #include "vm/message_handler.h" | 19 #include "vm/message_handler.h" | 
| 21 #include "vm/object_id_ring.h" | 20 #include "vm/object_id_ring.h" | 
| 22 #include "vm/object_store.h" | 21 #include "vm/object_store.h" | 
| 23 #include "vm/parser.h" | 22 #include "vm/parser.h" | 
| 24 #include "vm/port.h" | 23 #include "vm/port.h" | 
| 25 #include "vm/profiler.h" | 24 #include "vm/profiler.h" | 
| 26 #include "vm/reusable_handles.h" | 25 #include "vm/reusable_handles.h" | 
| 27 #include "vm/service.h" | 26 #include "vm/service.h" | 
| 28 #include "vm/simulator.h" | 27 #include "vm/simulator.h" | 
| 29 #include "vm/stack_frame.h" | 28 #include "vm/stack_frame.h" | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 40 DEFINE_FLAG(bool, report_usage_count, false, | 39 DEFINE_FLAG(bool, report_usage_count, false, | 
| 41             "Track function usage and report."); | 40             "Track function usage and report."); | 
| 42 DEFINE_FLAG(bool, trace_isolates, false, | 41 DEFINE_FLAG(bool, trace_isolates, false, | 
| 43             "Trace isolate creation and shut down."); | 42             "Trace isolate creation and shut down."); | 
| 44 DEFINE_FLAG(bool, pin_isolates, false, | 43 DEFINE_FLAG(bool, pin_isolates, false, | 
| 45             "Stop isolates from being destroyed automatically."); | 44             "Stop isolates from being destroyed automatically."); | 
| 46 | 45 | 
| 47 | 46 | 
| 48 void Isolate::RegisterClass(const Class& cls) { | 47 void Isolate::RegisterClass(const Class& cls) { | 
| 49   class_table()->Register(cls); | 48   class_table()->Register(cls); | 
| 50   if (object_histogram() != NULL) object_histogram()->RegisterClass(cls); | 49 } | 
|  | 50 | 
|  | 51 | 
|  | 52 void Isolate::RegisterClassAt(intptr_t index, const Class& cls) { | 
|  | 53   class_table()->RegisterAt(index, cls); | 
|  | 54 } | 
|  | 55 | 
|  | 56 | 
|  | 57 void Isolate::ValidateClassTable() { | 
|  | 58   class_table()->Validate(); | 
| 51 } | 59 } | 
| 52 | 60 | 
| 53 | 61 | 
| 54 class IsolateMessageHandler : public MessageHandler { | 62 class IsolateMessageHandler : public MessageHandler { | 
| 55  public: | 63  public: | 
| 56   explicit IsolateMessageHandler(Isolate* isolate); | 64   explicit IsolateMessageHandler(Isolate* isolate); | 
| 57   ~IsolateMessageHandler(); | 65   ~IsolateMessageHandler(); | 
| 58 | 66 | 
| 59   const char* name() const; | 67   const char* name() const; | 
| 60   void MessageNotify(Message::Priority priority); | 68   void MessageNotify(Message::Priority priority); | 
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 307       saved_stack_limit_(0), | 315       saved_stack_limit_(0), | 
| 308       message_handler_(NULL), | 316       message_handler_(NULL), | 
| 309       spawn_state_(NULL), | 317       spawn_state_(NULL), | 
| 310       is_runnable_(false), | 318       is_runnable_(false), | 
| 311       gc_prologue_callbacks_(), | 319       gc_prologue_callbacks_(), | 
| 312       gc_epilogue_callbacks_(), | 320       gc_epilogue_callbacks_(), | 
| 313       defer_finalization_count_(0), | 321       defer_finalization_count_(0), | 
| 314       deopt_context_(NULL), | 322       deopt_context_(NULL), | 
| 315       stacktrace_(NULL), | 323       stacktrace_(NULL), | 
| 316       stack_frame_index_(-1), | 324       stack_frame_index_(-1), | 
| 317       object_histogram_(NULL), |  | 
| 318       cha_used_(false), | 325       cha_used_(false), | 
| 319       object_id_ring_(NULL), | 326       object_id_ring_(NULL), | 
| 320       profiler_data_(NULL), | 327       profiler_data_(NULL), | 
| 321       thread_state_(NULL), | 328       thread_state_(NULL), | 
| 322       next_(NULL), | 329       next_(NULL), | 
| 323       REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 330       REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 
| 324       reusable_handles_() { | 331       reusable_handles_() { | 
| 325   if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) { |  | 
| 326     object_histogram_ = new ObjectHistogram(this); |  | 
| 327   } |  | 
| 328 } | 332 } | 
| 329 #undef REUSABLE_HANDLE_INITIALIZERS | 333 #undef REUSABLE_HANDLE_INITIALIZERS | 
| 330 | 334 | 
| 331 | 335 | 
| 332 Isolate::~Isolate() { | 336 Isolate::~Isolate() { | 
| 333   delete [] name_; | 337   delete [] name_; | 
| 334   delete heap_; | 338   delete heap_; | 
| 335   delete object_store_; | 339   delete object_store_; | 
| 336   delete api_state_; | 340   delete api_state_; | 
| 337   delete stub_code_; | 341   delete stub_code_; | 
| 338   delete debugger_; | 342   delete debugger_; | 
| 339 #if defined(USING_SIMULATOR) | 343 #if defined(USING_SIMULATOR) | 
| 340   delete simulator_; | 344   delete simulator_; | 
| 341 #endif | 345 #endif | 
| 342   delete mutex_; | 346   delete mutex_; | 
| 343   mutex_ = NULL;  // Fail fast if interrupts are scheduled on a dead isolate. | 347   mutex_ = NULL;  // Fail fast if interrupts are scheduled on a dead isolate. | 
| 344   delete message_handler_; | 348   delete message_handler_; | 
| 345   message_handler_ = NULL;  // Fail fast if we send messages to a dead isolate. | 349   message_handler_ = NULL;  // Fail fast if we send messages to a dead isolate. | 
| 346   ASSERT(deopt_context_ == NULL);  // No deopt in progress when isolate deleted. | 350   ASSERT(deopt_context_ == NULL);  // No deopt in progress when isolate deleted. | 
| 347   delete object_histogram_; |  | 
| 348   delete spawn_state_; | 351   delete spawn_state_; | 
| 349 } | 352 } | 
| 350 | 353 | 
| 351 | 354 | 
| 352 void Isolate::SetCurrent(Isolate* current) { | 355 void Isolate::SetCurrent(Isolate* current) { | 
| 353   Isolate* old_current = Current(); | 356   Isolate* old_current = Current(); | 
| 354   if (old_current != NULL) { | 357   if (old_current != NULL) { | 
| 355     old_current->set_thread_state(NULL); | 358     old_current->set_thread_state(NULL); | 
| 356     Profiler::EndExecution(old_current); | 359     Profiler::EndExecution(old_current); | 
| 357   } | 360   } | 
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 743   ASSERT(this == Isolate::Current()); | 746   ASSERT(this == Isolate::Current()); | 
| 744   ASSERT(top_resource() == NULL); | 747   ASSERT(top_resource() == NULL); | 
| 745   ASSERT((heap_ == NULL) || heap_->Verify()); | 748   ASSERT((heap_ == NULL) || heap_->Verify()); | 
| 746 | 749 | 
| 747   // Create an area where we do have a zone and a handle scope so that we can | 750   // Create an area where we do have a zone and a handle scope so that we can | 
| 748   // call VM functions while tearing this isolate down. | 751   // call VM functions while tearing this isolate down. | 
| 749   { | 752   { | 
| 750     StackZone stack_zone(this); | 753     StackZone stack_zone(this); | 
| 751     HandleScope handle_scope(this); | 754     HandleScope handle_scope(this); | 
| 752 | 755 | 
| 753     if (FLAG_print_object_histogram) { |  | 
| 754       heap()->CollectAllGarbage(); |  | 
| 755       object_histogram()->Print(); |  | 
| 756     } |  | 
| 757 |  | 
| 758     // Clean up debugger resources. | 756     // Clean up debugger resources. | 
| 759     debugger()->Shutdown(); | 757     debugger()->Shutdown(); | 
| 760 | 758 | 
| 761     // Close all the ports owned by this isolate. | 759     // Close all the ports owned by this isolate. | 
| 762     PortMap::ClosePorts(message_handler()); | 760     PortMap::ClosePorts(message_handler()); | 
| 763 | 761 | 
| 764     // Fail fast if anybody tries to post any more messsages to this isolate. | 762     // Fail fast if anybody tries to post any more messsages to this isolate. | 
| 765     delete message_handler(); | 763     delete message_handler(); | 
| 766     set_message_handler(NULL); | 764     set_message_handler(NULL); | 
| 767 | 765 | 
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1080   return func.raw(); | 1078   return func.raw(); | 
| 1081 } | 1079 } | 
| 1082 | 1080 | 
| 1083 | 1081 | 
| 1084 void IsolateSpawnState::Cleanup() { | 1082 void IsolateSpawnState::Cleanup() { | 
| 1085   SwitchIsolateScope switch_scope(isolate()); | 1083   SwitchIsolateScope switch_scope(isolate()); | 
| 1086   Dart::ShutdownIsolate(); | 1084   Dart::ShutdownIsolate(); | 
| 1087 } | 1085 } | 
| 1088 | 1086 | 
| 1089 }  // namespace dart | 1087 }  // namespace dart | 
| OLD | NEW | 
|---|