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 "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 deoptimized_code_array_(GrowableObjectArray::null()), | 593 deoptimized_code_array_(GrowableObjectArray::null()), |
594 metrics_list_head_(NULL), | 594 metrics_list_head_(NULL), |
595 next_(NULL), | 595 next_(NULL), |
596 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 596 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
597 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 597 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) |
598 reusable_handles_() { | 598 reusable_handles_() { |
599 set_vm_tag(VMTag::kIdleTagId); | 599 set_vm_tag(VMTag::kIdleTagId); |
600 set_user_tag(UserTags::kDefaultUserTag); | 600 set_user_tag(UserTags::kDefaultUserTag); |
601 } | 601 } |
602 | 602 |
603 Isolate::Isolate(Isolate* original) | |
604 : vm_tag_(0), | |
605 store_buffer_(true), | |
606 class_table_(original->class_table()), | |
607 message_notify_callback_(NULL), | |
608 name_(NULL), | |
609 start_time_(OS::GetCurrentTimeMicros()), | |
610 main_port_(0), | |
611 pause_capability_(0), | |
612 terminate_capability_(0), | |
613 errors_fatal_(true), | |
614 heap_(NULL), | |
615 object_store_(NULL), | |
616 top_exit_frame_info_(0), | |
617 init_callback_data_(NULL), | |
618 environment_callback_(NULL), | |
619 library_tag_handler_(NULL), | |
620 api_state_(NULL), | |
621 stub_code_(NULL), | |
622 debugger_(NULL), | |
623 single_step_(false), | |
624 resume_request_(false), | |
625 random_(), | |
626 simulator_(NULL), | |
627 long_jump_base_(NULL), | |
628 timer_list_(), | |
629 deopt_id_(0), | |
630 mutex_(new Mutex()), | |
631 stack_limit_(0), | |
632 saved_stack_limit_(0), | |
633 stack_overflow_flags_(0), | |
634 stack_overflow_count_(0), | |
635 message_handler_(NULL), | |
636 spawn_state_(NULL), | |
637 is_runnable_(false), | |
638 gc_prologue_callback_(NULL), | |
639 gc_epilogue_callback_(NULL), | |
640 defer_finalization_count_(0), | |
641 deopt_context_(NULL), | |
642 is_service_isolate_(false), | |
643 log_(new class Log()), | |
644 stacktrace_(NULL), | |
645 stack_frame_index_(-1), | |
646 last_allocationprofile_accumulator_reset_timestamp_(0), | |
647 last_allocationprofile_gc_timestamp_(0), | |
648 cha_(NULL), | |
649 object_id_ring_(NULL), | |
650 trace_buffer_(NULL), | |
651 profiler_data_(NULL), | |
652 thread_state_(NULL), | |
653 tag_table_(GrowableObjectArray::null()), | |
654 current_tag_(UserTag::null()), | |
655 default_tag_(UserTag::null()), | |
656 metrics_list_head_(NULL), | |
657 next_(NULL), | |
658 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | |
659 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | |
660 reusable_handles_() { | |
661 } | |
662 #undef REUSABLE_HANDLE_SCOPE_INIT | 603 #undef REUSABLE_HANDLE_SCOPE_INIT |
663 #undef REUSABLE_HANDLE_INITIALIZERS | 604 #undef REUSABLE_HANDLE_INITIALIZERS |
664 | 605 |
665 Isolate::~Isolate() { | 606 Isolate::~Isolate() { |
666 free(name_); | 607 free(name_); |
667 delete heap_; | 608 delete heap_; |
668 delete object_store_; | 609 delete object_store_; |
669 delete api_state_; | 610 delete api_state_; |
670 delete stub_code_; | 611 delete stub_code_; |
671 delete debugger_; | 612 delete debugger_; |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 } | 1299 } |
1359 | 1300 |
1360 private: | 1301 private: |
1361 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); | 1302 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); |
1362 }; | 1303 }; |
1363 | 1304 |
1364 | 1305 |
1365 void Isolate::Shutdown() { | 1306 void Isolate::Shutdown() { |
1366 ASSERT(this == Isolate::Current()); | 1307 ASSERT(this == Isolate::Current()); |
1367 ASSERT(top_resource() == NULL); | 1308 ASSERT(top_resource() == NULL); |
| 1309 |
| 1310 // Remove this isolate from the list *before* we start tearing it down, to |
| 1311 // avoid exposing it in a state of decay. |
| 1312 RemoveIsolateFromList(this); |
| 1313 |
| 1314 // Create an area where we do have a zone and a handle scope so that we can |
| 1315 // call VM functions while tearing this isolate down. |
| 1316 { |
| 1317 StackZone stack_zone(this); |
| 1318 HandleScope handle_scope(this); |
| 1319 |
1368 #if defined(DEBUG) | 1320 #if defined(DEBUG) |
1369 if (heap_ != NULL) { | 1321 if (heap_ != NULL) { |
1370 // Wait for concurrent GC tasks to finish before final verification. | 1322 // Wait for concurrent GC tasks to finish before final verification. |
1371 PageSpace* old_space = heap_->old_space(); | 1323 PageSpace* old_space = heap_->old_space(); |
1372 MonitorLocker ml(old_space->tasks_lock()); | 1324 MonitorLocker ml(old_space->tasks_lock()); |
1373 while (old_space->tasks() > 0) { | 1325 while (old_space->tasks() > 0) { |
1374 ml.Wait(); | 1326 ml.Wait(); |
1375 } | 1327 } |
1376 // The VM isolate keeps all objects marked. | 1328 // The VM isolate keeps all objects marked. |
1377 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); | 1329 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); |
1378 } | 1330 } |
1379 #endif // DEBUG | 1331 #endif // DEBUG |
1380 | 1332 |
1381 // Remove this isolate from the list *before* we start tearing it down, to | |
1382 // avoid exposing it in a state of decay. | |
1383 RemoveIsolateFromList(this); | |
1384 | |
1385 // Create an area where we do have a zone and a handle scope so that we can | |
1386 // call VM functions while tearing this isolate down. | |
1387 { | |
1388 StackZone stack_zone(this); | |
1389 HandleScope handle_scope(this); | |
1390 | |
1391 // Notify exit listeners that this isolate is shutting down. | 1333 // Notify exit listeners that this isolate is shutting down. |
1392 if (object_store() != NULL) { | 1334 if (object_store() != NULL) { |
1393 NotifyExitListeners(); | 1335 NotifyExitListeners(); |
1394 } | 1336 } |
1395 | 1337 |
1396 // Clean up debugger resources. | 1338 // Clean up debugger resources. |
1397 debugger()->Shutdown(); | 1339 debugger()->Shutdown(); |
1398 | 1340 |
1399 // Close all the ports owned by this isolate. | 1341 // Close all the ports owned by this isolate. |
1400 PortMap::ClosePorts(message_handler()); | 1342 PortMap::ClosePorts(message_handler()); |
(...skipping 23 matching lines...) Expand all Loading... |
1424 } | 1366 } |
1425 } | 1367 } |
1426 | 1368 |
1427 // TODO(5411455): For now just make sure there are no current isolates | 1369 // TODO(5411455): For now just make sure there are no current isolates |
1428 // as we are shutting down the isolate. | 1370 // as we are shutting down the isolate. |
1429 SetCurrent(NULL); | 1371 SetCurrent(NULL); |
1430 Profiler::ShutdownProfilingForIsolate(this); | 1372 Profiler::ShutdownProfilingForIsolate(this); |
1431 } | 1373 } |
1432 | 1374 |
1433 | 1375 |
1434 Isolate* Isolate::ShallowCopy() { | |
1435 return new Isolate(this); | |
1436 } | |
1437 | |
1438 | |
1439 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1376 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
1440 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; | 1377 Dart_IsolateInterruptCallback Isolate::interrupt_callback_ = NULL; |
1441 Dart_IsolateUnhandledExceptionCallback | 1378 Dart_IsolateUnhandledExceptionCallback |
1442 Isolate::unhandled_exception_callback_ = NULL; | 1379 Isolate::unhandled_exception_callback_ = NULL; |
1443 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; | 1380 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; |
1444 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; | 1381 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; |
1445 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; | 1382 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; |
1446 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL; | 1383 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL; |
1447 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL; | 1384 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL; |
1448 Dart_EntropySource Isolate::entropy_source_callback_ = NULL; | 1385 Dart_EntropySource Isolate::entropy_source_callback_ = NULL; |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 serialized_message_, serialized_message_len_); | 1906 serialized_message_, serialized_message_len_); |
1970 } | 1907 } |
1971 | 1908 |
1972 | 1909 |
1973 void IsolateSpawnState::Cleanup() { | 1910 void IsolateSpawnState::Cleanup() { |
1974 SwitchIsolateScope switch_scope(I); | 1911 SwitchIsolateScope switch_scope(I); |
1975 Dart::ShutdownIsolate(); | 1912 Dart::ShutdownIsolate(); |
1976 } | 1913 } |
1977 | 1914 |
1978 } // namespace dart | 1915 } // namespace dart |
OLD | NEW |