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

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

Issue 1685963002: Pass field to mutator thread so that it can be marked as boxed and all dependent code deoptimized (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address reviewer's comments Created 4 years, 10 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 #if defined(DEBUG) 757 #if defined(DEBUG)
758 #define REUSABLE_HANDLE_SCOPE_INIT(object) \ 758 #define REUSABLE_HANDLE_SCOPE_INIT(object) \
759 reusable_##object##_handle_scope_active_(false), 759 reusable_##object##_handle_scope_active_(false),
760 #else 760 #else
761 #define REUSABLE_HANDLE_SCOPE_INIT(object) 761 #define REUSABLE_HANDLE_SCOPE_INIT(object)
762 #endif // defined(DEBUG) 762 #endif // defined(DEBUG)
763 763
764 #define REUSABLE_HANDLE_INITIALIZERS(object) \ 764 #define REUSABLE_HANDLE_INITIALIZERS(object) \
765 object##_handle_(NULL), 765 object##_handle_(NULL),
766 766
767 // TODO(srdjan): Some Isolate monitors can be shared. Replace their usage with
768 // that shared monitor.
767 Isolate::Isolate(const Dart_IsolateFlags& api_flags) 769 Isolate::Isolate(const Dart_IsolateFlags& api_flags)
768 : stack_limit_(0), 770 : stack_limit_(0),
769 store_buffer_(new StoreBuffer()), 771 store_buffer_(new StoreBuffer()),
770 heap_(NULL), 772 heap_(NULL),
771 user_tag_(0), 773 user_tag_(0),
772 current_tag_(UserTag::null()), 774 current_tag_(UserTag::null()),
773 default_tag_(UserTag::null()), 775 default_tag_(UserTag::null()),
774 class_table_(), 776 class_table_(),
775 single_step_(false), 777 single_step_(false),
776 thread_registry_(new ThreadRegistry()), 778 thread_registry_(new ThreadRegistry()),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 pending_service_extension_calls_(GrowableObjectArray::null()), 826 pending_service_extension_calls_(GrowableObjectArray::null()),
825 registered_service_extension_handlers_(GrowableObjectArray::null()), 827 registered_service_extension_handlers_(GrowableObjectArray::null()),
826 metrics_list_head_(NULL), 828 metrics_list_head_(NULL),
827 compilation_allowed_(true), 829 compilation_allowed_(true),
828 all_classes_finalized_(false), 830 all_classes_finalized_(false),
829 next_(NULL), 831 next_(NULL),
830 pause_loop_monitor_(NULL), 832 pause_loop_monitor_(NULL),
831 cha_invalidation_gen_(kInvalidGen), 833 cha_invalidation_gen_(kInvalidGen),
832 field_invalidation_gen_(kInvalidGen), 834 field_invalidation_gen_(kInvalidGen),
833 prefix_invalidation_gen_(kInvalidGen), 835 prefix_invalidation_gen_(kInvalidGen),
836 boxed_field_list_monitor_(new Monitor()),
837 boxed_field_list_(GrowableObjectArray::null()),
834 spawn_count_monitor_(new Monitor()), 838 spawn_count_monitor_(new Monitor()),
835 spawn_count_(0) { 839 spawn_count_(0) {
836 flags_.CopyFrom(api_flags); 840 flags_.CopyFrom(api_flags);
837 // TODO(asiva): A Thread is not available here, need to figure out 841 // 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 842 // how the vm_tag (kEmbedderTagId) can be set, these tags need to
839 // move to the OSThread structure. 843 // move to the OSThread structure.
840 set_user_tag(UserTags::kDefaultUserTag); 844 set_user_tag(UserTags::kDefaultUserTag);
841 } 845 }
842 846
843 #undef REUSABLE_HANDLE_SCOPE_INIT 847 #undef REUSABLE_HANDLE_SCOPE_INIT
(...skipping 17 matching lines...) Expand all
861 delete message_handler_; 865 delete message_handler_;
862 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. 866 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. 867 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted.
864 delete spawn_state_; 868 delete spawn_state_;
865 if (FLAG_support_service) { 869 if (FLAG_support_service) {
866 delete object_id_ring_; 870 delete object_id_ring_;
867 } 871 }
868 object_id_ring_ = NULL; 872 object_id_ring_ = NULL;
869 delete pause_loop_monitor_; 873 delete pause_loop_monitor_;
870 pause_loop_monitor_ = NULL; 874 pause_loop_monitor_ = NULL;
875 delete boxed_field_list_monitor_;
876 boxed_field_list_monitor_ = NULL;
871 ASSERT(spawn_count_ == 0); 877 ASSERT(spawn_count_ == 0);
872 delete spawn_count_monitor_; 878 delete spawn_count_monitor_;
873 if (compiler_stats_ != NULL) { 879 if (compiler_stats_ != NULL) {
874 delete compiler_stats_; 880 delete compiler_stats_;
875 compiler_stats_ = NULL; 881 compiler_stats_ = NULL;
876 } 882 }
877 delete safepoint_handler_; 883 delete safepoint_handler_;
878 delete thread_registry_; 884 delete thread_registry_;
879 } 885 }
880 886
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); 1845 reinterpret_cast<RawObject**>(&deoptimized_code_array_));
1840 1846
1841 // Visit the pending service extension calls. 1847 // Visit the pending service extension calls.
1842 visitor->VisitPointer( 1848 visitor->VisitPointer(
1843 reinterpret_cast<RawObject**>(&pending_service_extension_calls_)); 1849 reinterpret_cast<RawObject**>(&pending_service_extension_calls_));
1844 1850
1845 // Visit the registered service extension handlers. 1851 // Visit the registered service extension handlers.
1846 visitor->VisitPointer( 1852 visitor->VisitPointer(
1847 reinterpret_cast<RawObject**>(&registered_service_extension_handlers_)); 1853 reinterpret_cast<RawObject**>(&registered_service_extension_handlers_));
1848 1854
1855 // Visit the boxed_field_list.
1856 // 'boxed_field_list_' access via mutator and background compilation threads
1857 // is guarded with a monitor. This means that we can visit it only
1858 // when at safepoint or the boxed_field_list_monitor_ lock has been taken.
1859 visitor->VisitPointer(reinterpret_cast<RawObject**>(&boxed_field_list_));
1860
1849 // Visit objects in the debugger. 1861 // Visit objects in the debugger.
1850 if (FLAG_support_debugger) { 1862 if (FLAG_support_debugger) {
1851 debugger()->VisitObjectPointers(visitor); 1863 debugger()->VisitObjectPointers(visitor);
1852 } 1864 }
1853 1865
1854 // Visit objects that are being used for deoptimization. 1866 // Visit objects that are being used for deoptimization.
1855 if (deopt_context() != NULL) { 1867 if (deopt_context() != NULL) {
1856 deopt_context()->VisitObjectPointers(visitor); 1868 deopt_context()->VisitObjectPointers(visitor);
1857 } 1869 }
1858 1870
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 pending_service_extension_calls_ = value.raw(); 2055 pending_service_extension_calls_ = value.raw();
2044 } 2056 }
2045 2057
2046 2058
2047 void Isolate::set_registered_service_extension_handlers( 2059 void Isolate::set_registered_service_extension_handlers(
2048 const GrowableObjectArray& value) { 2060 const GrowableObjectArray& value) {
2049 registered_service_extension_handlers_ = value.raw(); 2061 registered_service_extension_handlers_ = value.raw();
2050 } 2062 }
2051 2063
2052 2064
2065 void Isolate::AddDeoptimizingBoxedField(const Field& field) {
2066 MonitorLocker ml(boxed_field_list_monitor_);
2067 if (boxed_field_list_ == GrowableObjectArray::null()) {
2068 boxed_field_list_ = GrowableObjectArray::New(Heap::kOld);
2069 }
2070 const GrowableObjectArray& array =
2071 GrowableObjectArray::Handle(boxed_field_list_);
2072 array.Add(field, Heap::kOld);
2073 }
2074
2075
2076 RawField* Isolate::GetDeoptimizingBoxedField() {
2077 MonitorLocker ml(boxed_field_list_monitor_);
2078 if (boxed_field_list_ == GrowableObjectArray::null()) {
2079 return Field::null();
2080 }
2081 const GrowableObjectArray& array =
2082 GrowableObjectArray::Handle(boxed_field_list_);
2083 if (array.Length() == 0) {
2084 return Field::null();
2085 }
2086 return Field::RawCast(array.RemoveLast());
2087 }
2088
2089
2053 RawObject* Isolate::InvokePendingServiceExtensionCalls() { 2090 RawObject* Isolate::InvokePendingServiceExtensionCalls() {
2054 if (!FLAG_support_service) { 2091 if (!FLAG_support_service) {
2055 return Object::null(); 2092 return Object::null();
2056 } 2093 }
2057 GrowableObjectArray& calls = 2094 GrowableObjectArray& calls =
2058 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls()); 2095 GrowableObjectArray::Handle(GetAndClearPendingServiceExtensionCalls());
2059 if (calls.IsNull()) { 2096 if (calls.IsNull()) {
2060 return Object::null(); 2097 return Object::null();
2061 } 2098 }
2062 // Grab run function. 2099 // Grab run function.
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 void IsolateSpawnState::DecrementSpawnCount() { 2775 void IsolateSpawnState::DecrementSpawnCount() {
2739 ASSERT(spawn_count_monitor_ != NULL); 2776 ASSERT(spawn_count_monitor_ != NULL);
2740 ASSERT(spawn_count_ != NULL); 2777 ASSERT(spawn_count_ != NULL);
2741 MonitorLocker ml(spawn_count_monitor_); 2778 MonitorLocker ml(spawn_count_monitor_);
2742 ASSERT(*spawn_count_ > 0); 2779 ASSERT(*spawn_count_ > 0);
2743 *spawn_count_ = *spawn_count_ - 1; 2780 *spawn_count_ = *spawn_count_ - 1;
2744 ml.Notify(); 2781 ml.Notify();
2745 } 2782 }
2746 2783
2747 } // namespace dart 2784 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698