Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: runtime/vm/isolate.cc

Issue 1177153005: Enables clean VM shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix error propagation Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "include/dart_native_api.h"
8 #include "platform/assert.h" 9 #include "platform/assert.h"
9 #include "platform/json.h" 10 #include "platform/json.h"
10 #include "vm/code_observers.h" 11 #include "vm/code_observers.h"
11 #include "vm/compiler_stats.h" 12 #include "vm/compiler_stats.h"
12 #include "vm/coverage.h" 13 #include "vm/coverage.h"
14 #include "vm/dart_api_message.h"
13 #include "vm/dart_api_state.h" 15 #include "vm/dart_api_state.h"
14 #include "vm/dart_entry.h" 16 #include "vm/dart_entry.h"
15 #include "vm/debugger.h" 17 #include "vm/debugger.h"
16 #include "vm/deopt_instructions.h" 18 #include "vm/deopt_instructions.h"
17 #include "vm/heap.h" 19 #include "vm/heap.h"
18 #include "vm/lockers.h" 20 #include "vm/lockers.h"
19 #include "vm/log.h" 21 #include "vm/log.h"
20 #include "vm/message_handler.h" 22 #include "vm/message_handler.h"
21 #include "vm/object_id_ring.h" 23 #include "vm/object_id_ring.h"
22 #include "vm/object_store.h" 24 #include "vm/object_store.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void NotifyPauseOnStart(); 160 void NotifyPauseOnStart();
159 void NotifyPauseOnExit(); 161 void NotifyPauseOnExit();
160 162
161 #if defined(DEBUG) 163 #if defined(DEBUG)
162 // Check that it is safe to access this handler. 164 // Check that it is safe to access this handler.
163 void CheckAccess(); 165 void CheckAccess();
164 #endif 166 #endif
165 bool IsCurrentIsolate() const; 167 bool IsCurrentIsolate() const;
166 virtual Isolate* isolate() const { return isolate_; } 168 virtual Isolate* isolate() const { return isolate_; }
167 169
168 private:
169 // Keep both these enums in sync with isolate_patch.dart. 170 // Keep both these enums in sync with isolate_patch.dart.
170 // The different Isolate API message types. 171 // The different Isolate API message types.
171 enum { 172 enum {
172 kPauseMsg = 1, 173 kPauseMsg = 1,
173 kResumeMsg = 2, 174 kResumeMsg = 2,
174 kPingMsg = 3, 175 kPingMsg = 3,
175 kKillMsg = 4, 176 kKillMsg = 4,
176 kAddExitMsg = 5, 177 kAddExitMsg = 5,
177 kDelExitMsg = 6, 178 kDelExitMsg = 6,
178 kAddErrorMsg = 7, 179 kAddErrorMsg = 7,
179 kDelErrorMsg = 8, 180 kDelErrorMsg = 8,
180 kErrorFatalMsg = 9, 181 kErrorFatalMsg = 9,
181 }; 182 };
182 // The different Isolate API message priorities for ping and kill messages. 183 // The different Isolate API message priorities for ping and kill messages.
183 enum { 184 enum {
184 kImmediateAction = 0, 185 kImmediateAction = 0,
185 kBeforeNextEventAction = 1, 186 kBeforeNextEventAction = 1,
186 kAsEventAction = 2 187 kAsEventAction = 2
187 }; 188 };
188 189
190 private:
189 // A result of false indicates that the isolate should terminate the 191 // A result of false indicates that the isolate should terminate the
190 // processing of further events. 192 // processing of further events.
191 bool HandleLibMessage(const Array& message); 193 bool HandleLibMessage(const Array& message);
192 194
193 bool ProcessUnhandledException(const Error& result); 195 bool ProcessUnhandledException(const Error& result);
194 Isolate* isolate_; 196 Isolate* isolate_;
195 }; 197 };
196 198
197 199
198 IsolateMessageHandler::IsolateMessageHandler(Isolate* isolate) 200 IsolateMessageHandler::IsolateMessageHandler(Isolate* isolate)
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 bool Isolate::IsIsolateOf(Thread* thread) { 745 bool Isolate::IsIsolateOf(Thread* thread) {
744 return this == thread->isolate(); 746 return this == thread->isolate();
745 } 747 }
746 #endif // DEBUG 748 #endif // DEBUG
747 749
748 750
749 void Isolate::InitOnce() { 751 void Isolate::InitOnce() {
750 create_callback_ = NULL; 752 create_callback_ = NULL;
751 isolates_list_monitor_ = new Monitor(); 753 isolates_list_monitor_ = new Monitor();
752 ASSERT(isolates_list_monitor_ != NULL); 754 ASSERT(isolates_list_monitor_ != NULL);
755 EnableIsolateCreation();
753 } 756 }
754 757
755 758
756 Isolate* Isolate::Init(const char* name_prefix, 759 Isolate* Isolate::Init(const char* name_prefix,
757 const Dart_IsolateFlags& api_flags, 760 const Dart_IsolateFlags& api_flags,
758 bool is_vm_isolate) { 761 bool is_vm_isolate) {
759 Isolate* result = new Isolate(api_flags); 762 Isolate* result = new Isolate(api_flags);
760 ASSERT(result != NULL); 763 ASSERT(result != NULL);
761 764
762 // Initialize metrics. 765 // Initialize metrics.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 if (FLAG_trace_isolates) { 824 if (FLAG_trace_isolates) {
822 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 825 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
823 OS::Print("[+] Starting isolate:\n" 826 OS::Print("[+] Starting isolate:\n"
824 "\tisolate: %s\n", result->name()); 827 "\tisolate: %s\n", result->name());
825 } 828 }
826 } 829 }
827 if (FLAG_compiler_stats) { 830 if (FLAG_compiler_stats) {
828 result->compiler_stats_ = new CompilerStats(result); 831 result->compiler_stats_ = new CompilerStats(result);
829 } 832 }
830 ObjectIdRing::Init(result); 833 ObjectIdRing::Init(result);
831 // Add to isolate list. 834
832 AddIsolateTolist(result); 835 // Add to isolate list. Shutdown and delete the isolate on failure.
836 if (!AddIsolateToList(result)) {
837 result->LowLevelShutdown();
838 Thread::ExitIsolate();
839 delete result;
840 return NULL;
841 }
833 842
834 return result; 843 return result;
835 } 844 }
836 845
837 846
838 void Isolate::InitializeStackLimit() { 847 void Isolate::InitializeStackLimit() {
839 SetStackLimitFromStackBase(Isolate::GetCurrentStackPointer()); 848 SetStackLimitFromStackBase(Isolate::GetCurrentStackPointer());
840 } 849 }
841 850
842 851
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 FinalizablePersistentHandle* handle = 1457 FinalizablePersistentHandle* handle =
1449 reinterpret_cast<FinalizablePersistentHandle*>(addr); 1458 reinterpret_cast<FinalizablePersistentHandle*>(addr);
1450 handle->UpdateUnreachable(I); 1459 handle->UpdateUnreachable(I);
1451 } 1460 }
1452 1461
1453 private: 1462 private:
1454 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 1463 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
1455 }; 1464 };
1456 1465
1457 1466
1467 void Isolate::LowLevelShutdown() {
1468 // Ensure we have a zone and handle scope so that we can call VM functions,
1469 // but we no longer allocate new heap objects.
1470 StackZone stack_zone(this);
1471 HandleScope handle_scope(this);
1472 NoSafepointScope no_safepoint_scope;
1473
1474 if (compiler_stats_ != NULL) {
1475 compiler_stats()->Print();
1476 }
1477
1478 // Notify exit listeners that this isolate is shutting down.
1479 if (object_store() != NULL) {
1480 NotifyExitListeners();
1481 }
1482
1483 // Clean up debugger resources.
1484 debugger()->Shutdown();
1485
1486 // Close all the ports owned by this isolate.
1487 PortMap::ClosePorts(message_handler());
1488
1489 // Fail fast if anybody tries to post any more messsages to this isolate.
1490 delete message_handler();
1491 set_message_handler(NULL);
1492
1493 // Dump all accumulated timer data for the isolate.
1494 timer_list_.ReportTimers();
1495
1496 // Finalize any weak persistent handles with a non-null referent.
1497 FinalizeWeakPersistentHandlesVisitor visitor;
1498 api_state()->weak_persistent_handles().VisitHandles(&visitor);
1499 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor);
1500
1501 if (FLAG_trace_isolates) {
1502 heap()->PrintSizes();
1503 megamorphic_cache_table()->PrintSizes();
1504 Symbols::DumpStats();
1505 OS::Print("[-] Stopping isolate:\n"
1506 "\tisolate: %s\n", name());
1507 }
1508 }
1509
1510
1458 void Isolate::Shutdown() { 1511 void Isolate::Shutdown() {
1459 ASSERT(this == Isolate::Current()); 1512 ASSERT(this == Isolate::Current());
1460 ASSERT(top_resource() == NULL); 1513 ASSERT(top_resource() == NULL);
1461 #if defined(DEBUG) 1514 #if defined(DEBUG)
1462 if (heap_ != NULL) { 1515 if (heap_ != NULL) {
1463 // The VM isolate keeps all objects marked. 1516 // The VM isolate keeps all objects marked.
1464 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); 1517 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked);
1465 } 1518 }
1466 #endif // DEBUG 1519 #endif // DEBUG
1467 1520
1468 // First, perform higher-level cleanup that may need to allocate. 1521 // First, perform higher-level cleanup that may need to allocate.
1469 { 1522 {
1470 // Ensure we have a zone and handle scope so that we can call VM functions. 1523 // Ensure we have a zone and handle scope so that we can call VM functions.
1471 StackZone stack_zone(this); 1524 StackZone stack_zone(this);
1472 HandleScope handle_scope(this); 1525 HandleScope handle_scope(this);
1473 1526
1474 // Write out the coverage data if collection has been enabled. 1527 // Write out the coverage data if collection has been enabled.
1475 CodeCoverage::Write(this); 1528 if ((this != Dart::vm_isolate()) &&
1529 !ServiceIsolate::IsServiceIsolateDescendant(this)) {
1530 CodeCoverage::Write(this);
1531 }
1476 1532
1477 if ((timeline_event_recorder_ != NULL) && 1533 if ((timeline_event_recorder_ != NULL) &&
1478 (FLAG_timeline_trace_dir != NULL)) { 1534 (FLAG_timeline_trace_dir != NULL)) {
1479 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); 1535 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir);
1480 } 1536 }
1481 } 1537 }
1482 1538
1483 // Remove this isolate from the list *before* we start tearing it down, to 1539 // Remove this isolate from the list *before* we start tearing it down, to
1484 // avoid exposing it in a state of decay. 1540 // avoid exposing it in a state of decay.
1485 RemoveIsolateFromList(this); 1541 RemoveIsolateFromList(this);
1486 1542
1487 if (heap_ != NULL) { 1543 if (heap_ != NULL) {
1488 // Wait for any concurrent GC tasks to finish before shutting down. 1544 // Wait for any concurrent GC tasks to finish before shutting down.
1489 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). 1545 // TODO(koda): Support faster sweeper shutdown (e.g., after current page).
1490 PageSpace* old_space = heap_->old_space(); 1546 PageSpace* old_space = heap_->old_space();
1491 MonitorLocker ml(old_space->tasks_lock()); 1547 MonitorLocker ml(old_space->tasks_lock());
1492 while (old_space->tasks() > 0) { 1548 while (old_space->tasks() > 0) {
1493 ml.Wait(); 1549 ml.Wait();
1494 } 1550 }
1495 } 1551 }
1496 1552
1497 // Then, proceed with low-level teardown. 1553 // Then, proceed with low-level teardown.
1498 { 1554 LowLevelShutdown();
1499 // Ensure we have a zone and handle scope so that we can call VM functions,
1500 // but we no longer allocate new heap objects.
1501 StackZone stack_zone(this);
1502 HandleScope handle_scope(this);
1503 NoSafepointScope no_safepoint_scope;
1504
1505 if (compiler_stats_ != NULL) {
1506 compiler_stats()->Print();
1507 }
1508
1509 // Notify exit listeners that this isolate is shutting down.
1510 if (object_store() != NULL) {
1511 NotifyExitListeners();
1512 }
1513
1514 // Clean up debugger resources.
1515 debugger()->Shutdown();
1516
1517 // Close all the ports owned by this isolate.
1518 PortMap::ClosePorts(message_handler());
1519
1520 // Fail fast if anybody tries to post any more messsages to this isolate.
1521 delete message_handler();
1522 set_message_handler(NULL);
1523
1524 // Dump all accumulated timer data for the isolate.
1525 timer_list_.ReportTimers();
1526
1527 // Finalize any weak persistent handles with a non-null referent.
1528 FinalizeWeakPersistentHandlesVisitor visitor;
1529 api_state()->weak_persistent_handles().VisitHandles(&visitor);
1530 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor);
1531
1532 if (FLAG_trace_isolates) {
1533 heap()->PrintSizes();
1534 megamorphic_cache_table()->PrintSizes();
1535 Symbols::DumpStats();
1536 OS::Print("[-] Stopping isolate:\n"
1537 "\tisolate: %s\n", name());
1538 }
1539 }
1540 1555
1541 #if defined(DEBUG) 1556 #if defined(DEBUG)
1542 // No concurrent sweeper tasks should be running at this point. 1557 // No concurrent sweeper tasks should be running at this point.
1543 if (heap_ != NULL) { 1558 if (heap_ != NULL) {
1544 PageSpace* old_space = heap_->old_space(); 1559 PageSpace* old_space = heap_->old_space();
1545 MonitorLocker ml(old_space->tasks_lock()); 1560 MonitorLocker ml(old_space->tasks_lock());
1546 ASSERT(old_space->tasks() == 0); 1561 ASSERT(old_space->tasks() == 0);
1547 } 1562 }
1548 #endif 1563 #endif
1549 1564
(...skipping 12 matching lines...) Expand all
1562 Isolate::unhandled_exception_callback_ = NULL; 1577 Isolate::unhandled_exception_callback_ = NULL;
1563 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; 1578 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL;
1564 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; 1579 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL;
1565 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; 1580 Dart_FileReadCallback Isolate::file_read_callback_ = NULL;
1566 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL; 1581 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL;
1567 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL; 1582 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL;
1568 Dart_EntropySource Isolate::entropy_source_callback_ = NULL; 1583 Dart_EntropySource Isolate::entropy_source_callback_ = NULL;
1569 1584
1570 Monitor* Isolate::isolates_list_monitor_ = NULL; 1585 Monitor* Isolate::isolates_list_monitor_ = NULL;
1571 Isolate* Isolate::isolates_list_head_ = NULL; 1586 Isolate* Isolate::isolates_list_head_ = NULL;
1572 1587 bool Isolate::creation_enabled_ = false;
1573 1588
1574 void Isolate::IterateObjectPointers(ObjectPointerVisitor* visitor, 1589 void Isolate::IterateObjectPointers(ObjectPointerVisitor* visitor,
1575 bool visit_prologue_weak_handles, 1590 bool visit_prologue_weak_handles,
1576 bool validate_frames) { 1591 bool validate_frames) {
1577 HeapIterationScope heap_iteration_scope; 1592 HeapIterationScope heap_iteration_scope;
1578 VisitObjectPointers(visitor, visit_prologue_weak_handles, validate_frames); 1593 VisitObjectPointers(visitor, visit_prologue_weak_handles, validate_frames);
1579 } 1594 }
1580 1595
1581 1596
1582 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, 1597 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor,
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 intptr_t count = 0; 1926 intptr_t count = 0;
1912 Isolate* current = isolates_list_head_; 1927 Isolate* current = isolates_list_head_;
1913 while (current != NULL) { 1928 while (current != NULL) {
1914 count++; 1929 count++;
1915 current = current->next_; 1930 current = current->next_;
1916 } 1931 }
1917 return count; 1932 return count;
1918 } 1933 }
1919 1934
1920 1935
1921 void Isolate::AddIsolateTolist(Isolate* isolate) { 1936 bool Isolate::AddIsolateToList(Isolate* isolate) {
1922 MonitorLocker ml(isolates_list_monitor_); 1937 MonitorLocker ml(isolates_list_monitor_);
1938 if (!creation_enabled_) {
1939 return false;
1940 }
1923 ASSERT(isolate != NULL); 1941 ASSERT(isolate != NULL);
1924 ASSERT(isolate->next_ == NULL); 1942 ASSERT(isolate->next_ == NULL);
1925 isolate->next_ = isolates_list_head_; 1943 isolate->next_ = isolates_list_head_;
1926 isolates_list_head_ = isolate; 1944 isolates_list_head_ = isolate;
1945 return true;
1927 } 1946 }
1928 1947
1929 1948
1930 void Isolate::RemoveIsolateFromList(Isolate* isolate) { 1949 void Isolate::RemoveIsolateFromList(Isolate* isolate) {
1931 MonitorLocker ml(isolates_list_monitor_); 1950 MonitorLocker ml(isolates_list_monitor_);
1932 ASSERT(isolate != NULL); 1951 ASSERT(isolate != NULL);
1933 if (isolate == isolates_list_head_) { 1952 if (isolate == isolates_list_head_) {
1934 isolates_list_head_ = isolate->next_; 1953 isolates_list_head_ = isolate->next_;
1935 return; 1954 return;
1936 } 1955 }
1937 Isolate* previous = NULL; 1956 Isolate* previous = NULL;
1938 Isolate* current = isolates_list_head_; 1957 Isolate* current = isolates_list_head_;
1939 while (current) { 1958 while (current) {
1940 if (current == isolate) { 1959 if (current == isolate) {
1941 ASSERT(previous != NULL); 1960 ASSERT(previous != NULL);
1942 previous->next_ = current->next_; 1961 previous->next_ = current->next_;
1943 return; 1962 return;
1944 } 1963 }
1945 previous = current; 1964 previous = current;
1946 current = current->next_; 1965 current = current->next_;
1947 } 1966 }
1948 UNREACHABLE(); 1967 // If we are shutting down the VM, the isolate may not be in the list.
1968 ASSERT(!creation_enabled_);
1949 } 1969 }
1950 1970
1951 1971
1952 #if defined(DEBUG) 1972 #if defined(DEBUG)
1953 void Isolate::CheckForDuplicateThreadState(InterruptableThreadState* state) { 1973 void Isolate::CheckForDuplicateThreadState(InterruptableThreadState* state) {
1954 MonitorLocker ml(isolates_list_monitor_); 1974 MonitorLocker ml(isolates_list_monitor_);
1955 ASSERT(state != NULL); 1975 ASSERT(state != NULL);
1956 Isolate* current = isolates_list_head_; 1976 Isolate* current = isolates_list_head_;
1957 while (current) { 1977 while (current) {
1958 ASSERT(current->thread_state() != state); 1978 ASSERT(current->thread_state() != state);
1959 current = current->next_; 1979 current = current->next_;
1960 } 1980 }
1961 } 1981 }
1962 #endif 1982 #endif
1963 1983
1964 1984
1985 void Isolate::DisableIsolateCreation() {
1986 MonitorLocker ml(isolates_list_monitor_);
1987 creation_enabled_ = false;
1988 }
1989
1990
1991 void Isolate::EnableIsolateCreation() {
1992 MonitorLocker ml(isolates_list_monitor_);
1993 creation_enabled_ = true;
1994 }
1995
1996
1965 template<class T> 1997 template<class T>
1966 T* Isolate::AllocateReusableHandle() { 1998 T* Isolate::AllocateReusableHandle() {
1967 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); 1999 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle());
1968 T::initializeHandle(handle, T::null()); 2000 T::initializeHandle(handle, T::null());
1969 return handle; 2001 return handle;
1970 } 2002 }
1971 2003
1972 2004
2005 void Isolate::KillIsolate(Isolate* isolate) {
2006 Dart_CObject kill_msg;
2007 Dart_CObject* list_values[4];
2008 kill_msg.type = Dart_CObject_kArray;
2009 kill_msg.value.as_array.length = 4;
2010 kill_msg.value.as_array.values = list_values;
2011
2012 Dart_CObject oob;
2013 oob.type = Dart_CObject_kInt32;
2014 oob.value.as_int32 = Message::kIsolateLibOOBMsg;
2015 list_values[0] = &oob;
2016
2017 Dart_CObject kill;
2018 kill.type = Dart_CObject_kInt32;
2019 kill.value.as_int32 = IsolateMessageHandler::kKillMsg;
2020 list_values[1] = &kill;
2021
2022 Dart_CObject cap;
2023 cap.type = Dart_CObject_kCapability;
2024 cap.value.as_capability.id = isolate->terminate_capability();
2025 list_values[2] = &cap;
2026
2027 Dart_CObject imm;
2028 imm.type = Dart_CObject_kInt32;
2029 imm.value.as_int32 = IsolateMessageHandler::kImmediateAction;
2030 list_values[3] = &imm;
2031
2032 isolate->ScheduleInterrupts(Isolate::kMessageInterrupt);
2033 {
2034 uint8_t* buffer = NULL;
2035 ApiMessageWriter writer(&buffer, allocator);
2036 bool success = writer.WriteCMessage(&kill_msg);
2037 ASSERT(success);
2038
2039 // Post the message at the given port.
2040 success = PortMap::PostMessage(new Message(isolate->main_port(),
2041 buffer,
2042 writer.BytesWritten(),
2043 Message::kOOBPriority));
2044 ASSERT(success);
2045 }
2046 }
2047
2048
2049 class IsolateKillerVisitor : public IsolateVisitor {
2050 public:
2051 IsolateKillerVisitor() {}
2052
2053 virtual ~IsolateKillerVisitor() {}
2054
2055 void VisitIsolate(Isolate* isolate) {
2056 ASSERT(isolate != NULL);
2057 if (ServiceIsolate::IsServiceIsolateDescendant(isolate) ||
2058 (isolate == Dart::vm_isolate())) {
2059 return;
2060 }
2061 Isolate::KillIsolate(isolate);
2062 }
2063 };
2064
2065
2066 void Isolate::KillAllIsolates() {
2067 IsolateKillerVisitor visitor;
2068 VisitIsolates(&visitor);
2069 }
2070
2071
1973 static RawInstance* DeserializeObject(Isolate* isolate, 2072 static RawInstance* DeserializeObject(Isolate* isolate,
1974 Zone* zone, 2073 Zone* zone,
1975 uint8_t* obj_data, 2074 uint8_t* obj_data,
1976 intptr_t obj_len) { 2075 intptr_t obj_len) {
1977 if (obj_data == NULL) { 2076 if (obj_data == NULL) {
1978 return Instance::null(); 2077 return Instance::null();
1979 } 2078 }
1980 MessageSnapshotReader reader(obj_data, 2079 MessageSnapshotReader reader(obj_data,
1981 obj_len, 2080 obj_len,
1982 isolate, 2081 isolate,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 serialized_message_, serialized_message_len_); 2268 serialized_message_, serialized_message_len_);
2170 } 2269 }
2171 2270
2172 2271
2173 void IsolateSpawnState::Cleanup() { 2272 void IsolateSpawnState::Cleanup() {
2174 SwitchIsolateScope switch_scope(I); 2273 SwitchIsolateScope switch_scope(I);
2175 Dart::ShutdownIsolate(); 2274 Dart::ShutdownIsolate();
2176 } 2275 }
2177 2276
2178 } // namespace dart 2277 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698