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