summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2023-11-20 11:00:15 +0100
committer VladimĂ­r Marko <vmarko@google.com> 2023-11-20 12:04:25 +0000
commitd840ff0ff0fc409c3d2fef2a4d516551ed4c322b (patch)
treefa369a2a00821ecd19fc350291bcec99b646c3ea /compiler/optimizing
parent4f2fcccce50f229cb2b00cc07c040473a59c120b (diff)
Clean up after putting boxed caches to boot image.
Clean up after https://android-review.googlesource.com/2824676 . Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ic5ae98148499b8195669c7c81e7bffef9c8c9aa2
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/intrinsic_objects.cc20
-rw-r--r--compiler/optimizing/intrinsic_objects.h6
-rw-r--r--compiler/optimizing/intrinsics.cc8
3 files changed, 19 insertions, 15 deletions
diff --git a/compiler/optimizing/intrinsic_objects.cc b/compiler/optimizing/intrinsic_objects.cc
index 7c430acbe4..cf49f50d91 100644
--- a/compiler/optimizing/intrinsic_objects.cc
+++ b/compiler/optimizing/intrinsic_objects.cc
@@ -30,30 +30,33 @@ static constexpr size_t kIntrinsicObjectsOffset =
enum_cast<size_t>(ImageHeader::kIntrinsicObjectsStart);
template <typename T>
-static void FillIntrinsicsObjects(
+static int32_t FillIntrinsicsObjects(
ArtField* cache_field,
ObjPtr<mirror::ObjectArray<mirror::Object>> live_objects,
int32_t expected_low,
int32_t expected_high,
T type_check,
- size_t& index)
+ int32_t index)
REQUIRES_SHARED(Locks::mutator_lock_) {
ObjPtr<mirror::ObjectArray<mirror::Object>> cache =
ObjPtr<mirror::ObjectArray<mirror::Object>>::DownCast(
cache_field->GetObject(cache_field->GetDeclaringClass()));
- DCHECK_EQ(expected_high - expected_low + 1, cache->GetLength());
- for (int32_t i = 0, length = cache->GetLength(); i != length; ++i) {
- live_objects->Set(index++, cache->Get(i));
- type_check(cache->Get(i), expected_low++);
+ int32_t length = expected_high - expected_low + 1;
+ DCHECK_EQ(length, cache->GetLength());
+ for (int32_t i = 0; i != length; ++i) {
+ ObjPtr<mirror::Object> value = cache->GetWithoutChecks(i);
+ live_objects->Set(index + i, value);
+ type_check(value, expected_low + i);
}
+ return index + length;
}
void IntrinsicObjects::FillIntrinsicObjects(
ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects, size_t start_index) {
DCHECK_EQ(start_index, ImageHeader::kIntrinsicObjectsStart);
- size_t index = start_index;
+ int32_t index = dchecked_integral_cast<int32_t>(start_index);
#define FILL_OBJECTS(name, low, high, type, offset) \
- FillIntrinsicsObjects( \
+ index = FillIntrinsicsObjects( \
WellKnownClasses::java_lang_ ##name ##_ ##name ##Cache_cache, \
boot_image_live_objects, \
low, \
@@ -64,6 +67,7 @@ void IntrinsicObjects::FillIntrinsicObjects(
index);
BOXED_TYPES(FILL_OBJECTS)
#undef FILL_OBJECTS
+ DCHECK_EQ(dchecked_integral_cast<size_t>(index), start_index + GetNumberOfIntrinsicObjects());
}
static bool HasIntrinsicObjects(
diff --git a/compiler/optimizing/intrinsic_objects.h b/compiler/optimizing/intrinsic_objects.h
index 61f4825224..c9ae449467 100644
--- a/compiler/optimizing/intrinsic_objects.h
+++ b/compiler/optimizing/intrinsic_objects.h
@@ -41,7 +41,7 @@ template <class T> class ObjectArray;
V(Character, 0, 127, DataType::Type::kUint16, kShortCacheLastIndex) \
V(Integer, -128, 127, DataType::Type::kInt32, kCharacterCacheLastIndex)
-#define DEFINE_BOXED_CONSTANTS(name, low, high, primitive_type, start_index) \
+#define DEFINE_BOXED_CONSTANTS(name, low, high, unused, start_index) \
static constexpr size_t k ##name ##CacheLastIndex = start_index + (high - low + 1); \
static constexpr size_t k ##name ##CacheFirstIndex = start_index;
BOXED_TYPES(DEFINE_BOXED_CONSTANTS)
@@ -72,7 +72,7 @@ class IntrinsicObjects {
}
// Helpers returning addresses of objects, suitable for embedding in generated code.
-#define DEFINE_BOXED_ACCESSES(name, _, __, ___, start_index) \
+#define DEFINE_BOXED_ACCESSES(name, unused1, unused2, unused3, start_index) \
static ObjPtr<mirror::Object> Get ##name ##ValueOfObject( \
ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects, \
uint32_t index) REQUIRES_SHARED(Locks::mutator_lock_) { \
@@ -90,7 +90,7 @@ class IntrinsicObjects {
ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects, size_t start_index)
REQUIRES_SHARED(Locks::mutator_lock_);
- static size_t GetNumberOfIntrinsicObjects() {
+ static constexpr size_t GetNumberOfIntrinsicObjects() {
return kNumberOfBoxedCaches;
}
diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc
index e443a51889..d9623c0abb 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -124,21 +124,21 @@ static bool CheckIntegerCache(ObjPtr<mirror::ObjectArray<mirror::Object>> boot_i
ObjPtr<mirror::Class> integer_class = WellKnownClasses::java_lang_Integer.Get();
DCHECK(integer_class->IsInitialized());
- ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_cache = GetIntegerCacheArray(cache_class);
- if (!IntrinsicVisitor::CheckIntegerCacheFields(boot_image_cache)) {
+ ObjPtr<mirror::ObjectArray<mirror::Object>> current_cache = GetIntegerCacheArray(cache_class);
+ if (!IntrinsicVisitor::CheckIntegerCacheFields(current_cache)) {
return false;
}
// Check that the elements match the boot image intrinsic objects and check their values as well.
ArtField* value_field = integer_class->FindDeclaredInstanceField(kValueFieldName, "I");
DCHECK(value_field != nullptr);
- for (int32_t i = 0, len = boot_image_cache->GetLength(); i != len; ++i) {
+ for (int32_t i = 0, len = current_cache->GetLength(); i != len; ++i) {
ObjPtr<mirror::Object> boot_image_object =
IntrinsicObjects::GetIntegerValueOfObject(boot_image_live_objects, i);
DCHECK(Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(boot_image_object));
// No need for read barrier for comparison with a boot image object.
ObjPtr<mirror::Object> current_object =
- boot_image_cache->GetWithoutChecks<kVerifyNone, kWithoutReadBarrier>(i);
+ current_cache->GetWithoutChecks<kVerifyNone, kWithoutReadBarrier>(i);
if (boot_image_object != current_object) {
return false; // Messed up IntegerCache.cache[i]
}