From 87a4f54b9182a53834e1412eccec089fb11aad38 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 29 Jun 2021 23:13:29 +0000 Subject: [PATCH] [vm/concurrency] Use relaxed load/store to update Field::static_type_exactness. Use of relaxed atomic updates is fine because changes in field's type_exactness state should not update compilation result. Fixes https://github.com/dart-lang/sdk/issues/46492. TEST=IsolateSpawn on tsan Change-Id: Icfda1c788d931f594b32b78d690e26b6a7df9f35 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205246 Commit-Queue: Alexander Aprelev Reviewed-by: Martin Kustermann --- runtime/vm/clustered_snapshot.cc | 2 +- runtime/vm/object.cc | 2 +- runtime/vm/object.h | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index a67ace8dee9..42df2954a5e 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -1437,7 +1437,7 @@ class FieldDeserializationCluster : public DeserializationCluster { field.set_guarded_list_length_unsafe(Field::kNoFixedLength); field.set_guarded_list_length_in_object_offset_unsafe( Field::kUnknownLengthOffset); - field.set_static_type_exactness_state( + field.set_static_type_exactness_state_unsafe( StaticTypeExactnessState::NotTracking()); } } else { diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index ea59e19cac1..99c29570f42 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -10635,7 +10635,7 @@ void Field::InitializeNew(const Field& result, result.set_initializer_changed_after_initialization(false); NOT_IN_PRECOMPILED(result.set_kernel_offset(0)); result.set_has_pragma(false); - result.set_static_type_exactness_state( + result.set_static_type_exactness_state_unsafe( StaticTypeExactnessState::NotTracking()); auto isolate_group = IsolateGroup::Current(); diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 786fcb643a7..f2e14f43322 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -4145,11 +4145,20 @@ class Field : public Object { StaticTypeExactnessState static_type_exactness_state() const { return StaticTypeExactnessState::Decode( - untag()->static_type_exactness_state_); + LoadNonPointer( + &untag()->static_type_exactness_state_)); } void set_static_type_exactness_state(StaticTypeExactnessState state) const { - StoreNonPointer(&untag()->static_type_exactness_state_, state.Encode()); + DEBUG_ASSERT( + IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter()); + set_static_type_exactness_state_unsafe(state); + } + + void set_static_type_exactness_state_unsafe( + StaticTypeExactnessState state) const { + StoreNonPointer( + &untag()->static_type_exactness_state_, state.Encode()); } static intptr_t static_type_exactness_state_offset() {