Style cleanup for ObjPtr<>-ify changes.
Replace "ObjPtr<.> const" with "const ObjPtr<.>".
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I5a1c080bc88b091e15ee9eb0bb1ef6f6f290701c
diff --git a/dex2oat/linker/image_writer.cc b/dex2oat/linker/image_writer.cc
index d154569..e878678 100644
--- a/dex2oat/linker/image_writer.cc
+++ b/dex2oat/linker/image_writer.cc
@@ -1831,7 +1831,7 @@
mirror::String* ImageWriter::FindInternedString(mirror::String* string) {
Thread* const self = Thread::Current();
for (const ImageInfo& image_info : image_infos_) {
- ObjPtr<mirror::String> const found = image_info.intern_table_->LookupStrong(self, string);
+ const ObjPtr<mirror::String> found = image_info.intern_table_->LookupStrong(self, string);
DCHECK(image_info.intern_table_->LookupWeak(self, string) == nullptr)
<< string->ToModifiedUtf8();
if (found != nullptr) {
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 97234af..dde4f36 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2353,7 +2353,7 @@
return (*visitor_)(klass);
}
- ObjPtr<mirror::ClassLoader> const defining_class_loader_;
+ const ObjPtr<mirror::ClassLoader> defining_class_loader_;
ClassVisitor* const visitor_;
};
@@ -4241,7 +4241,7 @@
}
{
WriterMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_);
- ObjPtr<mirror::ClassLoader> const class_loader = klass->GetClassLoader();
+ const ObjPtr<mirror::ClassLoader> class_loader = klass->GetClassLoader();
ClassTable* const class_table = InsertClassTableForClassLoader(class_loader);
ObjPtr<mirror::Class> existing = class_table->Lookup(descriptor, hash);
if (existing != nullptr) {
@@ -5851,10 +5851,10 @@
{
WriterMutexLock mu(self, *Locks::classlinker_classes_lock_);
- ObjPtr<mirror::ClassLoader> const class_loader = h_new_class.Get()->GetClassLoader();
+ const ObjPtr<mirror::ClassLoader> class_loader = h_new_class.Get()->GetClassLoader();
ClassTable* const table = InsertClassTableForClassLoader(class_loader);
- ObjPtr<mirror::Class> existing = table->UpdateClass(descriptor, h_new_class.Get(),
- ComputeModifiedUtf8Hash(descriptor));
+ const ObjPtr<mirror::Class> existing =
+ table->UpdateClass(descriptor, h_new_class.Get(), ComputeModifiedUtf8Hash(descriptor));
if (class_loader != nullptr) {
// We updated the class in the class table, perform the write barrier so that the GC knows
// about the change.
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc
index e811afd..e890c1f 100644
--- a/runtime/class_loader_context.cc
+++ b/runtime/class_loader_context.cc
@@ -956,9 +956,9 @@
jni::DecodeArtField(WellKnownClasses::dalvik_system_DexFile_cookie);
ArtField* const dex_file_field =
jni::DecodeArtField(WellKnownClasses::dalvik_system_DexPathList__Element_dexFile);
- ObjPtr<mirror::Class> const element_class = soa.Decode<mirror::Class>(
+ const ObjPtr<mirror::Class> element_class = soa.Decode<mirror::Class>(
WellKnownClasses::dalvik_system_DexPathList__Element);
- ObjPtr<mirror::Class> const dexfile_class = soa.Decode<mirror::Class>(
+ const ObjPtr<mirror::Class> dexfile_class = soa.Decode<mirror::Class>(
WellKnownClasses::dalvik_system_DexFile);
for (int32_t i = 0; i < dex_elements->GetLength(); ++i) {
diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h
index a2cdb2c..5f8a0b0 100644
--- a/runtime/class_table-inl.h
+++ b/runtime/class_table-inl.h
@@ -91,8 +91,8 @@
template<ReadBarrierOption kReadBarrierOption>
inline mirror::Class* ClassTable::TableSlot::Read() const {
const uint32_t before = data_.load(std::memory_order_relaxed);
- ObjPtr<mirror::Class> const before_ptr(ExtractPtr(before));
- ObjPtr<mirror::Class> const after_ptr(
+ const ObjPtr<mirror::Class> before_ptr(ExtractPtr(before));
+ const ObjPtr<mirror::Class> after_ptr(
GcRoot<mirror::Class>(before_ptr).Read<kReadBarrierOption>());
if (kReadBarrierOption != kWithoutReadBarrier && before_ptr != after_ptr) {
// If another thread raced and updated the reference, do not store the read barrier updated
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc
index 5483364..9b67030 100644
--- a/runtime/gc/collector/concurrent_copying.cc
+++ b/runtime/gc/collector/concurrent_copying.cc
@@ -705,7 +705,7 @@
private:
ConcurrentCopying* const cc_;
- ObjPtr<mirror::Object> const holder_;
+ const ObjPtr<mirror::Object> holder_;
};
void ConcurrentCopying::VerifyNoMissingCardMarks() {
diff --git a/runtime/gc/reference_processor.cc b/runtime/gc/reference_processor.cc
index 4944639..b0fc7a6 100644
--- a/runtime/gc/reference_processor.cc
+++ b/runtime/gc/reference_processor.cc
@@ -91,7 +91,7 @@
// Under read barrier / concurrent copying collector, it's not safe to call GetReferent() when
// weak ref access is disabled as the call includes a read barrier which may push a ref onto the
// mark stack and interfere with termination of marking.
- ObjPtr<mirror::Object> const referent = reference->GetReferent();
+ const ObjPtr<mirror::Object> referent = reference->GetReferent();
// If the referent is null then it is already cleared, we can just return null since there is no
// scenario where it becomes non-null during the reference processing phase.
if (UNLIKELY(!SlowPathEnabled()) || referent == nullptr) {
diff --git a/runtime/gc/reference_queue.cc b/runtime/gc/reference_queue.cc
index 95871da..1c751e1 100644
--- a/runtime/gc/reference_queue.cc
+++ b/runtime/gc/reference_queue.cc
@@ -181,7 +181,7 @@
if (UNLIKELY(IsEmpty())) {
return;
}
- ObjPtr<mirror::Reference> const head = list_;
+ const ObjPtr<mirror::Reference> head = list_;
ObjPtr<mirror::Reference> ref = head;
do {
mirror::HeapReference<mirror::Object>* referent_addr = ref->GetReferentReferenceAddr();
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 46108cf..8b8567e 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -1403,13 +1403,13 @@
// This allows statically initializing ConcurrentHashMap and SynchronousQueue.
void UnstartedRuntime::UnstartedReferenceGetReferent(
Thread* self, ShadowFrame* shadow_frame, JValue* result, size_t arg_offset) {
- ObjPtr<mirror::Reference> const ref = down_cast<mirror::Reference*>(
+ const ObjPtr<mirror::Reference> ref = down_cast<mirror::Reference*>(
shadow_frame->GetVRegReference(arg_offset));
if (ref == nullptr) {
AbortTransactionOrFail(self, "Reference.getReferent() with null object");
return;
}
- ObjPtr<mirror::Object> const referent =
+ const ObjPtr<mirror::Object> referent =
Runtime::Current()->GetHeap()->GetReferenceProcessor()->GetReferent(self, ref);
result->SetL(referent);
}
diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc
index bbd6d68..370a456 100644
--- a/runtime/jni/java_vm_ext.cc
+++ b/runtime/jni/java_vm_ext.cc
@@ -272,7 +272,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
std::string jni_short_name(m->JniShortName());
std::string jni_long_name(m->JniLongName());
- ObjPtr<mirror::ClassLoader> const declaring_class_loader =
+ const ObjPtr<mirror::ClassLoader> declaring_class_loader =
m->GetDeclaringClass()->GetClassLoader();
ScopedObjectAccessUnchecked soa(Thread::Current());
void* const declaring_class_loader_allocator =
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index fe67a5b..cf0fd9a 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -1044,7 +1044,7 @@
inline bool Class::IsObjectArrayClass() {
// We do not need a read barrier here as the primitive type is constant,
// both from-space and to-space component type classes shall yield the same result.
- ObjPtr<Class> const component_type = GetComponentType<kVerifyFlags, kWithoutReadBarrier>();
+ const ObjPtr<Class> component_type = GetComponentType<kVerifyFlags, kWithoutReadBarrier>();
constexpr VerifyObjectFlags kNewFlags = RemoveThisFlags(kVerifyFlags);
return component_type != nullptr && !component_type->IsPrimitive<kNewFlags>();
}
@@ -1053,7 +1053,7 @@
bool Class::IsPrimitiveArray() {
// We do not need a read barrier here as the primitive type is constant,
// both from-space and to-space component type classes shall yield the same result.
- ObjPtr<Class> const component_type = GetComponentType<kVerifyFlags, kWithoutReadBarrier>();
+ const ObjPtr<Class> component_type = GetComponentType<kVerifyFlags, kWithoutReadBarrier>();
constexpr VerifyObjectFlags kNewFlags = RemoveThisFlags(kVerifyFlags);
return component_type != nullptr && component_type->IsPrimitive<kNewFlags>();
}
diff --git a/runtime/mirror/field.cc b/runtime/mirror/field.cc
index e885d41..f4d1e73 100644
--- a/runtime/mirror/field.cc
+++ b/runtime/mirror/field.cc
@@ -37,7 +37,7 @@
return &declaring_class->GetSFieldsPtr()->At(1);
}
}
- ObjPtr<mirror::DexCache> const dex_cache = declaring_class->GetDexCache();
+ const ObjPtr<mirror::DexCache> dex_cache = declaring_class->GetDexCache();
ArtField* art_field = dex_cache->GetResolvedField(GetDexFieldIndex(), kRuntimePointerSize);
if (UNLIKELY(art_field == nullptr)) {
if (IsStatic()) {
diff --git a/runtime/mirror/iftable-inl.h b/runtime/mirror/iftable-inl.h
index b9bd21c..c96082f 100644
--- a/runtime/mirror/iftable-inl.h
+++ b/runtime/mirror/iftable-inl.h
@@ -27,7 +27,7 @@
template<VerifyObjectFlags kVerifyFlags,
ReadBarrierOption kReadBarrierOption>
inline ObjPtr<Class> IfTable::GetInterface(int32_t i) {
- Class* interface =
+ ObjPtr<Class> interface =
GetWithoutChecks<kVerifyFlags, kReadBarrierOption>((i * kMax) + kInterface)->AsClass();
DCHECK(interface != nullptr);
return interface;
@@ -37,7 +37,7 @@
DCHECK(interface != nullptr);
DCHECK(interface->IsInterface());
const size_t idx = i * kMax + kInterface;
- DCHECK_EQ(Get(idx), static_cast<Object*>(nullptr));
+ DCHECK(Get(idx) == nullptr);
SetWithoutChecks<false>(idx, interface);
}
diff --git a/runtime/mirror/method_handles_lookup.cc b/runtime/mirror/method_handles_lookup.cc
index a32fe33..c26948d 100644
--- a/runtime/mirror/method_handles_lookup.cc
+++ b/runtime/mirror/method_handles_lookup.cc
@@ -29,7 +29,8 @@
namespace art {
namespace mirror {
-ObjPtr<MethodHandlesLookup> MethodHandlesLookup::Create(Thread* const self, Handle<Class> lookup_class)
+ObjPtr<MethodHandlesLookup> MethodHandlesLookup::Create(Thread* const self,
+ Handle<Class> lookup_class)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_) {
static constexpr uint32_t kAllModes = kAccPublic | kAccPrivate | kAccProtected | kAccStatic;
diff --git a/runtime/mirror/method_type.cc b/runtime/mirror/method_type.cc
index 005bb71..1d88d85 100644
--- a/runtime/mirror/method_type.cc
+++ b/runtime/mirror/method_type.cc
@@ -95,8 +95,8 @@
return Create(self, dst_rtype, dst_ptypes);
}
-size_t MethodType::NumberOfVRegs() REQUIRES_SHARED(Locks::mutator_lock_) {
- ObjPtr<ObjectArray<Class>> const p_types = GetPTypes();
+size_t MethodType::NumberOfVRegs() {
+ const ObjPtr<ObjectArray<Class>> p_types = GetPTypes();
const int32_t p_types_length = p_types->GetLength();
// Initialize |num_vregs| with number of parameters and only increment it for
@@ -112,10 +112,10 @@
}
bool MethodType::IsExactMatch(ObjPtr<MethodType> target) {
- ObjPtr<ObjectArray<Class>> const p_types = GetPTypes();
+ const ObjPtr<ObjectArray<Class>> p_types = GetPTypes();
const int32_t params_length = p_types->GetLength();
- ObjPtr<ObjectArray<Class>> const target_p_types = target->GetPTypes();
+ const ObjPtr<ObjectArray<Class>> target_p_types = target->GetPTypes();
if (params_length != target_p_types->GetLength()) {
return false;
}
@@ -128,10 +128,10 @@
}
bool MethodType::IsConvertible(ObjPtr<MethodType> target) {
- ObjPtr<ObjectArray<Class>> const p_types = GetPTypes();
+ const ObjPtr<ObjectArray<Class>> p_types = GetPTypes();
const int32_t params_length = p_types->GetLength();
- ObjPtr<ObjectArray<Class>> const target_p_types = target->GetPTypes();
+ const ObjPtr<ObjectArray<Class>> target_p_types = target->GetPTypes();
if (params_length != target_p_types->GetLength()) {
return false;
}
@@ -152,11 +152,11 @@
return true;
}
-std::string MethodType::PrettyDescriptor() REQUIRES_SHARED(Locks::mutator_lock_) {
+std::string MethodType::PrettyDescriptor() {
std::ostringstream ss;
ss << "(";
- ObjPtr<ObjectArray<Class>> const p_types = GetPTypes();
+ const ObjPtr<ObjectArray<Class>> p_types = GetPTypes();
const int32_t params_length = p_types->GetLength();
for (int32_t i = 0; i < params_length; ++i) {
ss << p_types->GetWithoutChecks(i)->PrettyDescriptor();
diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h
index 814d86a..3fa5d80 100644
--- a/runtime/mirror/object-inl.h
+++ b/runtime/mirror/object-inl.h
@@ -197,9 +197,9 @@
ALWAYS_INLINE bool Object::IsSpecificPrimitiveArray() {
// We do not need a read barrier here as the primitive type is constant, both from-space
// and to-space component type classes shall yield the same result. See ReadBarrierOption.
- ObjPtr<Class> klass = GetClass<kVerifyFlags, kWithoutReadBarrier>();
+ const ObjPtr<Class> klass = GetClass<kVerifyFlags, kWithoutReadBarrier>();
constexpr VerifyObjectFlags kNewFlags = RemoveThisFlags(kVerifyFlags);
- ObjPtr<Class> const component_type = klass->GetComponentType<kNewFlags, kWithoutReadBarrier>();
+ const ObjPtr<Class> component_type = klass->GetComponentType<kNewFlags, kWithoutReadBarrier>();
return component_type != nullptr &&
component_type->GetPrimitiveType<kNewFlags>() == kType;
}
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index f6adc80..b8d1d3f 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -71,7 +71,7 @@
void VisitRoot(mirror::CompressedReference<mirror::Object>* root ATTRIBUTE_UNUSED) const {}
private:
- ObjPtr<Object> const dest_obj_;
+ const ObjPtr<Object> dest_obj_;
};
Object* Object::CopyObject(ObjPtr<mirror::Object> dest,
diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc
index 28ae76c..c6afca0 100644
--- a/runtime/mirror/throwable.cc
+++ b/runtime/mirror/throwable.cc
@@ -80,11 +80,11 @@
}
int32_t Throwable::GetStackDepth() {
- ObjPtr<Object> stack_state = GetStackState();
+ const ObjPtr<Object> stack_state = GetStackState();
if (stack_state == nullptr || !stack_state->IsObjectArray()) {
return -1;
}
- ObjPtr<mirror::ObjectArray<Object>> const trace = stack_state->AsObjectArray<Object>();
+ const ObjPtr<mirror::ObjectArray<Object>> trace = stack_state->AsObjectArray<Object>();
const int32_t array_len = trace->GetLength();
DCHECK_GT(array_len, 0);
// See method BuildInternalStackTraceVisitor::Init for the format.
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index b77519b..7fb3c40 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -519,7 +519,7 @@
if (!class_linker->IsDexFileRegistered(self, *dex_file)) {
continue;
}
- ObjPtr<mirror::DexCache> const dex_cache = class_linker->FindDexCache(self, *dex_file);
+ const ObjPtr<mirror::DexCache> dex_cache = class_linker->FindDexCache(self, *dex_file);
DCHECK(dex_cache != nullptr); // Boot class path dex caches are never unloaded.
for (size_t j = 0, num_strings = dex_cache->NumStrings(); j < num_strings; ++j) {
auto pair = dex_cache->GetStrings()[j].load(std::memory_order_relaxed);
diff --git a/runtime/native/java_lang_ref_FinalizerReference.cc b/runtime/native/java_lang_ref_FinalizerReference.cc
index c89188c..535b243 100644
--- a/runtime/native/java_lang_ref_FinalizerReference.cc
+++ b/runtime/native/java_lang_ref_FinalizerReference.cc
@@ -30,14 +30,14 @@
static jboolean FinalizerReference_makeCircularListIfUnenqueued(JNIEnv* env, jobject javaThis) {
ScopedFastNativeObjectAccess soa(env);
- ObjPtr<mirror::FinalizerReference> ref = soa.Decode<mirror::FinalizerReference>(javaThis);
+ const ObjPtr<mirror::FinalizerReference> ref = soa.Decode<mirror::FinalizerReference>(javaThis);
return Runtime::Current()->GetHeap()->GetReferenceProcessor()->MakeCircularListIfUnenqueued(ref);
}
static jobject FinalizerReference_getReferent(JNIEnv* env, jobject javaThis) {
ScopedFastNativeObjectAccess soa(env);
- ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
- ObjPtr<mirror::Object> const referent =
+ const ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
+ const ObjPtr<mirror::Object> referent =
Runtime::Current()->GetHeap()->GetReferenceProcessor()->GetReferent(soa.Self(), ref);
return soa.AddLocalReference<jobject>(referent);
}
diff --git a/runtime/native/java_lang_ref_Reference.cc b/runtime/native/java_lang_ref_Reference.cc
index fc018d1..b241b1d 100644
--- a/runtime/native/java_lang_ref_Reference.cc
+++ b/runtime/native/java_lang_ref_Reference.cc
@@ -30,15 +30,15 @@
static jobject Reference_getReferent(JNIEnv* env, jobject javaThis) {
ScopedFastNativeObjectAccess soa(env);
- ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
- ObjPtr<mirror::Object> const referent =
+ const ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
+ const ObjPtr<mirror::Object> referent =
Runtime::Current()->GetHeap()->GetReferenceProcessor()->GetReferent(soa.Self(), ref);
return soa.AddLocalReference<jobject>(referent);
}
static void Reference_clearReferent(JNIEnv* env, jobject javaThis) {
ScopedFastNativeObjectAccess soa(env);
- ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
+ const ObjPtr<mirror::Reference> ref = soa.Decode<mirror::Reference>(javaThis);
Runtime::Current()->GetHeap()->GetReferenceProcessor()->ClearReferent(ref);
}
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 9080418..77849a4 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2938,13 +2938,13 @@
soa.Decode<mirror::Object>(internal)->AsObjectArray<mirror::Object>();
// Methods and dex PC trace is element 0.
DCHECK(decoded_traces->Get(0)->IsIntArray() || decoded_traces->Get(0)->IsLongArray());
- ObjPtr<mirror::PointerArray> const method_trace =
+ const ObjPtr<mirror::PointerArray> method_trace =
ObjPtr<mirror::PointerArray>::DownCast(MakeObjPtr(decoded_traces->Get(0)));
// Prepare parameters for StackTraceElement(String cls, String method, String file, int line)
ArtMethod* method = method_trace->GetElementPtrSize<ArtMethod*>(i, kRuntimePointerSize);
uint32_t dex_pc = method_trace->GetElementPtrSize<uint32_t>(
i + method_trace->GetLength() / 2, kRuntimePointerSize);
- ObjPtr<mirror::StackTraceElement> obj = CreateStackTraceElement(soa, method, dex_pc);
+ const ObjPtr<mirror::StackTraceElement> obj = CreateStackTraceElement(soa, method, dex_pc);
if (obj == nullptr) {
return nullptr;
}
diff --git a/runtime/verifier/reg_type_cache.cc b/runtime/verifier/reg_type_cache.cc
index 7bff255..1553017 100644
--- a/runtime/verifier/reg_type_cache.cc
+++ b/runtime/verifier/reg_type_cache.cc
@@ -243,7 +243,7 @@
return &RegTypeFromPrimitiveType(klass->GetPrimitiveType());
}
for (auto& pair : klass_entries_) {
- ObjPtr<mirror::Class> const reg_klass = pair.first.Read();
+ const ObjPtr<mirror::Class> reg_klass = pair.first.Read();
if (reg_klass == klass) {
const RegType* reg_type = pair.second;
if (MatchingPrecisionForClass(reg_type, precise)) {