Chromium Code Reviews| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 } else { | 485 } else { |
| 486 const Object& result = Object::Handle(zone, | 486 const Object& result = Object::Handle(zone, |
| 487 DartLibraryCalls::HandleMessage(msg_handler, msg)); | 487 DartLibraryCalls::HandleMessage(msg_handler, msg)); |
| 488 if (result.IsError()) { | 488 if (result.IsError()) { |
| 489 success = ProcessUnhandledException(Error::Cast(result)); | 489 success = ProcessUnhandledException(Error::Cast(result)); |
| 490 } else { | 490 } else { |
| 491 ASSERT(result.IsNull()); | 491 ASSERT(result.IsNull()); |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 delete message; | 494 delete message; |
| 495 if (success) { | |
| 496 const Object& result = | |
| 497 Object::Handle(zone, I->InvokePendingExtensionCalls()); | |
| 498 if (result.IsError()) { | |
| 499 success = ProcessUnhandledException(Error::Cast(result)); | |
| 500 } else { | |
| 501 ASSERT(result.IsNull()); | |
| 502 } | |
| 503 } | |
| 495 return success; | 504 return success; |
| 496 } | 505 } |
| 497 | 506 |
| 498 | 507 |
| 499 void IsolateMessageHandler::NotifyPauseOnStart() { | 508 void IsolateMessageHandler::NotifyPauseOnStart() { |
| 500 if (Service::debug_stream.enabled()) { | 509 if (Service::debug_stream.enabled()) { |
| 501 StartIsolateScope start_isolate(isolate()); | 510 StartIsolateScope start_isolate(isolate()); |
| 502 StackZone zone(I); | 511 StackZone zone(I); |
| 503 HandleScope handle_scope(I); | 512 HandleScope handle_scope(I); |
| 504 ServiceEvent pause_event(isolate(), ServiceEvent::kPauseStart); | 513 ServiceEvent pause_event(isolate(), ServiceEvent::kPauseStart); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 last_allocationprofile_accumulator_reset_timestamp_(0), | 698 last_allocationprofile_accumulator_reset_timestamp_(0), |
| 690 last_allocationprofile_gc_timestamp_(0), | 699 last_allocationprofile_gc_timestamp_(0), |
| 691 object_id_ring_(NULL), | 700 object_id_ring_(NULL), |
| 692 trace_buffer_(NULL), | 701 trace_buffer_(NULL), |
| 693 profiler_data_(NULL), | 702 profiler_data_(NULL), |
| 694 tag_table_(GrowableObjectArray::null()), | 703 tag_table_(GrowableObjectArray::null()), |
| 695 current_tag_(UserTag::null()), | 704 current_tag_(UserTag::null()), |
| 696 default_tag_(UserTag::null()), | 705 default_tag_(UserTag::null()), |
| 697 collected_closures_(GrowableObjectArray::null()), | 706 collected_closures_(GrowableObjectArray::null()), |
| 698 deoptimized_code_array_(GrowableObjectArray::null()), | 707 deoptimized_code_array_(GrowableObjectArray::null()), |
| 708 pending_extension_calls_(GrowableObjectArray::null()), | |
| 699 metrics_list_head_(NULL), | 709 metrics_list_head_(NULL), |
| 700 compilation_allowed_(true), | 710 compilation_allowed_(true), |
| 701 cha_(NULL), | 711 cha_(NULL), |
| 702 next_(NULL), | 712 next_(NULL), |
| 703 pause_loop_monitor_(NULL), | 713 pause_loop_monitor_(NULL), |
| 704 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 714 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
| 705 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 715 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) |
| 706 reusable_handles_() { | 716 reusable_handles_() { |
| 707 flags_.CopyFrom(api_flags); | 717 flags_.CopyFrom(api_flags); |
| 708 set_vm_tag(VMTag::kEmbedderTagId); | 718 set_vm_tag(VMTag::kEmbedderTagId); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1613 // Visit the tag table which is stored in the isolate. | 1623 // Visit the tag table which is stored in the isolate. |
| 1614 visitor->VisitPointer(reinterpret_cast<RawObject**>(&tag_table_)); | 1624 visitor->VisitPointer(reinterpret_cast<RawObject**>(&tag_table_)); |
| 1615 | 1625 |
| 1616 // Visit array of closures pending precompilation. | 1626 // Visit array of closures pending precompilation. |
| 1617 visitor->VisitPointer(reinterpret_cast<RawObject**>(&collected_closures_)); | 1627 visitor->VisitPointer(reinterpret_cast<RawObject**>(&collected_closures_)); |
| 1618 | 1628 |
| 1619 // Visit the deoptimized code array which is stored in the isolate. | 1629 // Visit the deoptimized code array which is stored in the isolate. |
| 1620 visitor->VisitPointer( | 1630 visitor->VisitPointer( |
| 1621 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); | 1631 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); |
| 1622 | 1632 |
| 1633 // Visit the pending service extension calls. | |
| 1634 visitor->VisitPointer( | |
| 1635 reinterpret_cast<RawObject**>(&pending_extension_calls_)); | |
| 1636 | |
| 1623 // Visit objects in the debugger. | 1637 // Visit objects in the debugger. |
| 1624 debugger()->VisitObjectPointers(visitor); | 1638 debugger()->VisitObjectPointers(visitor); |
| 1625 | 1639 |
| 1626 // Visit objects that are being used for deoptimization. | 1640 // Visit objects that are being used for deoptimization. |
| 1627 if (deopt_context() != NULL) { | 1641 if (deopt_context() != NULL) { |
| 1628 deopt_context()->VisitObjectPointers(visitor); | 1642 deopt_context()->VisitObjectPointers(visitor); |
| 1629 } | 1643 } |
| 1630 | 1644 |
| 1631 // Visit objects in thread registry (e.g., Dart stack, handles in zones). | 1645 // Visit objects in thread registry (e.g., Dart stack, handles in zones). |
| 1632 thread_registry()->VisitObjectPointers(visitor, validate_frames); | 1646 thread_registry()->VisitObjectPointers(visitor, validate_frames); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1818 if (deoptimized_code.IsNull()) { | 1832 if (deoptimized_code.IsNull()) { |
| 1819 // Not tracking deoptimized code. | 1833 // Not tracking deoptimized code. |
| 1820 return; | 1834 return; |
| 1821 } | 1835 } |
| 1822 // TODO(johnmccutchan): Scan this array and the isolate's profile before | 1836 // TODO(johnmccutchan): Scan this array and the isolate's profile before |
| 1823 // old space GC and remove the keep_code flag. | 1837 // old space GC and remove the keep_code flag. |
| 1824 deoptimized_code.Add(code); | 1838 deoptimized_code.Add(code); |
| 1825 } | 1839 } |
| 1826 | 1840 |
| 1827 | 1841 |
| 1842 void Isolate::set_pending_extension_calls(const GrowableObjectArray& value) { | |
| 1843 pending_extension_calls_ = value.raw(); | |
| 1844 } | |
| 1845 | |
| 1846 | |
| 1847 RawObject* Isolate::InvokePendingExtensionCalls() { | |
| 1848 GrowableObjectArray& calls = | |
| 1849 GrowableObjectArray::Handle(PrunePendingExtensionCalls()); | |
| 1850 if (calls.IsNull()) { | |
| 1851 return Object::null(); | |
| 1852 } | |
| 1853 const Array& arguments = Array::Handle(Array::New(1, Heap::kNew)); | |
| 1854 Object& result = Object::Handle(); | |
| 1855 Instance& closure = Instance::Handle(); | |
| 1856 for (intptr_t i = 0; i < calls.Length(); i++) { | |
| 1857 closure ^= calls.At(i); | |
| 1858 ASSERT(!closure.IsNull()); | |
| 1859 arguments.SetAt(0, closure); | |
| 1860 result = DartEntry::InvokeClosure(arguments); | |
| 1861 if (result.IsError()) { | |
| 1862 return result.raw(); | |
| 1863 } | |
| 1864 result = DartLibraryCalls::DrainMicrotaskQueue(); | |
| 1865 if (result.IsError()) { | |
| 1866 return result.raw(); | |
| 1867 } | |
| 1868 } | |
| 1869 return Object::null(); | |
| 1870 } | |
| 1871 | |
| 1872 | |
| 1873 RawGrowableObjectArray* Isolate::PrunePendingExtensionCalls() { | |
|
turnidge
2015/08/20 17:34:39
Maybe GetAndClearPendingExtensionCalls? Your choi
Cutch
2015/08/20 18:09:37
Done.
| |
| 1874 RawGrowableObjectArray* r = pending_extension_calls_; | |
| 1875 pending_extension_calls_ = GrowableObjectArray::null(); | |
| 1876 return r; | |
| 1877 } | |
| 1878 | |
| 1879 | |
| 1880 void Isolate::AppendExtensionCall(const Instance& closure) { | |
| 1881 GrowableObjectArray& calls = | |
| 1882 GrowableObjectArray::Handle(pending_extension_calls()); | |
| 1883 if (calls.IsNull()) { | |
| 1884 calls ^= GrowableObjectArray::New(Heap::kOld); | |
| 1885 ASSERT(!calls.IsNull()); | |
| 1886 set_pending_extension_calls(calls); | |
| 1887 } | |
| 1888 calls.Add(closure, Heap::kOld); | |
| 1889 } | |
| 1890 | |
| 1891 | |
| 1828 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) { | 1892 void Isolate::WakePauseEventHandler(Dart_Isolate isolate) { |
| 1829 Isolate* iso = reinterpret_cast<Isolate*>(isolate); | 1893 Isolate* iso = reinterpret_cast<Isolate*>(isolate); |
| 1830 MonitorLocker ml(iso->pause_loop_monitor_); | 1894 MonitorLocker ml(iso->pause_loop_monitor_); |
| 1831 ml.Notify(); | 1895 ml.Notify(); |
| 1832 } | 1896 } |
| 1833 | 1897 |
| 1834 | 1898 |
| 1835 void Isolate::PauseEventHandler() { | 1899 void Isolate::PauseEventHandler() { |
| 1836 // We are stealing a pause event (like a breakpoint) from the | 1900 // We are stealing a pause event (like a breakpoint) from the |
| 1837 // embedder. We don't know what kind of thread we are on -- it | 1901 // embedder. We don't know what kind of thread we are on -- it |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2146 serialized_message_, serialized_message_len_); | 2210 serialized_message_, serialized_message_len_); |
| 2147 } | 2211 } |
| 2148 | 2212 |
| 2149 | 2213 |
| 2150 void IsolateSpawnState::Cleanup() { | 2214 void IsolateSpawnState::Cleanup() { |
| 2151 SwitchIsolateScope switch_scope(I); | 2215 SwitchIsolateScope switch_scope(I); |
| 2152 Dart::ShutdownIsolate(); | 2216 Dart::ShutdownIsolate(); |
| 2153 } | 2217 } |
| 2154 | 2218 |
| 2155 } // namespace dart | 2219 } // namespace dart |
| OLD | NEW |