summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsics.cc
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2024-07-26 13:09:10 -0700
committer Hans Boehm <hboehm@google.com> 2024-08-14 20:07:27 +0000
commita5001fed23788c966fd87048d7f17ba8c0b51914 (patch)
treefc0b0e72db8cc316703c80480c8a8163abb80953 /compiler/optimizing/intrinsics.cc
parent3b6024d5db60c891c5ef6dc18cc17f8ece56c796 (diff)
Object.clone() allocates more movable objects
Make Object.clone() allocate an unmovable object only if the original was specifically allocated as nonmovable. Or at least get much closer to that. In the process, we stop allocated nonmovable objects in LargeObjectsSpace, so that we can better identifty them. Objects in image space cannot have been allocated as nonmovable: newNonMovableArray() involves JNI call, and this will cause a transaction failure. This is good, since the act of including the object in an ImageSpace would move it. The ZygoteSpace is allocated by copying objects into nonmoving space. To avoid having clone() treat the whole ZygoteSpace as nonmovable, we explicitly remember the non-class objects that were already there. Currently we use a std::set data structure for this. This seems a bit suboptimal; a sorted array may be an improvement. But empirically the set only contains a dozen or two elements for AOSP. We do implicitly allocate classes using the nonnmoving allocator. But those cannot be cloned. Thus we do not bother tracking them. For Array::CopyOf, we DCHECK that the argument was movable, and fix one of the callers to fail in a more appropriate way if we would otherwise violate that. Prevent jvmti from resizing a nonmovable array. I don't think anything good could have come of that anyway. This should prevent us from creating unrequested nonmovable objects, except as a result of the CC collector using that as a backup when it otherwise runs out of space during copying. Rename IsMovableObject() to somewhat clarify that it queries an implementation property, where IsNonMovable() is a query about intended object semantics, NOT implementation artifacts. Various drive-by documentation fixes for issues I encountered while trying to understand the code. Bug: 355291033 Bug: 354087169 Test: Build and boot AOSP Change-Id: Ia24dd1c2623d3d588c397332f87be45cc0f4bf27
Diffstat (limited to 'compiler/optimizing/intrinsics.cc')
-rw-r--r--compiler/optimizing/intrinsics.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index b87f6f3975..8ae2494357 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -218,7 +218,7 @@ void IntrinsicVisitor::AssertNonMovableStringClass() {
if (kIsDebugBuild) {
ScopedObjectAccess soa(Thread::Current());
ObjPtr<mirror::Class> string_class = GetClassRoot<mirror::String>();
- CHECK(!art::Runtime::Current()->GetHeap()->IsMovableObject(string_class));
+ CHECK(!art::Runtime::Current()->GetHeap()->ObjectMayMove(string_class));
}
}