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 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 // Paused at breakpoint. Don't tick. | 1759 // Paused at breakpoint. Don't tick. |
1760 return 0; | 1760 return 0; |
1761 } | 1761 } |
1762 MessageHandler* msg_handler = message_handler(); | 1762 MessageHandler* msg_handler = message_handler(); |
1763 if ((msg_handler != NULL) && | 1763 if ((msg_handler != NULL) && |
1764 (msg_handler->paused_on_start() || | 1764 (msg_handler->paused_on_start() || |
1765 msg_handler->paused_on_exit())) { | 1765 msg_handler->paused_on_exit())) { |
1766 // Paused at start / exit . Don't tick. | 1766 // Paused at start / exit . Don't tick. |
1767 return 0; | 1767 return 0; |
1768 } | 1768 } |
1769 InterruptableThreadState* state = thread_state(); | 1769 if (mutator_thread_ == NULL) { |
1770 if (state == NULL) { | 1770 // No active mutator. |
1771 // Isolate is not scheduled on a thread. | |
1772 ProfileIdle(); | 1771 ProfileIdle(); |
1773 return 1; | 1772 return 1; |
1774 } | 1773 } |
1775 ASSERT(state->id != OSThread::kInvalidThreadId); | 1774 |
1776 ThreadInterrupter::InterruptThread(state); | 1775 // TODO(johnmccutchan): Sample all threads, not just the mutator thread. |
| 1776 // TODO(johnmccutchan): Keep a global list of threads and use that |
| 1777 // instead of Isolate. |
| 1778 ThreadRegistry::EntryIterator it(thread_registry()); |
| 1779 while (it.HasNext()) { |
| 1780 const ThreadRegistry::Entry& entry = it.Next(); |
| 1781 if (entry.thread == mutator_thread_) { |
| 1782 ThreadInterrupter::InterruptThread(mutator_thread_); |
| 1783 break; |
| 1784 } |
| 1785 } |
1777 return 1; | 1786 return 1; |
1778 } | 1787 } |
1779 | 1788 |
1780 | 1789 |
1781 void Isolate::ProfileIdle() { | 1790 void Isolate::ProfileIdle() { |
1782 vm_tag_counters_.Increment(vm_tag()); | 1791 vm_tag_counters_.Increment(vm_tag()); |
1783 } | 1792 } |
1784 | 1793 |
1785 | 1794 |
1786 void Isolate::set_tag_table(const GrowableObjectArray& value) { | 1795 void Isolate::set_tag_table(const GrowableObjectArray& value) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 previous->next_ = current->next_; | 1928 previous->next_ = current->next_; |
1920 return; | 1929 return; |
1921 } | 1930 } |
1922 previous = current; | 1931 previous = current; |
1923 current = current->next_; | 1932 current = current->next_; |
1924 } | 1933 } |
1925 UNREACHABLE(); | 1934 UNREACHABLE(); |
1926 } | 1935 } |
1927 | 1936 |
1928 | 1937 |
1929 #if defined(DEBUG) | |
1930 void Isolate::CheckForDuplicateThreadState(InterruptableThreadState* state) { | |
1931 MonitorLocker ml(isolates_list_monitor_); | |
1932 ASSERT(state != NULL); | |
1933 Isolate* current = isolates_list_head_; | |
1934 while (current) { | |
1935 ASSERT(current->thread_state() != state); | |
1936 current = current->next_; | |
1937 } | |
1938 } | |
1939 #endif | |
1940 | |
1941 | |
1942 template<class T> | 1938 template<class T> |
1943 T* Isolate::AllocateReusableHandle() { | 1939 T* Isolate::AllocateReusableHandle() { |
1944 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); | 1940 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); |
1945 T::initializeHandle(handle, T::null()); | 1941 T::initializeHandle(handle, T::null()); |
1946 return handle; | 1942 return handle; |
1947 } | 1943 } |
1948 | 1944 |
1949 | 1945 |
1950 static RawInstance* DeserializeObject(Isolate* isolate, | 1946 static RawInstance* DeserializeObject(Isolate* isolate, |
1951 Zone* zone, | 1947 Zone* zone, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 serialized_message_, serialized_message_len_); | 2142 serialized_message_, serialized_message_len_); |
2147 } | 2143 } |
2148 | 2144 |
2149 | 2145 |
2150 void IsolateSpawnState::Cleanup() { | 2146 void IsolateSpawnState::Cleanup() { |
2151 SwitchIsolateScope switch_scope(I); | 2147 SwitchIsolateScope switch_scope(I); |
2152 Dart::ShutdownIsolate(); | 2148 Dart::ShutdownIsolate(); |
2153 } | 2149 } |
2154 | 2150 |
2155 } // namespace dart | 2151 } // namespace dart |
OLD | NEW |