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

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

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 bool Isolate::IsIsolateOf(Thread* thread) { 744 bool Isolate::IsIsolateOf(Thread* thread) {
743 return this == thread->isolate(); 745 return this == thread->isolate();
744 } 746 }
745 #endif // DEBUG 747 #endif // DEBUG
746 748
747 749
748 void Isolate::InitOnce() { 750 void Isolate::InitOnce() {
749 create_callback_ = NULL; 751 create_callback_ = NULL;
750 isolates_list_monitor_ = new Monitor(); 752 isolates_list_monitor_ = new Monitor();
751 ASSERT(isolates_list_monitor_ != NULL); 753 ASSERT(isolates_list_monitor_ != NULL);
754 EnableIsolateCreation();
752 } 755 }
753 756
754 757
755 Isolate* Isolate::Init(const char* name_prefix, 758 Isolate* Isolate::Init(const char* name_prefix,
756 const Dart_IsolateFlags& api_flags, 759 const Dart_IsolateFlags& api_flags,
757 bool is_vm_isolate) { 760 bool is_vm_isolate) {
758 Isolate* result = new Isolate(api_flags); 761 Isolate* result = new Isolate(api_flags);
759 ASSERT(result != NULL); 762 ASSERT(result != NULL);
760 763
761 // Initialize metrics. 764 // Initialize metrics.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (FLAG_trace_isolates) { 823 if (FLAG_trace_isolates) {
821 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 824 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
822 OS::Print("[+] Starting isolate:\n" 825 OS::Print("[+] Starting isolate:\n"
823 "\tisolate: %s\n", result->name()); 826 "\tisolate: %s\n", result->name());
824 } 827 }
825 } 828 }
826 if (FLAG_compiler_stats) { 829 if (FLAG_compiler_stats) {
827 result->compiler_stats_ = new CompilerStats(result); 830 result->compiler_stats_ = new CompilerStats(result);
828 } 831 }
829 ObjectIdRing::Init(result); 832 ObjectIdRing::Init(result);
830 // Add to isolate list. 833
831 AddIsolateTolist(result); 834 // Add to isolate list. Shutdown and delete the isolate on failure.
835 if (!AddIsolateToList(result)) {
836 result->LowLevelShutdown();
837 Thread::ExitIsolate();
838 delete result;
839 return NULL;
840 }
832 841
833 return result; 842 return result;
834 } 843 }
835 844
836 845
837 void Isolate::InitializeStackLimit() { 846 void Isolate::InitializeStackLimit() {
838 SetStackLimitFromStackBase(Isolate::GetCurrentStackPointer()); 847 SetStackLimitFromStackBase(Isolate::GetCurrentStackPointer());
839 } 848 }
840 849
841 850
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 FinalizablePersistentHandle* handle = 1456 FinalizablePersistentHandle* handle =
1448 reinterpret_cast<FinalizablePersistentHandle*>(addr); 1457 reinterpret_cast<FinalizablePersistentHandle*>(addr);
1449 handle->UpdateUnreachable(I); 1458 handle->UpdateUnreachable(I);
1450 } 1459 }
1451 1460
1452 private: 1461 private:
1453 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor); 1462 DISALLOW_COPY_AND_ASSIGN(FinalizeWeakPersistentHandlesVisitor);
1454 }; 1463 };
1455 1464
1456 1465
1466 void Isolate::LowLevelShutdown() {
1467 // Ensure we have a zone and handle scope so that we can call VM functions,
1468 // but we no longer allocate new heap objects.
1469 StackZone stack_zone(this);
1470 HandleScope handle_scope(this);
1471 NoSafepointScope no_safepoint_scope;
1472
1473 if (compiler_stats_ != NULL) {
1474 compiler_stats()->Print();
1475 }
1476
1477 // Notify exit listeners that this isolate is shutting down.
1478 if (object_store() != NULL) {
1479 NotifyExitListeners();
1480 }
1481
1482 // Clean up debugger resources.
1483 debugger()->Shutdown();
1484
1485 // Close all the ports owned by this isolate.
1486 PortMap::ClosePorts(message_handler());
1487
1488 // Fail fast if anybody tries to post any more messsages to this isolate.
1489 delete message_handler();
1490 set_message_handler(NULL);
1491
1492 // Dump all accumulated timer data for the isolate.
1493 timer_list_.ReportTimers();
1494
1495 // Finalize any weak persistent handles with a non-null referent.
1496 FinalizeWeakPersistentHandlesVisitor visitor;
1497 api_state()->weak_persistent_handles().VisitHandles(&visitor);
1498 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor);
1499
1500 if (FLAG_trace_isolates) {
1501 heap()->PrintSizes();
1502 megamorphic_cache_table()->PrintSizes();
1503 Symbols::DumpStats();
1504 OS::Print("[-] Stopping isolate:\n"
1505 "\tisolate: %s\n", name());
1506 }
1507 }
1508
1509
1457 void Isolate::Shutdown() { 1510 void Isolate::Shutdown() {
1458 ASSERT(this == Isolate::Current()); 1511 ASSERT(this == Isolate::Current());
1459 ASSERT(top_resource() == NULL); 1512 ASSERT(top_resource() == NULL);
1460 #if defined(DEBUG) 1513 #if defined(DEBUG)
1461 if (heap_ != NULL) { 1514 if (heap_ != NULL) {
1462 // The VM isolate keeps all objects marked. 1515 // The VM isolate keeps all objects marked.
1463 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); 1516 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked);
1464 } 1517 }
1465 #endif // DEBUG 1518 #endif // DEBUG
1466 1519
1467 // First, perform higher-level cleanup that may need to allocate. 1520 // First, perform higher-level cleanup that may need to allocate.
1468 { 1521 {
1469 // Ensure we have a zone and handle scope so that we can call VM functions. 1522 // Ensure we have a zone and handle scope so that we can call VM functions.
1470 StackZone stack_zone(this); 1523 StackZone stack_zone(this);
1471 HandleScope handle_scope(this); 1524 HandleScope handle_scope(this);
1472 1525
1473 // Write out the coverage data if collection has been enabled. 1526 // Write out the coverage data if collection has been enabled.
1474 CodeCoverage::Write(this); 1527 if ((this != Dart::vm_isolate()) &&
1528 !ServiceIsolate::IsServiceIsolateDescendant(this)) {
1529 CodeCoverage::Write(this);
1530 }
1475 1531
1476 if ((timeline_event_recorder_ != NULL) && 1532 if ((timeline_event_recorder_ != NULL) &&
1477 (FLAG_timeline_trace_dir != NULL)) { 1533 (FLAG_timeline_trace_dir != NULL)) {
1478 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir); 1534 timeline_event_recorder_->WriteTo(FLAG_timeline_trace_dir);
1479 } 1535 }
1480 } 1536 }
1481 1537
1482 // Remove this isolate from the list *before* we start tearing it down, to 1538 // Remove this isolate from the list *before* we start tearing it down, to
1483 // avoid exposing it in a state of decay. 1539 // avoid exposing it in a state of decay.
1484 RemoveIsolateFromList(this); 1540 RemoveIsolateFromList(this);
1485 1541
1486 if (heap_ != NULL) { 1542 if (heap_ != NULL) {
1487 // Wait for any concurrent GC tasks to finish before shutting down. 1543 // Wait for any concurrent GC tasks to finish before shutting down.
1488 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). 1544 // TODO(koda): Support faster sweeper shutdown (e.g., after current page).
1489 PageSpace* old_space = heap_->old_space(); 1545 PageSpace* old_space = heap_->old_space();
1490 MonitorLocker ml(old_space->tasks_lock()); 1546 MonitorLocker ml(old_space->tasks_lock());
1491 while (old_space->tasks() > 0) { 1547 while (old_space->tasks() > 0) {
1492 ml.Wait(); 1548 ml.Wait();
1493 } 1549 }
1494 } 1550 }
1495 1551
1496 // Then, proceed with low-level teardown. 1552 // Then, proceed with low-level teardown.
1497 { 1553 LowLevelShutdown();
1498 // Ensure we have a zone and handle scope so that we can call VM functions,
1499 // but we no longer allocate new heap objects.
1500 StackZone stack_zone(this);
1501 HandleScope handle_scope(this);
1502 NoSafepointScope no_safepoint_scope;
1503
1504 if (compiler_stats_ != NULL) {
1505 compiler_stats()->Print();
1506 }
1507
1508 // Notify exit listeners that this isolate is shutting down.
1509 if (object_store() != NULL) {
1510 NotifyExitListeners();
1511 }
1512
1513 // Clean up debugger resources.
1514 debugger()->Shutdown();
1515
1516 // Close all the ports owned by this isolate.
1517 PortMap::ClosePorts(message_handler());
1518
1519 // Fail fast if anybody tries to post any more messsages to this isolate.
1520 delete message_handler();
1521 set_message_handler(NULL);
1522
1523 // Dump all accumulated timer data for the isolate.
1524 timer_list_.ReportTimers();
1525
1526 // Finalize any weak persistent handles with a non-null referent.
1527 FinalizeWeakPersistentHandlesVisitor visitor;
1528 api_state()->weak_persistent_handles().VisitHandles(&visitor);
1529 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor);
1530
1531 if (FLAG_trace_isolates) {
1532 heap()->PrintSizes();
1533 megamorphic_cache_table()->PrintSizes();
1534 Symbols::DumpStats();
1535 OS::Print("[-] Stopping isolate:\n"
1536 "\tisolate: %s\n", name());
1537 }
1538 }
1539 1554
1540 #if defined(DEBUG) 1555 #if defined(DEBUG)
1541 // No concurrent sweeper tasks should be running at this point. 1556 // No concurrent sweeper tasks should be running at this point.
1542 if (heap_ != NULL) { 1557 if (heap_ != NULL) {
1543 PageSpace* old_space = heap_->old_space(); 1558 PageSpace* old_space = heap_->old_space();
1544 MonitorLocker ml(old_space->tasks_lock()); 1559 MonitorLocker ml(old_space->tasks_lock());
1545 ASSERT(old_space->tasks() == 0); 1560 ASSERT(old_space->tasks() == 0);
1546 } 1561 }
1547 #endif 1562 #endif
1548 1563
(...skipping 12 matching lines...) Expand all
1561 Isolate::unhandled_exception_callback_ = NULL; 1576 Isolate::unhandled_exception_callback_ = NULL;
1562 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL; 1577 Dart_IsolateShutdownCallback Isolate::shutdown_callback_ = NULL;
1563 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL; 1578 Dart_FileOpenCallback Isolate::file_open_callback_ = NULL;
1564 Dart_FileReadCallback Isolate::file_read_callback_ = NULL; 1579 Dart_FileReadCallback Isolate::file_read_callback_ = NULL;
1565 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL; 1580 Dart_FileWriteCallback Isolate::file_write_callback_ = NULL;
1566 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL; 1581 Dart_FileCloseCallback Isolate::file_close_callback_ = NULL;
1567 Dart_EntropySource Isolate::entropy_source_callback_ = NULL; 1582 Dart_EntropySource Isolate::entropy_source_callback_ = NULL;
1568 1583
1569 Monitor* Isolate::isolates_list_monitor_ = NULL; 1584 Monitor* Isolate::isolates_list_monitor_ = NULL;
1570 Isolate* Isolate::isolates_list_head_ = NULL; 1585 Isolate* Isolate::isolates_list_head_ = NULL;
1571 1586 bool Isolate::creation_enabled_ = false;
1572 1587
1573 void Isolate::IterateObjectPointers(ObjectPointerVisitor* visitor, 1588 void Isolate::IterateObjectPointers(ObjectPointerVisitor* visitor,
1574 bool visit_prologue_weak_handles, 1589 bool visit_prologue_weak_handles,
1575 bool validate_frames) { 1590 bool validate_frames) {
1576 HeapIterationScope heap_iteration_scope; 1591 HeapIterationScope heap_iteration_scope;
1577 VisitObjectPointers(visitor, visit_prologue_weak_handles, validate_frames); 1592 VisitObjectPointers(visitor, visit_prologue_weak_handles, validate_frames);
1578 } 1593 }
1579 1594
1580 1595
1581 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, 1596 void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 intptr_t count = 0; 1917 intptr_t count = 0;
1903 Isolate* current = isolates_list_head_; 1918 Isolate* current = isolates_list_head_;
1904 while (current != NULL) { 1919 while (current != NULL) {
1905 count++; 1920 count++;
1906 current = current->next_; 1921 current = current->next_;
1907 } 1922 }
1908 return count; 1923 return count;
1909 } 1924 }
1910 1925
1911 1926
1912 void Isolate::AddIsolateTolist(Isolate* isolate) { 1927 bool Isolate::AddIsolateToList(Isolate* isolate) {
1913 MonitorLocker ml(isolates_list_monitor_); 1928 MonitorLocker ml(isolates_list_monitor_);
1929 if (!creation_enabled_) {
1930 return false;
1931 }
1914 ASSERT(isolate != NULL); 1932 ASSERT(isolate != NULL);
1915 ASSERT(isolate->next_ == NULL); 1933 ASSERT(isolate->next_ == NULL);
1916 isolate->next_ = isolates_list_head_; 1934 isolate->next_ = isolates_list_head_;
1917 isolates_list_head_ = isolate; 1935 isolates_list_head_ = isolate;
1936 return true;
1918 } 1937 }
1919 1938
1920 1939
1921 void Isolate::RemoveIsolateFromList(Isolate* isolate) { 1940 void Isolate::RemoveIsolateFromList(Isolate* isolate) {
1922 MonitorLocker ml(isolates_list_monitor_); 1941 MonitorLocker ml(isolates_list_monitor_);
1923 ASSERT(isolate != NULL); 1942 ASSERT(isolate != NULL);
1924 if (isolate == isolates_list_head_) { 1943 if (isolate == isolates_list_head_) {
1925 isolates_list_head_ = isolate->next_; 1944 isolates_list_head_ = isolate->next_;
1926 return; 1945 return;
1927 } 1946 }
1928 Isolate* previous = NULL; 1947 Isolate* previous = NULL;
1929 Isolate* current = isolates_list_head_; 1948 Isolate* current = isolates_list_head_;
1930 while (current) { 1949 while (current) {
1931 if (current == isolate) { 1950 if (current == isolate) {
1932 ASSERT(previous != NULL); 1951 ASSERT(previous != NULL);
1933 previous->next_ = current->next_; 1952 previous->next_ = current->next_;
1934 return; 1953 return;
1935 } 1954 }
1936 previous = current; 1955 previous = current;
1937 current = current->next_; 1956 current = current->next_;
1938 } 1957 }
1939 UNREACHABLE(); 1958 // If we are shutting down the VM, the isolate may not be in the list.
1959 ASSERT(!creation_enabled_);
1940 } 1960 }
1941 1961
1942 1962
1943 #if defined(DEBUG) 1963 #if defined(DEBUG)
1944 void Isolate::CheckForDuplicateThreadState(InterruptableThreadState* state) { 1964 void Isolate::CheckForDuplicateThreadState(InterruptableThreadState* state) {
1945 MonitorLocker ml(isolates_list_monitor_); 1965 MonitorLocker ml(isolates_list_monitor_);
1946 ASSERT(state != NULL); 1966 ASSERT(state != NULL);
1947 Isolate* current = isolates_list_head_; 1967 Isolate* current = isolates_list_head_;
1948 while (current) { 1968 while (current) {
1949 ASSERT(current->thread_state() != state); 1969 ASSERT(current->thread_state() != state);
1950 current = current->next_; 1970 current = current->next_;
1951 } 1971 }
1952 } 1972 }
1953 #endif 1973 #endif
1954 1974
1955 1975
1976 void Isolate::DisableIsolateCreation() {
1977 MonitorLocker ml(isolates_list_monitor_);
1978 creation_enabled_ = false;
1979 }
1980
1981
1982 void Isolate::EnableIsolateCreation() {
1983 MonitorLocker ml(isolates_list_monitor_);
1984 creation_enabled_ = true;
1985 }
1986
1987
1956 template<class T> 1988 template<class T>
1957 T* Isolate::AllocateReusableHandle() { 1989 T* Isolate::AllocateReusableHandle() {
1958 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); 1990 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle());
1959 T::initializeHandle(handle, T::null()); 1991 T::initializeHandle(handle, T::null());
1960 return handle; 1992 return handle;
1961 } 1993 }
1962 1994
1963 1995
1996 void Isolate::KillIsolate(Isolate* isolate) {
Ivan Posva 2015/08/17 13:35:51 Why is this not an instance method?
zra 2015/08/18 06:23:14 Done.
1997 Dart_CObject kill_msg;
1998 Dart_CObject* list_values[4];
1999 kill_msg.type = Dart_CObject_kArray;
2000 kill_msg.value.as_array.length = 4;
2001 kill_msg.value.as_array.values = list_values;
2002
2003 Dart_CObject oob;
2004 oob.type = Dart_CObject_kInt32;
2005 oob.value.as_int32 = Message::kIsolateLibOOBMsg;
2006 list_values[0] = &oob;
2007
2008 Dart_CObject kill;
2009 kill.type = Dart_CObject_kInt32;
2010 kill.value.as_int32 = IsolateMessageHandler::kKillMsg;
2011 list_values[1] = &kill;
2012
2013 Dart_CObject cap;
2014 cap.type = Dart_CObject_kCapability;
2015 cap.value.as_capability.id = isolate->terminate_capability();
2016 list_values[2] = &cap;
2017
2018 Dart_CObject imm;
2019 imm.type = Dart_CObject_kInt32;
2020 imm.value.as_int32 = IsolateMessageHandler::kImmediateAction;
2021 list_values[3] = &imm;
2022
2023 isolate->ScheduleInterrupts(Isolate::kMessageInterrupt);
Ivan Posva 2015/08/17 13:35:51 What is this interrupt for? It will likely be hand
zra 2015/08/18 06:23:14 I was following the pattern in the implementation
2024 {
2025 uint8_t* buffer = NULL;
2026 ApiMessageWriter writer(&buffer, allocator);
2027 bool success = writer.WriteCMessage(&kill_msg);
2028 ASSERT(success);
2029
2030 // Post the message at the given port.
2031 success = PortMap::PostMessage(new Message(isolate->main_port(),
2032 buffer,
2033 writer.BytesWritten(),
2034 Message::kOOBPriority));
2035 ASSERT(success);
2036 }
2037 }
2038
2039
2040 class IsolateKillerVisitor : public IsolateVisitor {
2041 public:
2042 IsolateKillerVisitor() {}
2043
2044 virtual ~IsolateKillerVisitor() {}
2045
2046 void VisitIsolate(Isolate* isolate) {
2047 ASSERT(isolate != NULL);
2048 if (ServiceIsolate::IsServiceIsolateDescendant(isolate) ||
2049 (isolate == Dart::vm_isolate())) {
2050 return;
2051 }
2052 Isolate::KillIsolate(isolate);
Ivan Posva 2015/08/17 13:35:51 ditto isolate->Kill();
zra 2015/08/18 06:23:14 Done.
2053 }
2054 };
2055
2056
2057 void Isolate::KillAllIsolates() {
2058 IsolateKillerVisitor visitor;
2059 VisitIsolates(&visitor);
2060 }
2061
2062
1964 static RawInstance* DeserializeObject(Isolate* isolate, 2063 static RawInstance* DeserializeObject(Isolate* isolate,
1965 Zone* zone, 2064 Zone* zone,
1966 uint8_t* obj_data, 2065 uint8_t* obj_data,
1967 intptr_t obj_len) { 2066 intptr_t obj_len) {
1968 if (obj_data == NULL) { 2067 if (obj_data == NULL) {
1969 return Instance::null(); 2068 return Instance::null();
1970 } 2069 }
1971 MessageSnapshotReader reader(obj_data, 2070 MessageSnapshotReader reader(obj_data,
1972 obj_len, 2071 obj_len,
1973 isolate, 2072 isolate,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 serialized_message_, serialized_message_len_); 2259 serialized_message_, serialized_message_len_);
2161 } 2260 }
2162 2261
2163 2262
2164 void IsolateSpawnState::Cleanup() { 2263 void IsolateSpawnState::Cleanup() {
2165 SwitchIsolateScope switch_scope(I); 2264 SwitchIsolateScope switch_scope(I);
2166 Dart::ShutdownIsolate(); 2265 Dart::ShutdownIsolate();
2167 } 2266 }
2168 2267
2169 } // namespace dart 2268 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698