| 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" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 OS::PrintErr(" %s <- %s\n", | 364 OS::PrintErr(" %s <- %s\n", |
| 365 String::Handle(field.name()).ToCString(), | 365 String::Handle(field.name()).ToCString(), |
| 366 value.ToCString()); | 366 value.ToCString()); |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 object_ = &obj; | 370 object_ = &obj; |
| 371 } | 371 } |
| 372 | 372 |
| 373 | 373 |
| 374 #define REUSABLE_HANDLE_INITIALIZERS(object) \ |
| 375 object##_handle_(NULL), |
| 376 |
| 374 Isolate::Isolate() | 377 Isolate::Isolate() |
| 375 : store_buffer_(), | 378 : store_buffer_(), |
| 376 message_notify_callback_(NULL), | 379 message_notify_callback_(NULL), |
| 377 name_(NULL), | 380 name_(NULL), |
| 378 start_time_(OS::GetCurrentTimeMicros()), | 381 start_time_(OS::GetCurrentTimeMicros()), |
| 379 main_port_(0), | 382 main_port_(0), |
| 380 heap_(NULL), | 383 heap_(NULL), |
| 381 object_store_(NULL), | 384 object_store_(NULL), |
| 382 top_context_(Context::null()), | 385 top_context_(Context::null()), |
| 383 top_exit_frame_info_(0), | 386 top_exit_frame_info_(0), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 402 deopt_cpu_registers_copy_(NULL), | 405 deopt_cpu_registers_copy_(NULL), |
| 403 deopt_fpu_registers_copy_(NULL), | 406 deopt_fpu_registers_copy_(NULL), |
| 404 deopt_frame_copy_(NULL), | 407 deopt_frame_copy_(NULL), |
| 405 deopt_frame_copy_size_(0), | 408 deopt_frame_copy_size_(0), |
| 406 deferred_boxes_(NULL), | 409 deferred_boxes_(NULL), |
| 407 deferred_object_refs_(NULL), | 410 deferred_object_refs_(NULL), |
| 408 deferred_objects_count_(0), | 411 deferred_objects_count_(0), |
| 409 deferred_objects_(NULL), | 412 deferred_objects_(NULL), |
| 410 stacktrace_(NULL), | 413 stacktrace_(NULL), |
| 411 stack_frame_index_(-1), | 414 stack_frame_index_(-1), |
| 412 object_histogram_(NULL) { | 415 object_histogram_(NULL), |
| 416 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
| 417 handles_() { |
| 413 if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) { | 418 if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) { |
| 414 object_histogram_ = new ObjectHistogram(this); | 419 object_histogram_ = new ObjectHistogram(this); |
| 415 } | 420 } |
| 416 } | 421 } |
| 422 #undef REUSABLE_HANDLE_INITIALIZERS |
| 417 | 423 |
| 418 | 424 |
| 419 Isolate::~Isolate() { | 425 Isolate::~Isolate() { |
| 420 delete [] name_; | 426 delete [] name_; |
| 421 delete heap_; | 427 delete heap_; |
| 422 delete object_store_; | 428 delete object_store_; |
| 423 delete api_state_; | 429 delete api_state_; |
| 424 delete stub_code_; | 430 delete stub_code_; |
| 425 delete debugger_; | 431 delete debugger_; |
| 426 #if defined(USING_SIMULATOR) | 432 #if defined(USING_SIMULATOR) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 454 | 460 |
| 455 | 461 |
| 456 Isolate* Isolate::Init(const char* name_prefix) { | 462 Isolate* Isolate::Init(const char* name_prefix) { |
| 457 Isolate* result = new Isolate(); | 463 Isolate* result = new Isolate(); |
| 458 ASSERT(result != NULL); | 464 ASSERT(result != NULL); |
| 459 | 465 |
| 460 // TODO(5411455): For now just set the recently created isolate as | 466 // TODO(5411455): For now just set the recently created isolate as |
| 461 // the current isolate. | 467 // the current isolate. |
| 462 SetCurrent(result); | 468 SetCurrent(result); |
| 463 | 469 |
| 470 // Setup the isolate specific resuable handles. |
| 471 #define REUSABLE_HANDLE_ALLOCATION(object) \ |
| 472 result->object##_handle_ = result->AllocateReusableHandle<object>(); \ |
| 473 |
| 474 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION) |
| 475 #undef REUSABLE_HANDLE_ALLOCATION |
| 476 |
| 464 // Setup the isolate message handler. | 477 // Setup the isolate message handler. |
| 465 MessageHandler* handler = new IsolateMessageHandler(result); | 478 MessageHandler* handler = new IsolateMessageHandler(result); |
| 466 ASSERT(handler != NULL); | 479 ASSERT(handler != NULL); |
| 467 result->set_message_handler(handler); | 480 result->set_message_handler(handler); |
| 468 | 481 |
| 469 // Setup the Dart API state. | 482 // Setup the Dart API state. |
| 470 ApiState* state = new ApiState(); | 483 ApiState* state = new ApiState(); |
| 471 ASSERT(state != NULL); | 484 ASSERT(state != NULL); |
| 472 result->set_api_state(state); | 485 result->set_api_state(state); |
| 473 | 486 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 831 |
| 819 // Visit objects in the megamorphic cache. | 832 // Visit objects in the megamorphic cache. |
| 820 megamorphic_cache_table()->VisitObjectPointers(visitor); | 833 megamorphic_cache_table()->VisitObjectPointers(visitor); |
| 821 | 834 |
| 822 // Visit objects in per isolate stubs. | 835 // Visit objects in per isolate stubs. |
| 823 StubCode::VisitObjectPointers(visitor); | 836 StubCode::VisitObjectPointers(visitor); |
| 824 | 837 |
| 825 // Visit objects in zones. | 838 // Visit objects in zones. |
| 826 current_zone()->VisitObjectPointers(visitor); | 839 current_zone()->VisitObjectPointers(visitor); |
| 827 | 840 |
| 841 // Visit objects in isolate specific handles area. |
| 842 handles_.VisitObjectPointers(visitor); |
| 843 |
| 828 // Iterate over all the stack frames and visit objects on the stack. | 844 // Iterate over all the stack frames and visit objects on the stack. |
| 829 StackFrameIterator frames_iterator(validate_frames); | 845 StackFrameIterator frames_iterator(validate_frames); |
| 830 StackFrame* frame = frames_iterator.NextFrame(); | 846 StackFrame* frame = frames_iterator.NextFrame(); |
| 831 while (frame != NULL) { | 847 while (frame != NULL) { |
| 832 frame->VisitObjectPointers(visitor); | 848 frame->VisitObjectPointers(visitor); |
| 833 frame = frames_iterator.NextFrame(); | 849 frame = frames_iterator.NextFrame(); |
| 834 } | 850 } |
| 835 | 851 |
| 836 // Visit the dart api state for all local and persistent handles. | 852 // Visit the dart api state for all local and persistent handles. |
| 837 if (api_state() != NULL) { | 853 if (api_state() != NULL) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 return isolate->GetStatusStackFrame(frame_index); | 1059 return isolate->GetStatusStackFrame(frame_index); |
| 1044 } | 1060 } |
| 1045 } | 1061 } |
| 1046 | 1062 |
| 1047 // TODO(tball): "/isolate/<handle>/stacktrace/<frame-index>"/disassemble" | 1063 // TODO(tball): "/isolate/<handle>/stacktrace/<frame-index>"/disassemble" |
| 1048 | 1064 |
| 1049 return NULL; // Unimplemented query. | 1065 return NULL; // Unimplemented query. |
| 1050 } | 1066 } |
| 1051 | 1067 |
| 1052 | 1068 |
| 1069 template<class T> |
| 1070 T* Isolate::AllocateReusableHandle() { |
| 1071 T* handle = reinterpret_cast<T*>(handles_.AllocateScopedHandle()); |
| 1072 T::initializeHandle(handle, T::null()); |
| 1073 return handle; |
| 1074 } |
| 1075 |
| 1076 |
| 1053 static void FillDeferredSlots(DeferredSlot** slot_list) { | 1077 static void FillDeferredSlots(DeferredSlot** slot_list) { |
| 1054 DeferredSlot* slot = *slot_list; | 1078 DeferredSlot* slot = *slot_list; |
| 1055 *slot_list = NULL; | 1079 *slot_list = NULL; |
| 1056 | 1080 |
| 1057 while (slot != NULL) { | 1081 while (slot != NULL) { |
| 1058 DeferredSlot* current = slot; | 1082 DeferredSlot* current = slot; |
| 1059 slot = slot->next(); | 1083 slot = slot->next(); |
| 1060 | 1084 |
| 1061 current->Materialize(); | 1085 current->Materialize(); |
| 1062 | 1086 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 return func.raw(); | 1182 return func.raw(); |
| 1159 } | 1183 } |
| 1160 | 1184 |
| 1161 | 1185 |
| 1162 void IsolateSpawnState::Cleanup() { | 1186 void IsolateSpawnState::Cleanup() { |
| 1163 SwitchIsolateScope switch_scope(isolate()); | 1187 SwitchIsolateScope switch_scope(isolate()); |
| 1164 Dart::ShutdownIsolate(); | 1188 Dart::ShutdownIsolate(); |
| 1165 } | 1189 } |
| 1166 | 1190 |
| 1167 } // namespace dart | 1191 } // namespace dart |
| OLD | NEW |