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 "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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 pending_service_extension_calls_(GrowableObjectArray::null()), | 824 pending_service_extension_calls_(GrowableObjectArray::null()), |
| 825 registered_service_extension_handlers_(GrowableObjectArray::null()), | 825 registered_service_extension_handlers_(GrowableObjectArray::null()), |
| 826 metrics_list_head_(NULL), | 826 metrics_list_head_(NULL), |
| 827 compilation_allowed_(true), | 827 compilation_allowed_(true), |
| 828 all_classes_finalized_(false), | 828 all_classes_finalized_(false), |
| 829 next_(NULL), | 829 next_(NULL), |
| 830 pause_loop_monitor_(NULL), | 830 pause_loop_monitor_(NULL), |
| 831 cha_invalidation_gen_(kInvalidGen), | 831 cha_invalidation_gen_(kInvalidGen), |
| 832 field_invalidation_gen_(kInvalidGen), | 832 field_invalidation_gen_(kInvalidGen), |
| 833 prefix_invalidation_gen_(kInvalidGen), | 833 prefix_invalidation_gen_(kInvalidGen), |
| 834 boxed_field_list_monitor_(new Monitor()), | |
| 835 boxed_field_list_(GrowableObjectArray::null()), | |
| 834 spawn_count_monitor_(new Monitor()), | 836 spawn_count_monitor_(new Monitor()), |
| 835 spawn_count_(0) { | 837 spawn_count_(0) { |
| 836 flags_.CopyFrom(api_flags); | 838 flags_.CopyFrom(api_flags); |
| 837 // TODO(asiva): A Thread is not available here, need to figure out | 839 // TODO(asiva): A Thread is not available here, need to figure out |
| 838 // how the vm_tag (kEmbedderTagId) can be set, these tags need to | 840 // how the vm_tag (kEmbedderTagId) can be set, these tags need to |
| 839 // move to the OSThread structure. | 841 // move to the OSThread structure. |
| 840 set_user_tag(UserTags::kDefaultUserTag); | 842 set_user_tag(UserTags::kDefaultUserTag); |
| 841 } | 843 } |
| 842 | 844 |
| 843 #undef REUSABLE_HANDLE_SCOPE_INIT | 845 #undef REUSABLE_HANDLE_SCOPE_INIT |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 861 delete message_handler_; | 863 delete message_handler_; |
| 862 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. | 864 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
| 863 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. | 865 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. |
| 864 delete spawn_state_; | 866 delete spawn_state_; |
| 865 if (FLAG_support_service) { | 867 if (FLAG_support_service) { |
| 866 delete object_id_ring_; | 868 delete object_id_ring_; |
| 867 } | 869 } |
| 868 object_id_ring_ = NULL; | 870 object_id_ring_ = NULL; |
| 869 delete pause_loop_monitor_; | 871 delete pause_loop_monitor_; |
| 870 pause_loop_monitor_ = NULL; | 872 pause_loop_monitor_ = NULL; |
| 873 delete boxed_field_list_monitor_; | |
| 874 boxed_field_list_monitor_ = NULL; | |
| 871 ASSERT(spawn_count_ == 0); | 875 ASSERT(spawn_count_ == 0); |
| 872 delete spawn_count_monitor_; | 876 delete spawn_count_monitor_; |
|
siva
2016/02/10 17:57:35
We seem to have added a number of monitors to the
srdjan
2016/02/10 19:18:51
Added a TODO at Isolate constructor:
TODO(srdjan)
| |
| 873 if (compiler_stats_ != NULL) { | 877 if (compiler_stats_ != NULL) { |
| 874 delete compiler_stats_; | 878 delete compiler_stats_; |
| 875 compiler_stats_ = NULL; | 879 compiler_stats_ = NULL; |
| 876 } | 880 } |
| 877 delete safepoint_handler_; | 881 delete safepoint_handler_; |
| 878 delete thread_registry_; | 882 delete thread_registry_; |
| 879 } | 883 } |
| 880 | 884 |
| 881 | 885 |
| 882 void Isolate::InitOnce() { | 886 void Isolate::InitOnce() { |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); | 1843 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); |
| 1840 | 1844 |
| 1841 // Visit the pending service extension calls. | 1845 // Visit the pending service extension calls. |
| 1842 visitor->VisitPointer( | 1846 visitor->VisitPointer( |
| 1843 reinterpret_cast<RawObject**>(&pending_service_extension_calls_)); | 1847 reinterpret_cast<RawObject**>(&pending_service_extension_calls_)); |
| 1844 | 1848 |
| 1845 // Visit the registered service extension handlers. | 1849 // Visit the registered service extension handlers. |
| 1846 visitor->VisitPointer( | 1850 visitor->VisitPointer( |
| 1847 reinterpret_cast<RawObject**>(®istered_service_extension_handlers_)); | 1851 reinterpret_cast<RawObject**>(®istered_service_extension_handlers_)); |
| 1848 | 1852 |
| 1853 // Visit the boxed_field_list. | |
| 1854 visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_)); | |
|
siva
2016/02/10 17:57:35
This will work only if the visitor is at a safepoi
srdjan
2016/02/10 19:18:51
// 'boxed_field_list_' access via mutator and back
| |
| 1855 | |
| 1849 // Visit objects in the debugger. | 1856 // Visit objects in the debugger. |
| 1850 if (FLAG_support_debugger) { | 1857 if (FLAG_support_debugger) { |
| 1851 debugger()->VisitObjectPointers(visitor); | 1858 debugger()->VisitObjectPointers(visitor); |
| 1852 } | 1859 } |
| 1853 | 1860 |
| 1854 // Visit objects that are being used for deoptimization. | 1861 // Visit objects that are being used for deoptimization. |
| 1855 if (deopt_context() != NULL) { | 1862 if (deopt_context() != NULL) { |
| 1856 deopt_context()->VisitObjectPointers(visitor); | 1863 deopt_context()->VisitObjectPointers(visitor); |
| 1857 } | 1864 } |
| 1858 | 1865 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2043 pending_service_extension_calls_ = value.raw(); | 2050 pending_service_extension_calls_ = value.raw(); |
| 2044 } | 2051 } |
| 2045 | 2052 |
| 2046 | 2053 |
| 2047 void Isolate::set_registered_service_extension_handlers( | 2054 void Isolate::set_registered_service_extension_handlers( |
| 2048 const GrowableObjectArray& value) { | 2055 const GrowableObjectArray& value) { |
| 2049 registered_service_extension_handlers_ = value.raw(); | 2056 registered_service_extension_handlers_ = value.raw(); |
| 2050 } | 2057 } |
| 2051 | 2058 |
| 2052 | 2059 |
| 2060 void Isolate::AddDeoptimizingBoxedField(const Field& field) { | |
| 2061 MonitorLocker ml(boxed_field_list_monitor_); | |
| 2062 if (boxed_field_list_ == GrowableObjectArray::null()) { | |
| 2063 boxed_field_list_ = GrowableObjectArray::New(Heap::kOld); | |
| 2064 } | |
| 2065 const GrowableObjectArray& array = | |
| 2066 GrowableObjectArray::Handle(boxed_field_list_); | |
| 2067 array.Add(field, Heap::kOld); | |
| 2068 } | |
| 2069 | |
| 2070 | |
| 2071 RawField* Isolate::GetDeoptimizingBoxedField() { | |
| 2072 MonitorLocker ml(boxed_field_list_monitor_); | |
| 2073 if (boxed_field_list_ == GrowableObjectArray::null()) { | |
| 2074 return Field::null(); | |
| 2075 } | |
| 2076 const GrowableObjectArray& array = | |
| 2077 GrowableObjectArray::Handle(boxed_field_list_); | |
| 2078 if (array.Length() == 0) { | |
| 2079 return Field::null(); | |
| 2080 } | |
| 2081 return Field::RawCast(array.RemoveLast()); | |
| 2082 } | |
| 2083 | |
| 2084 | |
| 2053 RawObject* Isolate::InvokePendingServiceExtensionCalls() { | 2085 RawObject* Isolate::InvokePendingServiceExtensionCalls() { |
| 2054 if (!FLAG_support_service) { | 2086 if (!FLAG_support_service) { |
| 2055 return Object::null(); | 2087 return Object::null(); |
| 2056 } | 2088 } |
| 2057 GrowableObjectArray& calls = | 2089 GrowableObjectArray& calls = |
| 2058 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls()); | 2090 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls()); |
| 2059 if (calls.IsNull()) { | 2091 if (calls.IsNull()) { |
| 2060 return Object::null(); | 2092 return Object::null(); |
| 2061 } | 2093 } |
| 2062 // Grab run function. | 2094 // Grab run function. |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2738 void IsolateSpawnState::DecrementSpawnCount() { | 2770 void IsolateSpawnState::DecrementSpawnCount() { |
| 2739 ASSERT(spawn_count_monitor_ != NULL); | 2771 ASSERT(spawn_count_monitor_ != NULL); |
| 2740 ASSERT(spawn_count_ != NULL); | 2772 ASSERT(spawn_count_ != NULL); |
| 2741 MonitorLocker ml(spawn_count_monitor_); | 2773 MonitorLocker ml(spawn_count_monitor_); |
| 2742 ASSERT(*spawn_count_ > 0); | 2774 ASSERT(*spawn_count_ > 0); |
| 2743 *spawn_count_ = *spawn_count_ - 1; | 2775 *spawn_count_ = *spawn_count_ - 1; |
| 2744 ml.Notify(); | 2776 ml.Notify(); |
| 2745 } | 2777 } |
| 2746 | 2778 |
| 2747 } // namespace dart | 2779 } // namespace dart |
| OLD | NEW |