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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "vm/visitor.h" | 50 #include "vm/visitor.h" |
51 | 51 |
52 namespace dart { | 52 namespace dart { |
53 | 53 |
54 DECLARE_FLAG(bool, print_metrics); | 54 DECLARE_FLAG(bool, print_metrics); |
55 DECLARE_FLAG(bool, timing); | 55 DECLARE_FLAG(bool, timing); |
56 DECLARE_FLAG(bool, trace_service); | 56 DECLARE_FLAG(bool, trace_service); |
57 DECLARE_FLAG(bool, warn_on_pause_with_no_debugger); | 57 DECLARE_FLAG(bool, warn_on_pause_with_no_debugger); |
58 | 58 |
59 // Reload flags. | 59 // Reload flags. |
| 60 DECLARE_FLAG(int, reload_every); |
| 61 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
60 DECLARE_FLAG(bool, check_reloaded); | 62 DECLARE_FLAG(bool, check_reloaded); |
61 DECLARE_FLAG(int, reload_every); | |
62 DECLARE_FLAG(bool, reload_every_back_off); | 63 DECLARE_FLAG(bool, reload_every_back_off); |
63 DECLARE_FLAG(bool, trace_reload); | 64 DECLARE_FLAG(bool, trace_reload); |
| 65 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
64 | 66 |
65 #if !defined(PRODUCT) | 67 #if !defined(PRODUCT) |
66 static void CheckedModeHandler(bool value) { | 68 static void CheckedModeHandler(bool value) { |
67 FLAG_enable_asserts = value; | 69 FLAG_enable_asserts = value; |
68 FLAG_enable_type_checks = value; | 70 FLAG_enable_type_checks = value; |
69 } | 71 } |
70 | 72 |
71 // --enable-checked-mode and --checked both enable checked mode which is | 73 // --enable-checked-mode and --checked both enable checked mode which is |
72 // equivalent to setting --enable-asserts and --enable-type-checks. | 74 // equivalent to setting --enable-asserts and --enable-type-checks. |
73 DEFINE_FLAG_HANDLER(CheckedModeHandler, | 75 DEFINE_FLAG_HANDLER(CheckedModeHandler, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 NoOOBMessageScope::NoOOBMessageScope(Thread* thread) : StackResource(thread) { | 139 NoOOBMessageScope::NoOOBMessageScope(Thread* thread) : StackResource(thread) { |
138 thread->DeferOOBMessageInterrupts(); | 140 thread->DeferOOBMessageInterrupts(); |
139 } | 141 } |
140 | 142 |
141 NoOOBMessageScope::~NoOOBMessageScope() { | 143 NoOOBMessageScope::~NoOOBMessageScope() { |
142 thread()->RestoreOOBMessageInterrupts(); | 144 thread()->RestoreOOBMessageInterrupts(); |
143 } | 145 } |
144 | 146 |
145 NoReloadScope::NoReloadScope(Isolate* isolate, Thread* thread) | 147 NoReloadScope::NoReloadScope(Isolate* isolate, Thread* thread) |
146 : StackResource(thread), isolate_(isolate) { | 148 : StackResource(thread), isolate_(isolate) { |
147 #if !defined(PRODUCT) | 149 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
148 ASSERT(isolate_ != NULL); | 150 ASSERT(isolate_ != NULL); |
149 AtomicOperations::FetchAndIncrement(&(isolate_->no_reload_scope_depth_)); | 151 AtomicOperations::FetchAndIncrement(&(isolate_->no_reload_scope_depth_)); |
150 ASSERT(AtomicOperations::LoadRelaxed(&(isolate_->no_reload_scope_depth_)) >= | 152 ASSERT(AtomicOperations::LoadRelaxed(&(isolate_->no_reload_scope_depth_)) >= |
151 0); | 153 0); |
152 #endif // !defined(PRODUCT) | 154 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
153 } | 155 } |
154 | 156 |
155 NoReloadScope::~NoReloadScope() { | 157 NoReloadScope::~NoReloadScope() { |
156 #if !defined(PRODUCT) | 158 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
157 AtomicOperations::FetchAndDecrement(&(isolate_->no_reload_scope_depth_)); | 159 AtomicOperations::FetchAndDecrement(&(isolate_->no_reload_scope_depth_)); |
158 ASSERT(AtomicOperations::LoadRelaxed(&(isolate_->no_reload_scope_depth_)) >= | 160 ASSERT(AtomicOperations::LoadRelaxed(&(isolate_->no_reload_scope_depth_)) >= |
159 0); | 161 0); |
160 #endif // !defined(PRODUCT) | 162 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
161 } | 163 } |
162 | 164 |
163 void Isolate::RegisterClass(const Class& cls) { | 165 void Isolate::RegisterClass(const Class& cls) { |
164 #if !defined(PRODUCT) | 166 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
165 if (IsReloading()) { | 167 if (IsReloading()) { |
166 reload_context()->RegisterClass(cls); | 168 reload_context()->RegisterClass(cls); |
167 return; | 169 return; |
168 } | 170 } |
169 #endif // !defined(PRODUCT) | 171 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
170 class_table()->Register(cls); | 172 class_table()->Register(cls); |
171 } | 173 } |
172 | 174 |
173 void Isolate::RegisterClassAt(intptr_t index, const Class& cls) { | 175 void Isolate::RegisterClassAt(intptr_t index, const Class& cls) { |
174 class_table()->RegisterAt(index, cls); | 176 class_table()->RegisterAt(index, cls); |
175 } | 177 } |
176 | 178 |
177 void Isolate::ValidateClassTable() { | 179 void Isolate::ValidateClassTable() { |
178 class_table()->Validate(); | 180 class_table()->Validate(); |
179 } | 181 } |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 lib ^= libs.At(i); | 1043 lib ^= libs.At(i); |
1042 // If this library was loaded with Dart_LoadLibrary, it was marked | 1044 // If this library was loaded with Dart_LoadLibrary, it was marked |
1043 // as 'load in progres'. Set the status to 'loaded'. | 1045 // as 'load in progres'. Set the status to 'loaded'. |
1044 if (lib.LoadInProgress()) { | 1046 if (lib.LoadInProgress()) { |
1045 lib.SetLoaded(); | 1047 lib.SetLoaded(); |
1046 } | 1048 } |
1047 } | 1049 } |
1048 TokenStream::CloseSharedTokenList(this); | 1050 TokenStream::CloseSharedTokenList(this); |
1049 } | 1051 } |
1050 | 1052 |
1051 #if !defined(PRODUCT) | 1053 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1052 bool Isolate::CanReload() const { | 1054 bool Isolate::CanReload() const { |
1053 return !ServiceIsolate::IsServiceIsolateDescendant(this) && is_runnable() && | 1055 return !ServiceIsolate::IsServiceIsolateDescendant(this) && is_runnable() && |
1054 !IsReloading() && | 1056 !IsReloading() && |
1055 (AtomicOperations::LoadRelaxed(&no_reload_scope_depth_) == 0) && | 1057 (AtomicOperations::LoadRelaxed(&no_reload_scope_depth_) == 0) && |
1056 IsolateCreationEnabled(); | 1058 IsolateCreationEnabled(); |
1057 } | 1059 } |
1058 | 1060 |
1059 bool Isolate::ReloadSources(JSONStream* js, | 1061 bool Isolate::ReloadSources(JSONStream* js, |
1060 bool force_reload, | 1062 bool force_reload, |
1061 const char* root_script_url, | 1063 const char* root_script_url, |
(...skipping 11 matching lines...) Expand all Loading... |
1073 } | 1075 } |
1074 | 1076 |
1075 void Isolate::DeleteReloadContext() { | 1077 void Isolate::DeleteReloadContext() { |
1076 // Another thread may be in the middle of GetClassForHeapWalkAt. | 1078 // Another thread may be in the middle of GetClassForHeapWalkAt. |
1077 Thread* thread = Thread::Current(); | 1079 Thread* thread = Thread::Current(); |
1078 SafepointOperationScope safepoint_scope(thread); | 1080 SafepointOperationScope safepoint_scope(thread); |
1079 | 1081 |
1080 delete reload_context_; | 1082 delete reload_context_; |
1081 reload_context_ = NULL; | 1083 reload_context_ = NULL; |
1082 } | 1084 } |
1083 #endif // !defined(PRODUCT) | 1085 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1084 | 1086 |
1085 void Isolate::DoneFinalizing() { | 1087 void Isolate::DoneFinalizing() { |
1086 #if !defined(PRODUCT) | 1088 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1087 if (IsReloading()) { | 1089 if (IsReloading()) { |
1088 reload_context_->FinalizeLoading(); | 1090 reload_context_->FinalizeLoading(); |
1089 } | 1091 } |
1090 #endif // !defined(PRODUCT) | 1092 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1091 } | 1093 } |
1092 | 1094 |
1093 bool Isolate::MakeRunnable() { | 1095 bool Isolate::MakeRunnable() { |
1094 ASSERT(Isolate::Current() == NULL); | 1096 ASSERT(Isolate::Current() == NULL); |
1095 | 1097 |
1096 MutexLocker ml(mutex_); | 1098 MutexLocker ml(mutex_); |
1097 // Check if we are in a valid state to make the isolate runnable. | 1099 // Check if we are in a valid state to make the isolate runnable. |
1098 if (is_runnable() == true) { | 1100 if (is_runnable() == true) { |
1099 return false; // Already runnable. | 1101 return false; // Already runnable. |
1100 } | 1102 } |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 #if defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME) | 1463 #if defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME) |
1462 if (!isolate->HasAttemptedReload()) { | 1464 if (!isolate->HasAttemptedReload()) { |
1463 // For this verification we need to stop the background compiler earlier. | 1465 // For this verification we need to stop the background compiler earlier. |
1464 // This would otherwise happen in Dart::ShowdownIsolate. | 1466 // This would otherwise happen in Dart::ShowdownIsolate. |
1465 isolate->StopBackgroundCompiler(); | 1467 isolate->StopBackgroundCompiler(); |
1466 isolate->heap()->CollectAllGarbage(); | 1468 isolate->heap()->CollectAllGarbage(); |
1467 HeapIterationScope iteration(thread); | 1469 HeapIterationScope iteration(thread); |
1468 VerifyCanonicalVisitor check_canonical(thread); | 1470 VerifyCanonicalVisitor check_canonical(thread); |
1469 iteration.IterateObjects(&check_canonical); | 1471 iteration.IterateObjects(&check_canonical); |
1470 } | 1472 } |
1471 #endif // DEBUG | 1473 #endif // defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME) |
1472 const Error& error = Error::Handle(thread->sticky_error()); | 1474 const Error& error = Error::Handle(thread->sticky_error()); |
1473 if (!error.IsNull() && !error.IsUnwindError()) { | 1475 if (!error.IsNull() && !error.IsUnwindError()) { |
1474 OS::PrintErr("in ShutdownIsolate: %s\n", error.ToErrorCString()); | 1476 OS::PrintErr("in ShutdownIsolate: %s\n", error.ToErrorCString()); |
1475 } | 1477 } |
1476 Dart::RunShutdownCallback(); | 1478 Dart::RunShutdownCallback(); |
1477 } | 1479 } |
1478 // Shut the isolate down. | 1480 // Shut the isolate down. |
1479 Dart::ShutdownIsolate(isolate); | 1481 Dart::ShutdownIsolate(isolate); |
1480 } | 1482 } |
1481 | 1483 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 #endif // !defined(PRODUCT) | 1632 #endif // !defined(PRODUCT) |
1631 } | 1633 } |
1632 | 1634 |
1633 void Isolate::StopBackgroundCompiler() { | 1635 void Isolate::StopBackgroundCompiler() { |
1634 // Wait until all background compilation has finished. | 1636 // Wait until all background compilation has finished. |
1635 if (background_compiler_ != NULL) { | 1637 if (background_compiler_ != NULL) { |
1636 BackgroundCompiler::Stop(this); | 1638 BackgroundCompiler::Stop(this); |
1637 } | 1639 } |
1638 } | 1640 } |
1639 | 1641 |
1640 #if !defined(PRODUCT) | 1642 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1641 void Isolate::MaybeIncreaseReloadEveryNStackOverflowChecks() { | 1643 void Isolate::MaybeIncreaseReloadEveryNStackOverflowChecks() { |
1642 if (FLAG_reload_every_back_off) { | 1644 if (FLAG_reload_every_back_off) { |
1643 if (reload_every_n_stack_overflow_checks_ < 5000) { | 1645 if (reload_every_n_stack_overflow_checks_ < 5000) { |
1644 reload_every_n_stack_overflow_checks_ += 99; | 1646 reload_every_n_stack_overflow_checks_ += 99; |
1645 } else { | 1647 } else { |
1646 reload_every_n_stack_overflow_checks_ *= 2; | 1648 reload_every_n_stack_overflow_checks_ *= 2; |
1647 } | 1649 } |
1648 // Cap the value. | 1650 // Cap the value. |
1649 if (reload_every_n_stack_overflow_checks_ > 1000000) { | 1651 if (reload_every_n_stack_overflow_checks_ > 1000000) { |
1650 reload_every_n_stack_overflow_checks_ = 1000000; | 1652 reload_every_n_stack_overflow_checks_ = 1000000; |
1651 } | 1653 } |
1652 } | 1654 } |
1653 } | 1655 } |
1654 #endif // !defined(PRODUCT) | 1656 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1655 | 1657 |
1656 void Isolate::Shutdown() { | 1658 void Isolate::Shutdown() { |
1657 ASSERT(this == Isolate::Current()); | 1659 ASSERT(this == Isolate::Current()); |
1658 StopBackgroundCompiler(); | 1660 StopBackgroundCompiler(); |
1659 | 1661 |
1660 #if defined(DEBUG) | 1662 #if defined(DEBUG) |
1661 if (heap_ != NULL && FLAG_verify_on_transition) { | 1663 if (heap_ != NULL && FLAG_verify_on_transition) { |
1662 // The VM isolate keeps all objects marked. | 1664 // The VM isolate keeps all objects marked. |
1663 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); | 1665 heap_->Verify(this == Dart::vm_isolate() ? kRequireMarked : kForbidMarked); |
1664 } | 1666 } |
(...skipping 25 matching lines...) Expand all Loading... |
1690 if (heap_ != NULL) { | 1692 if (heap_ != NULL) { |
1691 // Wait for any concurrent GC tasks to finish before shutting down. | 1693 // Wait for any concurrent GC tasks to finish before shutting down. |
1692 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). | 1694 // TODO(koda): Support faster sweeper shutdown (e.g., after current page). |
1693 PageSpace* old_space = heap_->old_space(); | 1695 PageSpace* old_space = heap_->old_space(); |
1694 MonitorLocker ml(old_space->tasks_lock()); | 1696 MonitorLocker ml(old_space->tasks_lock()); |
1695 while (old_space->tasks() > 0) { | 1697 while (old_space->tasks() > 0) { |
1696 ml.Wait(); | 1698 ml.Wait(); |
1697 } | 1699 } |
1698 } | 1700 } |
1699 | 1701 |
1700 #if !defined(PRODUCT) | 1702 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1701 if (FLAG_check_reloaded && is_runnable() && (this != Dart::vm_isolate()) && | 1703 if (FLAG_check_reloaded && is_runnable() && (this != Dart::vm_isolate()) && |
1702 !ServiceIsolate::IsServiceIsolateDescendant(this)) { | 1704 !ServiceIsolate::IsServiceIsolateDescendant(this)) { |
1703 if (!HasAttemptedReload()) { | 1705 if (!HasAttemptedReload()) { |
1704 FATAL( | 1706 FATAL( |
1705 "Isolate did not reload before exiting and " | 1707 "Isolate did not reload before exiting and " |
1706 "--check-reloaded is enabled.\n"); | 1708 "--check-reloaded is enabled.\n"); |
1707 } | 1709 } |
1708 } | 1710 } |
1709 #endif // !defined(PRODUCT) | 1711 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1710 | 1712 |
1711 // Then, proceed with low-level teardown. | 1713 // Then, proceed with low-level teardown. |
1712 LowLevelShutdown(); | 1714 LowLevelShutdown(); |
1713 | 1715 |
1714 #if defined(DEBUG) | 1716 #if defined(DEBUG) |
1715 // No concurrent sweeper tasks should be running at this point. | 1717 // No concurrent sweeper tasks should be running at this point. |
1716 if (heap_ != NULL) { | 1718 if (heap_ != NULL) { |
1717 PageSpace* old_space = heap_->old_space(); | 1719 PageSpace* old_space = heap_->old_space(); |
1718 MonitorLocker ml(old_space->tasks_lock()); | 1720 MonitorLocker ml(old_space->tasks_lock()); |
1719 ASSERT(old_space->tasks() == 0); | 1721 ASSERT(old_space->tasks() == 0); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 | 1789 |
1788 // Visit the boxed_field_list_. | 1790 // Visit the boxed_field_list_. |
1789 // 'boxed_field_list_' access via mutator and background compilation threads | 1791 // 'boxed_field_list_' access via mutator and background compilation threads |
1790 // is guarded with a monitor. This means that we can visit it only | 1792 // is guarded with a monitor. This means that we can visit it only |
1791 // when at safepoint or the field_list_mutex_ lock has been taken. | 1793 // when at safepoint or the field_list_mutex_ lock has been taken. |
1792 visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_)); | 1794 visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_)); |
1793 | 1795 |
1794 #if !defined(PRODUCT) | 1796 #if !defined(PRODUCT) |
1795 // Visit objects in the debugger. | 1797 // Visit objects in the debugger. |
1796 debugger()->VisitObjectPointers(visitor); | 1798 debugger()->VisitObjectPointers(visitor); |
1797 | 1799 #if !defined(DART_PRECOMPILED_RUNTIME) |
1798 // Visit objects that are being used for isolate reload. | 1800 // Visit objects that are being used for isolate reload. |
1799 if (reload_context() != NULL) { | 1801 if (reload_context() != NULL) { |
1800 reload_context()->VisitObjectPointers(visitor); | 1802 reload_context()->VisitObjectPointers(visitor); |
1801 } | 1803 } |
| 1804 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1802 if (ServiceIsolate::IsServiceIsolate(this)) { | 1805 if (ServiceIsolate::IsServiceIsolate(this)) { |
1803 ServiceIsolate::VisitObjectPointers(visitor); | 1806 ServiceIsolate::VisitObjectPointers(visitor); |
1804 } | 1807 } |
1805 #endif // !defined(PRODUCT) | 1808 #endif // !defined(PRODUCT) |
1806 | 1809 |
1807 #if !defined(DART_PRECOMPILED_RUNTIME) | 1810 #if !defined(DART_PRECOMPILED_RUNTIME) |
1808 // Visit objects that are being used for deoptimization. | 1811 // Visit objects that are being used for deoptimization. |
1809 if (deopt_context() != NULL) { | 1812 if (deopt_context() != NULL) { |
1810 deopt_context()->VisitObjectPointers(visitor); | 1813 deopt_context()->VisitObjectPointers(visitor); |
1811 } | 1814 } |
1812 #endif | 1815 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1813 | 1816 |
1814 VisitStackPointers(visitor, validate_frames); | 1817 VisitStackPointers(visitor, validate_frames); |
1815 } | 1818 } |
1816 | 1819 |
1817 void Isolate::VisitStackPointers(ObjectPointerVisitor* visitor, | 1820 void Isolate::VisitStackPointers(ObjectPointerVisitor* visitor, |
1818 bool validate_frames) { | 1821 bool validate_frames) { |
1819 // Visit objects in all threads (e.g., Dart stack, handles in zones). | 1822 // Visit objects in all threads (e.g., Dart stack, handles in zones). |
1820 thread_registry()->VisitObjectPointers(visitor, validate_frames); | 1823 thread_registry()->VisitObjectPointers(visitor, validate_frames); |
1821 } | 1824 } |
1822 | 1825 |
1823 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { | 1826 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor) { |
1824 if (api_state() != NULL) { | 1827 if (api_state() != NULL) { |
1825 api_state()->VisitWeakHandles(visitor); | 1828 api_state()->VisitWeakHandles(visitor); |
1826 } | 1829 } |
1827 } | 1830 } |
1828 | 1831 |
1829 void Isolate::PrepareForGC() { | 1832 void Isolate::PrepareForGC() { |
1830 thread_registry()->PrepareForGC(); | 1833 thread_registry()->PrepareForGC(); |
1831 } | 1834 } |
1832 | 1835 |
1833 RawClass* Isolate::GetClassForHeapWalkAt(intptr_t cid) { | 1836 RawClass* Isolate::GetClassForHeapWalkAt(intptr_t cid) { |
1834 RawClass* raw_class = NULL; | 1837 RawClass* raw_class = NULL; |
1835 #ifndef PRODUCT | 1838 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1836 if (IsReloading()) { | 1839 if (IsReloading()) { |
1837 raw_class = reload_context()->GetClassForHeapWalkAt(cid); | 1840 raw_class = reload_context()->GetClassForHeapWalkAt(cid); |
1838 } else { | 1841 } else { |
1839 raw_class = class_table()->At(cid); | 1842 raw_class = class_table()->At(cid); |
1840 } | 1843 } |
1841 #else | 1844 #else |
1842 raw_class = class_table()->At(cid); | 1845 raw_class = class_table()->At(cid); |
1843 #endif // !PRODUCT | 1846 #endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
1844 ASSERT(raw_class != NULL); | 1847 ASSERT(raw_class != NULL); |
1845 ASSERT(remapping_cids() || raw_class->ptr()->id_ == cid); | 1848 ASSERT(remapping_cids() || raw_class->ptr()->id_ == cid); |
1846 return raw_class; | 1849 return raw_class; |
1847 } | 1850 } |
1848 | 1851 |
1849 void Isolate::AddPendingDeopt(uword fp, uword pc) { | 1852 void Isolate::AddPendingDeopt(uword fp, uword pc) { |
1850 // GrowableArray::Add is not atomic and may be interrupt by a profiler | 1853 // GrowableArray::Add is not atomic and may be interrupt by a profiler |
1851 // stack walk. | 1854 // stack walk. |
1852 MallocGrowableArray<PendingLazyDeopt>* old_pending_deopts = pending_deopts_; | 1855 MallocGrowableArray<PendingLazyDeopt>* old_pending_deopts = pending_deopts_; |
1853 MallocGrowableArray<PendingLazyDeopt>* new_pending_deopts = | 1856 MallocGrowableArray<PendingLazyDeopt>* new_pending_deopts = |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 jsobj.AddPropertyTimeMillis("startTime", start_time); | 1921 jsobj.AddPropertyTimeMillis("startTime", start_time); |
1919 { | 1922 { |
1920 JSONObject jsheap(&jsobj, "_heaps"); | 1923 JSONObject jsheap(&jsobj, "_heaps"); |
1921 heap()->PrintToJSONObject(Heap::kNew, &jsheap); | 1924 heap()->PrintToJSONObject(Heap::kNew, &jsheap); |
1922 heap()->PrintToJSONObject(Heap::kOld, &jsheap); | 1925 heap()->PrintToJSONObject(Heap::kOld, &jsheap); |
1923 } | 1926 } |
1924 | 1927 |
1925 jsobj.AddProperty("runnable", is_runnable()); | 1928 jsobj.AddProperty("runnable", is_runnable()); |
1926 jsobj.AddProperty("livePorts", message_handler()->live_ports()); | 1929 jsobj.AddProperty("livePorts", message_handler()->live_ports()); |
1927 jsobj.AddProperty("pauseOnExit", message_handler()->should_pause_on_exit()); | 1930 jsobj.AddProperty("pauseOnExit", message_handler()->should_pause_on_exit()); |
| 1931 #if !defined(DART_PRECOMPILED_RUNTIME) |
1928 jsobj.AddProperty("_isReloading", IsReloading()); | 1932 jsobj.AddProperty("_isReloading", IsReloading()); |
| 1933 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1929 | 1934 |
1930 if (!is_runnable()) { | 1935 if (!is_runnable()) { |
1931 // Isolate is not yet runnable. | 1936 // Isolate is not yet runnable. |
1932 ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL)); | 1937 ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL)); |
1933 ServiceEvent pause_event(this, ServiceEvent::kNone); | 1938 ServiceEvent pause_event(this, ServiceEvent::kNone); |
1934 jsobj.AddProperty("pauseEvent", &pause_event); | 1939 jsobj.AddProperty("pauseEvent", &pause_event); |
1935 } else if (message_handler()->is_paused_on_start() || | 1940 } else if (message_handler()->is_paused_on_start() || |
1936 message_handler()->should_pause_on_start()) { | 1941 message_handler()->should_pause_on_start()) { |
1937 ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL)); | 1942 ASSERT((debugger() == NULL) || (debugger()->PauseEvent() == NULL)); |
1938 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); | 1943 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2300 // until we are told to resume. | 2305 // until we are told to resume. |
2301 if (pause_loop_monitor_ == NULL) { | 2306 if (pause_loop_monitor_ == NULL) { |
2302 pause_loop_monitor_ = new Monitor(); | 2307 pause_loop_monitor_ = new Monitor(); |
2303 } | 2308 } |
2304 Dart_EnterScope(); | 2309 Dart_EnterScope(); |
2305 MonitorLocker ml(pause_loop_monitor_); | 2310 MonitorLocker ml(pause_loop_monitor_); |
2306 | 2311 |
2307 Dart_MessageNotifyCallback saved_notify_callback = message_notify_callback(); | 2312 Dart_MessageNotifyCallback saved_notify_callback = message_notify_callback(); |
2308 set_message_notify_callback(Isolate::WakePauseEventHandler); | 2313 set_message_notify_callback(Isolate::WakePauseEventHandler); |
2309 | 2314 |
| 2315 #if !defined(DART_PRECOMPILED_RUNTIME) |
2310 const bool had_isolate_reload_context = reload_context() != NULL; | 2316 const bool had_isolate_reload_context = reload_context() != NULL; |
2311 const int64_t start_time_micros = | 2317 const int64_t start_time_micros = |
2312 !had_isolate_reload_context ? 0 : reload_context()->start_time_micros(); | 2318 !had_isolate_reload_context ? 0 : reload_context()->start_time_micros(); |
| 2319 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
2313 bool resume = false; | 2320 bool resume = false; |
2314 while (true) { | 2321 while (true) { |
2315 // Handle all available vm service messages, up to a resume | 2322 // Handle all available vm service messages, up to a resume |
2316 // request. | 2323 // request. |
2317 while (!resume && Dart_HasServiceMessages()) { | 2324 while (!resume && Dart_HasServiceMessages()) { |
2318 ml.Exit(); | 2325 ml.Exit(); |
2319 resume = Dart_HandleServiceMessages(); | 2326 resume = Dart_HandleServiceMessages(); |
2320 ml.Enter(); | 2327 ml.Enter(); |
2321 } | 2328 } |
2322 if (resume) { | 2329 if (resume) { |
2323 break; | 2330 break; |
2324 } | 2331 } |
2325 | 2332 |
| 2333 #if !defined(DART_PRECOMPILED_RUNTIME) |
2326 if (had_isolate_reload_context && (reload_context() == NULL)) { | 2334 if (had_isolate_reload_context && (reload_context() == NULL)) { |
2327 if (FLAG_trace_reload) { | 2335 if (FLAG_trace_reload) { |
2328 const int64_t reload_time_micros = | 2336 const int64_t reload_time_micros = |
2329 OS::GetCurrentMonotonicMicros() - start_time_micros; | 2337 OS::GetCurrentMonotonicMicros() - start_time_micros; |
2330 double reload_millis = MicrosecondsToMilliseconds(reload_time_micros); | 2338 double reload_millis = MicrosecondsToMilliseconds(reload_time_micros); |
2331 OS::Print("Reloading has finished! (%.2f ms)\n", reload_millis); | 2339 OS::Print("Reloading has finished! (%.2f ms)\n", reload_millis); |
2332 } | 2340 } |
2333 break; | 2341 break; |
2334 } | 2342 } |
| 2343 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
2335 | 2344 |
2336 // Wait for more service messages. | 2345 // Wait for more service messages. |
2337 Monitor::WaitResult res = ml.Wait(); | 2346 Monitor::WaitResult res = ml.Wait(); |
2338 ASSERT(res == Monitor::kNotified); | 2347 ASSERT(res == Monitor::kNotified); |
2339 } | 2348 } |
2340 set_message_notify_callback(saved_notify_callback); | 2349 set_message_notify_callback(saved_notify_callback); |
2341 Dart_ExitScope(); | 2350 Dart_ExitScope(); |
2342 } | 2351 } |
2343 #endif // !PRODUCT | 2352 #endif // !PRODUCT |
2344 | 2353 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 void IsolateSpawnState::DecrementSpawnCount() { | 2841 void IsolateSpawnState::DecrementSpawnCount() { |
2833 ASSERT(spawn_count_monitor_ != NULL); | 2842 ASSERT(spawn_count_monitor_ != NULL); |
2834 ASSERT(spawn_count_ != NULL); | 2843 ASSERT(spawn_count_ != NULL); |
2835 MonitorLocker ml(spawn_count_monitor_); | 2844 MonitorLocker ml(spawn_count_monitor_); |
2836 ASSERT(*spawn_count_ > 0); | 2845 ASSERT(*spawn_count_ > 0); |
2837 *spawn_count_ = *spawn_count_ - 1; | 2846 *spawn_count_ = *spawn_count_ - 1; |
2838 ml.Notify(); | 2847 ml.Notify(); |
2839 } | 2848 } |
2840 | 2849 |
2841 } // namespace dart | 2850 } // namespace dart |
OLD | NEW |