summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-09-11 08:30:08 -0700
committerAndreas Gampe <agampe@google.com>2014-09-15 19:50:12 -0700
commit5a4b8a236030460651a3136397d23ca6744e7eb7 (patch)
tree0e43891398e416d3fa77c7de391bf4db4408e8ee /runtime
parent19f7c95491a053b818f914137fa73df0517b8792 (diff)
downloadart-5a4b8a236030460651a3136397d23ca6744e7eb7.zip
art-5a4b8a236030460651a3136397d23ca6744e7eb7.tar.gz
art-5a4b8a236030460651a3136397d23ca6744e7eb7.tar.bz2
ART: Rename Handle hierarchy
Bring the names in line with normal OO principles: ConstHandle becomes Handle, and Handle becomes MutableHandle. Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
Diffstat (limited to 'runtime')
-rw-r--r--runtime/class_linker.cc129
-rw-r--r--runtime/class_linker.h99
-rw-r--r--runtime/class_linker_test.cc8
-rw-r--r--runtime/debugger.cc2
-rw-r--r--runtime/entrypoints/quick/quick_trampoline_entrypoints.cc4
-rw-r--r--runtime/field_helper.h5
-rw-r--r--runtime/gc/space/space_test.h8
-rw-r--r--runtime/handle.h51
-rw-r--r--runtime/handle_scope.h24
-rw-r--r--runtime/interpreter/interpreter_common.cc6
-rw-r--r--runtime/method_helper-inl.h14
-rw-r--r--runtime/method_helper.cc50
-rw-r--r--runtime/method_helper.h53
-rw-r--r--runtime/mirror/array.cc2
-rw-r--r--runtime/mirror/art_method.cc2
-rw-r--r--runtime/mirror/class.cc2
-rw-r--r--runtime/mirror/class.h4
-rw-r--r--runtime/mirror/object_test.cc10
-rw-r--r--runtime/monitor_test.cc8
-rw-r--r--runtime/object_lock.cc2
-rw-r--r--runtime/object_lock.h4
-rw-r--r--runtime/proxy_test.cc16
-rw-r--r--runtime/thread.cc2
-rw-r--r--runtime/transaction_test.cc2
-rw-r--r--runtime/verifier/method_verifier.cc22
-rw-r--r--runtime/verifier/method_verifier.h34
26 files changed, 317 insertions, 246 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 74b262f..1686c27 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1875,7 +1875,7 @@ void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* ar
} else {
Thread* self = Thread::Current();
StackHandleScope<1> hs(self);
- Handle<mirror::ObjectArray<mirror::Class>> classes =
+ MutableHandle<mirror::ObjectArray<mirror::Class>> classes =
hs.NewHandle<mirror::ObjectArray<mirror::Class>>(nullptr);
GetClassesVisitorArrayArg local_arg;
local_arg.classes = &classes;
@@ -2078,7 +2078,7 @@ ClassPathEntry FindInClassPath(const char* descriptor,
mirror::Class* ClassLinker::FindClassInPathClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader) {
+ Handle<mirror::ClassLoader> class_loader) {
if (class_loader->GetClass() !=
soa.Decode<mirror::Class*>(WellKnownClasses::dalvik_system_PathClassLoader) ||
class_loader->GetParent()->GetClass() !=
@@ -2162,7 +2162,7 @@ mirror::Class* ClassLinker::FindClassInPathClassLoader(ScopedObjectAccessAlready
}
mirror::Class* ClassLinker::FindClass(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader) {
+ Handle<mirror::ClassLoader> class_loader) {
DCHECK_NE(*descriptor, '\0') << "descriptor is empty string";
DCHECK(self != nullptr);
self->AssertNoPendingException();
@@ -2267,7 +2267,7 @@ mirror::Class* ClassLinker::FindClass(Thread* self, const char* descriptor,
}
mirror::Class* ClassLinker::DefineClass(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile& dex_file,
const DexFile::ClassDef& dex_class_def) {
StackHandleScope<3> hs(self);
@@ -2694,7 +2694,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) {
// Ignore virtual methods on the iterator.
}
-void ClassLinker::LinkCode(ConstHandle<mirror::ArtMethod> method,
+void ClassLinker::LinkCode(Handle<mirror::ArtMethod> method,
const OatFile::OatClass* oat_class,
const DexFile& dex_file, uint32_t dex_method_index,
uint32_t method_index) {
@@ -2777,7 +2777,7 @@ void ClassLinker::LinkCode(ConstHandle<mirror::ArtMethod> method,
void ClassLinker::LoadClass(Thread* self, const DexFile& dex_file,
const DexFile::ClassDef& dex_class_def,
- ConstHandle<mirror::Class> klass,
+ Handle<mirror::Class> klass,
mirror::ClassLoader* class_loader) {
CHECK(klass.Get() != nullptr);
CHECK(klass->GetDexCache() != nullptr);
@@ -2820,7 +2820,7 @@ void ClassLinker::LoadClass(Thread* self, const DexFile& dex_file,
void ClassLinker::LoadClassMembers(Thread* self, const DexFile& dex_file,
const byte* class_data,
- ConstHandle<mirror::Class> klass,
+ Handle<mirror::Class> klass,
mirror::ClassLoader* class_loader,
const OatFile::OatClass* oat_class) {
// Load fields.
@@ -2927,8 +2927,8 @@ void ClassLinker::LoadClassMembers(Thread* self, const DexFile& dex_file,
}
void ClassLinker::LoadField(const DexFile& /*dex_file*/, const ClassDataItemIterator& it,
- ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ArtField> dst) {
+ Handle<mirror::Class> klass,
+ Handle<mirror::ArtField> dst) {
uint32_t field_idx = it.GetMemberIndex();
dst->SetDexFieldIndex(field_idx);
dst->SetDeclaringClass(klass.Get());
@@ -2937,7 +2937,7 @@ void ClassLinker::LoadField(const DexFile& /*dex_file*/, const ClassDataItemIter
mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file,
const ClassDataItemIterator& it,
- ConstHandle<mirror::Class> klass) {
+ Handle<mirror::Class> klass) {
uint32_t dex_method_idx = it.GetMemberIndex();
const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
const char* method_name = dex_file.StringDataByIdx(method_id.name_idx_);
@@ -3009,7 +3009,7 @@ void ClassLinker::AppendToBootClassPath(Thread* self, const DexFile& dex_file) {
}
void ClassLinker::AppendToBootClassPath(const DexFile& dex_file,
- ConstHandle<mirror::DexCache> dex_cache) {
+ Handle<mirror::DexCache> dex_cache) {
CHECK(dex_cache.Get() != nullptr) << dex_file.GetLocation();
boot_class_path_.push_back(&dex_file);
RegisterDexFile(dex_file, dex_cache);
@@ -3032,7 +3032,7 @@ bool ClassLinker::IsDexFileRegistered(const DexFile& dex_file) {
}
void ClassLinker::RegisterDexFileLocked(const DexFile& dex_file,
- ConstHandle<mirror::DexCache> dex_cache) {
+ Handle<mirror::DexCache> dex_cache) {
dex_lock_.AssertExclusiveHeld(Thread::Current());
CHECK(dex_cache.Get() != nullptr) << dex_file.GetLocation();
CHECK(dex_cache->GetLocation()->Equals(dex_file.GetLocation()))
@@ -3070,7 +3070,7 @@ void ClassLinker::RegisterDexFile(const DexFile& dex_file) {
}
void ClassLinker::RegisterDexFile(const DexFile& dex_file,
- ConstHandle<mirror::DexCache> dex_cache) {
+ Handle<mirror::DexCache> dex_cache) {
WriterMutexLock mu(Thread::Current(), dex_lock_);
RegisterDexFileLocked(dex_file, dex_cache);
}
@@ -3148,11 +3148,12 @@ mirror::Class* ClassLinker::InitializePrimitiveClass(mirror::Class* primitive_cl
//
// Returns nullptr with an exception raised on failure.
mirror::Class* ClassLinker::CreateArrayClass(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader) {
+ Handle<mirror::ClassLoader> class_loader) {
// Identify the underlying component type
CHECK_EQ('[', descriptor[0]);
StackHandleScope<2> hs(self);
- Handle<mirror::Class> component_type(hs.NewHandle(FindClass(self, descriptor + 1, class_loader)));
+ MutableHandle<mirror::Class> component_type(hs.NewHandle(FindClass(self, descriptor + 1,
+ class_loader)));
if (component_type.Get() == nullptr) {
DCHECK(self->IsExceptionPending());
// We need to accept erroneous classes as component types.
@@ -3545,7 +3546,7 @@ void ClassLinker::LookupClasses(const char* descriptor, std::vector<mirror::Clas
}
}
-void ClassLinker::VerifyClass(Thread* self, ConstHandle<mirror::Class> klass) {
+void ClassLinker::VerifyClass(Thread* self, Handle<mirror::Class> klass) {
// TODO: assert that the monitor on the Class is held
ObjectLock<mirror::Class> lock(self, klass);
@@ -3687,7 +3688,7 @@ void ClassLinker::VerifyClass(Thread* self, ConstHandle<mirror::Class> klass) {
}
}
-void ClassLinker::EnsurePreverifiedMethods(ConstHandle<mirror::Class> klass) {
+void ClassLinker::EnsurePreverifiedMethods(Handle<mirror::Class> klass) {
if (!klass->IsPreverified()) {
klass->SetPreverifiedFlagOnAllMethods();
klass->SetPreverified();
@@ -3766,7 +3767,7 @@ bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class
}
void ClassLinker::ResolveClassExceptionHandlerTypes(const DexFile& dex_file,
- ConstHandle<mirror::Class> klass) {
+ Handle<mirror::Class> klass) {
for (size_t i = 0; i < klass->NumDirectMethods(); i++) {
ResolveMethodExceptionHandlerTypes(dex_file, klass->GetDirectMethod(i));
}
@@ -3806,15 +3807,15 @@ void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file,
}
static void CheckProxyConstructor(mirror::ArtMethod* constructor);
-static void CheckProxyMethod(ConstHandle<mirror::ArtMethod> method,
- ConstHandle<mirror::ArtMethod> prototype);
+static void CheckProxyMethod(Handle<mirror::ArtMethod> method,
+ Handle<mirror::ArtMethod> prototype);
mirror::Class* ClassLinker::CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa, jstring name,
jobjectArray interfaces, jobject loader,
jobjectArray methods, jobjectArray throws) {
Thread* self = soa.Self();
StackHandleScope<8> hs(self);
- Handle<mirror::Class> klass(hs.NewHandle(
+ MutableHandle<mirror::Class> klass(hs.NewHandle(
AllocClass(self, GetClassRoot(kJavaLangClass), sizeof(mirror::Class))));
if (klass.Get() == nullptr) {
CHECK(self->IsExceptionPending()); // OOME.
@@ -4002,7 +4003,7 @@ mirror::ArtMethod* ClassLinker::FindMethodForProxy(mirror::Class* proxy_class,
mirror::ArtMethod* ClassLinker::CreateProxyConstructor(Thread* self,
- ConstHandle<mirror::Class> klass,
+ Handle<mirror::Class> klass,
mirror::Class* proxy_class) {
// Create constructor for Proxy that must initialize h
mirror::ObjectArray<mirror::ArtMethod>* proxy_direct_methods =
@@ -4036,8 +4037,8 @@ static void CheckProxyConstructor(mirror::ArtMethod* constructor)
}
mirror::ArtMethod* ClassLinker::CreateProxyMethod(Thread* self,
- ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ArtMethod> prototype) {
+ Handle<mirror::Class> klass,
+ Handle<mirror::ArtMethod> prototype) {
// Ensure prototype is in dex cache so that we can use the dex cache to look up the overridden
// prototype method
prototype->GetDeclaringClass()->GetDexCache()->SetResolvedMethod(prototype->GetDexMethodIndex(),
@@ -4064,8 +4065,8 @@ mirror::ArtMethod* ClassLinker::CreateProxyMethod(Thread* self,
return method;
}
-static void CheckProxyMethod(ConstHandle<mirror::ArtMethod> method,
- ConstHandle<mirror::ArtMethod> prototype)
+static void CheckProxyMethod(Handle<mirror::ArtMethod> method,
+ Handle<mirror::ArtMethod> prototype)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
// Basic sanity
CHECK(!prototype->IsFinal());
@@ -4122,7 +4123,7 @@ static bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics,
return true;
}
-bool ClassLinker::InitializeClass(Thread* self, ConstHandle<mirror::Class> klass,
+bool ClassLinker::InitializeClass(Thread* self, Handle<mirror::Class> klass,
bool can_init_statics, bool can_init_parents) {
// see JLS 3rd edition, 12.4.2 "Detailed Initialization Procedure" for the locking protocol
@@ -4301,7 +4302,7 @@ bool ClassLinker::InitializeClass(Thread* self, ConstHandle<mirror::Class> klass
return success;
}
-bool ClassLinker::WaitForInitializeClass(ConstHandle<mirror::Class> klass, Thread* self,
+bool ClassLinker::WaitForInitializeClass(Handle<mirror::Class> klass, Thread* self,
ObjectLock<mirror::Class>& lock)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
while (true) {
@@ -4341,14 +4342,14 @@ bool ClassLinker::WaitForInitializeClass(ConstHandle<mirror::Class> klass, Threa
LOG(FATAL) << "Not Reached" << PrettyClass(klass.Get());
}
-bool ClassLinker::ValidateSuperClassDescriptors(ConstHandle<mirror::Class> klass) {
+bool ClassLinker::ValidateSuperClassDescriptors(Handle<mirror::Class> klass) {
if (klass->IsInterface()) {
return true;
}
// Begin with the methods local to the superclass.
StackHandleScope<2> hs(Thread::Current());
- MethodHelper mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
- MethodHelper super_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper super_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
if (klass->HasSuperClass() &&
klass->GetClassLoader() != klass->GetSuperClass()->GetClassLoader()) {
for (int i = klass->GetSuperClass()->GetVTableLength() - 1; i >= 0; --i) {
@@ -4386,8 +4387,8 @@ bool ClassLinker::ValidateSuperClassDescriptors(ConstHandle<mirror::Class> klass
return true;
}
-bool ClassLinker::EnsureInitialized(Thread* self, ConstHandle<mirror::Class> c,
- bool can_init_fields, bool can_init_parents) {
+bool ClassLinker::EnsureInitialized(Thread* self, Handle<mirror::Class> c, bool can_init_fields,
+ bool can_init_parents) {
DCHECK(c.Get() != nullptr);
if (c->IsInitialized()) {
EnsurePreverifiedMethods(c);
@@ -4442,8 +4443,8 @@ void ClassLinker::FixupTemporaryDeclaringClass(mirror::Class* temp_class, mirror
}
}
-bool ClassLinker::LinkClass(Thread* self, const char* descriptor, ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ObjectArray<mirror::Class>> interfaces,
+bool ClassLinker::LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass,
+ Handle<mirror::ObjectArray<mirror::Class>> interfaces,
mirror::Class** new_class) {
CHECK_EQ(mirror::Class::kStatusLoaded, klass->GetStatus());
@@ -4508,7 +4509,7 @@ bool ClassLinker::LinkClass(Thread* self, const char* descriptor, ConstHandle<mi
return true;
}
-bool ClassLinker::LoadSuperAndInterfaces(ConstHandle<mirror::Class> klass, const DexFile& dex_file) {
+bool ClassLinker::LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file) {
CHECK_EQ(mirror::Class::kStatusIdx, klass->GetStatus());
const DexFile::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex());
uint16_t super_class_idx = class_def.superclass_idx_;
@@ -4552,7 +4553,7 @@ bool ClassLinker::LoadSuperAndInterfaces(ConstHandle<mirror::Class> klass, const
return true;
}
-bool ClassLinker::LinkSuperClass(ConstHandle<mirror::Class> klass) {
+bool ClassLinker::LinkSuperClass(Handle<mirror::Class> klass) {
CHECK(!klass->IsPrimitive());
mirror::Class* super = klass->GetSuperClass();
if (klass.Get() == GetClassRoot(kJavaLangObject)) {
@@ -4612,8 +4613,8 @@ bool ClassLinker::LinkSuperClass(ConstHandle<mirror::Class> klass) {
}
// Populate the class vtable and itable. Compute return type indices.
-bool ClassLinker::LinkMethods(Thread* self, ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ObjectArray<mirror::Class>> interfaces) {
+bool ClassLinker::LinkMethods(Thread* self, Handle<mirror::Class> klass,
+ Handle<mirror::ObjectArray<mirror::Class>> interfaces) {
self->AllowThreadSuspension();
if (klass->IsInterface()) {
// No vtable.
@@ -4634,7 +4635,7 @@ bool ClassLinker::LinkMethods(Thread* self, ConstHandle<mirror::Class> klass,
return true;
}
-bool ClassLinker::LinkVirtualMethods(Thread* self, ConstHandle<mirror::Class> klass) {
+bool ClassLinker::LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass) {
if (klass->HasSuperClass()) {
uint32_t max_count = klass->NumVirtualMethods() +
klass->GetSuperClass()->GetVTableLength();
@@ -4642,7 +4643,7 @@ bool ClassLinker::LinkVirtualMethods(Thread* self, ConstHandle<mirror::Class> kl
CHECK_LE(actual_count, max_count);
StackHandleScope<4> hs(self);
Handle<mirror::Class> super_class(hs.NewHandle(klass->GetSuperClass()));
- Handle<mirror::ObjectArray<mirror::ArtMethod>> vtable;
+ MutableHandle<mirror::ObjectArray<mirror::ArtMethod>> vtable;
if (super_class->ShouldHaveEmbeddedImtAndVTable()) {
vtable = hs.NewHandle(AllocArtMethodArray(self, max_count));
if (UNLIKELY(vtable.Get() == nullptr)) {
@@ -4663,8 +4664,8 @@ bool ClassLinker::LinkVirtualMethods(Thread* self, ConstHandle<mirror::Class> kl
}
// See if any of our virtual methods override the superclass.
- MethodHelper local_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
- MethodHelper super_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper local_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper super_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
for (size_t i = 0; i < klass->NumVirtualMethods(); ++i) {
mirror::ArtMethod* local_method = klass->GetVirtualMethodDuringLinking(i);
local_mh.ChangeMethod(local_method);
@@ -4736,8 +4737,8 @@ bool ClassLinker::LinkVirtualMethods(Thread* self, ConstHandle<mirror::Class> kl
return true;
}
-bool ClassLinker::LinkInterfaceMethods(ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ObjectArray<mirror::Class>> interfaces) {
+bool ClassLinker::LinkInterfaceMethods(Handle<mirror::Class> klass,
+ Handle<mirror::ObjectArray<mirror::Class>> interfaces) {
Thread* const self = Thread::Current();
Runtime* const runtime = Runtime::Current();
// Set the imt table to be all conflicts by default.
@@ -4780,7 +4781,7 @@ bool ClassLinker::LinkInterfaceMethods(ConstHandle<mirror::Class> klass,
}
}
StackHandleScope<5> hs(self);
- Handle<mirror::IfTable> iftable(hs.NewHandle(AllocIfTable(self, ifcount)));
+ MutableHandle<mirror::IfTable> iftable(hs.NewHandle(AllocIfTable(self, ifcount)));
if (UNLIKELY(iftable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
@@ -4863,8 +4864,8 @@ bool ClassLinker::LinkInterfaceMethods(ConstHandle<mirror::Class> klass,
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
- MethodHelper interface_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
- MethodHelper vtable_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper interface_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper vtable_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
size_t max_miranda_methods = 0; // The max size of miranda_list.
for (size_t i = 0; i < ifcount; ++i) {
max_miranda_methods += iftable->GetInterface(i)->NumVirtualMethods();
@@ -4973,7 +4974,7 @@ bool ClassLinker::LinkInterfaceMethods(ConstHandle<mirror::Class> klass,
klass->SetVirtualMethods(virtuals);
StackHandleScope<1> hs(self);
- Handle<mirror::ObjectArray<mirror::ArtMethod>> vtable(
+ MutableHandle<mirror::ObjectArray<mirror::ArtMethod>> vtable(
hs.NewHandle(klass->GetVTableDuringLinking()));
CHECK(vtable.Get() != nullptr);
int old_vtable_count = vtable->GetLength();
@@ -5005,12 +5006,12 @@ bool ClassLinker::LinkInterfaceMethods(ConstHandle<mirror::Class> klass,
return true;
}
-bool ClassLinker::LinkInstanceFields(Thread* self, ConstHandle<mirror::Class> klass) {
+bool ClassLinker::LinkInstanceFields(Thread* self, Handle<mirror::Class> klass) {
CHECK(klass.Get() != nullptr);
return LinkFields(self, klass, false, nullptr);
}
-bool ClassLinker::LinkStaticFields(Thread* self, ConstHandle<mirror::Class> klass, size_t* class_size) {
+bool ClassLinker::LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size) {
CHECK(klass.Get() != nullptr);
return LinkFields(self, klass, true, class_size);
}
@@ -5042,7 +5043,7 @@ struct LinkFieldsComparator {
}
};
-bool ClassLinker::LinkFields(Thread* self, ConstHandle<mirror::Class> klass, bool is_static,
+bool ClassLinker::LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_static,
size_t* class_size) {
self->AllowThreadSuspension();
size_t num_fields =
@@ -5188,7 +5189,7 @@ bool ClassLinker::LinkFields(Thread* self, ConstHandle<mirror::Class> klass, boo
// Set the bitmap of reference offsets, refOffsets, from the ifields
// list.
-void ClassLinker::CreateReferenceInstanceOffsets(ConstHandle<mirror::Class> klass) {
+void ClassLinker::CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) {
uint32_t reference_offsets = 0;
mirror::Class* super_class = klass->GetSuperClass();
if (super_class != nullptr) {
@@ -5202,7 +5203,7 @@ void ClassLinker::CreateReferenceInstanceOffsets(ConstHandle<mirror::Class> klas
CreateReferenceOffsets(klass, reference_offsets);
}
-void ClassLinker::CreateReferenceOffsets(ConstHandle<mirror::Class> klass,
+void ClassLinker::CreateReferenceOffsets(Handle<mirror::Class> klass,
uint32_t reference_offsets) {
size_t num_reference_fields = klass->NumReferenceInstanceFieldsDuringLinking();
mirror::ObjectArray<mirror::ArtField>* fields = klass->GetIFields();
@@ -5227,7 +5228,7 @@ void ClassLinker::CreateReferenceOffsets(ConstHandle<mirror::Class> klass,
}
mirror::String* ClassLinker::ResolveString(const DexFile& dex_file, uint32_t string_idx,
- ConstHandle<mirror::DexCache> dex_cache) {
+ Handle<mirror::DexCache> dex_cache) {
DCHECK(dex_cache.Get() != nullptr);
mirror::String* resolved = dex_cache->GetResolvedString(string_idx);
if (resolved != nullptr) {
@@ -5249,8 +5250,8 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, uint16_t type_i
}
mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, uint16_t type_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader) {
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader) {
DCHECK(dex_cache.Get() != nullptr);
mirror::Class* resolved = dex_cache->GetResolvedType(type_idx);
if (resolved == nullptr) {
@@ -5282,9 +5283,9 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, uint16_t type_i
}
mirror::ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, uint32_t method_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
- ConstHandle<mirror::ArtMethod> referrer,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
+ Handle<mirror::ArtMethod> referrer,
InvokeType type) {
DCHECK(dex_cache.Get() != nullptr);
// Check for hit in the dex cache.
@@ -5435,8 +5436,8 @@ mirror::ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, uint32_t
}
mirror::ArtField* ClassLinker::ResolveField(const DexFile& dex_file, uint32_t field_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
bool is_static) {
DCHECK(dex_cache.Get() != nullptr);
mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx);
@@ -5478,8 +5479,8 @@ mirror::ArtField* ClassLinker::ResolveField(const DexFile& dex_file, uint32_t fi
mirror::ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file,
uint32_t field_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader) {
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader) {
DCHECK(dex_cache.Get() != nullptr);
mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx);
if (resolved != nullptr) {
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index b6c62a9..3ea74e0 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -48,7 +48,7 @@ namespace mirror {
class StackTraceElement;
} // namespace mirror
-template<class T> class ConstHandle;
+template<class T> class Handle;
class InternTable;
template<class T> class ObjectLock;
class ScopedObjectAccessAlreadyRunnable;
@@ -73,13 +73,13 @@ class ClassLinker {
// Finds a class by its descriptor, loading it if necessary.
// If class_loader is null, searches boot_class_path_.
mirror::Class* FindClass(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader)
+ Handle<mirror::ClassLoader> class_loader)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Find a class in the path class loader, loading it if necessary.
mirror::Class* FindClassInPathClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader)
+ Handle<mirror::ClassLoader> class_loader)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Finds a class by its descriptor using the "system" class loader, ie by searching the
@@ -98,7 +98,7 @@ class ClassLinker {
// Define a new a class based on a ClassDef from a DexFile
mirror::Class* DefineClass(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile& dex_file, const DexFile::ClassDef& dex_class_def)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -142,7 +142,7 @@ class ClassLinker {
// Resolve a String with the given index from the DexFile, storing the
// result in the DexCache.
mirror::String* ResolveString(const DexFile& dex_file, uint32_t string_idx,
- ConstHandle<mirror::DexCache> dex_cache)
+ Handle<mirror::DexCache> dex_cache)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Resolve a Type with the given index from the DexFile, storing the
@@ -165,8 +165,8 @@ class ClassLinker {
// type, since it may be referenced from but not contained within
// the given DexFile.
mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader)
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Resolve a method with a given ID from the DexFile, storing the
@@ -176,9 +176,9 @@ class ClassLinker {
// virtual method.
mirror::ArtMethod* ResolveMethod(const DexFile& dex_file,
uint32_t method_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
- ConstHandle<mirror::ArtMethod> referrer,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
+ Handle<mirror::ArtMethod> referrer,
InvokeType type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -202,8 +202,8 @@ class ClassLinker {
// field.
mirror::ArtField* ResolveField(const DexFile& dex_file,
uint32_t field_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
bool is_static)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -212,8 +212,8 @@ class ClassLinker {
// in ResolveType. No is_static argument is provided so that Java
// field resolution semantics are followed.
mirror::ArtField* ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader)
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Get shorty from method index without resolution. Used to do handlerization.
@@ -223,7 +223,7 @@ class ClassLinker {
// Returns true on success, false if there's an exception pending.
// can_run_clinit=false allows the compiler to attempt to init a class,
// given the restriction that no <clinit> execution is possible.
- bool EnsureInitialized(Thread* self, ConstHandle<mirror::Class> c, bool can_init_fields,
+ bool EnsureInitialized(Thread* self, Handle<mirror::Class> c, bool can_init_fields,
bool can_init_parents)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -234,7 +234,7 @@ class ClassLinker {
void RegisterDexFile(const DexFile& dex_file)
LOCKS_EXCLUDED(dex_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void RegisterDexFile(const DexFile& dex_file, ConstHandle<mirror::DexCache> dex_cache)
+ void RegisterDexFile(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
LOCKS_EXCLUDED(dex_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -326,13 +326,13 @@ class ClassLinker {
size_t length)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void VerifyClass(Thread* self, ConstHandle<mirror::Class> klass)
+ void VerifyClass(Thread* self, Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass,
mirror::Class::Status& oat_file_class_status)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void ResolveClassExceptionHandlerTypes(const DexFile& dex_file,
- ConstHandle<mirror::Class> klass)
+ Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -445,12 +445,12 @@ class ClassLinker {
mirror::Class* CreateArrayClass(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader)
+ Handle<mirror::ClassLoader> class_loader)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void AppendToBootClassPath(Thread* self, const DexFile& dex_file)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void AppendToBootClassPath(const DexFile& dex_file, ConstHandle<mirror::DexCache> dex_cache)
+ void AppendToBootClassPath(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Precomputes size needed for Class, in the case of a non-temporary class this size must be
@@ -459,20 +459,20 @@ class ClassLinker {
const DexFile::ClassDef& dex_class_def);
void LoadClass(Thread* self, const DexFile& dex_file, const DexFile::ClassDef& dex_class_def,
- ConstHandle<mirror::Class> klass, mirror::ClassLoader* class_loader)
+ Handle<mirror::Class> klass, mirror::ClassLoader* class_loader)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void LoadClassMembers(Thread* self, const DexFile& dex_file, const byte* class_data,
- ConstHandle<mirror::Class> klass, mirror::ClassLoader* class_loader,
+ Handle<mirror::Class> klass, mirror::ClassLoader* class_loader,
const OatFile::OatClass* oat_class)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it,
- ConstHandle<mirror::Class> klass, ConstHandle<mirror::ArtField> dst)
+ Handle<mirror::Class> klass, Handle<mirror::ArtField> dst)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file,
const ClassDataItemIterator& dex_method,
- ConstHandle<mirror::Class> klass)
+ Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -482,23 +482,23 @@ class ClassLinker {
OatFile::OatClass FindOatClass(const DexFile& dex_file, uint16_t class_def_idx, bool* found)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void RegisterDexFileLocked(const DexFile& dex_file, ConstHandle<mirror::DexCache> dex_cache)
+ void RegisterDexFileLocked(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
EXCLUSIVE_LOCKS_REQUIRED(dex_lock_)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool IsDexFileRegisteredLocked(const DexFile& dex_file)
SHARED_LOCKS_REQUIRED(dex_lock_, Locks::mutator_lock_);
- bool InitializeClass(Thread* self, ConstHandle<mirror::Class> klass, bool can_run_clinit,
+ bool InitializeClass(Thread* self, Handle<mirror::Class> klass, bool can_run_clinit,
bool can_init_parents)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool WaitForInitializeClass(ConstHandle<mirror::Class> klass, Thread* self,
+ bool WaitForInitializeClass(Handle<mirror::Class> klass, Thread* self,
ObjectLock<mirror::Class>& lock);
- bool ValidateSuperClassDescriptors(ConstHandle<mirror::Class> klass)
+ bool ValidateSuperClassDescriptors(Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool IsSameDescriptorInDifferentClassContexts(Thread* self, const char* descriptor,
- ConstHandle<mirror::ClassLoader> class_loader1,
- ConstHandle<mirror::ClassLoader> class_loader2)
+ Handle<mirror::ClassLoader> class_loader1,
+ Handle<mirror::ClassLoader> class_loader2)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, mirror::ArtMethod* method,
@@ -506,41 +506,40 @@ class ClassLinker {
mirror::Class* klass2)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkClass(Thread* self, const char* descriptor, ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ObjectArray<mirror::Class>> interfaces,
+ bool LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass,
+ Handle<mirror::ObjectArray<mirror::Class>> interfaces,
mirror::Class** new_class)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkSuperClass(ConstHandle<mirror::Class> klass)
+ bool LinkSuperClass(Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LoadSuperAndInterfaces(ConstHandle<mirror::Class> klass, const DexFile& dex_file)
+ bool LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkMethods(Thread* self, ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ObjectArray<mirror::Class>> interfaces)
+ bool LinkMethods(Thread* self, Handle<mirror::Class> klass,
+ Handle<mirror::ObjectArray<mirror::Class>> interfaces)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkVirtualMethods(Thread* self, ConstHandle<mirror::Class> klass)
+ bool LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkInterfaceMethods(ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ObjectArray<mirror::Class>> interfaces)
+ bool LinkInterfaceMethods(Handle<mirror::Class> klass,
+ Handle<mirror::ObjectArray<mirror::Class>> interfaces)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkStaticFields(Thread* self, ConstHandle<mirror::Class> klass, size_t* class_size)
+ bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkInstanceFields(Thread* self, ConstHandle<mirror::Class> klass)
+ bool LinkInstanceFields(Thread* self, Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool LinkFields(Thread* self, ConstHandle<mirror::Class> klass, bool is_static,
- size_t* class_size)
+ bool LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_static, size_t* class_size)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void LinkCode(ConstHandle<mirror::ArtMethod> method, const OatFile::OatClass* oat_class,
+ void LinkCode(Handle<mirror::ArtMethod> method, const OatFile::OatClass* oat_class,
const DexFile& dex_file, uint32_t dex_method_index, uint32_t method_index)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void CreateReferenceInstanceOffsets(ConstHandle<mirror::Class> klass)
+ void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void CreateReferenceOffsets(ConstHandle<mirror::Class> klass, uint32_t reference_offsets)
+ void CreateReferenceOffsets(Handle<mirror::Class> klass, uint32_t reference_offsets)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// For use by ImageWriter to find DexCaches for its roots
@@ -632,16 +631,16 @@ class ClassLinker {
const uint32_t* dex_location_checksum,
std::string* error_msg);
- mirror::ArtMethod* CreateProxyConstructor(Thread* self, ConstHandle<mirror::Class> klass,
+ mirror::ArtMethod* CreateProxyConstructor(Thread* self, Handle<mirror::Class> klass,
mirror::Class* proxy_class)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- mirror::ArtMethod* CreateProxyMethod(Thread* self, ConstHandle<mirror::Class> klass,
- ConstHandle<mirror::ArtMethod> prototype)
+ mirror::ArtMethod* CreateProxyMethod(Thread* self, Handle<mirror::Class> klass,
+ Handle<mirror::ArtMethod> prototype)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Ensures that methods have the kAccPreverified bit set. We use the kAccPreverfied bit on the
// class access flags to determine whether this has been done before.
- void EnsurePreverifiedMethods(ConstHandle<mirror::Class> c)
+ void EnsurePreverifiedMethods(Handle<mirror::Class> c)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::Class* LookupClassFromTableLocked(const char* descriptor,
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 273d4c0..613ac66 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -278,10 +278,11 @@ class ClassLinkerTest : public CommonRuntimeTest {
// Confirm that all instances fields are packed together at the start
EXPECT_GE(klass->NumInstanceFields(), klass->NumReferenceInstanceFields());
StackHandleScope<1> hs(Thread::Current());
- FieldHelper fh(hs.NewHandle<mirror::ArtField>(nullptr));
+ MutableHandle<mirror::ArtField> fhandle = hs.NewHandle<mirror::ArtField>(nullptr);
for (size_t i = 0; i < klass->NumReferenceInstanceFields(); i++) {
mirror::ArtField* field = klass->GetInstanceField(i);
- fh.ChangeField(field);
+ fhandle.Assign(field);
+ FieldHelper fh(fhandle);
ASSERT_TRUE(!field->IsPrimitiveType());
mirror::Class* field_type = fh.GetType();
ASSERT_TRUE(field_type != NULL);
@@ -289,7 +290,8 @@ class ClassLinkerTest : public CommonRuntimeTest {
}
for (size_t i = klass->NumReferenceInstanceFields(); i < klass->NumInstanceFields(); i++) {
mirror::ArtField* field = klass->GetInstanceField(i);
- fh.ChangeField(field);
+ fhandle.Assign(field);
+ FieldHelper fh(fhandle);
mirror::Class* field_type = fh.GetType();
ASSERT_TRUE(field_type != NULL);
if (!fh.GetField()->IsPrimitiveType() || !field_type->IsPrimitive()) {
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index c8bb537..cc1e0b9 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -3611,7 +3611,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) {
}
// Translate the method through the vtable, unless the debugger wants to suppress it.
- Handle<mirror::ArtMethod> m(hs.NewHandle(pReq->method));
+ MutableHandle<mirror::ArtMethod> m(hs.NewHandle(pReq->method));
if ((pReq->options & JDWP::INVOKE_NONVIRTUAL) == 0 && pReq->receiver != nullptr) {
mirror::ArtMethod* actual_method = pReq->klass->FindVirtualMethodForVirtualOrInterface(m.Get());
if (actual_method != m.Get()) {
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 95dd8be..1dbbb70 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -1488,7 +1488,7 @@ class BuildGenericJniFrameVisitor FINAL : public QuickArgumentVisitor {
// Initialize padding entries.
size_t expected_slots = handle_scope_->NumberOfReferences();
while (cur_entry_ < expected_slots) {
- handle_scope_->GetHandle(cur_entry_++).Assign(nullptr);
+ handle_scope_->GetMutableHandle(cur_entry_++).Assign(nullptr);
}
DCHECK_NE(cur_entry_, 0U);
}
@@ -1509,7 +1509,7 @@ class BuildGenericJniFrameVisitor FINAL : public QuickArgumentVisitor {
uintptr_t BuildGenericJniFrameVisitor::FillJniCall::PushHandle(mirror::Object* ref) {
uintptr_t tmp;
- Handle<mirror::Object> h = handle_scope_->GetHandle(cur_entry_);
+ MutableHandle<mirror::Object> h = handle_scope_->GetMutableHandle(cur_entry_);
h.Assign(ref);
tmp = reinterpret_cast<uintptr_t>(h.ToJObject());
cur_entry_++;
diff --git a/runtime/field_helper.h b/runtime/field_helper.h
index 5eae55e..8097025 100644
--- a/runtime/field_helper.h
+++ b/runtime/field_helper.h
@@ -27,11 +27,6 @@ class FieldHelper {
public:
explicit FieldHelper(Handle<mirror::ArtField> f) : field_(f) {}
- void ChangeField(mirror::ArtField* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK(new_f != nullptr);
- field_.Assign(new_f);
- }
-
mirror::ArtField* GetField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
return field_.Get();
}
diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h
index 0291155..7211bb4 100644
--- a/runtime/gc/space/space_test.h
+++ b/runtime/gc/space/space_test.h
@@ -181,7 +181,7 @@ void SpaceTest::ZygoteSpaceTestBody(CreateSpaceFn create_space) {
// Succeeds, fits without adjusting the footprint limit.
size_t ptr1_bytes_allocated, ptr1_usable_size;
StackHandleScope<3> hs(soa.Self());
- Handle<mirror::Object> ptr1(
+ MutableHandle<mirror::Object> ptr1(
hs.NewHandle(Alloc(space, self, 1 * MB, &ptr1_bytes_allocated, &ptr1_usable_size)));
EXPECT_TRUE(ptr1.Get() != nullptr);
EXPECT_LE(1U * MB, ptr1_bytes_allocated);
@@ -194,7 +194,7 @@ void SpaceTest::ZygoteSpaceTestBody(CreateSpaceFn create_space) {
// Succeeds, adjusts the footprint.
size_t ptr3_bytes_allocated, ptr3_usable_size;
- Handle<mirror::Object> ptr3(
+ MutableHandle<mirror::Object> ptr3(
hs.NewHandle(AllocWithGrowth(space, self, 8 * MB, &ptr3_bytes_allocated, &ptr3_usable_size)));
EXPECT_TRUE(ptr3.Get() != nullptr);
EXPECT_LE(8U * MB, ptr3_bytes_allocated);
@@ -284,7 +284,7 @@ void SpaceTest::AllocAndFreeTestBody(CreateSpaceFn create_space) {
// Succeeds, fits without adjusting the footprint limit.
size_t ptr1_bytes_allocated, ptr1_usable_size;
StackHandleScope<3> hs(soa.Self());
- Handle<mirror::Object> ptr1(
+ MutableHandle<mirror::Object> ptr1(
hs.NewHandle(Alloc(space, self, 1 * MB, &ptr1_bytes_allocated, &ptr1_usable_size)));
EXPECT_TRUE(ptr1.Get() != nullptr);
EXPECT_LE(1U * MB, ptr1_bytes_allocated);
@@ -297,7 +297,7 @@ void SpaceTest::AllocAndFreeTestBody(CreateSpaceFn create_space) {
// Succeeds, adjusts the footprint.
size_t ptr3_bytes_allocated, ptr3_usable_size;
- Handle<mirror::Object> ptr3(
+ MutableHandle<mirror::Object> ptr3(
hs.NewHandle(AllocWithGrowth(space, self, 8 * MB, &ptr3_bytes_allocated, &ptr3_usable_size)));
EXPECT_TRUE(ptr3.Get() != nullptr);
EXPECT_LE(8U * MB, ptr3_bytes_allocated);
diff --git a/runtime/handle.h b/runtime/handle.h
index 06938e5..addb663 100644
--- a/runtime/handle.h
+++ b/runtime/handle.h
@@ -30,23 +30,23 @@ template<class T> class Handle;
// Handles are memory locations that contain GC roots. As the mirror::Object*s within a handle are
// GC visible then the GC may move the references within them, something that couldn't be done with
-// a wrap pointer. Handles are generally allocated within HandleScopes. ConstHandle is a super-class
-// of Handle and doesn't support assignment operations.
+// a wrap pointer. Handles are generally allocated within HandleScopes. Handle is a super-class
+// of MutableHandle and doesn't support assignment operations.
template<class T>
-class ConstHandle {
+class Handle {
public:
- ConstHandle() : reference_(nullptr) {
+ Handle() : reference_(nullptr) {
}
- ALWAYS_INLINE ConstHandle(const ConstHandle<T>& handle) : reference_(handle.reference_) {
+ ALWAYS_INLINE Handle(const Handle<T>& handle) : reference_(handle.reference_) {
}
- ALWAYS_INLINE ConstHandle<T>& operator=(const ConstHandle<T>& handle) {
+ ALWAYS_INLINE Handle<T>& operator=(const Handle<T>& handle) {
reference_ = handle.reference_;
return *this;
}
- ALWAYS_INLINE explicit ConstHandle(StackReference<T>* reference) : reference_(reference) {
+ ALWAYS_INLINE explicit Handle(StackReference<T>* reference) : reference_(reference) {
}
ALWAYS_INLINE T& operator*() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -73,11 +73,11 @@ class ConstHandle {
StackReference<T>* reference_;
template<typename S>
- explicit ConstHandle(StackReference<S>* reference)
+ explicit Handle(StackReference<S>* reference)
: reference_(reinterpret_cast<StackReference<T>*>(reference)) {
}
template<typename S>
- explicit ConstHandle(const ConstHandle<S>& handle)
+ explicit Handle(const Handle<S>& handle)
: reference_(reinterpret_cast<StackReference<T>*>(handle.reference_)) {
}
@@ -91,7 +91,7 @@ class ConstHandle {
private:
friend class BuildGenericJniFrameVisitor;
- template<class S> friend class ConstHandle;
+ template<class S> friend class Handle;
friend class HandleScope;
template<class S> friend class HandleWrapper;
template<size_t kNumReferences> friend class StackHandleScope;
@@ -99,42 +99,43 @@ class ConstHandle {
// Handles that support assignment.
template<class T>
-class Handle : public ConstHandle<T> {
+class MutableHandle : public Handle<T> {
public:
- Handle() {
+ MutableHandle() {
}
- ALWAYS_INLINE Handle(const Handle<T>& handle) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : ConstHandle<T>(handle.reference_) {
+ ALWAYS_INLINE MutableHandle(const MutableHandle<T>& handle)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ : Handle<T>(handle.reference_) {
}
- ALWAYS_INLINE Handle<T>& operator=(const Handle<T>& handle)
+ ALWAYS_INLINE MutableHandle<T>& operator=(const MutableHandle<T>& handle)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- ConstHandle<T>::operator=(handle);
+ Handle<T>::operator=(handle);
return *this;
}
- ALWAYS_INLINE explicit Handle(StackReference<T>* reference)
+ ALWAYS_INLINE explicit MutableHandle(StackReference<T>* reference)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : ConstHandle<T>(reference) {
+ : Handle<T>(reference) {
}
ALWAYS_INLINE T* Assign(T* reference) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- StackReference<T>* ref = ConstHandle<T>::GetReference();
+ StackReference<T>* ref = Handle<T>::GetReference();
T* const old = ref->AsMirrorPtr();
ref->Assign(reference);
return old;
}
template<typename S>
- explicit Handle(const Handle<S>& handle) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : ConstHandle<T>(handle) {
+ explicit MutableHandle(const MutableHandle<S>& handle) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ : Handle<T>(handle) {
}
protected:
template<typename S>
- explicit Handle(StackReference<S>* reference) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : ConstHandle<T>(reference) {
+ explicit MutableHandle(StackReference<S>* reference) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ : Handle<T>(reference) {
}
private:
@@ -146,9 +147,9 @@ class Handle : public ConstHandle<T> {
// A special case of Handle that only holds references to null.
template<class T>
-class NullHandle : public ConstHandle<T> {
+class NullHandle : public Handle<T> {
public:
- NullHandle() : ConstHandle<T>(&null_ref_) {
+ NullHandle() : Handle<T>(&null_ref_) {
}
private:
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h
index 42ef779..99059f9 100644
--- a/runtime/handle_scope.h
+++ b/runtime/handle_scope.h
@@ -89,6 +89,12 @@ class PACKED(4) HandleScope {
return Handle<mirror::Object>(&references_[i]);
}
+ MutableHandle<mirror::Object> GetMutableHandle(size_t i)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE {
+ DCHECK_LT(i, number_of_references_);
+ return MutableHandle<mirror::Object>(&references_[i]);
+ }
+
void SetReference(size_t i, mirror::Object* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
ALWAYS_INLINE {
DCHECK_LT(i, number_of_references_);
@@ -139,14 +145,14 @@ class PACKED(4) HandleScope {
// A wrapper which wraps around Object** and restores the pointer in the destructor.
// TODO: Add more functionality.
template<class T>
-class HandleWrapper : public Handle<T> {
+class HandleWrapper : public MutableHandle<T> {
public:
- HandleWrapper(T** obj, const Handle<T>& handle)
- : Handle<T>(handle), obj_(obj) {
+ HandleWrapper(T** obj, const MutableHandle<T>& handle)
+ : MutableHandle<T>(handle), obj_(obj) {
}
~HandleWrapper() {
- *obj_ = Handle<T>::Get();
+ *obj_ = MutableHandle<T>::Get();
}
private:
@@ -169,10 +175,10 @@ class PACKED(4) StackHandleScope FINAL : public HandleScope {
return references_storage_[i].AsMirrorPtr();
}
- Handle<mirror::Object> GetHandle(size_t i) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ MutableHandle<mirror::Object> GetHandle(size_t i) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
ALWAYS_INLINE {
DCHECK_LT(i, number_of_references_);
- return Handle<mirror::Object>(&references_storage_[i]);
+ return MutableHandle<mirror::Object>(&references_storage_[i]);
}
void SetReference(size_t i, mirror::Object* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
@@ -182,9 +188,9 @@ class PACKED(4) StackHandleScope FINAL : public HandleScope {
}
template<class T>
- Handle<T> NewHandle(T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ MutableHandle<T> NewHandle(T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
SetReference(pos_, object);
- Handle<T> h(GetHandle(pos_));
+ MutableHandle<T> h(GetHandle(pos_));
pos_++;
return h;
}
@@ -192,7 +198,7 @@ class PACKED(4) StackHandleScope FINAL : public HandleScope {
template<class T>
HandleWrapper<T> NewHandleWrapper(T** object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
SetReference(pos_, *object);
- Handle<T> h(GetHandle(pos_));
+ MutableHandle<T> h(GetHandle(pos_));
pos_++;
return HandleWrapper<T>(object, h);
}
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 2129c1b..9f08013 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -455,7 +455,7 @@ class CatchLocationFinder : public StackVisitor {
Thread* const self_;
StackHandleScope<1> handle_scope_;
Handle<mirror::Throwable>* exception_;
- Handle<mirror::ArtMethod> catch_method_;
+ MutableHandle<mirror::ArtMethod> catch_method_;
uint32_t catch_dex_pc_;
bool clear_exception_;
@@ -780,8 +780,8 @@ void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count)
}
// Helper function to deal with class loading in an unstarted runtime.
-static void UnstartedRuntimeFindClass(Thread* self, ConstHandle<mirror::String> className,
- ConstHandle<mirror::ClassLoader> class_loader, JValue* result,
+static void UnstartedRuntimeFindClass(Thread* self, Handle<mirror::String> className,
+ Handle<mirror::ClassLoader> class_loader, JValue* result,
const std::string& method_name, bool initialize_class,
bool abort_if_not_found)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
diff --git a/runtime/method_helper-inl.h b/runtime/method_helper-inl.h
index 9af835f..143f4bc 100644
--- a/runtime/method_helper-inl.h
+++ b/runtime/method_helper-inl.h
@@ -26,7 +26,9 @@
namespace art {
-inline bool MethodHelper::HasSameNameAndSignature(MethodHelper* other) {
+template <template <class T> class HandleKind>
+template <template <class T2> class HandleKind2>
+inline bool MethodHelperT<HandleKind>::HasSameNameAndSignature(MethodHelperT<HandleKind2>* other) {
const DexFile* dex_file = method_->GetDexFile();
const DexFile::MethodId& mid = dex_file->GetMethodId(GetMethod()->GetDexMethodIndex());
if (method_->GetDexCache() == other->method_->GetDexCache()) {
@@ -43,7 +45,9 @@ inline bool MethodHelper::HasSameNameAndSignature(MethodHelper* other) {
return dex_file->GetMethodSignature(mid) == other_dex_file->GetMethodSignature(other_mid);
}
-inline mirror::Class* MethodHelper::GetClassFromTypeIdx(uint16_t type_idx, bool resolve) {
+template <template <class T> class HandleKind>
+inline mirror::Class* MethodHelperT<HandleKind>::GetClassFromTypeIdx(uint16_t type_idx,
+ bool resolve) {
mirror::ArtMethod* method = GetMethod();
mirror::Class* type = method->GetDexCacheResolvedType(type_idx);
if (type == nullptr && resolve) {
@@ -53,7 +57,8 @@ inline mirror::Class* MethodHelper::GetClassFromTypeIdx(uint16_t type_idx, bool
return type;
}
-inline mirror::Class* MethodHelper::GetReturnType(bool resolve) {
+template <template <class T> class HandleKind>
+inline mirror::Class* MethodHelperT<HandleKind>::GetReturnType(bool resolve) {
mirror::ArtMethod* method = GetMethod();
const DexFile* dex_file = method->GetDexFile();
const DexFile::MethodId& method_id = dex_file->GetMethodId(method->GetDexMethodIndex());
@@ -62,7 +67,8 @@ inline mirror::Class* MethodHelper::GetReturnType(bool resolve) {
return GetClassFromTypeIdx(return_type_idx, resolve);
}
-inline mirror::String* MethodHelper::ResolveString(uint32_t string_idx) {
+template <template <class T> class HandleKind>
+inline mirror::String* MethodHelperT<HandleKind>::ResolveString(uint32_t string_idx) {
mirror::ArtMethod* method = GetMethod();
mirror::String* s = method->GetDexCacheStrings()->Get(string_idx);
if (UNLIKELY(s == nullptr)) {
diff --git a/runtime/method_helper.cc b/runtime/method_helper.cc
index d6f83a8..79c2b91 100644
--- a/runtime/method_helper.cc
+++ b/runtime/method_helper.cc
@@ -25,7 +25,8 @@
namespace art {
-mirror::String* MethodHelper::GetNameAsString(Thread* self) {
+template <template <class T> class HandleKind>
+mirror::String* MethodHelperT<HandleKind>::GetNameAsString(Thread* self) {
const DexFile* dex_file = method_->GetDexFile();
mirror::ArtMethod* method = method_->GetInterfaceMethodIfProxy();
uint32_t dex_method_idx = method->GetDexMethodIndex();
@@ -36,7 +37,10 @@ mirror::String* MethodHelper::GetNameAsString(Thread* self) {
dex_cache);
}
-bool MethodHelper::HasSameSignatureWithDifferentClassLoaders(MethodHelper* other) {
+template <template <class T> class HandleKind>
+template <template <class T2> class HandleKind2>
+bool MethodHelperT<HandleKind>::HasSameSignatureWithDifferentClassLoaders(
+ MethodHelperT<HandleKind2>* other) {
if (UNLIKELY(GetReturnType() != other->GetReturnType())) {
return false;
}
@@ -62,7 +66,8 @@ bool MethodHelper::HasSameSignatureWithDifferentClassLoaders(MethodHelper* other
return true;
}
-uint32_t MethodHelper::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile)
+template <template <class T> class HandleKind>
+uint32_t MethodHelperT<HandleKind>::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* method = GetMethod();
const DexFile* dexfile = method->GetDexFile();
@@ -102,8 +107,9 @@ uint32_t MethodHelper::FindDexMethodIndexInOtherDexFile(const DexFile& other_dex
return DexFile::kDexNoIndex;
}
-uint32_t MethodHelper::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile,
- uint32_t name_and_signature_idx)
+template <template <typename> class HandleKind>
+uint32_t MethodHelperT<HandleKind>::FindDexMethodIndexInOtherDexFile(
+ const DexFile& other_dexfile, uint32_t name_and_signature_idx)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::ArtMethod* method = GetMethod();
const DexFile* dexfile = method->GetDexFile();
@@ -133,4 +139,38 @@ uint32_t MethodHelper::FindDexMethodIndexInOtherDexFile(const DexFile& other_dex
return DexFile::kDexNoIndex;
}
+// Instantiate methods.
+template mirror::String* MethodHelperT<Handle>::GetNameAsString(Thread* self);
+
+template mirror::String* MethodHelperT<MutableHandle>::GetNameAsString(Thread* self);
+
+template
+uint32_t MethodHelperT<Handle>::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile);
+template
+uint32_t MethodHelperT<MutableHandle>::FindDexMethodIndexInOtherDexFile(
+ const DexFile& other_dexfile);
+
+template
+uint32_t MethodHelperT<Handle>::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile,
+ uint32_t name_and_signature_idx);
+template
+uint32_t MethodHelperT<MutableHandle>::FindDexMethodIndexInOtherDexFile(
+ const DexFile& other_dexfile, uint32_t name_and_signature_idx);
+
+template
+bool MethodHelperT<Handle>::HasSameSignatureWithDifferentClassLoaders<Handle>(
+ MethodHelperT<Handle>* other);
+
+template
+bool MethodHelperT<Handle>::HasSameSignatureWithDifferentClassLoaders<MutableHandle>(
+ MethodHelperT<MutableHandle>* other);
+
+template
+bool MethodHelperT<MutableHandle>::HasSameSignatureWithDifferentClassLoaders<Handle>(
+ MethodHelperT<Handle>* other);
+
+template
+bool MethodHelperT<MutableHandle>::HasSameSignatureWithDifferentClassLoaders<MutableHandle>(
+ MethodHelperT<MutableHandle>* other);
+
} // namespace art
diff --git a/runtime/method_helper.h b/runtime/method_helper.h
index 8150456..fe364d3 100644
--- a/runtime/method_helper.h
+++ b/runtime/method_helper.h
@@ -24,17 +24,11 @@
namespace art {
-class MethodHelper {
+template <template <class T> class HandleKind>
+class MethodHelperT {
public:
- explicit MethodHelper(Handle<mirror::ArtMethod> m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- : method_(m), shorty_(nullptr), shorty_len_(0) {
- SetMethod(m.Get());
- }
-
- void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- DCHECK(new_m != nullptr);
- SetMethod(new_m);
- shorty_ = nullptr;
+ explicit MethodHelperT(HandleKind<mirror::ArtMethod> m)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : method_(m), shorty_(nullptr), shorty_len_(0) {
}
mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -110,10 +104,12 @@ class MethodHelper {
return GetParamPrimitiveType(param) == Primitive::kPrimNot;
}
- ALWAYS_INLINE bool HasSameNameAndSignature(MethodHelper* other)
+ template <template <class T> class HandleKind2>
+ ALWAYS_INLINE bool HasSameNameAndSignature(MethodHelperT<HandleKind2>* other)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- bool HasSameSignatureWithDifferentClassLoaders(MethodHelper* other)
+ template <template <class T> class HandleKind2>
+ bool HasSameSignatureWithDifferentClassLoaders(MethodHelperT<HandleKind2>* other)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
mirror::Class* GetClassFromTypeIdx(uint16_t type_idx, bool resolve = true)
@@ -130,6 +126,33 @@ class MethodHelper {
uint32_t name_and_signature_idx)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ protected:
+ HandleKind<mirror::ArtMethod> method_;
+
+ const char* shorty_;
+ uint32_t shorty_len_;
+
+ private:
+ template <template <class T2> class HandleKind2> friend class MethodHelperT;
+
+ DISALLOW_COPY_AND_ASSIGN(MethodHelperT);
+};
+
+class MethodHelper : public MethodHelperT<Handle> {
+ using MethodHelperT<Handle>::MethodHelperT;
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MethodHelper);
+};
+
+class MutableMethodHelper : public MethodHelperT<MutableHandle> {
+ using MethodHelperT<MutableHandle>::MethodHelperT;
+ public:
+ void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ DCHECK(new_m != nullptr);
+ SetMethod(new_m);
+ shorty_ = nullptr;
+ }
+
private:
// Set the method_ field, for proxy methods looking up the interface method via the resolved
// methods table.
@@ -137,11 +160,7 @@ class MethodHelper {
method_.Assign(method);
}
- Handle<mirror::ArtMethod> method_;
- const char* shorty_;
- uint32_t shorty_len_;
-
- DISALLOW_COPY_AND_ASSIGN(MethodHelper);
+ DISALLOW_COPY_AND_ASSIGN(MutableMethodHelper);
};
} // namespace art
diff --git a/runtime/mirror/array.cc b/runtime/mirror/array.cc
index f54af85..4535f6c 100644
--- a/runtime/mirror/array.cc
+++ b/runtime/mirror/array.cc
@@ -94,7 +94,7 @@ Array* Array::CreateMultiArray(Thread* self, Handle<Class> element_class,
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
mirror::Class* element_class_ptr = element_class.Get();
StackHandleScope<1> hs(self);
- Handle<mirror::Class> array_class(
+ MutableHandle<mirror::Class> array_class(
hs.NewHandle(class_linker->FindArrayClass(self, &element_class_ptr)));
if (UNLIKELY(array_class.Get() == nullptr)) {
CHECK(self->IsExceptionPending());
diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc
index 131f5d6..159d04d 100644
--- a/runtime/mirror/art_method.cc
+++ b/runtime/mirror/art_method.cc
@@ -143,7 +143,7 @@ ArtMethod* ArtMethod::FindOverriddenMethod() {
} else {
StackHandleScope<2> hs(Thread::Current());
MethodHelper mh(hs.NewHandle(this));
- MethodHelper interface_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
+ MutableMethodHelper interface_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
IfTable* iftable = GetDeclaringClass()->GetIfTable();
for (size_t i = 0; i < iftable->Count() && result == NULL; i++) {
Class* interface = iftable->GetInterface(i);
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index e7d8163..0ee8fa8 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -760,7 +760,7 @@ uint16_t Class::GetDirectInterfaceTypeIdx(uint32_t idx) {
return GetInterfaceTypeList()->GetTypeItem(idx).type_idx_;
}
-mirror::Class* Class::GetDirectInterface(Thread* self, ConstHandle<mirror::Class> klass,
+mirror::Class* Class::GetDirectInterface(Thread* self, Handle<mirror::Class> klass,
uint32_t idx) {
DCHECK(klass.Get() != nullptr);
DCHECK(!klass->IsPrimitive());
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index aad678f..4a8d6dc 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -65,7 +65,7 @@
namespace art {
struct ClassOffsets;
-template<class T> class ConstHandle;
+template<class T> class Handle;
template<class T> class Handle;
class Signature;
class StringPiece;
@@ -990,7 +990,7 @@ class MANAGED Class FINAL : public Object {
uint16_t GetDirectInterfaceTypeIdx(uint32_t idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- static mirror::Class* GetDirectInterface(Thread* self, ConstHandle<mirror::Class> klass,
+ static mirror::Class* GetDirectInterface(Thread* self, Handle<mirror::Class> klass,
uint32_t idx)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index aa181ee..1290a3d 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -161,7 +161,7 @@ TEST_F(ObjectTest, AllocArray) {
ScopedObjectAccess soa(Thread::Current());
Class* c = class_linker_->FindSystemClass(soa.Self(), "[I");
StackHandleScope<1> hs(soa.Self());
- Handle<Array> a(
+ MutableHandle<Array> a(
hs.NewHandle(Array::Alloc<true>(soa.Self(), c, 1, c->GetComponentSize(),
Runtime::Current()->GetHeap()->GetCurrentAllocator())));
EXPECT_TRUE(c == a->GetClass());
@@ -184,7 +184,7 @@ TEST_F(ObjectTest, AllocArray_FillUsable) {
ScopedObjectAccess soa(Thread::Current());
Class* c = class_linker_->FindSystemClass(soa.Self(), "[B");
StackHandleScope<1> hs(soa.Self());
- Handle<Array> a(
+ MutableHandle<Array> a(
hs.NewHandle(Array::Alloc<true>(soa.Self(), c, 1, c->GetComponentSize(),
Runtime::Current()->GetHeap()->GetCurrentAllocator(), true)));
EXPECT_TRUE(c == a->GetClass());
@@ -287,7 +287,7 @@ TEST_F(ObjectTest, CreateMultiArray) {
StackHandleScope<2> hs(soa.Self());
Handle<Class> c(hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "I")));
- Handle<IntArray> dims(hs.NewHandle(IntArray::Alloc(soa.Self(), 1)));
+ MutableHandle<IntArray> dims(hs.NewHandle(IntArray::Alloc(soa.Self(), 1)));
dims->Set<false>(0, 1);
Array* multi = Array::CreateMultiArray(soa.Self(), c, dims);
EXPECT_TRUE(multi->GetClass() == class_linker_->FindSystemClass(soa.Self(), "[I"));
@@ -485,8 +485,8 @@ TEST_F(ObjectTest, DescriptorCompare) {
ArtMethod* m4_2 = klass2->GetVirtualMethod(3);
EXPECT_STREQ(m4_2->GetName(), "m4");
- MethodHelper mh(hs.NewHandle(m1_1));
- MethodHelper mh2(hs.NewHandle(m1_2));
+ MutableMethodHelper mh(hs.NewHandle(m1_1));
+ MutableMethodHelper mh2(hs.NewHandle(m1_2));
EXPECT_TRUE(mh.HasSameNameAndSignature(&mh2));
EXPECT_TRUE(mh2.HasSameNameAndSignature(&mh));
diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc
index af24368..704e041 100644
--- a/runtime/monitor_test.cc
+++ b/runtime/monitor_test.cc
@@ -58,7 +58,7 @@ class MonitorTest : public CommonRuntimeTest {
static const size_t kMaxHandles = 1000000; // Use arbitrary large amount for now.
static void FillHeap(Thread* self, ClassLinker* class_linker,
std::unique_ptr<StackHandleScope<kMaxHandles>>* hsp,
- std::vector<Handle<mirror::Object>>* handles)
+ std::vector<MutableHandle<mirror::Object>>* handles)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Runtime::Current()->GetHeap()->SetIdealFootprint(1 * GB);
@@ -73,7 +73,7 @@ static void FillHeap(Thread* self, ClassLinker* class_linker,
// Start allocating with 128K
size_t length = 128 * KB / 4;
while (length > 10) {
- Handle<mirror::Object> h((*hsp)->NewHandle<mirror::Object>(
+ MutableHandle<mirror::Object> h((*hsp)->NewHandle<mirror::Object>(
mirror::ObjectArray<mirror::Object>::Alloc(self, ca.Get(), length / 4)));
if (self->IsExceptionPending() || h.Get() == nullptr) {
self->ClearException();
@@ -92,7 +92,7 @@ static void FillHeap(Thread* self, ClassLinker* class_linker,
// Allocate simple objects till it fails.
while (!self->IsExceptionPending()) {
- Handle<mirror::Object> h = (*hsp)->NewHandle<mirror::Object>(c->AllocObject(self));
+ MutableHandle<mirror::Object> h = (*hsp)->NewHandle<mirror::Object>(c->AllocObject(self));
if (!self->IsExceptionPending() && h.Get() != nullptr) {
handles->push_back(h);
}
@@ -307,7 +307,7 @@ static void CommonWaitSetup(MonitorTest* test, ClassLinker* class_linker, uint64
// Fill the heap.
std::unique_ptr<StackHandleScope<kMaxHandles>> hsp;
- std::vector<Handle<mirror::Object>> handles;
+ std::vector<MutableHandle<mirror::Object>> handles;
{
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
diff --git a/runtime/object_lock.cc b/runtime/object_lock.cc
index a2668ec..f7accc0 100644
--- a/runtime/object_lock.cc
+++ b/runtime/object_lock.cc
@@ -22,7 +22,7 @@
namespace art {
template <typename T>
-ObjectLock<T>::ObjectLock(Thread* self, ConstHandle<T> object) : self_(self), obj_(object) {
+ObjectLock<T>::ObjectLock(Thread* self, Handle<T> object) : self_(self), obj_(object) {
CHECK(object.Get() != nullptr);
obj_->MonitorEnter(self_);
}
diff --git a/runtime/object_lock.h b/runtime/object_lock.h
index 38690bc..acddc03 100644
--- a/runtime/object_lock.h
+++ b/runtime/object_lock.h
@@ -28,7 +28,7 @@ class Thread;
template <typename T>
class ObjectLock {
public:
- ObjectLock(Thread* self, ConstHandle<T> object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ ObjectLock(Thread* self, Handle<T> object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
~ObjectLock() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -40,7 +40,7 @@ class ObjectLock {
private:
Thread* const self_;
- ConstHandle<T> const obj_;
+ Handle<T> const obj_;
DISALLOW_COPY_AND_ASSIGN(ObjectLock);
};
diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc
index d977ce9..1eded62 100644
--- a/runtime/proxy_test.cc
+++ b/runtime/proxy_test.cc
@@ -183,7 +183,8 @@ TEST_F(ProxyTest, ProxyFieldHelper) {
ASSERT_TRUE(throwsFieldClass.Get() != nullptr);
// Test "Class[] interfaces" field.
- FieldHelper fh(hs.NewHandle(static_fields->Get(0)));
+ MutableHandle<mirror::ArtField> fhandle = hs.NewHandle(static_fields->Get(0));
+ FieldHelper fh(fhandle);
EXPECT_EQ("interfaces", std::string(fh.GetField()->GetName()));
EXPECT_EQ("[Ljava/lang/Class;", std::string(fh.GetField()->GetTypeDescriptor()));
EXPECT_EQ(interfacesFieldClass.Get(), fh.GetType());
@@ -191,12 +192,13 @@ TEST_F(ProxyTest, ProxyFieldHelper) {
EXPECT_FALSE(fh.GetField()->IsPrimitiveType());
// Test "Class[][] throws" field.
- fh.ChangeField(static_fields->Get(1));
- EXPECT_EQ("throws", std::string(fh.GetField()->GetName()));
- EXPECT_EQ("[[Ljava/lang/Class;", std::string(fh.GetField()->GetTypeDescriptor()));
- EXPECT_EQ(throwsFieldClass.Get(), fh.GetType());
- EXPECT_EQ("L$Proxy1234;", std::string(fh.GetDeclaringClassDescriptor()));
- EXPECT_FALSE(fh.GetField()->IsPrimitiveType());
+ fhandle.Assign(static_fields->Get(1));
+ FieldHelper fh2(fhandle);
+ EXPECT_EQ("throws", std::string(fh2.GetField()->GetName()));
+ EXPECT_EQ("[[Ljava/lang/Class;", std::string(fh2.GetField()->GetTypeDescriptor()));
+ EXPECT_EQ(throwsFieldClass.Get(), fh2.GetType());
+ EXPECT_EQ("L$Proxy1234;", std::string(fh2.GetDeclaringClassDescriptor()));
+ EXPECT_FALSE(fh2.GetField()->IsPrimitiveType());
}
} // namespace art
diff --git a/runtime/thread.cc b/runtime/thread.cc
index d4ac02b..c54bebe 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -446,7 +446,7 @@ void Thread::CreatePeer(const char* name, bool as_daemon, jobject thread_group)
ScopedObjectAccess soa(self);
StackHandleScope<1> hs(self);
- Handle<mirror::String> peer_thread_name(hs.NewHandle(GetThreadName(soa)));
+ MutableHandle<mirror::String> peer_thread_name(hs.NewHandle(GetThreadName(soa)));
if (peer_thread_name.Get() == nullptr) {
// The Thread constructor should have set the Thread.name to a
// non-null value. However, because we can run without code
diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc
index 8c37489..432a2fe 100644
--- a/runtime/transaction_test.cc
+++ b/runtime/transaction_test.cc
@@ -460,7 +460,7 @@ TEST_F(TransactionTest, BlacklistedClass) {
// Load and verify java.lang.ExceptionInInitializerError and java.lang.InternalError which will
// be thrown by class initialization due to native call.
- Handle<mirror::Class> h_klass(
+ MutableHandle<mirror::Class> h_klass(
hs.NewHandle(class_linker_->FindSystemClass(soa.Self(),
"Ljava/lang/ExceptionInInitializerError;")));
ASSERT_TRUE(h_klass.Get() != nullptr);
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 1502978..f241281 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -127,8 +127,8 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self,
MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self,
const DexFile* dex_file,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def,
bool allow_soft_failures,
std::string* error) {
@@ -250,11 +250,11 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(Thread* self,
MethodVerifier::FailureKind MethodVerifier::VerifyMethod(Thread* self, uint32_t method_idx,
const DexFile* dex_file,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def,
const DexFile::CodeItem* code_item,
- ConstHandle<mirror::ArtMethod> method,
+ Handle<mirror::ArtMethod> method,
uint32_t method_access_flags,
bool allow_soft_failures,
bool need_precise_constants) {
@@ -299,11 +299,11 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(Thread* self, uint32_t
MethodVerifier* MethodVerifier::VerifyMethodAndDump(Thread* self, std::ostream& os, uint32_t dex_method_idx,
const DexFile* dex_file,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def,
const DexFile::CodeItem* code_item,
- ConstHandle<mirror::ArtMethod> method,
+ Handle<mirror::ArtMethod> method,
uint32_t method_access_flags) {
MethodVerifier* verifier = new MethodVerifier(self, dex_file, dex_cache, class_loader,
class_def, code_item, dex_method_idx, method,
@@ -317,11 +317,11 @@ MethodVerifier* MethodVerifier::VerifyMethodAndDump(Thread* self, std::ostream&
}
MethodVerifier::MethodVerifier(Thread* self,
- const DexFile* dex_file, ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ const DexFile* dex_file, Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def,
const DexFile::CodeItem* code_item, uint32_t dex_method_idx,
- ConstHandle<mirror::ArtMethod> method, uint32_t method_access_flags,
+ Handle<mirror::ArtMethod> method, uint32_t method_access_flags,
bool can_load_classes, bool allow_soft_failures,
bool need_precise_constants, bool verify_to_dump)
: self_(self),
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index 9fb19d3..87acb20 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -144,19 +144,19 @@ class MethodVerifier {
std::string* error)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static FailureKind VerifyClass(Thread* self, const DexFile* dex_file,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def,
bool allow_soft_failures, std::string* error)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static MethodVerifier* VerifyMethodAndDump(Thread* self, std::ostream& os, uint32_t method_idx,
const DexFile* dex_file,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def,
const DexFile::CodeItem* code_item,
- ConstHandle<mirror::ArtMethod> method,
+ Handle<mirror::ArtMethod> method,
uint32_t method_access_flags)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -206,10 +206,10 @@ class MethodVerifier {
return can_load_classes_;
}
- MethodVerifier(Thread* self, const DexFile* dex_file, ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader, const DexFile::ClassDef* class_def,
+ MethodVerifier(Thread* self, const DexFile* dex_file, Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader, const DexFile::ClassDef* class_def,
const DexFile::CodeItem* code_item, uint32_t method_idx,
- ConstHandle<mirror::ArtMethod> method,
+ Handle<mirror::ArtMethod> method,
uint32_t access_flags, bool can_load_classes, bool allow_soft_failures,
bool need_precise_constants) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
: MethodVerifier(self, dex_file, dex_cache, class_loader, class_def, code_item, method_idx,
@@ -245,10 +245,10 @@ class MethodVerifier {
private:
// Private constructor for dumping.
- MethodVerifier(Thread* self, const DexFile* dex_file, ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader, const DexFile::ClassDef* class_def,
+ MethodVerifier(Thread* self, const DexFile* dex_file, Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader, const DexFile::ClassDef* class_def,
const DexFile::CodeItem* code_item, uint32_t method_idx,
- ConstHandle<mirror::ArtMethod> method, uint32_t access_flags,
+ Handle<mirror::ArtMethod> method, uint32_t access_flags,
bool can_load_classes, bool allow_soft_failures, bool need_precise_constants,
bool verify_to_dump)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -271,11 +271,11 @@ class MethodVerifier {
* for code flow problems.
*/
static FailureKind VerifyMethod(Thread* self, uint32_t method_idx, const DexFile* dex_file,
- ConstHandle<mirror::DexCache> dex_cache,
- ConstHandle<mirror::ClassLoader> class_loader,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
const DexFile::ClassDef* class_def_idx,
const DexFile::CodeItem* code_item,
- ConstHandle<mirror::ArtMethod> method, uint32_t method_access_flags,
+ Handle<mirror::ArtMethod> method, uint32_t method_access_flags,
bool allow_soft_failures, bool need_precise_constants)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -661,14 +661,14 @@ class MethodVerifier {
const uint32_t dex_method_idx_; // The method we're working on.
// Its object representation if known.
- ConstHandle<mirror::ArtMethod> mirror_method_ GUARDED_BY(Locks::mutator_lock_);
+ Handle<mirror::ArtMethod> mirror_method_ GUARDED_BY(Locks::mutator_lock_);
const uint32_t method_access_flags_; // Method's access flags.
const RegType* return_type_; // Lazily computed return type of the method.
const DexFile* const dex_file_; // The dex file containing the method.
// The dex_cache for the declaring class of the method.
- ConstHandle<mirror::DexCache> dex_cache_ GUARDED_BY(Locks::mutator_lock_);
+ Handle<mirror::DexCache> dex_cache_ GUARDED_BY(Locks::mutator_lock_);
// The class loader for the declaring class of the method.
- ConstHandle<mirror::ClassLoader> class_loader_ GUARDED_BY(Locks::mutator_lock_);
+ Handle<mirror::ClassLoader> class_loader_ GUARDED_BY(Locks::mutator_lock_);
const DexFile::ClassDef* const class_def_; // The class def of the declaring class of the method.
const DexFile::CodeItem* const code_item_; // The code item containing the code for the method.
const RegType* declaring_class_; // Lazily computed reg type of the method's declaring class.