summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2025-02-17 11:35:49 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2025-02-18 08:56:17 -0800
commit9a4f8f8fe5133f7c3b17d2ad9d502f64b40f6033 (patch)
tree7147c14ab2d796dd25716c04a417ee0dfb8eabcb
parent17c7ed2de734cf892b005b1d15b3db9855506f14 (diff)
`AllocArt{Field,Method}Array()` requires mutator lock.
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: If11ba77ddcbab62442d18067f4fc9df910f86bb0
-rw-r--r--runtime/class_linker.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 0fc18335da..406172ca5d 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -540,13 +540,19 @@ class ClassLinker {
REQUIRES(!Locks::dex_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
+ // Allocating `ArtField` and `ArtMethod` arrays can lead to adding new arenas to
+ // the `LinearAlloc` but the CMC GC's `CompactionPause()` does not expect new
+ // arenas being concurrently added. Therefore we require these allocations to be
+ // done with the mutator lock held shared as this prevents concurrent execution
+ // with the `CompactionPause()` where we hold the mutator lock exclusively.
LengthPrefixedArray<ArtField>* AllocArtFieldArray(Thread* self,
LinearAlloc* allocator,
- size_t length);
-
+ size_t length)
+ REQUIRES_SHARED(Locks::mutator_lock_);
LengthPrefixedArray<ArtMethod>* AllocArtMethodArray(Thread* self,
LinearAlloc* allocator,
- size_t length);
+ size_t length)
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Convenience AllocClass() overload that uses mirror::Class::InitializeClassVisitor
// for the class initialization and uses the `java_lang_Class` from class roots