@@ -1115,10 +1115,10 @@ void Object::Init(Isolate* isolate) {
11151115 // in the vm isolate. See special handling in Class::SuperClass().
11161116 cls = type_arguments_class_;
11171117 cls.set_interfaces(Object::empty_array());
1118- cls.SetFields(Object::empty_array());
11191118 {
11201119 Thread* thread = Thread::Current();
11211120 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
1121+ cls.SetFields(Object::empty_array());
11221122 cls.SetFunctions(Object::empty_array());
11231123 }
11241124
@@ -4354,6 +4354,9 @@ ErrorPtr Class::EnsureIsAllocateFinalized(Thread* thread) const {
43544354void Class::SetFields(const Array& value) const {
43554355 ASSERT(!value.IsNull());
43564356#if defined(DEBUG)
4357+ Thread* thread = Thread::Current();
4358+ ASSERT(thread->IsMutatorThread());
4359+ ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
43574360 // Verify that all the fields in the array have this class as owner.
43584361 Field& field = Field::Handle();
43594362 intptr_t len = value.Length();
@@ -4368,13 +4371,23 @@ void Class::SetFields(const Array& value) const {
43684371}
43694372
43704373void Class::AddField(const Field& field) const {
4374+ #if defined(DEBUG)
4375+ Thread* thread = Thread::Current();
4376+ ASSERT(thread->IsMutatorThread());
4377+ ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
4378+ #endif
43714379 const Array& arr = Array::Handle(fields());
43724380 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1));
43734381 new_arr.SetAt(arr.Length(), field);
43744382 SetFields(new_arr);
43754383}
43764384
43774385void Class::AddFields(const GrowableArray<const Field*>& new_fields) const {
4386+ #if defined(DEBUG)
4387+ Thread* thread = Thread::Current();
4388+ ASSERT(thread->IsMutatorThread());
4389+ ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
4390+ #endif
43784391 const intptr_t num_new_fields = new_fields.length();
43794392 if (num_new_fields == 0) return;
43804393 const Array& arr = Array::Handle(fields());
0 commit comments