diff options
author | Brian Carlstrom <bdc@google.com> | 2013-07-30 01:26:50 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2013-08-13 18:09:46 -0700 |
commit | ea46f950e7a51585db293cd7f047de190a482414 (patch) | |
tree | 9dddc8073547a2dcb58a19e1728932a89cb149c3 /runtime | |
parent | 5e3572709b5a5d59957f835db4f73760ecef08da (diff) | |
download | art-ea46f950e7a51585db293cd7f047de190a482414.zip art-ea46f950e7a51585db293cd7f047de190a482414.tar.gz art-ea46f950e7a51585db293cd7f047de190a482414.tar.bz2 |
Refactor java.lang.reflect implementation
Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.
Move to ArtMethod/Field instead of AbstractMethod/Field and have
java.lang.reflect APIs delegate to ArtMethod/ArtField.
Bug: 10014286.
Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
Diffstat (limited to 'runtime')
118 files changed, 1879 insertions, 1915 deletions
diff --git a/runtime/Android.mk b/runtime/Android.mk index 69e13e5..b34abe4 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -78,11 +78,11 @@ LIBART_COMMON_SRC_FILES := \ locks.cc \ mem_map.cc \ memory_region.cc \ - mirror/abstract_method.cc \ + mirror/art_field.cc \ + mirror/art_method.cc \ mirror/array.cc \ mirror/class.cc \ mirror/dex_cache.cc \ - mirror/field.cc \ mirror/object.cc \ mirror/stack_trace_element.cc \ mirror/string.cc \ diff --git a/runtime/arch/arm/context_arm.cc b/runtime/arch/arm/context_arm.cc index 6b9538e..102e126 100644 --- a/runtime/arch/arm/context_arm.cc +++ b/runtime/arch/arm/context_arm.cc @@ -16,7 +16,7 @@ #include "context_arm.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" #include "thread.h" @@ -41,7 +41,7 @@ void ArmContext::Reset() { } void ArmContext::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); uint32_t fp_core_spills = method->GetFpSpillMask(); size_t spill_count = __builtin_popcount(core_spills); diff --git a/runtime/arch/arm/entrypoints_init_arm.cc b/runtime/arch/arm/entrypoints_init_arm.cc index 810a683..9e6902d 100644 --- a/runtime/arch/arm/entrypoints_init_arm.cc +++ b/runtime/arch/arm/entrypoints_init_arm.cc @@ -31,8 +31,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -112,8 +112,8 @@ extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index a78e5ee..b957708 100644 --- a/runtime/arch/mips/context_mips.cc +++ b/runtime/arch/mips/context_mips.cc @@ -16,7 +16,7 @@ #include "context_mips.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" @@ -40,7 +40,7 @@ void MipsContext::Reset() { } void MipsContext::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); uint32_t fp_core_spills = method->GetFpSpillMask(); size_t spill_count = __builtin_popcount(core_spills); diff --git a/runtime/arch/mips/entrypoints_init_mips.cc b/runtime/arch/mips/entrypoints_init_mips.cc index a0d3995..40d7cd9 100644 --- a/runtime/arch/mips/entrypoints_init_mips.cc +++ b/runtime/arch/mips/entrypoints_init_mips.cc @@ -30,8 +30,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -113,8 +113,8 @@ extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index c728ae9..66a51f7 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -16,7 +16,7 @@ #include "context_x86.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" @@ -36,7 +36,7 @@ void X86Context::Reset() { } void X86Context::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); size_t spill_count = __builtin_popcount(core_spills); DCHECK_EQ(method->GetFpSpillMask(), 0u); diff --git a/runtime/arch/x86/entrypoints_init_x86.cc b/runtime/arch/x86/entrypoints_init_x86.cc index 9b54d55..abc2990 100644 --- a/runtime/arch/x86/entrypoints_init_x86.cc +++ b/runtime/arch/x86/entrypoints_init_x86.cc @@ -29,8 +29,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -95,8 +95,8 @@ extern "C" int32_t art_quick_string_compareto(void*, void*); extern "C" void* art_quick_memcpy(void*, const void*, size_t); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc index 073d67b..6a7ceee 100644 --- a/runtime/check_jni.cc +++ b/runtime/check_jni.cc @@ -24,9 +24,9 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -44,7 +44,7 @@ namespace art { static void JniAbort(const char* jni_function_name, const char* msg) { Thread* self = Thread::Current(); ScopedObjectAccess soa(self); - mirror::AbstractMethod* current_method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* current_method = self->GetCurrentMethod(NULL); std::ostringstream os; os << "JNI DETECTED ERROR IN APPLICATION: " << msg; @@ -131,7 +131,7 @@ static const char* gBuiltInPrefixes[] = { NULL }; -static bool ShouldTrace(JavaVMExt* vm, const mirror::AbstractMethod* method) +static bool ShouldTrace(JavaVMExt* vm, const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // If both "-Xcheck:jni" and "-Xjnitrace:" are enabled, we print trace messages // when a native method that matches the -Xjnitrace argument calls a JNI function @@ -204,7 +204,7 @@ class ScopedCheck { */ void CheckFieldType(jobject java_object, jfieldID fid, char prim, bool isStatic) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* f = CheckFieldID(fid); + mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -259,7 +259,7 @@ class ScopedCheck { return; } - mirror::Field* f = CheckFieldID(fid); + mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -286,7 +286,7 @@ class ScopedCheck { */ void CheckSig(jmethodID mid, const char* expectedType, bool isStatic) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = CheckMethodID(mid); + mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -313,7 +313,7 @@ class ScopedCheck { void CheckStaticFieldID(jclass java_class, jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::Class* c = soa_.Decode<mirror::Class*>(java_class); - const mirror::Field* f = CheckFieldID(fid); + const mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -334,7 +334,7 @@ class ScopedCheck { */ void CheckStaticMethod(jclass java_class, jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::AbstractMethod* m = CheckMethodID(mid); + const mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -354,7 +354,7 @@ class ScopedCheck { */ void CheckVirtualMethod(jobject java_object, jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::AbstractMethod* m = CheckMethodID(mid); + const mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -404,7 +404,7 @@ class ScopedCheck { void Check(bool entry, const char* fmt0, ...) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { va_list ap; - const mirror::AbstractMethod* traceMethod = NULL; + const mirror::ArtMethod* traceMethod = NULL; if (has_method_ && (!soa_.Vm()->trace.empty() || VLOG_IS_ON(third_party_jni))) { // We need to guard some of the invocation interface's calls: a bad caller might // use DetachCurrentThread or GetEnv on a thread that's not yet attached. @@ -477,7 +477,7 @@ class ScopedCheck { } } else if (ch == 'f') { // jfieldID jfieldID fid = va_arg(ap, jfieldID); - mirror::Field* f = reinterpret_cast<mirror::Field*>(fid); + mirror::ArtField* f = reinterpret_cast<mirror::ArtField*>(fid); msg += PrettyField(f); if (!entry) { StringAppendF(&msg, " (%p)", fid); @@ -490,7 +490,7 @@ class ScopedCheck { StringAppendF(&msg, "%d", i); } else if (ch == 'm') { // jmethodID jmethodID mid = va_arg(ap, jmethodID); - mirror::AbstractMethod* m = reinterpret_cast<mirror::AbstractMethod*>(mid); + mirror::ArtMethod* m = reinterpret_cast<mirror::ArtMethod*>(mid); msg += PrettyMethod(m); if (!entry) { StringAppendF(&msg, " (%p)", mid); @@ -700,13 +700,13 @@ class ScopedCheck { } } - mirror::Field* CheckFieldID(jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtField* CheckFieldID(jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (fid == NULL) { JniAbortF(function_name_, "jfieldID was NULL"); return NULL; } - mirror::Field* f = soa_.DecodeField(fid); - if (!Runtime::Current()->GetHeap()->IsHeapAddress(f) || !f->IsField()) { + mirror::ArtField* f = soa_.DecodeField(fid); + if (!Runtime::Current()->GetHeap()->IsHeapAddress(f) || !f->IsArtField()) { Runtime::Current()->GetHeap()->DumpSpaces(); JniAbortF(function_name_, "invalid jfieldID: %p", fid); return NULL; @@ -714,13 +714,13 @@ class ScopedCheck { return f; } - mirror::AbstractMethod* CheckMethodID(jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtMethod* CheckMethodID(jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (mid == NULL) { JniAbortF(function_name_, "jmethodID was NULL"); return NULL; } - mirror::AbstractMethod* m = soa_.DecodeMethod(mid); - if (!Runtime::Current()->GetHeap()->IsHeapAddress(m) || !m->IsMethod()) { + mirror::ArtMethod* m = soa_.DecodeMethod(mid); + if (!Runtime::Current()->GetHeap()->IsHeapAddress(m) || !m->IsArtMethod()) { Runtime::Current()->GetHeap()->DumpSpaces(); JniAbortF(function_name_, "invalid jmethodID: %p", mid); return NULL; diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 4d01b66..ad568b1 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -19,15 +19,15 @@ #include "class_linker.h" +#include "mirror/art_field.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" #include "mirror/iftable.h" #include "mirror/object_array.h" namespace art { inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { mirror::String* resolved_string = referrer->GetDexCacheStrings()->Get(string_idx); if (UNLIKELY(resolved_string == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -39,7 +39,7 @@ inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, } inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { mirror::Class* resolved_type = referrer->GetDexCacheResolvedTypes()->Get(type_idx); if (UNLIKELY(resolved_type == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -51,7 +51,7 @@ inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, return resolved_type; } -inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror::Field* referrer) { +inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); mirror::DexCache* dex_cache = declaring_class->GetDexCache(); mirror::Class* resolved_type = dex_cache->GetResolvedType(type_idx); @@ -63,10 +63,10 @@ inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror:: return resolved_type; } -inline mirror::AbstractMethod* ClassLinker::ResolveMethod(uint32_t method_idx, - const mirror::AbstractMethod* referrer, - InvokeType type) { - mirror::AbstractMethod* resolved_method = +inline mirror::ArtMethod* ClassLinker::ResolveMethod(uint32_t method_idx, + const mirror::ArtMethod* referrer, + InvokeType type) { + mirror::ArtMethod* resolved_method = referrer->GetDexCacheResolvedMethods()->Get(method_idx); if (UNLIKELY(resolved_method == NULL || resolved_method->IsRuntimeMethod())) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -78,10 +78,10 @@ inline mirror::AbstractMethod* ClassLinker::ResolveMethod(uint32_t method_idx, return resolved_method; } -inline mirror::Field* ClassLinker::ResolveField(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - bool is_static) { - mirror::Field* resolved_field = +inline mirror::ArtField* ClassLinker::ResolveField(uint32_t field_idx, + const mirror::ArtMethod* referrer, + bool is_static) { + mirror::ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx); if (UNLIKELY(resolved_field == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -109,16 +109,10 @@ inline mirror::ObjectArray<mirror::String>* ClassLinker::AllocStringArray(Thread length); } -inline mirror::ObjectArray<mirror::AbstractMethod>* ClassLinker::AllocAbstractMethodArray(Thread* self, - size_t length) { - return mirror::ObjectArray<mirror::AbstractMethod>::Alloc(self, - GetClassRoot(kJavaLangReflectAbstractMethodArrayClass), length); -} - -inline mirror::ObjectArray<mirror::AbstractMethod>* ClassLinker::AllocMethodArray(Thread* self, - size_t length) { - return mirror::ObjectArray<mirror::AbstractMethod>::Alloc(self, - GetClassRoot(kJavaLangReflectMethodArrayClass), length); +inline mirror::ObjectArray<mirror::ArtMethod>* ClassLinker::AllocArtMethodArray(Thread* self, + size_t length) { + return mirror::ObjectArray<mirror::ArtMethod>::Alloc(self, + GetClassRoot(kJavaLangReflectArtMethodArrayClass), length); } inline mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) { @@ -126,11 +120,11 @@ inline mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) mirror::IfTable::Alloc(self, GetClassRoot(kObjectArrayClass), ifcount * mirror::IfTable::kMax)); } -inline mirror::ObjectArray<mirror::Field>* ClassLinker::AllocFieldArray(Thread* self, - size_t length) { - return mirror::ObjectArray<mirror::Field>::Alloc(self, - GetClassRoot(kJavaLangReflectFieldArrayClass), - length); +inline mirror::ObjectArray<mirror::ArtField>* ClassLinker::AllocArtFieldArray(Thread* self, + size_t length) { + return mirror::ObjectArray<mirror::ArtField>::Alloc(self, + GetClassRoot(kJavaLangReflectArtFieldArrayClass), + length); } inline mirror::Class* ClassLinker::GetClassRoot(ClassRoot class_root) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index c7a8f7e..1e21736 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -43,14 +43,13 @@ #include "leb128.h" #include "oat.h" #include "oat_file.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" #include "mirror/iftable-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" @@ -145,15 +144,12 @@ const char* ClassLinker::class_roots_descriptors_[] = { "Ljava/lang/String;", "Ljava/lang/DexCache;", "Ljava/lang/ref/Reference;", - "Ljava/lang/reflect/Constructor;", - "Ljava/lang/reflect/Field;", - "Ljava/lang/reflect/AbstractMethod;", - "Ljava/lang/reflect/Method;", + "Ljava/lang/reflect/ArtField;", + "Ljava/lang/reflect/ArtMethod;", "Ljava/lang/reflect/Proxy;", "[Ljava/lang/String;", - "[Ljava/lang/reflect/AbstractMethod;", - "[Ljava/lang/reflect/Field;", - "[Ljava/lang/reflect/Method;", + "[Ljava/lang/reflect/ArtField;", + "[Ljava/lang/reflect/ArtMethod;", "Ljava/lang/ClassLoader;", "Ljava/lang/Throwable;", "Ljava/lang/ClassNotFoundException;", @@ -292,56 +288,38 @@ void ClassLinker::InitFromCompiler(const std::vector<const DexFile*>& boot_class java_lang_DexCache->SetStatus(mirror::Class::kStatusResolved); // Constructor, Field, Method, and AbstractMethod are necessary so that FindClass can link members. - SirtRef<mirror::Class> java_lang_reflect_Field(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::FieldClass))); - CHECK(java_lang_reflect_Field.get() != NULL); - java_lang_reflect_Field->SetObjectSize(sizeof(mirror::Field)); - SetClassRoot(kJavaLangReflectField, java_lang_reflect_Field.get()); - java_lang_reflect_Field->SetStatus(mirror::Class::kStatusResolved); - mirror::Field::SetClass(java_lang_reflect_Field.get()); - - SirtRef<mirror::Class> java_lang_reflect_AbstractMethod(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_AbstractMethod.get() != NULL); - java_lang_reflect_AbstractMethod->SetObjectSize(sizeof(mirror::AbstractMethod)); - SetClassRoot(kJavaLangReflectAbstractMethod, java_lang_reflect_AbstractMethod.get()); - java_lang_reflect_AbstractMethod->SetStatus(mirror::Class::kStatusResolved); - - SirtRef<mirror::Class> java_lang_reflect_Constructor(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_Constructor.get() != NULL); - java_lang_reflect_Constructor->SetObjectSize(sizeof(mirror::Constructor)); - java_lang_reflect_Constructor->SetSuperClass(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectConstructor, java_lang_reflect_Constructor.get()); - java_lang_reflect_Constructor->SetStatus(mirror::Class::kStatusResolved); - - SirtRef<mirror::Class> java_lang_reflect_Method(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_Method.get() != NULL); - java_lang_reflect_Method->SetObjectSize(sizeof(mirror::Method)); - java_lang_reflect_Method->SetSuperClass(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectMethod, java_lang_reflect_Method.get()); - java_lang_reflect_Method->SetStatus(mirror::Class::kStatusResolved); - - mirror::AbstractMethod::SetClasses(java_lang_reflect_Constructor.get(), - java_lang_reflect_Method.get()); + SirtRef<mirror::Class> java_lang_reflect_ArtField(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::ArtFieldClass))); + CHECK(java_lang_reflect_ArtField.get() != NULL); + java_lang_reflect_ArtField->SetObjectSize(sizeof(mirror::ArtField)); + SetClassRoot(kJavaLangReflectArtField, java_lang_reflect_ArtField.get()); + java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusResolved); + mirror::ArtField::SetClass(java_lang_reflect_ArtField.get()); + + SirtRef<mirror::Class> java_lang_reflect_ArtMethod(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::ArtMethodClass))); + CHECK(java_lang_reflect_ArtMethod.get() != NULL); + java_lang_reflect_ArtMethod->SetObjectSize(sizeof(mirror::ArtMethod)); + SetClassRoot(kJavaLangReflectArtMethod, java_lang_reflect_ArtMethod.get()); + java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusResolved); + + mirror::ArtMethod::SetClass(java_lang_reflect_ArtMethod.get()); // Set up array classes for string, field, method - SirtRef<mirror::Class> object_array_string(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); + SirtRef<mirror::Class> object_array_string(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); object_array_string->SetComponentType(java_lang_String.get()); SetClassRoot(kJavaLangStringArrayClass, object_array_string.get()); - SirtRef<mirror::Class> object_array_abstract_method(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_abstract_method->SetComponentType(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectAbstractMethodArrayClass, object_array_abstract_method.get()); + SirtRef<mirror::Class> object_array_art_method(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); + object_array_art_method->SetComponentType(java_lang_reflect_ArtMethod.get()); + SetClassRoot(kJavaLangReflectArtMethodArrayClass, object_array_art_method.get()); - SirtRef<mirror::Class> object_array_field(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_field->SetComponentType(java_lang_reflect_Field.get()); - SetClassRoot(kJavaLangReflectFieldArrayClass, object_array_field.get()); - - SirtRef<mirror::Class> object_array_method(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_method->SetComponentType(java_lang_reflect_Method.get()); - SetClassRoot(kJavaLangReflectMethodArrayClass, object_array_method.get()); + SirtRef<mirror::Class> object_array_art_field(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); + object_array_art_field->SetComponentType(java_lang_reflect_ArtField.get()); + SetClassRoot(kJavaLangReflectArtFieldArrayClass, object_array_art_field.get()); // Setup boot_class_path_ and register class_path now that we can use AllocObjectArray to create // DexCache instances. Needs to be after String, Field, Method arrays since AllocDexCache uses @@ -422,42 +400,29 @@ void ClassLinker::InitFromCompiler(const std::vector<const DexFile*>& boot_class kh.ChangeClass(object_array_class.get()); CHECK_EQ(java_lang_Cloneable, kh.GetDirectInterface(0)); CHECK_EQ(java_io_Serializable, kh.GetDirectInterface(1)); - // Run Class, Constructor, Field, and Method through FindSystemClass. This initializes their + // Run Class, ArtField, and ArtMethod through FindSystemClass. This initializes their // dex_cache_ fields and register them in classes_. mirror::Class* Class_class = FindSystemClass("Ljava/lang/Class;"); CHECK_EQ(java_lang_Class.get(), Class_class); - java_lang_reflect_AbstractMethod->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Abstract_method_class = FindSystemClass("Ljava/lang/reflect/AbstractMethod;"); - CHECK_EQ(java_lang_reflect_AbstractMethod.get(), Abstract_method_class); - - // Method extends AbstractMethod so must reset after. - java_lang_reflect_Method->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Method_class = FindSystemClass("Ljava/lang/reflect/Method;"); - CHECK_EQ(java_lang_reflect_Method.get(), Method_class); + java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusNotReady); + mirror::Class* Art_method_class = FindSystemClass("Ljava/lang/reflect/ArtMethod;"); + CHECK_EQ(java_lang_reflect_ArtMethod.get(), Art_method_class); - // Constructor extends AbstractMethod so must reset after. - java_lang_reflect_Constructor->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Constructor_class = FindSystemClass("Ljava/lang/reflect/Constructor;"); - CHECK_EQ(java_lang_reflect_Constructor.get(), Constructor_class); - - java_lang_reflect_Field->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Field_class = FindSystemClass("Ljava/lang/reflect/Field;"); - CHECK_EQ(java_lang_reflect_Field.get(), Field_class); + java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusNotReady); + mirror::Class* Art_field_class = FindSystemClass("Ljava/lang/reflect/ArtField;"); + CHECK_EQ(java_lang_reflect_ArtField.get(), Art_field_class); mirror::Class* String_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangStringArrayClass]); CHECK_EQ(object_array_string.get(), String_array_class); - mirror::Class* Abstract_method_array_class = - FindSystemClass(class_roots_descriptors_[kJavaLangReflectAbstractMethodArrayClass]); - CHECK_EQ(object_array_abstract_method.get(), Abstract_method_array_class); - - mirror::Class* Field_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangReflectFieldArrayClass]); - CHECK_EQ(object_array_field.get(), Field_array_class); + mirror::Class* Art_method_array_class = + FindSystemClass(class_roots_descriptors_[kJavaLangReflectArtMethodArrayClass]); + CHECK_EQ(object_array_art_method.get(), Art_method_array_class); - mirror::Class* Method_array_class = - FindSystemClass(class_roots_descriptors_[kJavaLangReflectMethodArrayClass]); - CHECK_EQ(object_array_method.get(), Method_array_class); + mirror::Class* Art_field_array_class = + FindSystemClass(class_roots_descriptors_[kJavaLangReflectArtFieldArrayClass]); + CHECK_EQ(object_array_art_field.get(), Art_field_array_class); // End of special init trickery, subsequent classes may be loaded via FindSystemClass. @@ -516,31 +481,31 @@ void ClassLinker::FinishInit() { const DexFile& java_lang_dex = *java_lang_ref_Reference->GetDexCache()->GetDexFile(); - mirror::Field* pendingNext = java_lang_ref_Reference->GetInstanceField(0); + mirror::ArtField* pendingNext = java_lang_ref_Reference->GetInstanceField(0); FieldHelper fh(pendingNext, this); CHECK_STREQ(fh.GetName(), "pendingNext"); CHECK_EQ(java_lang_dex.GetFieldId(pendingNext->GetDexFieldIndex()).type_idx_, java_lang_ref_Reference->GetDexTypeIndex()); - mirror::Field* queue = java_lang_ref_Reference->GetInstanceField(1); + mirror::ArtField* queue = java_lang_ref_Reference->GetInstanceField(1); fh.ChangeField(queue); CHECK_STREQ(fh.GetName(), "queue"); CHECK_EQ(java_lang_dex.GetFieldId(queue->GetDexFieldIndex()).type_idx_, java_lang_ref_ReferenceQueue->GetDexTypeIndex()); - mirror::Field* queueNext = java_lang_ref_Reference->GetInstanceField(2); + mirror::ArtField* queueNext = java_lang_ref_Reference->GetInstanceField(2); fh.ChangeField(queueNext); CHECK_STREQ(fh.GetName(), "queueNext"); CHECK_EQ(java_lang_dex.GetFieldId(queueNext->GetDexFieldIndex()).type_idx_, java_lang_ref_Reference->GetDexTypeIndex()); - mirror::Field* referent = java_lang_ref_Reference->GetInstanceField(3); + mirror::ArtField* referent = java_lang_ref_Reference->GetInstanceField(3); fh.ChangeField(referent); CHECK_STREQ(fh.GetName(), "referent"); CHECK_EQ(java_lang_dex.GetFieldId(referent->GetDexFieldIndex()).type_idx_, GetClassRoot(kJavaLangObject)->GetDexTypeIndex()); - mirror::Field* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); + mirror::ArtField* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); fh.ChangeField(zombie); CHECK_STREQ(fh.GetName(), "zombie"); CHECK_EQ(java_lang_dex.GetFieldId(zombie->GetDexFieldIndex()).type_idx_, @@ -958,8 +923,8 @@ static void InitFromImageCallbackCommon(mirror::Object* obj, ClassLinker* class_ ClassHelper kh(klass, class_linker); mirror::Class* existing = class_linker->InsertClass(kh.GetDescriptor(), klass, true); DCHECK(existing == NULL) << kh.GetDescriptor(); - } else if (interpret_only_mode && obj->IsMethod()) { - mirror::AbstractMethod* method = obj->AsMethod(); + } else if (interpret_only_mode && obj->IsArtMethod()) { + mirror::ArtMethod* method = obj->AsArtMethod(); if (!method->IsNative()) { method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterBridge); if (method != Runtime::Current()->GetResolutionMethod()) { @@ -1027,8 +992,7 @@ void ClassLinker::InitFromImage() { // Set classes on AbstractMethod early so that IsMethod tests can be performed during the live // bitmap walk. - mirror::AbstractMethod::SetClasses(GetClassRoot(kJavaLangReflectConstructor), - GetClassRoot(kJavaLangReflectMethod)); + mirror::ArtMethod::SetClass(GetClassRoot(kJavaLangReflectArtMethod)); // reinit clases_ table { @@ -1049,7 +1013,7 @@ void ClassLinker::InitFromImage() { array_iftable_ = GetClassRoot(kObjectArrayClass)->GetIfTable(); DCHECK(array_iftable_ == GetClassRoot(kBooleanArrayClass)->GetIfTable()); // String class root was set above - mirror::Field::SetClass(GetClassRoot(kJavaLangReflectField)); + mirror::ArtField::SetClass(GetClassRoot(kJavaLangReflectArtField)); mirror::BooleanArray::SetArrayClass(GetClassRoot(kBooleanArrayClass)); mirror::ByteArray::SetArrayClass(GetClassRoot(kByteArrayClass)); mirror::CharArray::SetArrayClass(GetClassRoot(kCharArrayClass)); @@ -1132,8 +1096,8 @@ void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* ar ClassLinker::~ClassLinker() { mirror::Class::ResetClass(); mirror::String::ResetClass(); - mirror::Field::ResetClass(); - mirror::AbstractMethod::ResetClasses(); + mirror::ArtField::ResetClass(); + mirror::ArtMethod::ResetClass(); mirror::BooleanArray::ResetArrayClass(); mirror::ByteArray::ResetArrayClass(); mirror::CharArray::ResetArrayClass(); @@ -1172,13 +1136,13 @@ mirror::DexCache* ClassLinker::AllocDexCache(Thread* self, const DexFile& dex_fi if (types.get() == NULL) { return NULL; } - SirtRef<mirror::ObjectArray<mirror::AbstractMethod> > - methods(self, AllocAbstractMethodArray(self, dex_file.NumMethodIds())); + SirtRef<mirror::ObjectArray<mirror::ArtMethod> > + methods(self, AllocArtMethodArray(self, dex_file.NumMethodIds())); if (methods.get() == NULL) { return NULL; } - SirtRef<mirror::ObjectArray<mirror::Field> > - fields(self, AllocFieldArray(self, dex_file.NumFieldIds())); + SirtRef<mirror::ObjectArray<mirror::ArtField> > + fields(self, AllocArtFieldArray(self, dex_file.NumFieldIds())); if (fields.get() == NULL) { return NULL; } @@ -1214,16 +1178,12 @@ mirror::Class* ClassLinker::AllocClass(Thread* self, size_t class_size) { return AllocClass(self, GetClassRoot(kJavaLangClass), class_size); } -mirror::Field* ClassLinker::AllocField(Thread* self) { - return down_cast<mirror::Field*>(GetClassRoot(kJavaLangReflectField)->AllocObject(self)); +mirror::ArtField* ClassLinker::AllocArtField(Thread* self) { + return down_cast<mirror::ArtField*>(GetClassRoot(kJavaLangReflectArtField)->AllocObject(self)); } -mirror::Method* ClassLinker::AllocMethod(Thread* self) { - return down_cast<mirror::Method*>(GetClassRoot(kJavaLangReflectMethod)->AllocObject(self)); -} - -mirror::Constructor* ClassLinker::AllocConstructor(Thread* self) { - return down_cast<mirror::Constructor*>(GetClassRoot(kJavaLangReflectConstructor)->AllocObject(self)); +mirror::ArtMethod* ClassLinker::AllocArtMethod(Thread* self) { + return down_cast<mirror::ArtMethod*>(GetClassRoot(kJavaLangReflectArtMethod)->AllocObject(self)); } mirror::ObjectArray<mirror::StackTraceElement>* ClassLinker::AllocStackTraceElementArray(Thread* self, @@ -1364,14 +1324,10 @@ mirror::Class* ClassLinker::DefineClass(const StringPiece& descriptor, klass.reset(GetClassRoot(kJavaLangString)); } else if (descriptor == "Ljava/lang/DexCache;") { klass.reset(GetClassRoot(kJavaLangDexCache)); - } else if (descriptor == "Ljava/lang/reflect/Field;") { - klass.reset(GetClassRoot(kJavaLangReflectField)); - } else if (descriptor == "Ljava/lang/reflect/AbstractMethod;") { - klass.reset(GetClassRoot(kJavaLangReflectAbstractMethod)); - } else if (descriptor == "Ljava/lang/reflect/Constructor;") { - klass.reset(GetClassRoot(kJavaLangReflectConstructor)); - } else if (descriptor == "Ljava/lang/reflect/Method;") { - klass.reset(GetClassRoot(kJavaLangReflectMethod)); + } else if (descriptor == "Ljava/lang/reflect/ArtField;") { + klass.reset(GetClassRoot(kJavaLangReflectArtField)); + } else if (descriptor == "Ljava/lang/reflect/ArtMethod;") { + klass.reset(GetClassRoot(kJavaLangReflectArtMethod)); } else { klass.reset(AllocClass(self, SizeOfClass(dex_file, dex_class_def))); } @@ -1519,7 +1475,7 @@ static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file, uint32 return 0; } -const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::AbstractMethod* method) { +const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::ArtMethod* method) { // Although we overwrite the trampoline of non-static methods, we may get here via the resolution // method for direct methods (or virtual methods made direct). mirror::Class* declaring_class = method->GetDeclaringClass(); @@ -1553,7 +1509,7 @@ const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::AbstractMeth } // Special case to get oat code without overwriting a trampoline. -const void* ClassLinker::GetOatCodeFor(const mirror::AbstractMethod* method) { +const void* ClassLinker::GetOatCodeFor(const mirror::ArtMethod* method) { CHECK(!method->IsAbstract()) << PrettyMethod(method); if (method->IsProxyMethod()) { #if !defined(ART_USE_PORTABLE_COMPILER) @@ -1580,7 +1536,7 @@ const void* ClassLinker::GetOatCodeFor(const DexFile& dex_file, uint32_t method_ } // Returns true if the method must run with interpreter, false otherwise. -static bool NeedsInterpreter(const mirror::AbstractMethod* method, const void* code) { +static bool NeedsInterpreter(const mirror::ArtMethod* method, const void* code) { if (code == NULL) { // No code: need interpreter. return true; @@ -1617,7 +1573,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { } // Link the code of methods skipped by LinkCode for (size_t method_index = 0; it.HasNextDirectMethod(); ++method_index, it.Next()) { - mirror::AbstractMethod* method = klass->GetDirectMethod(method_index); + mirror::ArtMethod* method = klass->GetDirectMethod(method_index); if (!method->IsStatic()) { // Only update static methods. continue; @@ -1633,7 +1589,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { // Ignore virtual methods on the iterator. } -static void LinkCode(SirtRef<mirror::AbstractMethod>& method, const OatFile::OatClass* oat_class, +static void LinkCode(SirtRef<mirror::ArtMethod>& method, const OatFile::OatClass* oat_class, uint32_t method_index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Method shouldn't have already been linked. @@ -1707,18 +1663,18 @@ void ClassLinker::LoadClass(const DexFile& dex_file, ClassDataItemIterator it(dex_file, class_data); Thread* self = Thread::Current(); if (it.NumStaticFields() != 0) { - klass->SetSFields(AllocFieldArray(self, it.NumStaticFields())); + klass->SetSFields(AllocArtFieldArray(self, it.NumStaticFields())); } if (it.NumInstanceFields() != 0) { - klass->SetIFields(AllocFieldArray(self, it.NumInstanceFields())); + klass->SetIFields(AllocArtFieldArray(self, it.NumInstanceFields())); } for (size_t i = 0; it.HasNextStaticField(); i++, it.Next()) { - SirtRef<mirror::Field> sfield(self, AllocField(self)); + SirtRef<mirror::ArtField> sfield(self, AllocArtField(self)); klass->SetStaticField(i, sfield.get()); LoadField(dex_file, it, klass, sfield); } for (size_t i = 0; it.HasNextInstanceField(); i++, it.Next()) { - SirtRef<mirror::Field> ifield(self, AllocField(self)); + SirtRef<mirror::ArtField> ifield(self, AllocArtField(self)); klass->SetInstanceField(i, ifield.get()); LoadField(dex_file, it, klass, ifield); } @@ -1731,15 +1687,15 @@ void ClassLinker::LoadClass(const DexFile& dex_file, // Load methods. if (it.NumDirectMethods() != 0) { // TODO: append direct methods to class object - klass->SetDirectMethods(AllocAbstractMethodArray(self, it.NumDirectMethods())); + klass->SetDirectMethods(AllocArtMethodArray(self, it.NumDirectMethods())); } if (it.NumVirtualMethods() != 0) { // TODO: append direct methods to class object - klass->SetVirtualMethods(AllocMethodArray(self, it.NumVirtualMethods())); + klass->SetVirtualMethods(AllocArtMethodArray(self, it.NumVirtualMethods())); } size_t class_def_method_index = 0; for (size_t i = 0; it.HasNextDirectMethod(); i++, it.Next()) { - SirtRef<mirror::AbstractMethod> method(self, LoadMethod(self, dex_file, it, klass)); + SirtRef<mirror::ArtMethod> method(self, LoadMethod(self, dex_file, it, klass)); klass->SetDirectMethod(i, method.get()); if (oat_class.get() != NULL) { LinkCode(method, oat_class.get(), class_def_method_index); @@ -1748,7 +1704,7 @@ void ClassLinker::LoadClass(const DexFile& dex_file, class_def_method_index++; } for (size_t i = 0; it.HasNextVirtualMethod(); i++, it.Next()) { - SirtRef<mirror::AbstractMethod> method(self, LoadMethod(self, dex_file, it, klass)); + SirtRef<mirror::ArtMethod> method(self, LoadMethod(self, dex_file, it, klass)); klass->SetVirtualMethod(i, method.get()); DCHECK_EQ(class_def_method_index, it.NumDirectMethods() + i); if (oat_class.get() != NULL) { @@ -1760,27 +1716,22 @@ void ClassLinker::LoadClass(const DexFile& dex_file, } void ClassLinker::LoadField(const DexFile& /*dex_file*/, const ClassDataItemIterator& it, - SirtRef<mirror::Class>& klass, SirtRef<mirror::Field>& dst) { + SirtRef<mirror::Class>& klass, SirtRef<mirror::ArtField>& dst) { uint32_t field_idx = it.GetMemberIndex(); dst->SetDexFieldIndex(field_idx); dst->SetDeclaringClass(klass.get()); dst->SetAccessFlags(it.GetMemberAccessFlags()); } -mirror::AbstractMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file, +mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file, const ClassDataItemIterator& it, SirtRef<mirror::Class>& klass) { uint32_t dex_method_idx = it.GetMemberIndex(); const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); StringPiece method_name(dex_file.GetMethodName(method_id)); - mirror::AbstractMethod* dst = NULL; - if (method_name == "<init>") { - dst = AllocConstructor(self); - } else { - dst = AllocMethod(self); - } - DCHECK(dst->IsMethod()) << PrettyDescriptor(dst->GetClass()); + mirror::ArtMethod* dst = AllocArtMethod(self); + DCHECK(dst->IsArtMethod()) << PrettyDescriptor(dst->GetClass()); const char* old_cause = self->StartAssertNoThreadSuspension("LoadMethod"); dst->SetDexMethodIndex(dex_method_idx); @@ -1824,7 +1775,7 @@ mirror::AbstractMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex dst->SetDexCacheResolvedTypes(klass->GetDexCache()->GetResolvedTypes()); dst->SetDexCacheInitializedStaticStorage(klass->GetDexCache()->GetInitializedStaticStorage()); - CHECK(dst->IsMethod()); + CHECK(dst->IsArtMethod()); self->EndAssertNoThreadSuspension(old_cause); return dst; @@ -1918,7 +1869,7 @@ mirror::DexCache* ClassLinker::FindDexCache(const DexFile& dex_file) const { return NULL; } -void ClassLinker::FixupDexCaches(mirror::AbstractMethod* resolution_method) const { +void ClassLinker::FixupDexCaches(mirror::ArtMethod* resolution_method) const { ReaderMutexLock mu(Thread::Current(), dex_lock_); for (size_t i = 0; i != dex_caches_.size(); ++i) { dex_caches_[i]->Fixup(resolution_method); @@ -2007,12 +1958,10 @@ mirror::Class* ClassLinker::CreateArrayClass(const std::string& descriptor, new_class.reset(GetClassRoot(kObjectArrayClass)); } else if (descriptor == class_roots_descriptors_[kJavaLangStringArrayClass]) { new_class.reset(GetClassRoot(kJavaLangStringArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectAbstractMethodArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectAbstractMethodArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectFieldArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectFieldArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectMethodArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectMethodArrayClass)); + } else if (descriptor == class_roots_descriptors_[kJavaLangReflectArtMethodArrayClass]) { + new_class.reset(GetClassRoot(kJavaLangReflectArtMethodArrayClass)); + } else if (descriptor == class_roots_descriptors_[kJavaLangReflectArtFieldArrayClass]) { + new_class.reset(GetClassRoot(kJavaLangReflectArtFieldArrayClass)); } else if (descriptor == "[C") { new_class.reset(GetClassRoot(kCharArrayClass)); } else if (descriptor == "[I") { @@ -2428,7 +2377,7 @@ void ClassLinker::ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mir } void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, - mirror::AbstractMethod* method) { + mirror::ArtMethod* method) { // similar to DexVerifier::ScanTryCatchBlocks and dex2oat's ResolveExceptionsForMethod. const DexFile::CodeItem* code_item = dex_file.GetCodeItem(method->GetCodeItemOffset()); if (code_item == NULL) { @@ -2457,14 +2406,14 @@ void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, } } -static void CheckProxyConstructor(mirror::AbstractMethod* constructor); -static void CheckProxyMethod(mirror::AbstractMethod* method, - SirtRef<mirror::AbstractMethod>& prototype); +static void CheckProxyConstructor(mirror::ArtMethod* constructor); +static void CheckProxyMethod(mirror::ArtMethod* method, + SirtRef<mirror::ArtMethod>& prototype); mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, mirror::ObjectArray<mirror::Class>* interfaces, mirror::ClassLoader* loader, - mirror::ObjectArray<mirror::AbstractMethod>* methods, + mirror::ObjectArray<mirror::ArtMethod>* methods, mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws) { Thread* self = Thread::Current(); SirtRef<mirror::Class> klass(self, AllocClass(self, GetClassRoot(kJavaLangClass), @@ -2484,30 +2433,30 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, klass->SetDexTypeIndex(DexFile::kDexNoIndex16); // Instance fields are inherited, but we add a couple of static fields... - klass->SetSFields(AllocFieldArray(self, 2)); + klass->SetSFields(AllocArtFieldArray(self, 2)); // 1. Create a static field 'interfaces' that holds the _declared_ interfaces implemented by // our proxy, so Class.getInterfaces doesn't return the flattened set. - SirtRef<mirror::Field> interfaces_sfield(self, AllocField(self)); + SirtRef<mirror::ArtField> interfaces_sfield(self, AllocArtField(self)); klass->SetStaticField(0, interfaces_sfield.get()); interfaces_sfield->SetDexFieldIndex(0); interfaces_sfield->SetDeclaringClass(klass.get()); interfaces_sfield->SetAccessFlags(kAccStatic | kAccPublic | kAccFinal); // 2. Create a static field 'throws' that holds exceptions thrown by our methods. - SirtRef<mirror::Field> throws_sfield(self, AllocField(self)); + SirtRef<mirror::ArtField> throws_sfield(self, AllocArtField(self)); klass->SetStaticField(1, throws_sfield.get()); throws_sfield->SetDexFieldIndex(1); throws_sfield->SetDeclaringClass(klass.get()); throws_sfield->SetAccessFlags(kAccStatic | kAccPublic | kAccFinal); // Proxies have 1 direct method, the constructor - klass->SetDirectMethods(AllocAbstractMethodArray(self, 1)); + klass->SetDirectMethods(AllocArtMethodArray(self, 1)); klass->SetDirectMethod(0, CreateProxyConstructor(self, klass, proxy_class)); // Create virtual method using specified prototypes size_t num_virtual_methods = methods->GetLength(); - klass->SetVirtualMethods(AllocMethodArray(self, num_virtual_methods)); + klass->SetVirtualMethods(AllocArtMethodArray(self, num_virtual_methods)); for (size_t i = 0; i < num_virtual_methods; ++i) { - SirtRef<mirror::AbstractMethod> prototype(self, methods->Get(i)); + SirtRef<mirror::ArtMethod> prototype(self, methods->Get(i)); klass->SetVirtualMethod(i, CreateProxyMethod(self, klass, prototype)); } @@ -2532,7 +2481,7 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, CHECK(klass->GetIFields() == NULL); CheckProxyConstructor(klass->GetDirectMethod(0)); for (size_t i = 0; i < num_virtual_methods; ++i) { - SirtRef<mirror::AbstractMethod> prototype(self, methods->Get(i)); + SirtRef<mirror::ArtMethod> prototype(self, methods->Get(i)); CheckProxyMethod(klass->GetVirtualMethod(i), prototype); } @@ -2559,8 +2508,8 @@ std::string ClassLinker::GetDescriptorForProxy(const mirror::Class* proxy_class) return DotToDescriptor(name->ToModifiedUtf8().c_str()); } -mirror::AbstractMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class, - const mirror::AbstractMethod* proxy_method) { +mirror::ArtMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class, + const mirror::ArtMethod* proxy_method) { DCHECK(proxy_class->IsProxyClass()); DCHECK(proxy_method->IsProxyMethod()); // Locate the dex cache of the original interface/Object @@ -2577,31 +2526,31 @@ mirror::AbstractMethod* ClassLinker::FindMethodForProxy(const mirror::Class* pro } CHECK(dex_cache != NULL); uint32_t method_idx = proxy_method->GetDexMethodIndex(); - mirror::AbstractMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx); + mirror::ArtMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx); CHECK(resolved_method != NULL); return resolved_method; } -mirror::AbstractMethod* ClassLinker::CreateProxyConstructor(Thread* self, - SirtRef<mirror::Class>& klass, - mirror::Class* proxy_class) { +mirror::ArtMethod* ClassLinker::CreateProxyConstructor(Thread* self, + SirtRef<mirror::Class>& klass, + mirror::Class* proxy_class) { // Create constructor for Proxy that must initialize h - mirror::ObjectArray<mirror::AbstractMethod>* proxy_direct_methods = + mirror::ObjectArray<mirror::ArtMethod>* proxy_direct_methods = proxy_class->GetDirectMethods(); - CHECK_EQ(proxy_direct_methods->GetLength(), 15); - mirror::AbstractMethod* proxy_constructor = proxy_direct_methods->Get(2); + CHECK_EQ(proxy_direct_methods->GetLength(), 16); + mirror::ArtMethod* proxy_constructor = proxy_direct_methods->Get(2); // Clone the existing constructor of Proxy (our constructor would just invoke it so steal its // code_ too) - mirror::AbstractMethod* constructor = - down_cast<mirror::AbstractMethod*>(proxy_constructor->Clone(self)); + mirror::ArtMethod* constructor = + down_cast<mirror::ArtMethod*>(proxy_constructor->Clone(self)); // Make this constructor public and fix the class to be our Proxy version constructor->SetAccessFlags((constructor->GetAccessFlags() & ~kAccProtected) | kAccPublic); constructor->SetDeclaringClass(klass.get()); return constructor; } -static void CheckProxyConstructor(mirror::AbstractMethod* constructor) +static void CheckProxyConstructor(mirror::ArtMethod* constructor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(constructor->IsConstructor()); MethodHelper mh(constructor); @@ -2610,15 +2559,15 @@ static void CheckProxyConstructor(mirror::AbstractMethod* constructor) DCHECK(constructor->IsPublic()); } -mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef<mirror::Class>& klass, - SirtRef<mirror::AbstractMethod>& prototype) { +mirror::ArtMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef<mirror::Class>& klass, + SirtRef<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(), prototype.get()); // We steal everything from the prototype (such as DexCache, invoke stub, etc.) then specialize // as necessary - mirror::AbstractMethod* method = down_cast<mirror::AbstractMethod*>(prototype->Clone(self)); + mirror::ArtMethod* method = down_cast<mirror::ArtMethod*>(prototype->Clone(self)); // Set class to be the concrete proxy class and clear the abstract flag, modify exceptions to // the intersection of throw exceptions as defined in Proxy @@ -2627,7 +2576,7 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef<mir // At runtime the method looks like a reference and argument saving method, clone the code // related parameters from this method. - mirror::AbstractMethod* refs_and_args = + mirror::ArtMethod* refs_and_args = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); method->SetCoreSpillMask(refs_and_args->GetCoreSpillMask()); method->SetFpSpillMask(refs_and_args->GetFpSpillMask()); @@ -2638,8 +2587,8 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef<mir return method; } -static void CheckProxyMethod(mirror::AbstractMethod* method, - SirtRef<mirror::AbstractMethod>& prototype) +static void CheckProxyMethod(mirror::ArtMethod* method, + SirtRef<mirror::ArtMethod>& prototype) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Basic sanity CHECK(!prototype->IsFinal()); @@ -2669,7 +2618,7 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo Thread* self = Thread::Current(); - mirror::AbstractMethod* clinit = NULL; + mirror::ArtMethod* clinit = NULL; { // see JLS 3rd edition, 12.4.2 "Detailed Initialization Procedure" for the locking protocol ObjectLock lock(self, klass); @@ -2842,7 +2791,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { klass->GetClassLoader() != klass->GetSuperClass()->GetClassLoader()) { const mirror::Class* super = klass->GetSuperClass(); for (int i = super->GetVTable()->GetLength() - 1; i >= 0; --i) { - const mirror::AbstractMethod* method = klass->GetVTable()->Get(i); + const mirror::ArtMethod* method = klass->GetVTable()->Get(i); if (method != super->GetVTable()->Get(i) && !IsSameMethodSignatureInDifferentClassContexts(method, super, klass)) { ThrowLinkageError(klass, "Class %s method %s resolves differently in superclass %s", @@ -2857,7 +2806,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { mirror::Class* interface = iftable->GetInterface(i); if (klass->GetClassLoader() != interface->GetClassLoader()) { for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - const mirror::AbstractMethod* method = iftable->GetMethodArray(i)->Get(j); + const mirror::ArtMethod* method = iftable->GetMethodArray(i)->Get(j); if (!IsSameMethodSignatureInDifferentClassContexts(method, interface, method->GetDeclaringClass())) { ThrowLinkageError(klass, "Class %s method %s resolves differently in interface %s", @@ -2874,7 +2823,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { // Returns true if classes referenced by the signature of the method are the // same classes in klass1 as they are in klass2. -bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::AbstractMethod* method, +bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, const mirror::Class* klass1, const mirror::Class* klass2) { if (klass1 == klass2) { @@ -2969,7 +2918,7 @@ bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_run_clinit, bool } void ClassLinker::ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, - mirror::Class* c, SafeMap<uint32_t, mirror::Field*>& field_map) { + mirror::Class* c, SafeMap<uint32_t, mirror::ArtField*>& field_map) { mirror::ClassLoader* cl = c->GetClassLoader(); const byte* class_data = dex_file.GetClassData(dex_class_def); ClassDataItemIterator it(dex_file, class_data); @@ -2997,7 +2946,7 @@ bool ClassLinker::InitializeStaticFields(mirror::Class* klass) { if (it.HasNext()) { // We reordered the fields, so we need to be able to map the field indexes to the right fields. - SafeMap<uint32_t, mirror::Field*> field_map; + SafeMap<uint32_t, mirror::ArtField*> field_map; ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); for (size_t i = 0; it.HasNext(); i++, it.Next()) { it.ReadValueToField(field_map.Get(i)); @@ -3161,17 +3110,17 @@ bool ClassLinker::LinkVirtualMethods(SirtRef<mirror::Class>& klass) { size_t actual_count = klass->GetSuperClass()->GetVTable()->GetLength(); CHECK_LE(actual_count, max_count); // TODO: do not assign to the vtable field until it is fully constructed. - SirtRef<mirror::ObjectArray<mirror::AbstractMethod> > + SirtRef<mirror::ObjectArray<mirror::ArtMethod> > vtable(self, klass->GetSuperClass()->GetVTable()->CopyOf(self, max_count)); // See if any of our virtual methods override the superclass. MethodHelper local_mh(NULL, this); MethodHelper super_mh(NULL, this); for (size_t i = 0; i < klass->NumVirtualMethods(); ++i) { - mirror::AbstractMethod* local_method = klass->GetVirtualMethodDuringLinking(i); + mirror::ArtMethod* local_method = klass->GetVirtualMethodDuringLinking(i); local_mh.ChangeMethod(local_method); size_t j = 0; for (; j < actual_count; ++j) { - mirror::AbstractMethod* super_method = vtable->Get(j); + mirror::ArtMethod* super_method = vtable->Get(j); super_mh.ChangeMethod(super_method); if (local_mh.HasSameNameAndSignature(&super_mh)) { if (klass->CanAccessMember(super_method->GetDeclaringClass(), super_method->GetAccessFlags())) { @@ -3215,10 +3164,10 @@ bool ClassLinker::LinkVirtualMethods(SirtRef<mirror::Class>& klass) { ThrowClassFormatError(klass.get(), "Too many methods: %d", num_virtual_methods); return false; } - SirtRef<mirror::ObjectArray<mirror::AbstractMethod> > - vtable(self, AllocMethodArray(self, num_virtual_methods)); + SirtRef<mirror::ObjectArray<mirror::ArtMethod> > + vtable(self, AllocArtMethodArray(self, num_virtual_methods)); for (size_t i = 0; i < num_virtual_methods; ++i) { - mirror::AbstractMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); + mirror::ArtMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); vtable->Set(i, virtual_method); virtual_method->SetMethodIndex(i & 0xFFFF); } @@ -3328,19 +3277,19 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass, if (klass->IsInterface()) { return true; } - std::vector<mirror::AbstractMethod*> miranda_list; + std::vector<mirror::ArtMethod*> miranda_list; MethodHelper vtable_mh(NULL, this); MethodHelper interface_mh(NULL, this); for (size_t i = 0; i < ifcount; ++i) { mirror::Class* interface = iftable->GetInterface(i); size_t num_methods = interface->NumVirtualMethods(); if (num_methods > 0) { - mirror::ObjectArray<mirror::AbstractMethod>* method_array = - AllocMethodArray(self, num_methods); + mirror::ObjectArray<mirror::ArtMethod>* method_array = + AllocArtMethodArray(self, num_methods); iftable->SetMethodArray(i, method_array); - mirror::ObjectArray<mirror::AbstractMethod>* vtable = klass->GetVTableDuringLinking(); + mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking(); for (size_t j = 0; j < num_methods; ++j) { - mirror::AbstractMethod* interface_method = interface->GetVirtualMethod(j); + mirror::ArtMethod* interface_method = interface->GetVirtualMethod(j); interface_mh.ChangeMethod(interface_method); int32_t k; // For each method listed in the interface's method list, find the @@ -3352,7 +3301,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass, // those don't end up in the virtual method table, so it shouldn't // matter which direction we go. We walk it backward anyway.) for (k = vtable->GetLength() - 1; k >= 0; --k) { - mirror::AbstractMethod* vtable_method = vtable->Get(k); + mirror::ArtMethod* vtable_method = vtable->Get(k); vtable_mh.ChangeMethod(vtable_method); if (interface_mh.HasSameNameAndSignature(&vtable_mh)) { if (!vtable_method->IsAbstract() && !vtable_method->IsPublic()) { @@ -3367,9 +3316,9 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass, } } if (k < 0) { - SirtRef<mirror::AbstractMethod> miranda_method(self, NULL); + SirtRef<mirror::ArtMethod> miranda_method(self, NULL); for (size_t mir = 0; mir < miranda_list.size(); mir++) { - mirror::AbstractMethod* mir_method = miranda_list[mir]; + mirror::ArtMethod* mir_method = miranda_list[mir]; vtable_mh.ChangeMethod(mir_method); if (interface_mh.HasSameNameAndSignature(&vtable_mh)) { miranda_method.reset(miranda_list[mir]); @@ -3378,7 +3327,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass, } if (miranda_method.get() == NULL) { // point the interface table at a phantom slot - miranda_method.reset(down_cast<mirror::AbstractMethod*>(interface_method->Clone(self))); + miranda_method.reset(down_cast<mirror::ArtMethod*>(interface_method->Clone(self))); miranda_list.push_back(miranda_method.get()); } method_array->Set(j, miranda_method.get()); @@ -3390,17 +3339,17 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass, int old_method_count = klass->NumVirtualMethods(); int new_method_count = old_method_count + miranda_list.size(); klass->SetVirtualMethods((old_method_count == 0) - ? AllocMethodArray(self, new_method_count) + ? AllocArtMethodArray(self, new_method_count) : klass->GetVirtualMethods()->CopyOf(self, new_method_count)); - SirtRef<mirror::ObjectArray<mirror::AbstractMethod> > + SirtRef<mirror::ObjectArray<mirror::ArtMethod> > vtable(self, klass->GetVTableDuringLinking()); CHECK(vtable.get() != NULL); int old_vtable_count = vtable->GetLength(); int new_vtable_count = old_vtable_count + miranda_list.size(); vtable.reset(vtable->CopyOf(self, new_vtable_count)); for (size_t i = 0; i < miranda_list.size(); ++i) { - mirror::AbstractMethod* method = miranda_list[i]; + mirror::ArtMethod* method = miranda_list[i]; // Leave the declaring class alone as type indices are relative to it method->SetAccessFlags(method->GetAccessFlags() | kAccMiranda); method->SetMethodIndex(0xFFFF & (old_vtable_count + i)); @@ -3411,7 +3360,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef<mirror::Class>& klass, klass->SetVTable(vtable.get()); } - mirror::ObjectArray<mirror::AbstractMethod>* vtable = klass->GetVTableDuringLinking(); + mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking(); for (int i = 0; i < vtable->GetLength(); ++i) { CHECK(vtable->Get(i) != NULL); } @@ -3439,7 +3388,7 @@ struct LinkFieldsComparator { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : fh_(fh) {} // No thread safety analysis as will be called from STL. Checked lock held in constructor. - bool operator()(const mirror::Field* field1, const mirror::Field* field2) + bool operator()(const mirror::ArtField* field1, const mirror::ArtField* field2) NO_THREAD_SAFETY_ANALYSIS { // First come reference fields, then 64-bit, and finally 32-bit fh_->ChangeField(field1); @@ -3471,7 +3420,7 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { size_t num_fields = is_static ? klass->NumStaticFields() : klass->NumInstanceFields(); - mirror::ObjectArray<mirror::Field>* fields = + mirror::ObjectArray<mirror::ArtField>* fields = is_static ? klass->GetSFields() : klass->GetIFields(); // Initialize size and field_offset @@ -3493,7 +3442,7 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { // we want a relatively stable order so that adding new fields // minimizes disruption of C++ version such as Class and Method. - std::deque<mirror::Field*> grouped_and_sorted_fields; + std::deque<mirror::ArtField*> grouped_and_sorted_fields; for (size_t i = 0; i < num_fields; i++) { grouped_and_sorted_fields.push_back(fields->Get(i)); } @@ -3506,7 +3455,7 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { size_t current_field = 0; size_t num_reference_fields = 0; for (; current_field < num_fields; current_field++) { - mirror::Field* field = grouped_and_sorted_fields.front(); + mirror::ArtField* field = grouped_and_sorted_fields.front(); fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); bool isPrimitive = type != Primitive::kPrimNot; @@ -3525,7 +3474,7 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { // into place. If we can't find one, we'll have to pad it. if (current_field != num_fields && !IsAligned<8>(field_offset.Uint32Value())) { for (size_t i = 0; i < grouped_and_sorted_fields.size(); i++) { - mirror::Field* field = grouped_and_sorted_fields[i]; + mirror::ArtField* field = grouped_and_sorted_fields[i]; fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); CHECK(type != Primitive::kPrimNot); // should only be working on primitive types @@ -3546,7 +3495,7 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { // finish assigning field offsets to all fields. DCHECK(current_field == num_fields || IsAligned<8>(field_offset.Uint32Value())); while (!grouped_and_sorted_fields.empty()) { - mirror::Field* field = grouped_and_sorted_fields.front(); + mirror::ArtField* field = grouped_and_sorted_fields.front(); grouped_and_sorted_fields.pop_front(); fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); @@ -3576,12 +3525,12 @@ bool ClassLinker::LinkFields(SirtRef<mirror::Class>& klass, bool is_static) { // non-reference fields, and all double-wide fields are aligned. bool seen_non_ref = false; for (size_t i = 0; i < num_fields; i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); if (false) { // enable to debug field layout LOG(INFO) << "LinkFields: " << (is_static ? "static" : "instance") << " class=" << PrettyClass(klass.get()) << " field=" << PrettyField(field) - << " offset=" << field->GetField32(MemberOffset(mirror::Field::OffsetOffset()), + << " offset=" << field->GetField32(MemberOffset(mirror::ArtField::OffsetOffset()), false); } fh.ChangeField(field); @@ -3644,14 +3593,14 @@ void ClassLinker::CreateReferenceOffsets(SirtRef<mirror::Class>& klass, bool is_ size_t num_reference_fields = is_static ? klass->NumReferenceStaticFieldsDuringLinking() : klass->NumReferenceInstanceFieldsDuringLinking(); - const mirror::ObjectArray<mirror::Field>* fields = + const mirror::ObjectArray<mirror::ArtField>* fields = is_static ? klass->GetSFields() : klass->GetIFields(); // All of the fields that contain object references are guaranteed // to be at the beginning of the fields list. for (size_t i = 0; i < num_reference_fields; ++i) { // Note that byte_offset is the offset from the beginning of // object, not the offset into instance data - const mirror::Field* field = fields->Get(i); + const mirror::ArtField* field = fields->Get(i); MemberOffset byte_offset = field->GetOffsetDuringLinking(); CHECK_EQ(byte_offset.Uint32Value() & (CLASS_OFFSET_ALIGNMENT - 1), 0U); if (CLASS_CAN_ENCODE_OFFSET(byte_offset.Uint32Value())) { @@ -3716,15 +3665,15 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, return resolved; } -mirror::AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, +mirror::ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, uint32_t method_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, InvokeType type) { DCHECK(dex_cache != NULL); // Check for hit in the dex cache. - mirror::AbstractMethod* resolved = dex_cache->GetResolvedMethod(method_idx); + mirror::ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx); if (resolved != NULL) { return resolved; } @@ -3863,13 +3812,13 @@ mirror::AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, } } -mirror::Field* ClassLinker::ResolveField(const DexFile& dex_file, +mirror::ArtField* ClassLinker::ResolveField(const DexFile& dex_file, uint32_t field_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, bool is_static) { DCHECK(dex_cache != NULL); - mirror::Field* resolved = dex_cache->GetResolvedField(field_idx); + mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx); if (resolved != NULL) { return resolved; } @@ -3903,12 +3852,12 @@ mirror::Field* ClassLinker::ResolveField(const DexFile& dex_file, return resolved; } -mirror::Field* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, +mirror::ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader) { DCHECK(dex_cache != NULL); - mirror::Field* resolved = dex_cache->GetResolvedField(field_idx); + mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx); if (resolved != NULL) { return resolved; } @@ -3930,7 +3879,7 @@ mirror::Field* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, return resolved; } -const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::AbstractMethod* referrer, +const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); mirror::DexCache* dex_cache = declaring_class->GetDexCache(); diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 67be2ff..d0cc562 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -106,7 +106,7 @@ class ClassLinker { // Resolve a String with the given index from the DexFile, storing the // result in the DexCache. The referrer is used to identify the // target DexCache and ClassLoader to use for resolution. - mirror::String* ResolveString(uint32_t string_idx, const mirror::AbstractMethod* referrer) + mirror::String* ResolveString(uint32_t string_idx, const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a String with the given index from the DexFile, storing the @@ -130,10 +130,10 @@ class ClassLinker { // Resolve a Type with the given index from the DexFile, storing the // result in the DexCache. The referrer is used to identify the // target DexCache and ClassLoader to use for resolution. - mirror::Class* ResolveType(uint16_t type_idx, const mirror::AbstractMethod* referrer) + mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Class* ResolveType(uint16_t type_idx, const mirror::Field* referrer) + mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a type with the given ID from the DexFile, storing the @@ -151,20 +151,20 @@ class ClassLinker { // in ResolveType. What is unique is the method type argument which // is used to determine if this method is a direct, static, or // virtual method. - mirror::AbstractMethod* ResolveMethod(const DexFile& dex_file, - uint32_t method_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, - const mirror::AbstractMethod* referrer, - InvokeType type) + mirror::ArtMethod* ResolveMethod(const DexFile& dex_file, + uint32_t method_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader, + const mirror::ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* ResolveMethod(uint32_t method_idx, const mirror::AbstractMethod* referrer, - InvokeType type) + mirror::ArtMethod* ResolveMethod(uint32_t method_idx, const mirror::ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* ResolveField(uint32_t field_idx, const mirror::AbstractMethod* referrer, - bool is_static) + mirror::ArtField* ResolveField(uint32_t field_idx, const mirror::ArtMethod* referrer, + bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the @@ -172,25 +172,25 @@ class ClassLinker { // in ResolveType. What is unique is the is_static argument which is // used to determine if we are resolving a static or non-static // field. - mirror::Field* ResolveField(const DexFile& dex_file, - uint32_t field_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, - bool is_static) + mirror::ArtField* ResolveField(const DexFile& dex_file, + uint32_t field_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader, + bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the // result in DexCache. The ClassLinker and ClassLoader are used as // in ResolveType. No is_static argument is provided so that Java // field resolution semantics are followed. - mirror::Field* ResolveFieldJLS(const DexFile& dex_file, - uint32_t field_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader) + mirror::ArtField* ResolveFieldJLS(const DexFile& dex_file, + uint32_t field_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get shorty from method index without resolution. Used to do handlerization. - const char* MethodShorty(uint32_t method_idx, mirror::AbstractMethod* referrer, uint32_t* length) + const char* MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns true on success, false if there's an exception pending. @@ -232,7 +232,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsDexFileRegistered(const DexFile& dex_file) const LOCKS_EXCLUDED(dex_lock_); - void FixupDexCaches(mirror::AbstractMethod* resolution_method) const + void FixupDexCaches(mirror::ArtMethod* resolution_method) const LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -283,16 +283,13 @@ class ClassLinker { mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray<mirror::AbstractMethod>* AllocAbstractMethodArray(Thread* self, size_t length) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - mirror::ObjectArray<mirror::AbstractMethod>* AllocMethodArray(Thread* self, size_t length) + mirror::ObjectArray<mirror::ArtMethod>* AllocArtMethodArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray<mirror::Field>* AllocFieldArray(Thread* self, size_t length) + mirror::ObjectArray<mirror::ArtField>* AllocArtFieldArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::ObjectArray<mirror::StackTraceElement>* AllocStackTraceElementArray(Thread* self, @@ -305,23 +302,23 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::AbstractMethod* klass) + void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreateProxyClass(mirror::String* name, mirror::ObjectArray<mirror::Class>* interfaces, mirror::ClassLoader* loader, - mirror::ObjectArray<mirror::AbstractMethod>* methods, + mirror::ObjectArray<mirror::ArtMethod>* methods, mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string GetDescriptorForProxy(const mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* FindMethodForProxy(const mirror::Class* proxy_class, - const mirror::AbstractMethod* proxy_method) + mirror::ArtMethod* FindMethodForProxy(const mirror::Class* proxy_class, + const mirror::ArtMethod* proxy_method) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method when its class isn't yet initialized - const void* GetOatCodeFor(const mirror::AbstractMethod* method) + const void* GetOatCodeFor(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method from a method index. @@ -361,7 +358,7 @@ class ClassLinker { private: explicit ClassLinker(InternTable*); - const OatFile::OatMethod GetOatMethodFor(const mirror::AbstractMethod* method) + const OatFile::OatMethod GetOatMethodFor(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Initialize class linker by bootstraping from dex files @@ -386,9 +383,8 @@ class ClassLinker { mirror::Class* AllocClass(Thread* self, size_t class_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* AllocField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Method* AllocMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Constructor* AllocConstructor(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtField* AllocArtField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtMethod* AllocArtMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -405,7 +401,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, - mirror::Class* c, SafeMap<uint32_t, mirror::Field*>& field_map) + mirror::Class* c, SafeMap<uint32_t, mirror::ArtField*>& field_map) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t SizeOfClass(const DexFile& dex_file, @@ -418,12 +414,12 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it, - SirtRef<mirror::Class>& klass, SirtRef<mirror::Field>& dst) + SirtRef<mirror::Class>& klass, SirtRef<mirror::ArtField>& dst) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* LoadMethod(Thread* self, const DexFile& dex_file, - const ClassDataItemIterator& dex_method, - SirtRef<mirror::Class>& klass) + mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file, + const ClassDataItemIterator& dex_method, + SirtRef<mirror::Class>& klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -455,7 +451,7 @@ class ClassLinker { const mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsSameMethodSignatureInDifferentClassContexts(const mirror::AbstractMethod* method, + bool IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, const mirror::Class* klass1, const mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -519,11 +515,11 @@ class ClassLinker { EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateProxyConstructor(Thread* self, SirtRef<mirror::Class>& klass, - mirror::Class* proxy_class) + mirror::ArtMethod* CreateProxyConstructor(Thread* self, SirtRef<mirror::Class>& klass, + mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateProxyMethod(Thread* self, SirtRef<mirror::Class>& klass, - SirtRef<mirror::AbstractMethod>& prototype) + mirror::ArtMethod* CreateProxyMethod(Thread* self, SirtRef<mirror::Class>& klass, + SirtRef<mirror::ArtMethod>& prototype) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::vector<const DexFile*> boot_class_path_; @@ -554,15 +550,12 @@ class ClassLinker { kJavaLangString, kJavaLangDexCache, kJavaLangRefReference, - kJavaLangReflectConstructor, - kJavaLangReflectField, - kJavaLangReflectAbstractMethod, - kJavaLangReflectMethod, + kJavaLangReflectArtField, + kJavaLangReflectArtMethod, kJavaLangReflectProxy, kJavaLangStringArrayClass, - kJavaLangReflectAbstractMethodArrayClass, - kJavaLangReflectFieldArrayClass, - kJavaLangReflectMethodArrayClass, + kJavaLangReflectArtFieldArrayClass, + kJavaLangReflectArtMethodArrayClass, kJavaLangClassLoader, kJavaLangThrowable, kJavaLangClassNotFoundException, diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 4659fd1..6442f5a 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -24,42 +24,17 @@ #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" #include "gc/heap.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" #include "mirror/stack_trace_element.h" #include "sirt_ref.h" -using ::art::mirror::AbstractMethod; -using ::art::mirror::AbstractMethodClass; -using ::art::mirror::CharArray; -using ::art::mirror::Class; -using ::art::mirror::ClassClass; -using ::art::mirror::ClassLoader; -using ::art::mirror::Constructor; -using ::art::mirror::DexCache; -using ::art::mirror::DoubleArray; -using ::art::mirror::Field; -using ::art::mirror::FieldClass; -using ::art::mirror::IfTable; -using ::art::mirror::IntArray; -using ::art::mirror::LongArray; -using ::art::mirror::Method; -using ::art::mirror::Object; -using ::art::mirror::ObjectArray; -using ::art::mirror::Proxy; -using ::art::mirror::ShortArray; -using ::art::mirror::StackTraceElement; -using ::art::mirror::StaticStorageBase; -using ::art::mirror::String; -using ::art::mirror::StringClass; -using ::art::mirror::Throwable; - namespace art { class ClassLinkerTest : public CommonTest { @@ -69,9 +44,9 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(class_linker_->FindSystemClass(descriptor.c_str()) == NULL); Thread* self = Thread::Current(); EXPECT_TRUE(self->IsExceptionPending()); - Object* exception = self->GetException(NULL); + mirror::Object* exception = self->GetException(NULL); self->ClearException(); - Class* exception_class = class_linker_->FindSystemClass("Ljava/lang/NoClassDefFoundError;"); + mirror::Class* exception_class = class_linker_->FindSystemClass("Ljava/lang/NoClassDefFoundError;"); EXPECT_TRUE(exception->InstanceOf(exception_class)); } @@ -80,7 +55,7 @@ class ClassLinkerTest : public CommonTest { AssertPrimitiveClass(descriptor, class_linker_->FindSystemClass(descriptor.c_str())); } - void AssertPrimitiveClass(const std::string& descriptor, const Class* primitive) + void AssertPrimitiveClass(const std::string& descriptor, const mirror::Class* primitive) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper primitive_ch(primitive); ASSERT_TRUE(primitive != NULL); @@ -91,7 +66,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(primitive->GetSuperClass() == NULL); EXPECT_FALSE(primitive->HasSuperClass()); EXPECT_TRUE(primitive->GetClassLoader() == NULL); - EXPECT_EQ(Class::kStatusInitialized, primitive->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, primitive->GetStatus()); EXPECT_FALSE(primitive->IsErroneous()); EXPECT_TRUE(primitive->IsLoaded()); EXPECT_TRUE(primitive->IsResolved()); @@ -118,9 +93,9 @@ class ClassLinkerTest : public CommonTest { void AssertArrayClass(const std::string& array_descriptor, const std::string& component_type, - ClassLoader* class_loader) + mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Class* array = class_linker_->FindClass(array_descriptor.c_str(), class_loader); + mirror::Class* array = class_linker_->FindClass(array_descriptor.c_str(), class_loader); ClassHelper array_component_ch(array->GetComponentType()); EXPECT_STREQ(component_type.c_str(), array_component_ch.GetDescriptor()); EXPECT_EQ(class_loader, array->GetClassLoader()); @@ -128,7 +103,7 @@ class ClassLinkerTest : public CommonTest { AssertArrayClass(array_descriptor, array); } - void AssertArrayClass(const std::string& array_descriptor, Class* array) + void AssertArrayClass(const std::string& array_descriptor, mirror::Class* array) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper kh(array); ASSERT_TRUE(array != NULL); @@ -142,7 +117,7 @@ class ClassLinkerTest : public CommonTest { ASSERT_TRUE(array->GetComponentType() != NULL); kh.ChangeClass(array->GetComponentType()); ASSERT_TRUE(kh.GetDescriptor() != NULL); - EXPECT_EQ(Class::kStatusInitialized, array->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, array->GetStatus()); EXPECT_FALSE(array->IsErroneous()); EXPECT_TRUE(array->IsLoaded()); EXPECT_TRUE(array->IsResolved()); @@ -163,7 +138,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_EQ(2U, kh.NumDirectInterfaces()); EXPECT_TRUE(array->GetVTable() != NULL); EXPECT_EQ(2, array->GetIfTableCount()); - IfTable* iftable = array->GetIfTable(); + mirror::IfTable* iftable = array->GetIfTable(); ASSERT_TRUE(iftable != NULL); kh.ChangeClass(kh.GetDirectInterface(0)); EXPECT_STREQ(kh.GetDescriptor(), "Ljava/lang/Cloneable;"); @@ -172,7 +147,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_STREQ(kh.GetDescriptor(), "Ljava/io/Serializable;"); } - void AssertMethod(AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void AssertMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(method); EXPECT_TRUE(method != NULL); EXPECT_TRUE(method->GetClass() != NULL); @@ -193,7 +168,7 @@ class ClassLinkerTest : public CommonTest { method->GetDexCacheInitializedStaticStorage()); } - void AssertField(Class* klass, Field* field) + void AssertField(mirror::Class* klass, mirror::ArtField* field) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FieldHelper fh(field); EXPECT_TRUE(field != NULL); @@ -203,7 +178,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(fh.GetType() != NULL); } - void AssertClass(const std::string& descriptor, Class* klass) + void AssertClass(const std::string& descriptor, mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper kh(klass); EXPECT_STREQ(descriptor.c_str(), kh.GetDescriptor()); @@ -222,7 +197,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_FALSE(klass->IsArrayClass()); EXPECT_TRUE(klass->GetComponentType() == NULL); EXPECT_TRUE(klass->IsInSamePackage(klass)); - EXPECT_TRUE(Class::IsInSamePackage(kh.GetDescriptor(), kh.GetDescriptor())); + EXPECT_TRUE(mirror::Class::IsInSamePackage(kh.GetDescriptor(), kh.GetDescriptor())); if (klass->IsInterface()) { EXPECT_TRUE(klass->IsAbstract()); if (klass->NumDirectMethods() == 1) { @@ -238,9 +213,9 @@ class ClassLinkerTest : public CommonTest { } } EXPECT_EQ(klass->IsInterface(), klass->GetVTable() == NULL); - const IfTable* iftable = klass->GetIfTable(); + const mirror::IfTable* iftable = klass->GetIfTable(); for (int i = 0; i < klass->GetIfTableCount(); i++) { - Class* interface = iftable->GetInterface(i); + mirror::Class* interface = iftable->GetInterface(i); ASSERT_TRUE(interface != NULL); if (klass->IsInterface()) { EXPECT_EQ(0U, iftable->GetMethodArrayCount(i)); @@ -266,27 +241,27 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(klass->CanAccess(klass)); for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - AbstractMethod* method = klass->GetDirectMethod(i); + mirror::ArtMethod* method = klass->GetDirectMethod(i); AssertMethod(method); EXPECT_TRUE(method->IsDirect()); EXPECT_EQ(klass, method->GetDeclaringClass()); } for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - AbstractMethod* method = klass->GetVirtualMethod(i); + mirror::ArtMethod* method = klass->GetVirtualMethod(i); AssertMethod(method); EXPECT_FALSE(method->IsDirect()); EXPECT_TRUE(method->GetDeclaringClass()->IsAssignableFrom(klass)); } for (size_t i = 0; i < klass->NumInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); AssertField(klass, field); EXPECT_FALSE(field->IsStatic()); } for (size_t i = 0; i < klass->NumStaticFields(); i++) { - Field* field = klass->GetStaticField(i); + mirror::ArtField* field = klass->GetStaticField(i); AssertField(klass, field); EXPECT_TRUE(field->IsStatic()); } @@ -295,17 +270,17 @@ class ClassLinkerTest : public CommonTest { EXPECT_GE(klass->NumInstanceFields(), klass->NumReferenceInstanceFields()); FieldHelper fh; for (size_t i = 0; i < klass->NumReferenceInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); fh.ChangeField(field); ASSERT_TRUE(!fh.IsPrimitiveType()); - Class* field_type = fh.GetType(); + mirror::Class* field_type = fh.GetType(); ASSERT_TRUE(field_type != NULL); ASSERT_TRUE(!field_type->IsPrimitive()); } for (size_t i = klass->NumReferenceInstanceFields(); i < klass->NumInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); fh.ChangeField(field); - Class* field_type = fh.GetType(); + mirror::Class* field_type = fh.GetType(); ASSERT_TRUE(field_type != NULL); if (!fh.IsPrimitiveType() || !field_type->IsPrimitive()) { // While Reference.referent is not primitive, the ClassLinker @@ -315,7 +290,7 @@ class ClassLinkerTest : public CommonTest { } size_t total_num_reference_instance_fields = 0; - Class* k = klass; + mirror::Class* k = klass; while (k != NULL) { total_num_reference_instance_fields += k->NumReferenceInstanceFields(); k = k->GetSuperClass(); @@ -324,10 +299,10 @@ class ClassLinkerTest : public CommonTest { total_num_reference_instance_fields == 0); } - void AssertDexFileClass(ClassLoader* class_loader, const std::string& descriptor) + void AssertDexFileClass(mirror::ClassLoader* class_loader, const std::string& descriptor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ASSERT_TRUE(descriptor != NULL); - Class* klass = class_linker_->FindSystemClass(descriptor.c_str()); + mirror::Class* klass = class_linker_->FindSystemClass(descriptor.c_str()); ASSERT_TRUE(klass != NULL); EXPECT_STREQ(descriptor.c_str(), ClassHelper(klass).GetDescriptor()); EXPECT_EQ(class_loader, klass->GetClassLoader()); @@ -340,7 +315,7 @@ class ClassLinkerTest : public CommonTest { } } - void AssertDexFile(const DexFile* dex, ClassLoader* class_loader) + void AssertDexFile(const DexFile* dex, mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ASSERT_TRUE(dex != NULL); @@ -358,14 +333,14 @@ class ClassLinkerTest : public CommonTest { } class_linker_->VisitRoots(TestRootVisitor, NULL, false); // Verify the dex cache has resolution methods in all resolved method slots - DexCache* dex_cache = class_linker_->FindDexCache(*dex); - ObjectArray<AbstractMethod>* resolved_methods = dex_cache->GetResolvedMethods(); + mirror::DexCache* dex_cache = class_linker_->FindDexCache(*dex); + mirror::ObjectArray<mirror::ArtMethod>* resolved_methods = dex_cache->GetResolvedMethods(); for (size_t i = 0; i < static_cast<size_t>(resolved_methods->GetLength()); i++) { EXPECT_TRUE(resolved_methods->Get(i) != NULL); } } - static void TestRootVisitor(const Object* root, void*) { + static void TestRootVisitor(const mirror::Object* root, void*) { EXPECT_TRUE(root != NULL); } }; @@ -385,7 +360,7 @@ struct CheckOffsets { std::vector<CheckOffset> offsets; bool Check() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Class* klass = Runtime::Current()->GetClassLinker()->FindSystemClass(class_descriptor.c_str()); + mirror::Class* klass = Runtime::Current()->GetClassLinker()->FindSystemClass(class_descriptor.c_str()); CHECK(klass != NULL) << class_descriptor; bool error = false; @@ -412,7 +387,7 @@ struct CheckOffsets { FieldHelper fh; for (size_t i = 0; i < offsets.size(); i++) { - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); fh.ChangeField(field); StringPiece field_name(fh.GetName()); if (field_name != offsets[i].java_name) { @@ -422,7 +397,7 @@ struct CheckOffsets { if (error) { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); fh.ChangeField(field); StringPiece field_name(fh.GetName()); if (field_name != offsets[i].java_name) { @@ -437,7 +412,7 @@ struct CheckOffsets { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); if (field->GetOffset().Uint32Value() != offset.cpp_offset) { error = true; } @@ -445,7 +420,7 @@ struct CheckOffsets { if (error) { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); if (field->GetOffset().Uint32Value() != offset.cpp_offset) { LOG(ERROR) << "OFFSET MISMATCH NEXT LINE:"; } @@ -464,195 +439,179 @@ struct CheckOffsets { // Note that ClassLinkerTest.ValidateFieldOrderOfJavaCppUnionClasses // is first since if it is failing, others are unlikely to succeed. -struct ObjectOffsets : public CheckOffsets<Object> { - ObjectOffsets() : CheckOffsets<Object>(false, "Ljava/lang/Object;") { +struct ObjectOffsets : public CheckOffsets<mirror::Object> { + ObjectOffsets() : CheckOffsets<mirror::Object>(false, "Ljava/lang/Object;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Object, klass_), "shadow$_klass_")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Object, klass_), "shadow$_klass_")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Object, monitor_), "shadow$_monitor_")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Object, monitor_), "shadow$_monitor_")); }; }; -struct FieldOffsets : public CheckOffsets<Field> { - FieldOffsets() : CheckOffsets<Field>(false, "Ljava/lang/reflect/Field;") { +struct ArtFieldOffsets : public CheckOffsets<mirror::ArtField> { + ArtFieldOffsets() : CheckOffsets<mirror::ArtField>(false, "Ljava/lang/reflect/ArtField;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, declaring_class_), "declaringClass")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, field_dex_idx_), "fieldDexIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, offset_), "offset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, field_dex_idx_), "fieldDexIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, offset_), "offset")); }; }; -struct AbstractMethodOffsets : public CheckOffsets<AbstractMethod> { - AbstractMethodOffsets() : CheckOffsets<AbstractMethod>(false, "Ljava/lang/reflect/AbstractMethod;") { +struct ArtMethodOffsets : public CheckOffsets<mirror::ArtMethod> { + ArtMethodOffsets() : CheckOffsets<mirror::ArtMethod>(false, "Ljava/lang/reflect/ArtMethod;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_), "declaringClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_resolved_methods_), "dexCacheResolvedMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_resolved_types_), "dexCacheResolvedTypes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_strings_), "dexCacheStrings")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_resolved_methods_), "dexCacheResolvedMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_resolved_types_), "dexCacheResolvedTypes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_strings_), "dexCacheStrings")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, code_item_offset_), "codeItemOffset")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, core_spill_mask_), "coreSpillMask")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_compiled_code_), "entryPointFromCompiledCode")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_interpreter_), "entryPointFromInterpreter")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, fp_spill_mask_), "fpSpillMask")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, frame_size_in_bytes_), "frameSizeInBytes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, gc_map_), "gcMap")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, mapping_table_), "mappingTable")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, method_dex_index_), "methodDexIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, method_index_), "methodIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, native_method_), "nativeMethod")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, vmap_table_), "vmapTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, code_item_offset_), "codeItemOffset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, core_spill_mask_), "coreSpillMask")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, entry_point_from_compiled_code_), "entryPointFromCompiledCode")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, entry_point_from_interpreter_), "entryPointFromInterpreter")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, fp_spill_mask_), "fpSpillMask")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, frame_size_in_bytes_), "frameSizeInBytes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, gc_map_), "gcMap")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, mapping_table_), "mappingTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_dex_index_), "methodDexIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_index_), "methodIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, native_method_), "nativeMethod")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, vmap_table_), "vmapTable")); }; }; -struct ConstructorOffsets : public CheckOffsets<Constructor> { - // java.lang.reflect.Constructor is a subclass of java.lang.reflect.AbstractMethod - ConstructorOffsets() : CheckOffsets<Constructor>(false, "Ljava/lang/reflect/Constructor;") { - } -}; - -struct MethodOffsets : public CheckOffsets<Method> { - // java.lang.reflect.Method is a subclass of java.lang.reflect.AbstractMethod - MethodOffsets() : CheckOffsets<Method>(false, "Ljava/lang/reflect/Method;") { - } -}; - -struct ClassOffsets : public CheckOffsets<Class> { - ClassOffsets() : CheckOffsets<Class>(false, "Ljava/lang/Class;") { +struct ClassOffsets : public CheckOffsets<mirror::Class> { + ClassOffsets() : CheckOffsets<mirror::Class>(false, "Ljava/lang/Class;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_loader_), "classLoader")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, component_type_), "componentType")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, dex_cache_), "dexCache")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, direct_methods_), "directMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, ifields_), "iFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, iftable_), "ifTable")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, name_), "name")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, sfields_), "sFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, super_class_), "superClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, verify_error_class_), "verifyErrorClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, virtual_methods_), "virtualMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, vtable_), "vtable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_loader_), "classLoader")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, component_type_), "componentType")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_cache_), "dexCache")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, direct_methods_), "directMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, ifields_), "iFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, iftable_), "ifTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, name_), "name")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, sfields_), "sFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, super_class_), "superClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, verify_error_class_), "verifyErrorClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, virtual_methods_), "virtualMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, vtable_), "vtable")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_size_), "classSize")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, clinit_thread_id_), "clinitThreadId")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, dex_type_idx_), "dexTypeIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_instance_fields_), "numReferenceInstanceFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_static_fields_), "numReferenceStaticFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, object_size_), "objectSize")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, primitive_type_), "primitiveType")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_instance_offsets_), "referenceInstanceOffsets")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_static_offsets_), "referenceStaticOffsets")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, status_), "status")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_size_), "classSize")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, clinit_thread_id_), "clinitThreadId")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_type_idx_), "dexTypeIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_instance_fields_), "numReferenceInstanceFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_static_fields_), "numReferenceStaticFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, object_size_), "objectSize")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, primitive_type_), "primitiveType")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, reference_instance_offsets_), "referenceInstanceOffsets")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, reference_static_offsets_), "referenceStaticOffsets")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, status_), "status")); }; }; -struct StringOffsets : public CheckOffsets<String> { - StringOffsets() : CheckOffsets<String>(false, "Ljava/lang/String;") { +struct StringOffsets : public CheckOffsets<mirror::String> { + StringOffsets() : CheckOffsets<mirror::String>(false, "Ljava/lang/String;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, array_), "value")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, array_), "value")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, count_), "count")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, hash_code_), "hashCode")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, offset_), "offset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, count_), "count")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, hash_code_), "hashCode")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, offset_), "offset")); }; }; -struct ThrowableOffsets : public CheckOffsets<Throwable> { - ThrowableOffsets() : CheckOffsets<Throwable>(false, "Ljava/lang/Throwable;") { +struct ThrowableOffsets : public CheckOffsets<mirror::Throwable> { + ThrowableOffsets() : CheckOffsets<mirror::Throwable>(false, "Ljava/lang/Throwable;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, cause_), "cause")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, detail_message_), "detailMessage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, stack_state_), "stackState")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, stack_trace_), "stackTrace")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, suppressed_exceptions_), "suppressedExceptions")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, cause_), "cause")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, detail_message_), "detailMessage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, stack_state_), "stackState")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, stack_trace_), "stackTrace")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, suppressed_exceptions_), "suppressedExceptions")); }; }; -struct StackTraceElementOffsets : public CheckOffsets<StackTraceElement> { - StackTraceElementOffsets() : CheckOffsets<StackTraceElement>(false, "Ljava/lang/StackTraceElement;") { +struct StackTraceElementOffsets : public CheckOffsets<mirror::StackTraceElement> { + StackTraceElementOffsets() : CheckOffsets<mirror::StackTraceElement>(false, "Ljava/lang/StackTraceElement;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, declaring_class_), "declaringClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, file_name_), "fileName")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, method_name_), "methodName")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, line_number_), "lineNumber")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, file_name_), "fileName")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, method_name_), "methodName")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, line_number_), "lineNumber")); }; }; -struct ClassLoaderOffsets : public CheckOffsets<ClassLoader> { - ClassLoaderOffsets() : CheckOffsets<ClassLoader>(false, "Ljava/lang/ClassLoader;") { +struct ClassLoaderOffsets : public CheckOffsets<mirror::ClassLoader> { + ClassLoaderOffsets() : CheckOffsets<mirror::ClassLoader>(false, "Ljava/lang/ClassLoader;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, packages_), "packages")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, parent_), "parent")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, proxyCache_), "proxyCache")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, packages_), "packages")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, parent_), "parent")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, proxyCache_), "proxyCache")); }; }; -struct ProxyOffsets : public CheckOffsets<Proxy> { - ProxyOffsets() : CheckOffsets<Proxy>(false, "Ljava/lang/reflect/Proxy;") { +struct ProxyOffsets : public CheckOffsets<mirror::Proxy> { + ProxyOffsets() : CheckOffsets<mirror::Proxy>(false, "Ljava/lang/reflect/Proxy;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Proxy, h_), "h")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Proxy, h_), "h")); }; }; -struct ClassClassOffsets : public CheckOffsets<ClassClass> { - ClassClassOffsets() : CheckOffsets<ClassClass>(true, "Ljava/lang/Class;") { +struct ClassClassOffsets : public CheckOffsets<mirror::ClassClass> { + ClassClassOffsets() : CheckOffsets<mirror::ClassClass>(true, "Ljava/lang/Class;") { // padding 32-bit - CHECK_EQ(OFFSETOF_MEMBER(ClassClass, padding_) + 4, - OFFSETOF_MEMBER(ClassClass, serialVersionUID_)); + CHECK_EQ(OFFSETOF_MEMBER(mirror::ClassClass, padding_) + 4, + OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_)); // alphabetical 64-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassClass, serialVersionUID_), "serialVersionUID")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_), "serialVersionUID")); }; }; -struct StringClassOffsets : public CheckOffsets<StringClass> { - StringClassOffsets() : CheckOffsets<StringClass>(true, "Ljava/lang/String;") { +struct StringClassOffsets : public CheckOffsets<mirror::StringClass> { + StringClassOffsets() : CheckOffsets<mirror::StringClass>(true, "Ljava/lang/String;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, ASCII_), "ASCII")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, ASCII_), "ASCII")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); // padding 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); // alphabetical 64-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, serialVersionUID_), "serialVersionUID")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, serialVersionUID_), "serialVersionUID")); }; }; -struct FieldClassOffsets : public CheckOffsets<FieldClass> { - FieldClassOffsets() : CheckOffsets<FieldClass>(true, "Ljava/lang/reflect/Field;") { - // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(FieldClass, ORDER_BY_NAME_AND_DECLARING_CLASS_), "ORDER_BY_NAME_AND_DECLARING_CLASS")); +struct ArtFieldClassOffsets : public CheckOffsets<mirror::ArtFieldClass> { + ArtFieldClassOffsets() : CheckOffsets<mirror::ArtFieldClass>(true, "Ljava/lang/reflect/ArtField;") { }; }; -struct MethodClassOffsets : public CheckOffsets<AbstractMethodClass> { - MethodClassOffsets() : CheckOffsets<AbstractMethodClass>(true, "Ljava/lang/reflect/Method;") { - // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethodClass, ORDER_BY_SIGNATURE_), "ORDER_BY_SIGNATURE")); +struct ArtMethodClassOffsets : public CheckOffsets<mirror::ArtMethodClass> { + ArtMethodClassOffsets() : CheckOffsets<mirror::ArtMethodClass>(true, "Ljava/lang/reflect/ArtMethod;") { }; }; -struct DexCacheOffsets : public CheckOffsets<DexCache> { - DexCacheOffsets() : CheckOffsets<DexCache>(false, "Ljava/lang/DexCache;") { +struct DexCacheOffsets : public CheckOffsets<mirror::DexCache> { + DexCacheOffsets() : CheckOffsets<mirror::DexCache>(false, "Ljava/lang/DexCache;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, initialized_static_storage_), "initializedStaticStorage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, location_), "location")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_fields_), "resolvedFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_methods_), "resolvedMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_types_), "resolvedTypes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, strings_), "strings")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, dex_file_), "dexFile")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, initialized_static_storage_), "initializedStaticStorage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, location_), "location")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_fields_), "resolvedFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_methods_), "resolvedMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_types_), "resolvedTypes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, strings_), "strings")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, dex_file_), "dexFile")); }; }; @@ -662,10 +621,8 @@ struct DexCacheOffsets : public CheckOffsets<DexCache> { TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { ScopedObjectAccess soa(Thread::Current()); EXPECT_TRUE(ObjectOffsets().Check()); - EXPECT_TRUE(ConstructorOffsets().Check()); - EXPECT_TRUE(MethodOffsets().Check()); - EXPECT_TRUE(FieldOffsets().Check()); - EXPECT_TRUE(AbstractMethodOffsets().Check()); + EXPECT_TRUE(ArtFieldOffsets().Check()); + EXPECT_TRUE(ArtMethodOffsets().Check()); EXPECT_TRUE(ClassOffsets().Check()); EXPECT_TRUE(StringOffsets().Check()); EXPECT_TRUE(ThrowableOffsets().Check()); @@ -676,8 +633,8 @@ TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { EXPECT_TRUE(ClassClassOffsets().Check()); EXPECT_TRUE(StringClassOffsets().Check()); - EXPECT_TRUE(FieldClassOffsets().Check()); - EXPECT_TRUE(MethodClassOffsets().Check()); + EXPECT_TRUE(ArtFieldClassOffsets().Check()); + EXPECT_TRUE(ArtMethodClassOffsets().Check()); } TEST_F(ClassLinkerTest, FindClassNonexistent) { @@ -688,14 +645,14 @@ TEST_F(ClassLinkerTest, FindClassNonexistent) { TEST_F(ClassLinkerTest, FindClassNested) { ScopedObjectAccess soa(Thread::Current()); - SirtRef<ClassLoader> class_loader(soa.Self(), soa.Decode<ClassLoader*>(LoadDex("Nested"))); + SirtRef<mirror::ClassLoader> class_loader(soa.Self(), soa.Decode<mirror::ClassLoader*>(LoadDex("Nested"))); - Class* outer = class_linker_->FindClass("LNested;", class_loader.get()); + mirror::Class* outer = class_linker_->FindClass("LNested;", class_loader.get()); ASSERT_TRUE(outer != NULL); EXPECT_EQ(0U, outer->NumVirtualMethods()); EXPECT_EQ(1U, outer->NumDirectMethods()); - Class* inner = class_linker_->FindClass("LNested$Inner;", class_loader.get()); + mirror::Class* inner = class_linker_->FindClass("LNested$Inner;", class_loader.get()); ASSERT_TRUE(inner != NULL); EXPECT_EQ(0U, inner->NumVirtualMethods()); EXPECT_EQ(1U, inner->NumDirectMethods()); @@ -717,7 +674,7 @@ TEST_F(ClassLinkerTest, FindClass_Primitives) { TEST_F(ClassLinkerTest, FindClass) { ScopedObjectAccess soa(Thread::Current()); - Class* JavaLangObject = class_linker_->FindSystemClass("Ljava/lang/Object;"); + mirror::Class* JavaLangObject = class_linker_->FindSystemClass("Ljava/lang/Object;"); ClassHelper kh(JavaLangObject); ASSERT_TRUE(JavaLangObject != NULL); ASSERT_TRUE(JavaLangObject->GetClass() != NULL); @@ -727,12 +684,12 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_TRUE(JavaLangObject->GetSuperClass() == NULL); EXPECT_FALSE(JavaLangObject->HasSuperClass()); EXPECT_TRUE(JavaLangObject->GetClassLoader() == NULL); - EXPECT_EQ(Class::kStatusResolved, JavaLangObject->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, JavaLangObject->GetStatus()); EXPECT_FALSE(JavaLangObject->IsErroneous()); EXPECT_TRUE(JavaLangObject->IsLoaded()); EXPECT_TRUE(JavaLangObject->IsResolved()); - EXPECT_FALSE(JavaLangObject->IsVerified()); - EXPECT_FALSE(JavaLangObject->IsInitialized()); + EXPECT_TRUE(JavaLangObject->IsVerified()); + EXPECT_TRUE(JavaLangObject->IsInitialized()); EXPECT_FALSE(JavaLangObject->IsArrayInstance()); EXPECT_FALSE(JavaLangObject->IsArrayClass()); EXPECT_TRUE(JavaLangObject->GetComponentType() == NULL); @@ -752,9 +709,9 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_EQ(0U, JavaLangObject->NumStaticFields()); EXPECT_EQ(0U, kh.NumDirectInterfaces()); - SirtRef<ClassLoader> class_loader(soa.Self(), soa.Decode<ClassLoader*>(LoadDex("MyClass"))); + SirtRef<mirror::ClassLoader> class_loader(soa.Self(), soa.Decode<mirror::ClassLoader*>(LoadDex("MyClass"))); AssertNonExistentClass("LMyClass;"); - Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader.get()); + mirror::Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader.get()); kh.ChangeClass(MyClass); ASSERT_TRUE(MyClass != NULL); ASSERT_TRUE(MyClass->GetClass() != NULL); @@ -764,7 +721,7 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_TRUE(MyClass->GetSuperClass() == JavaLangObject); EXPECT_TRUE(MyClass->HasSuperClass()); EXPECT_EQ(class_loader.get(), MyClass->GetClassLoader()); - EXPECT_EQ(Class::kStatusResolved, MyClass->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusResolved, MyClass->GetStatus()); EXPECT_FALSE(MyClass->IsErroneous()); EXPECT_TRUE(MyClass->IsLoaded()); EXPECT_TRUE(MyClass->IsResolved()); @@ -805,12 +762,13 @@ TEST_F(ClassLinkerTest, LibCore) { // start of the object TEST_F(ClassLinkerTest, ValidateObjectArrayElementsOffset) { ScopedObjectAccess soa(Thread::Current()); - Class* array_class = class_linker_->FindSystemClass("[Ljava/lang/String;"); - ObjectArray<String>* array = ObjectArray<String>::Alloc(soa.Self(), array_class, 0); + mirror::Class* array_class = class_linker_->FindSystemClass("[Ljava/lang/String;"); + mirror::ObjectArray<mirror::String>* array = + mirror::ObjectArray<mirror::String>::Alloc(soa.Self(), array_class, 0); uint32_t array_offset = reinterpret_cast<uint32_t>(array); uint32_t data_offset = - array_offset + ObjectArray<String>::DataOffset(sizeof(String*)).Uint32Value(); - if (sizeof(String*) == sizeof(int32_t)) { + array_offset + mirror::ObjectArray<mirror::String>::DataOffset(sizeof(mirror::String*)).Uint32Value(); + if (sizeof(mirror::String*) == sizeof(int32_t)) { EXPECT_TRUE(IsAligned<4>(data_offset)); // Check 4 byte alignment. } else { EXPECT_TRUE(IsAligned<8>(data_offset)); // Check 8 byte alignment. @@ -819,27 +777,27 @@ TEST_F(ClassLinkerTest, ValidateObjectArrayElementsOffset) { TEST_F(ClassLinkerTest, ValidatePrimitiveArrayElementsOffset) { ScopedObjectAccess soa(Thread::Current()); - SirtRef<LongArray> long_array(soa.Self(), LongArray::Alloc(soa.Self(), 0)); + SirtRef<mirror::LongArray> long_array(soa.Self(), mirror::LongArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[J"), long_array->GetClass()); uintptr_t data_offset = reinterpret_cast<uintptr_t>(long_array->GetData()); EXPECT_TRUE(IsAligned<8>(data_offset)); // Longs require 8 byte alignment - SirtRef<DoubleArray> double_array(soa.Self(), DoubleArray::Alloc(soa.Self(), 0)); + SirtRef<mirror::DoubleArray> double_array(soa.Self(), mirror::DoubleArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[D"), double_array->GetClass()); data_offset = reinterpret_cast<uintptr_t>(double_array->GetData()); EXPECT_TRUE(IsAligned<8>(data_offset)); // Doubles require 8 byte alignment - SirtRef<IntArray> int_array(soa.Self(), IntArray::Alloc(soa.Self(), 0)); + SirtRef<mirror::IntArray> int_array(soa.Self(), mirror::IntArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[I"), int_array->GetClass()); data_offset = reinterpret_cast<uintptr_t>(int_array->GetData()); EXPECT_TRUE(IsAligned<4>(data_offset)); // Ints require 4 byte alignment - SirtRef<CharArray> char_array(soa.Self(), CharArray::Alloc(soa.Self(), 0)); + SirtRef<mirror::CharArray> char_array(soa.Self(), mirror::CharArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[C"), char_array->GetClass()); data_offset = reinterpret_cast<uintptr_t>(char_array->GetData()); EXPECT_TRUE(IsAligned<2>(data_offset)); // Chars require 2 byte alignment - SirtRef<ShortArray> short_array(soa.Self(), ShortArray::Alloc(soa.Self(), 0)); + SirtRef<mirror::ShortArray> short_array(soa.Self(), mirror::ShortArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[S"), short_array->GetClass()); data_offset = reinterpret_cast<uintptr_t>(short_array->GetData()); EXPECT_TRUE(IsAligned<2>(data_offset)); // Shorts require 2 byte alignment @@ -851,7 +809,7 @@ TEST_F(ClassLinkerTest, ValidateBoxedTypes) { // Validate that the "value" field is always the 0th field in each of java.lang's box classes. // This lets UnboxPrimitive avoid searching for the field by name at runtime. ScopedObjectAccess soa(Thread::Current()); - Class* c; + mirror::Class* c; c = class_linker_->FindClass("Ljava/lang/Boolean;", NULL); FieldHelper fh(c->GetIFields()->Get(0)); EXPECT_STREQ("value", fh.GetName()); @@ -880,10 +838,10 @@ TEST_F(ClassLinkerTest, ValidateBoxedTypes) { TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) { ScopedObjectAccess soa(Thread::Current()); - SirtRef<ClassLoader> class_loader_1(soa.Self(), soa.Decode<ClassLoader*>(LoadDex("MyClass"))); - SirtRef<ClassLoader> class_loader_2(soa.Self(), soa.Decode<ClassLoader*>(LoadDex("MyClass"))); - Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1.get()); - Class* MyClass_2 = class_linker_->FindClass("LMyClass;", class_loader_2.get()); + SirtRef<mirror::ClassLoader> class_loader_1(soa.Self(), soa.Decode<mirror::ClassLoader*>(LoadDex("MyClass"))); + SirtRef<mirror::ClassLoader> class_loader_2(soa.Self(), soa.Decode<mirror::ClassLoader*>(LoadDex("MyClass"))); + mirror::Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1.get()); + mirror::Class* MyClass_2 = class_linker_->FindClass("LMyClass;", class_loader_2.get()); EXPECT_TRUE(MyClass_1 != NULL); EXPECT_TRUE(MyClass_2 != NULL); EXPECT_NE(MyClass_1, MyClass_2); @@ -891,72 +849,72 @@ TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) { TEST_F(ClassLinkerTest, StaticFields) { ScopedObjectAccess soa(Thread::Current()); - SirtRef<ClassLoader> class_loader(soa.Self(), soa.Decode<ClassLoader*>(LoadDex("Statics"))); - Class* statics = class_linker_->FindClass("LStatics;", class_loader.get()); + SirtRef<mirror::ClassLoader> class_loader(soa.Self(), soa.Decode<mirror::ClassLoader*>(LoadDex("Statics"))); + mirror::Class* statics = class_linker_->FindClass("LStatics;", class_loader.get()); class_linker_->EnsureInitialized(statics, true, true); // Static final primitives that are initialized by a compile-time constant // expression resolve to a copy of a constant value from the constant pool. // So <clinit> should be null. - AbstractMethod* clinit = statics->FindDirectMethod("<clinit>", "()V"); + mirror::ArtMethod* clinit = statics->FindDirectMethod("<clinit>", "()V"); EXPECT_TRUE(clinit == NULL); EXPECT_EQ(9U, statics->NumStaticFields()); - Field* s0 = statics->FindStaticField("s0", "Z"); + mirror::ArtField* s0 = statics->FindStaticField("s0", "Z"); FieldHelper fh(s0); - EXPECT_STREQ(ClassHelper(s0->GetClass()).GetDescriptor(), "Ljava/lang/reflect/Field;"); + EXPECT_STREQ(ClassHelper(s0->GetClass()).GetDescriptor(), "Ljava/lang/reflect/ArtField;"); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimBoolean); EXPECT_EQ(true, s0->GetBoolean(statics)); s0->SetBoolean(statics, false); - Field* s1 = statics->FindStaticField("s1", "B"); + mirror::ArtField* s1 = statics->FindStaticField("s1", "B"); fh.ChangeField(s1); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimByte); EXPECT_EQ(5, s1->GetByte(statics)); s1->SetByte(statics, 6); - Field* s2 = statics->FindStaticField("s2", "C"); + mirror::ArtField* s2 = statics->FindStaticField("s2", "C"); fh.ChangeField(s2); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimChar); EXPECT_EQ('a', s2->GetChar(statics)); s2->SetChar(statics, 'b'); - Field* s3 = statics->FindStaticField("s3", "S"); + mirror::ArtField* s3 = statics->FindStaticField("s3", "S"); fh.ChangeField(s3); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimShort); EXPECT_EQ(-536, s3->GetShort(statics)); s3->SetShort(statics, -535); - Field* s4 = statics->FindStaticField("s4", "I"); + mirror::ArtField* s4 = statics->FindStaticField("s4", "I"); fh.ChangeField(s4); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimInt); EXPECT_EQ(2000000000, s4->GetInt(statics)); s4->SetInt(statics, 2000000001); - Field* s5 = statics->FindStaticField("s5", "J"); + mirror::ArtField* s5 = statics->FindStaticField("s5", "J"); fh.ChangeField(s5); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimLong); EXPECT_EQ(0x1234567890abcdefLL, s5->GetLong(statics)); s5->SetLong(statics, 0x34567890abcdef12LL); - Field* s6 = statics->FindStaticField("s6", "F"); + mirror::ArtField* s6 = statics->FindStaticField("s6", "F"); fh.ChangeField(s6); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimFloat); EXPECT_EQ(0.5, s6->GetFloat(statics)); s6->SetFloat(statics, 0.75); - Field* s7 = statics->FindStaticField("s7", "D"); + mirror::ArtField* s7 = statics->FindStaticField("s7", "D"); fh.ChangeField(s7); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimDouble); EXPECT_EQ(16777217, s7->GetDouble(statics)); s7->SetDouble(statics, 16777219); - Field* s8 = statics->FindStaticField("s8", "Ljava/lang/String;"); + mirror::ArtField* s8 = statics->FindStaticField("s8", "Ljava/lang/String;"); fh.ChangeField(s8); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimNot); EXPECT_TRUE(s8->GetObject(statics)->AsString()->Equals("android")); - s8->SetObject(s8->GetDeclaringClass(), String::AllocFromModifiedUtf8(soa.Self(), "robot")); + s8->SetObject(s8->GetDeclaringClass(), mirror::String::AllocFromModifiedUtf8(soa.Self(), "robot")); // TODO: Remove EXPECT_FALSE when GCC can handle EXPECT_EQ // http://code.google.com/p/googletest/issues/detail?id=322 @@ -973,27 +931,27 @@ TEST_F(ClassLinkerTest, StaticFields) { TEST_F(ClassLinkerTest, Interfaces) { ScopedObjectAccess soa(Thread::Current()); - SirtRef<ClassLoader> class_loader(soa.Self(), soa.Decode<ClassLoader*>(LoadDex("Interfaces"))); - Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader.get()); - Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader.get()); - Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader.get()); - Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader.get()); - Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader.get()); + SirtRef<mirror::ClassLoader> class_loader(soa.Self(), soa.Decode<mirror::ClassLoader*>(LoadDex("Interfaces"))); + mirror::Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader.get()); + mirror::Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader.get()); + mirror::Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader.get()); + mirror::Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader.get()); + mirror::Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader.get()); EXPECT_TRUE(I->IsAssignableFrom(A)); EXPECT_TRUE(J->IsAssignableFrom(A)); EXPECT_TRUE(J->IsAssignableFrom(K)); EXPECT_TRUE(K->IsAssignableFrom(B)); EXPECT_TRUE(J->IsAssignableFrom(B)); - AbstractMethod* Ii = I->FindVirtualMethod("i", "()V"); - AbstractMethod* Jj1 = J->FindVirtualMethod("j1", "()V"); - AbstractMethod* Jj2 = J->FindVirtualMethod("j2", "()V"); - AbstractMethod* Kj1 = K->FindInterfaceMethod("j1", "()V"); - AbstractMethod* Kj2 = K->FindInterfaceMethod("j2", "()V"); - AbstractMethod* Kk = K->FindInterfaceMethod("k", "()V"); - AbstractMethod* Ai = A->FindVirtualMethod("i", "()V"); - AbstractMethod* Aj1 = A->FindVirtualMethod("j1", "()V"); - AbstractMethod* Aj2 = A->FindVirtualMethod("j2", "()V"); + mirror::ArtMethod* Ii = I->FindVirtualMethod("i", "()V"); + mirror::ArtMethod* Jj1 = J->FindVirtualMethod("j1", "()V"); + mirror::ArtMethod* Jj2 = J->FindVirtualMethod("j2", "()V"); + mirror::ArtMethod* Kj1 = K->FindInterfaceMethod("j1", "()V"); + mirror::ArtMethod* Kj2 = K->FindInterfaceMethod("j2", "()V"); + mirror::ArtMethod* Kk = K->FindInterfaceMethod("k", "()V"); + mirror::ArtMethod* Ai = A->FindVirtualMethod("i", "()V"); + mirror::ArtMethod* Aj1 = A->FindVirtualMethod("j1", "()V"); + mirror::ArtMethod* Aj2 = A->FindVirtualMethod("j2", "()V"); ASSERT_TRUE(Ii != NULL); ASSERT_TRUE(Jj1 != NULL); ASSERT_TRUE(Jj2 != NULL); @@ -1015,10 +973,10 @@ TEST_F(ClassLinkerTest, Interfaces) { EXPECT_EQ(Aj1, A->FindVirtualMethodForVirtualOrInterface(Jj1)); EXPECT_EQ(Aj2, A->FindVirtualMethodForVirtualOrInterface(Jj2)); - Field* Afoo = A->FindStaticField("foo", "Ljava/lang/String;"); - Field* Bfoo = B->FindStaticField("foo", "Ljava/lang/String;"); - Field* Jfoo = J->FindStaticField("foo", "Ljava/lang/String;"); - Field* Kfoo = K->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Afoo = A->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Bfoo = B->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Jfoo = J->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Kfoo = K->FindStaticField("foo", "Ljava/lang/String;"); ASSERT_TRUE(Afoo != NULL); EXPECT_EQ(Afoo, Bfoo); EXPECT_EQ(Afoo, Jfoo); @@ -1033,30 +991,30 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) { ScopedObjectAccess soa(Thread::Current()); jobject jclass_loader = LoadDex("StaticsFromCode"); - SirtRef<ClassLoader> class_loader(soa.Self(), soa.Decode<ClassLoader*>(jclass_loader)); + SirtRef<mirror::ClassLoader> class_loader(soa.Self(), soa.Decode<mirror::ClassLoader*>(jclass_loader)); const DexFile* dex_file = Runtime::Current()->GetCompileTimeClassPath(jclass_loader)[0]; CHECK(dex_file != NULL); - Class* klass = class_linker_->FindClass("LStaticsFromCode;", class_loader.get()); - AbstractMethod* clinit = klass->FindDirectMethod("<clinit>", "()V"); - AbstractMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); + mirror::Class* klass = class_linker_->FindClass("LStaticsFromCode;", class_loader.get()); + mirror::ArtMethod* clinit = klass->FindDirectMethod("<clinit>", "()V"); + mirror::ArtMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); const DexFile::StringId* string_id = dex_file->FindStringId("LStaticsFromCode;"); ASSERT_TRUE(string_id != NULL); const DexFile::TypeId* type_id = dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id)); ASSERT_TRUE(type_id != NULL); uint32_t type_idx = dex_file->GetIndexForTypeId(*type_id); EXPECT_TRUE(clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx) == NULL); - StaticStorageBase* uninit = ResolveVerifyAndClinit(type_idx, clinit, Thread::Current(), true, false); + mirror::StaticStorageBase* uninit = ResolveVerifyAndClinit(type_idx, clinit, Thread::Current(), true, false); EXPECT_TRUE(uninit != NULL); EXPECT_TRUE(clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx) == NULL); - StaticStorageBase* init = ResolveVerifyAndClinit(type_idx, getS0, Thread::Current(), true, false); + mirror::StaticStorageBase* init = ResolveVerifyAndClinit(type_idx, getS0, Thread::Current(), true, false); EXPECT_TRUE(init != NULL); EXPECT_EQ(init, clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx)); } TEST_F(ClassLinkerTest, FinalizableBit) { ScopedObjectAccess soa(Thread::Current()); - Class* c; + mirror::Class* c; // Object has a finalize method, but we know it's empty. c = class_linker_->FindSystemClass("Ljava/lang/Object;"); @@ -1092,7 +1050,7 @@ TEST_F(ClassLinkerTest, ClassRootDescriptors) { ScopedObjectAccess soa(Thread::Current()); ClassHelper kh; for (int i = 0; i < ClassLinker::kClassRootsMax; i++) { - Class* klass = class_linker_->GetClassRoot(ClassLinker::ClassRoot(i)); + mirror::Class* klass = class_linker_->GetClassRoot(ClassLinker::ClassRoot(i)); kh.ChangeClass(klass); EXPECT_TRUE(kh.GetDescriptor() != NULL); EXPECT_STREQ(kh.GetDescriptor(), diff --git a/runtime/common_test.h b/runtime/common_test.h index 7110e11..ced2af9 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -181,7 +181,7 @@ class CommonTest : public testing::Test { reinterpret_cast<uint32_t>(gc_map)); } - void MakeExecutable(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void MakeExecutable(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); LOG(INFO) << "MakeExecutable " << PrettyMethod(method); @@ -348,7 +348,7 @@ class CommonTest : public testing::Test { compiler_driver_->SetSupportBootImageFixup(false); // We're back in native, take the opportunity to initialize well known classes. - WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv()); + WellKnownClasses::Init(Thread::Current()->GetJniEnv()); // Create the heap thread pool so that the GC runs in parallel for tests. Normally, the thread // pool is created by the runtime. runtime_->GetHeap()->CreateThreadPool(); @@ -464,7 +464,7 @@ class CommonTest : public testing::Test { } } - void CompileMethod(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void CompileMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); base::TimingLogger timings("CommonTest::CompileMethod", false, false); timings.StartSplit("CompileOne"); @@ -480,7 +480,7 @@ class CommonTest : public testing::Test { std::string class_descriptor(DotToDescriptor(class_name)); mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), class_loader); CHECK(klass != NULL) << "Class not found " << class_name; - mirror::AbstractMethod* method = klass->FindDirectMethod(method_name, signature); + mirror::ArtMethod* method = klass->FindDirectMethod(method_name, signature); CHECK(method != NULL) << "Direct method not found: " << class_name << "." << method_name << signature; CompileMethod(method); @@ -494,7 +494,7 @@ class CommonTest : public testing::Test { std::string class_descriptor(DotToDescriptor(class_name)); mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), class_loader); CHECK(klass != NULL) << "Class not found " << class_name; - mirror::AbstractMethod* method = klass->FindVirtualMethod(method_name, signature); + mirror::ArtMethod* method = klass->FindVirtualMethod(method_name, signature); CHECK(method != NULL) << "Virtual method not found: " << class_name << "." << method_name << signature; CompileMethod(method); diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc index 2a55e31..26ce5be 100644 --- a/runtime/common_throws.cc +++ b/runtime/common_throws.cc @@ -21,7 +21,7 @@ #include "dex_file-inl.h" #include "dex_instruction-inl.h" #include "invoke_type.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -68,7 +68,7 @@ static void ThrowException(const ThrowLocation* throw_location, const char* exce // AbstractMethodError -void ThrowAbstractMethodError(const mirror::AbstractMethod* method) { +void ThrowAbstractMethodError(const mirror::ArtMethod* method) { ThrowException(NULL, "Ljava/lang/AbstractMethodError;", NULL, StringPrintf("abstract method \"%s\"", PrettyMethod(method).c_str()).c_str()); @@ -136,8 +136,8 @@ void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* access } void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, - const mirror::AbstractMethod* caller, - const mirror::AbstractMethod* called, + const mirror::ArtMethod* caller, + const mirror::ArtMethod* called, InvokeType type) { std::ostringstream msg; msg << "Illegal class access ('" << PrettyDescriptor(referrer) << "' attempting to access '" @@ -146,26 +146,27 @@ void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirr ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::AbstractMethod* accessed) { +void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) { std::ostringstream msg; msg << "Method '" << PrettyMethod(accessed) << "' is inaccessible to class '" << PrettyDescriptor(referrer) << "'"; ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::Field* accessed) { +void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) { std::ostringstream msg; msg << "Field '" << PrettyField(accessed, false) << "' is inaccessible to class '" << PrettyDescriptor(referrer) << "'"; ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorFinalField(const mirror::AbstractMethod* referrer, - mirror::Field* accessed) { +void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer, + mirror::ArtField* accessed) { std::ostringstream msg; msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '" << PrettyMethod(referrer) << "'"; - ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer != NULL ? referrer->GetClass() : NULL, + ThrowException(NULL, "Ljava/lang/IllegalAccessError;", + referrer != NULL ? referrer->GetClass() : NULL, msg.str().c_str()); } @@ -186,8 +187,8 @@ void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const ch // IncompatibleClassChangeError void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, - mirror::AbstractMethod* method, - const mirror::AbstractMethod* referrer) { + mirror::ArtMethod* method, + const mirror::ArtMethod* referrer) { std::ostringstream msg; msg << "The method '" << PrettyMethod(method) << "' was expected to be of type " << expected_type << " but instead was found to be of type " << found_type; @@ -196,9 +197,9 @@ void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType foun msg.str().c_str()); } -void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::AbstractMethod* interface_method, +void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method, mirror::Object* this_object, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { // Referrer is calling interface_method on this_object, however, the interface_method isn't // implemented by this_object. CHECK(this_object != NULL); @@ -212,8 +213,8 @@ void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::Ab msg.str().c_str()); } -void ThrowIncompatibleClassChangeErrorField(const mirror::Field* resolved_field, bool is_static, - const mirror::AbstractMethod* referrer) { +void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static, + const mirror::ArtMethod* referrer) { std::ostringstream msg; msg << "Expected '" << PrettyField(resolved_field) << "' to be a " << (is_static ? "static" : "instance") << " field" << " rather than a " @@ -241,7 +242,8 @@ void ThrowLinkageError(const mirror::Class* referrer, const char* fmt, ...) { // NegativeArraySizeException void ThrowNegativeArraySizeException(int size) { - ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, StringPrintf("%d", size).c_str()); + ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, + StringPrintf("%d", size).c_str()); } void ThrowNegativeArraySizeException(const char* msg) { @@ -285,7 +287,7 @@ void ThrowNoSuchMethodError(uint32_t method_idx) { // NullPointerException void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, - mirror::Field* field, bool is_read) { + mirror::ArtField* field, bool is_read) { std::ostringstream msg; msg << "Attempt to " << (is_read ? "read from" : "write to") << " field '" << PrettyField(field, true) << "' on a null object reference"; @@ -303,7 +305,8 @@ static void ThrowNullPointerExceptionForMethodAccessImpl(const ThrowLocation& th ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL, msg.str().c_str()); } -void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, uint32_t method_idx, +void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, + uint32_t method_idx, InvokeType type) { mirror::DexCache* dex_cache = throw_location.GetMethod()->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); @@ -312,7 +315,7 @@ void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_locatio } void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, InvokeType type) { mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); @@ -348,7 +351,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { // Since we replaced the method index, we ask the verifier to tell us which // method is invoked at this location. - mirror::AbstractMethod* method = + mirror::ArtMethod* method = verifier::MethodVerifier::FindInvokedMethodAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (method != NULL) { @@ -368,7 +371,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IGET_BYTE: case Instruction::IGET_CHAR: case Instruction::IGET_SHORT: { - mirror::Field* field = + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), throw_location.GetMethod(), false); ThrowNullPointerExceptionForFieldAccess(throw_location, field, true /* read */); @@ -379,7 +382,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IGET_OBJECT_QUICK: { // Since we replaced the field index, we ask the verifier to tell us which // field is accessed at this location. - mirror::Field* field = + mirror::ArtField* field = verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (field != NULL) { @@ -399,7 +402,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IPUT_BYTE: case Instruction::IPUT_CHAR: case Instruction::IPUT_SHORT: { - mirror::Field* field = + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), throw_location.GetMethod(), false); ThrowNullPointerExceptionForFieldAccess(throw_location, field, false /* write */); @@ -410,7 +413,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IPUT_OBJECT_QUICK: { // Since we replaced the field index, we ask the verifier to tell us which // field is accessed at this location. - mirror::Field* field = + mirror::ArtField* field = verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (field != NULL) { diff --git a/runtime/common_throws.h b/runtime/common_throws.h index b7f2754..99c6343 100644 --- a/runtime/common_throws.h +++ b/runtime/common_throws.h @@ -22,9 +22,9 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtField; +class ArtMethod; class Class; -class Field; class Object; } // namespace mirror class StringPiece; @@ -32,7 +32,7 @@ class ThrowLocation; // AbstractMethodError -void ThrowAbstractMethodError(const mirror::AbstractMethod* method) +void ThrowAbstractMethodError(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // ArithmeticException @@ -74,19 +74,19 @@ void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* access SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, - const mirror::AbstractMethod* caller, - const mirror::AbstractMethod* called, + const mirror::ArtMethod* caller, + const mirror::ArtMethod* called, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::AbstractMethod* accessed) +void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::Field* accessed) +void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorFinalField(const mirror::AbstractMethod* referrer, - mirror::Field* accessed) +void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer, + mirror::ArtField* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) @@ -101,17 +101,17 @@ void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const ch // IncompatibleClassChangeError void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, - mirror::AbstractMethod* method, - const mirror::AbstractMethod* referrer) + mirror::ArtMethod* method, + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::AbstractMethod* interface_method, +void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method, mirror::Object* this_object, - const mirror::AbstractMethod* referrer) + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIncompatibleClassChangeErrorField(const mirror::Field* resolved_field, bool is_static, - const mirror::AbstractMethod* referrer) +void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static, + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIncompatibleClassChangeError(const mirror::Class* referrer, const char* fmt, ...) @@ -149,7 +149,7 @@ void ThrowNoSuchMethodError(uint32_t method_idx) // NullPointerException void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, - mirror::Field* field, + mirror::ArtField* field, bool is_read) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -159,7 +159,7 @@ void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_locatio SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 3591a50..569a370 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -30,11 +30,11 @@ #include "gc/space/space-inl.h" #include "invoke_arg_array_builder.h" #include "jdwp/object_registry.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -60,7 +60,7 @@ static const size_t kMaxAllocRecordStackDepth = 16; // Max 255. static const size_t kDefaultNumAllocRecords = 64*1024; // Must be a power of 2. struct AllocRecordStackTraceElement { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; uint32_t dex_pc; int32_t LineNumber() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -84,9 +84,9 @@ struct AllocRecord { }; struct Breakpoint { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; uint32_t dex_pc; - Breakpoint(mirror::AbstractMethod* method, uint32_t dex_pc) : method(method), dex_pc(dex_pc) {} + Breakpoint(mirror::ArtMethod* method, uint32_t dex_pc) : method(method), dex_pc(dex_pc) {} }; static std::ostream& operator<<(std::ostream& os, const Breakpoint& rhs) @@ -103,7 +103,7 @@ struct SingleStepControl { JDWP::JdwpStepSize step_size; JDWP::JdwpStepDepth step_depth; - const mirror::AbstractMethod* method; + const mirror::ArtMethod* method; int32_t line_number; // Or -1 for native methods. std::set<uint32_t> dex_pcs; int stack_depth; @@ -115,7 +115,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList virtual ~DebugInstrumentationListener() {} virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (method->IsNative()) { // TODO: post location events is a suspension point and native method entry stubs aren't. @@ -125,7 +125,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList } virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { UNUSED(return_value); @@ -136,7 +136,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList Dbg::PostLocationEvent(method, dex_pc, this_object, Dbg::kMethodExit); } - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // We're not recorded to listen to this kind of event, so complain. LOG(ERROR) << "Unexpected method unwind event in debugger " << PrettyMethod(method) @@ -144,13 +144,13 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList } virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Dbg::UpdateDebugger(thread, this_object, method, new_dex_pc); } virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Dbg::PostException(thread, throw_location, catch_method, catch_dex_pc, exception_object); @@ -194,7 +194,7 @@ static size_t gAllocRecordCount GUARDED_BY(gAllocTrackerLock) = 0; static std::vector<Breakpoint> gBreakpoints GUARDED_BY(Locks::breakpoint_lock_); static SingleStepControl gSingleStepControl GUARDED_BY(Locks::breakpoint_lock_); -static bool IsBreakpoint(const mirror::AbstractMethod* m, uint32_t dex_pc) +static bool IsBreakpoint(const mirror::ArtMethod* m, uint32_t dex_pc) LOCKS_EXCLUDED(Locks::breakpoint_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); @@ -1131,7 +1131,7 @@ bool Dbg::MatchType(JDWP::RefTypeId instance_class_id, JDWP::RefTypeId class_id) return c1->IsAssignableFrom(c2); } -static JDWP::FieldId ToFieldId(const mirror::Field* f) +static JDWP::FieldId ToFieldId(const mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); @@ -1140,7 +1140,7 @@ static JDWP::FieldId ToFieldId(const mirror::Field* f) #endif } -static JDWP::MethodId ToMethodId(const mirror::AbstractMethod* m) +static JDWP::MethodId ToMethodId(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); @@ -1149,25 +1149,25 @@ static JDWP::MethodId ToMethodId(const mirror::AbstractMethod* m) #endif } -static mirror::Field* FromFieldId(JDWP::FieldId fid) +static mirror::ArtField* FromFieldId(JDWP::FieldId fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); #else - return reinterpret_cast<mirror::Field*>(static_cast<uintptr_t>(fid)); + return reinterpret_cast<mirror::ArtField*>(static_cast<uintptr_t>(fid)); #endif } -static mirror::AbstractMethod* FromMethodId(JDWP::MethodId mid) +static mirror::ArtMethod* FromMethodId(JDWP::MethodId mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); #else - return reinterpret_cast<mirror::AbstractMethod*>(static_cast<uintptr_t>(mid)); + return reinterpret_cast<mirror::ArtMethod*>(static_cast<uintptr_t>(mid)); #endif } -static void SetLocation(JDWP::JdwpLocation& location, mirror::AbstractMethod* m, uint32_t dex_pc) +static void SetLocation(JDWP::JdwpLocation& location, mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (m == NULL) { memset(&location, 0, sizeof(location)); @@ -1182,13 +1182,13 @@ static void SetLocation(JDWP::JdwpLocation& location, mirror::AbstractMethod* m, std::string Dbg::GetMethodName(JDWP::MethodId method_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); return MethodHelper(m).GetName(); } std::string Dbg::GetFieldName(JDWP::FieldId field_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); return FieldHelper(f).GetName(); } @@ -1230,7 +1230,7 @@ static uint16_t MangleSlot(uint16_t slot, const char* name) { return newSlot; } -static uint16_t DemangleSlot(uint16_t slot, mirror::AbstractMethod* m) +static uint16_t DemangleSlot(uint16_t slot, mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (slot == kEclipseWorkaroundSlot) { return 0; @@ -1255,7 +1255,7 @@ JDWP::JdwpError Dbg::OutputDeclaredFields(JDWP::RefTypeId class_id, bool with_ge expandBufAdd4BE(pReply, instance_field_count + static_field_count); for (size_t i = 0; i < instance_field_count + static_field_count; ++i) { - mirror::Field* f = (i < instance_field_count) ? c->GetInstanceField(i) : c->GetStaticField(i - instance_field_count); + mirror::ArtField* f = (i < instance_field_count) ? c->GetInstanceField(i) : c->GetStaticField(i - instance_field_count); FieldHelper fh(f); expandBufAddFieldId(pReply, ToFieldId(f)); expandBufAddUtf8String(pReply, fh.GetName()); @@ -1283,7 +1283,7 @@ JDWP::JdwpError Dbg::OutputDeclaredMethods(JDWP::RefTypeId class_id, bool with_g expandBufAdd4BE(pReply, direct_method_count + virtual_method_count); for (size_t i = 0; i < direct_method_count + virtual_method_count; ++i) { - mirror::AbstractMethod* m = (i < direct_method_count) ? c->GetDirectMethod(i) : c->GetVirtualMethod(i - direct_method_count); + mirror::ArtMethod* m = (i < direct_method_count) ? c->GetDirectMethod(i) : c->GetVirtualMethod(i - direct_method_count); MethodHelper mh(m); expandBufAddMethodId(pReply, ToMethodId(m)); expandBufAddUtf8String(pReply, mh.GetName()); @@ -1327,7 +1327,7 @@ void Dbg::OutputLineTable(JDWP::RefTypeId, JDWP::MethodId method_id, JDWP::Expan return true; } }; - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); MethodHelper mh(m); uint64_t start, end; if (m->IsNative()) { @@ -1381,14 +1381,14 @@ void Dbg::OutputVariableTable(JDWP::RefTypeId, JDWP::MethodId method_id, bool wi ++pContext->variable_count; } }; - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); MethodHelper mh(m); const DexFile::CodeItem* code_item = mh.GetCodeItem(); // arg_count considers doubles and longs to take 2 units. // variable_count considers everything to take 1 unit. std::string shorty(mh.GetShorty()); - expandBufAdd4BE(pReply, mirror::AbstractMethod::NumArgRegisters(shorty)); + expandBufAdd4BE(pReply, mirror::ArtMethod::NumArgRegisters(shorty)); // We don't know the total number of variables yet, so leave a blank and update it later. size_t variable_count_offset = expandBufGetLength(pReply); @@ -1408,7 +1408,7 @@ void Dbg::OutputVariableTable(JDWP::RefTypeId, JDWP::MethodId method_id, bool wi JDWP::JdwpError Dbg::GetBytecodes(JDWP::RefTypeId, JDWP::MethodId method_id, std::vector<uint8_t>& bytecodes) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); if (m == NULL) { return JDWP::ERR_INVALID_METHODID; } @@ -1445,7 +1445,7 @@ static JDWP::JdwpError GetFieldValueImpl(JDWP::RefTypeId ref_type_id, JDWP::Obje if ((!is_static && o == NULL) || o == ObjectRegistry::kInvalidObject) { return JDWP::ERR_INVALID_OBJECT; } - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); mirror::Class* receiver_class = c; if (receiver_class == NULL && o != NULL) { @@ -1511,7 +1511,7 @@ static JDWP::JdwpError SetFieldValueImpl(JDWP::ObjectId object_id, JDWP::FieldId if ((!is_static && o == NULL) || o == ObjectRegistry::kInvalidObject) { return JDWP::ERR_INVALID_OBJECT; } - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); // The RI only enforces the static/non-static mismatch in one direction. // TODO: should we change the tests and check both? @@ -1580,7 +1580,7 @@ JDWP::JdwpError Dbg::GetThreadName(JDWP::ObjectId thread_id, std::string& name) // We still need to report the zombie threads' names, so we can't just call Thread::GetThreadName. mirror::Object* thread_object = gRegistry->Get<mirror::Object*>(thread_id); - mirror::Field* java_lang_Thread_name_field = + mirror::ArtField* java_lang_Thread_name_field = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); mirror::String* s = reinterpret_cast<mirror::String*>(java_lang_Thread_name_field->GetObject(thread_object)); @@ -1612,7 +1612,7 @@ JDWP::JdwpError Dbg::GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* p mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/Thread;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("group", "Ljava/lang/ThreadGroup;"); + mirror::ArtField* f = c->FindInstanceField("group", "Ljava/lang/ThreadGroup;"); CHECK(f != NULL); mirror::Object* group = f->GetObject(thread_object); CHECK(group != NULL); @@ -1629,7 +1629,7 @@ std::string Dbg::GetThreadGroupName(JDWP::ObjectId thread_group_id) { mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/ThreadGroup;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("name", "Ljava/lang/String;"); + mirror::ArtField* f = c->FindInstanceField("name", "Ljava/lang/String;"); CHECK(f != NULL); mirror::String* s = reinterpret_cast<mirror::String*>(f->GetObject(thread_group)); return s->ToModifiedUtf8(); @@ -1641,7 +1641,7 @@ JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId thread_group_id) { mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/ThreadGroup;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("parent", "Ljava/lang/ThreadGroup;"); + mirror::ArtField* f = c->FindInstanceField("parent", "Ljava/lang/ThreadGroup;"); CHECK(f != NULL); mirror::Object* parent = f->GetObject(thread_group); return gRegistry->Add(parent); @@ -1649,14 +1649,14 @@ JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId thread_group_id) { JDWP::ObjectId Dbg::GetSystemThreadGroupId() { ScopedObjectAccessUnchecked soa(Thread::Current()); - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup); mirror::Object* group = f->GetObject(f->GetDeclaringClass()); return gRegistry->Add(group); } JDWP::ObjectId Dbg::GetMainThreadGroupId() { ScopedObjectAccess soa(Thread::Current()); - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup); mirror::Object* group = f->GetObject(f->GetDeclaringClass()); return gRegistry->Add(group); } @@ -1793,12 +1793,12 @@ void Dbg::GetChildThreadGroups(JDWP::ObjectId thread_group_id, std::vector<JDWP: mirror::Object* thread_group = gRegistry->Get<mirror::Object*>(thread_group_id); // Get the ArrayList<ThreadGroup> "groups" out of this thread group... - mirror::Field* groups_field = thread_group->GetClass()->FindInstanceField("groups", "Ljava/util/List;"); + mirror::ArtField* groups_field = thread_group->GetClass()->FindInstanceField("groups", "Ljava/util/List;"); mirror::Object* groups_array_list = groups_field->GetObject(thread_group); // Get the array and size out of the ArrayList<ThreadGroup>... - mirror::Field* array_field = groups_array_list->GetClass()->FindInstanceField("array", "[Ljava/lang/Object;"); - mirror::Field* size_field = groups_array_list->GetClass()->FindInstanceField("size", "I"); + mirror::ArtField* array_field = groups_array_list->GetClass()->FindInstanceField("array", "[Ljava/lang/Object;"); + mirror::ArtField* size_field = groups_array_list->GetClass()->FindInstanceField("size", "I"); mirror::ObjectArray<mirror::Object>* groups_array = array_field->GetObject(groups_array_list)->AsObjectArray<mirror::Object>(); const int32_t size = size_field->GetInt(groups_array_list); @@ -2017,7 +2017,7 @@ void Dbg::GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl return true; // Not our frame, carry on. } // TODO: check that the tag is compatible with the actual type of the slot! - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); uint16_t reg = DemangleSlot(slot_, m); switch (tag_) { @@ -2156,7 +2156,7 @@ void Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl return true; // Not our frame, carry on. } // TODO: check that the tag is compatible with the actual type of the slot! - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); uint16_t reg = DemangleSlot(slot_, m); switch (tag_) { @@ -2226,7 +2226,7 @@ void Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl visitor.WalkStack(); } -void Dbg::PostLocationEvent(const mirror::AbstractMethod* m, int dex_pc, +void Dbg::PostLocationEvent(const mirror::ArtMethod* m, int dex_pc, mirror::Object* this_object, int event_flags) { mirror::Class* c = m->GetDeclaringClass(); @@ -2246,7 +2246,7 @@ void Dbg::PostLocationEvent(const mirror::AbstractMethod* m, int dex_pc, } void Dbg::PostException(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) { if (!IsDebuggerActive()) { return; @@ -2280,7 +2280,7 @@ void Dbg::PostClassPrepare(mirror::Class* c) { } void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* m, uint32_t dex_pc) { + const mirror::ArtMethod* m, uint32_t dex_pc) { if (!IsDebuggerActive() || dex_pc == static_cast<uint32_t>(-2) /* fake method exit */) { return; } @@ -2361,14 +2361,14 @@ void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object, void Dbg::WatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); - mirror::AbstractMethod* m = FromMethodId(location->method_id); + mirror::ArtMethod* m = FromMethodId(location->method_id); gBreakpoints.push_back(Breakpoint(m, location->dex_pc)); VLOG(jdwp) << "Set breakpoint #" << (gBreakpoints.size() - 1) << ": " << gBreakpoints[gBreakpoints.size() - 1]; } void Dbg::UnwatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); - mirror::AbstractMethod* m = FromMethodId(location->method_id); + mirror::ArtMethod* m = FromMethodId(location->method_id); for (size_t i = 0; i < gBreakpoints.size(); ++i) { if (gBreakpoints[i].method == m && gBreakpoints[i].dex_pc == location->dex_pc) { VLOG(jdwp) << "Removed breakpoint #" << i << ": " << gBreakpoints[i]; @@ -2468,7 +2468,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize // annotalysis. bool VisitFrame() NO_THREAD_SAFETY_ANALYSIS { Locks::breakpoint_lock_->AssertHeld(Thread::Current()); - const mirror::AbstractMethod* m = GetMethod(); + const mirror::ArtMethod* m = GetMethod(); if (!m->IsRuntimeMethod()) { ++gSingleStepControl.stack_depth; if (gSingleStepControl.method == NULL) { @@ -2538,7 +2538,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize uint32_t last_pc; }; gSingleStepControl.dex_pcs.clear(); - const mirror::AbstractMethod* m = gSingleStepControl.method; + const mirror::ArtMethod* m = gSingleStepControl.method; if (m->IsNative()) { gSingleStepControl.line_number = -1; } else { @@ -2675,7 +2675,7 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec return status; } - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); if (m->IsStatic() != (receiver == NULL)) { return JDWP::ERR_INVALID_METHODID; } @@ -2798,7 +2798,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { // We can be called while an exception is pending. We need // to preserve that across the method invocation. SirtRef<mirror::Object> old_throw_this_object(soa.Self(), NULL); - SirtRef<mirror::AbstractMethod> old_throw_method(soa.Self(), NULL); + SirtRef<mirror::ArtMethod> old_throw_method(soa.Self(), NULL); SirtRef<mirror::Throwable> old_exception(soa.Self(), NULL); uint32_t old_throw_dex_pc; { @@ -2812,9 +2812,9 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { } // Translate the method through the vtable, unless the debugger wants to suppress it. - mirror::AbstractMethod* m = pReq->method_; + mirror::ArtMethod* m = pReq->method_; if ((pReq->options_ & JDWP::INVOKE_NONVIRTUAL) == 0 && pReq->receiver_ != NULL) { - mirror::AbstractMethod* actual_method = pReq->class_->FindVirtualMethodForVirtualOrInterface(pReq->method_); + mirror::ArtMethod* actual_method = pReq->class_->FindVirtualMethodForVirtualOrInterface(pReq->method_); if (actual_method != m) { VLOG(jdwp) << "ExecuteMethod translated " << PrettyMethod(m) << " to " << PrettyMethod(actual_method); m = actual_method; @@ -3491,7 +3491,7 @@ struct AllocRecordStackVisitor : public StackVisitor { if (depth >= kMaxAllocRecordStackDepth) { return false; } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (!m->IsRuntimeMethod()) { record->stack[depth].method = m; record->stack[depth].dex_pc = GetDexPc(); @@ -3574,7 +3574,7 @@ void Dbg::DumpRecentAllocations() { << PrettyClass(record->type); for (size_t stack_frame = 0; stack_frame < kMaxAllocRecordStackDepth; ++stack_frame) { - const mirror::AbstractMethod* m = record->stack[stack_frame].method; + const mirror::ArtMethod* m = record->stack[stack_frame].method; if (m == NULL) { break; } @@ -3695,7 +3695,7 @@ jbyteArray Dbg::GetRecentAllocations() { MethodHelper mh; for (size_t i = 0; i < kMaxAllocRecordStackDepth; i++) { - mirror::AbstractMethod* m = record->stack[i].method; + mirror::ArtMethod* m = record->stack[i].method; if (m != NULL) { mh.ChangeMethod(m); class_names.Add(mh.GetDeclaringClassDescriptor()); diff --git a/runtime/debugger.h b/runtime/debugger.h index 6b7e2ba..2282305 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -32,7 +32,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Class; class Object; class Throwable; @@ -64,7 +64,7 @@ struct DebugInvokeReq { mirror::Object* receiver_; /* not used for ClassType.InvokeMethod */ mirror::Object* thread_; mirror::Class* class_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; uint32_t arg_count_; uint64_t* arg_values_; /* will be NULL if arg_count_ == 0 */ uint32_t options_; @@ -324,11 +324,11 @@ class Dbg { kMethodEntry = 0x04, kMethodExit = 0x08, }; - static void PostLocationEvent(const mirror::AbstractMethod* method, int pcOffset, + static void PostLocationEvent(const mirror::ArtMethod* method, int pcOffset, mirror::Object* thisPtr, int eventFlags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void PostException(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void PostThreadStart(Thread* t) @@ -339,7 +339,7 @@ class Dbg { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void UpdateDebugger(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) LOCKS_EXCLUDED(Locks::breakpoint_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index aaff0fc..45b3427 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -31,9 +31,8 @@ #include "dex_file_verifier.h" #include "globals.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/string.h" #include "os.h" #include "safe_map.h" @@ -624,7 +623,7 @@ std::string DexFile::CreateMethodSignature(uint32_t proto_idx, int32_t* unicode_ return descriptor; } -int32_t DexFile::GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const { +int32_t DexFile::GetLineNumFromPC(const mirror::ArtMethod* method, uint32_t rel_pc) const { // For native method, lineno should be -2 to indicate it is native. Note that // "line number == -2" is how libcore tells from StackTraceElement. if (method->GetCodeItemOffset() == 0) { @@ -1024,7 +1023,7 @@ void EncodedStaticFieldValueIterator::Next() { ptr_ += width; } -void EncodedStaticFieldValueIterator::ReadValueToField(mirror::Field* field) const { +void EncodedStaticFieldValueIterator::ReadValueToField(mirror::ArtField* field) const { switch (type_) { case kBoolean: field->SetBoolean(field->GetDeclaringClass(), jval_.z); break; case kByte: field->SetByte(field->GetDeclaringClass(), jval_.b); break; diff --git a/runtime/dex_file.h b/runtime/dex_file.h index a60a139..006b692 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -34,10 +34,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class ClassLoader; -class DexCache; -class Field; + class ArtField; + class ArtMethod; + class ClassLoader; + class DexCache; } // namespace mirror class ClassLinker; class ZipArchive; @@ -786,7 +786,7 @@ class DexFile { // Returns -2 for native methods (as expected in exception traces). // // This is used by runtime; therefore use art::Method not art::DexFile::Method. - int32_t GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const + int32_t GetLineNumFromPC(const mirror::ArtMethod* method, uint32_t rel_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DecodeDebugInfo(const CodeItem* code_item, bool is_static, uint32_t method_idx, @@ -1135,7 +1135,7 @@ class EncodedStaticFieldValueIterator { ClassLinker* linker, const DexFile::ClassDef& class_def) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ReadValueToField(mirror::Field* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void ReadValueToField(mirror::ArtField* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool HasNext() { return pos_ < array_size_; } diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index c297841..6b8c41e 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -19,9 +19,9 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" @@ -33,7 +33,7 @@ namespace art { // Helper function to allocate array for FILLED_NEW_ARRAY. -mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* referrer, +mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* referrer, int32_t component_count, Thread* self, bool access_check) { if (UNLIKELY(component_count < 0)) { @@ -73,7 +73,7 @@ mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMet } } -mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, +mirror::ArtField* FindFieldFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, Thread* self, FindFieldType type, size_t expected_size, bool access_check) { bool is_primitive; @@ -91,7 +91,7 @@ mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMetho default: is_primitive = true; is_set = true; is_static = true; break; } ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Field* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static); + mirror::ArtField* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static); if (UNLIKELY(resolved_field == NULL)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. return NULL; // Failure. @@ -158,12 +158,12 @@ mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMetho } // Slow path method resolution -mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, +mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* referrer, Thread* self, bool access_check, InvokeType type) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); bool is_direct = type == kStatic || type == kDirect; - mirror::AbstractMethod* resolved_method = class_linker->ResolveMethod(method_idx, referrer, type); + mirror::ArtMethod* resolved_method = class_linker->ResolveMethod(method_idx, referrer, type); if (UNLIKELY(resolved_method == NULL)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. return NULL; // Failure. @@ -179,7 +179,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* if (is_direct) { return resolved_method; } else if (type == kInterface) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); if (UNLIKELY(interface_method == NULL)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, this_object, @@ -189,7 +189,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* return interface_method; } } else { - mirror::ObjectArray<mirror::AbstractMethod>* vtable; + mirror::ObjectArray<mirror::ArtMethod>* vtable; uint16_t vtable_index = resolved_method->GetMethodIndex(); if (type == kSuper) { vtable = referrer->GetDeclaringClass()->GetSuperClass()->GetVTable(); @@ -231,7 +231,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* if (is_direct) { return resolved_method; } else if (type == kInterface) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); if (UNLIKELY(interface_method == NULL)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, this_object, @@ -241,7 +241,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* return interface_method; } } else { - mirror::ObjectArray<mirror::AbstractMethod>* vtable; + mirror::ObjectArray<mirror::ArtMethod>* vtable; uint16_t vtable_index = resolved_method->GetMethodIndex(); if (type == kSuper) { mirror::Class* super_class = referring_class->GetSuperClass(); @@ -326,17 +326,15 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char } } - // Call InvocationHandler.invoke(Object proxy, Method method, Object[] args). - jobject inv_hand = soa.Env()->GetObjectField(rcvr_jobj, - WellKnownClasses::java_lang_reflect_Proxy_h); + // Call Proxy.invoke(Proxy proxy, ArtMethod method, Object[] args). jvalue invocation_args[3]; invocation_args[0].l = rcvr_jobj; invocation_args[1].l = interface_method_jobj; invocation_args[2].l = args_jobj; jobject result = - soa.Env()->CallObjectMethodA(inv_hand, - WellKnownClasses::java_lang_reflect_InvocationHandler_invoke, - invocation_args); + soa.Env()->CallStaticObjectMethodA(WellKnownClasses::java_lang_reflect_Proxy, + WellKnownClasses::java_lang_reflect_Proxy_invoke, + invocation_args); // Unbox result and handle error conditions. if (LIKELY(!soa.Self()->IsExceptionPending())) { @@ -346,10 +344,10 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char } else { mirror::Object* result_ref = soa.Decode<mirror::Object*>(result); mirror::Object* rcvr = soa.Decode<mirror::Object*>(rcvr_jobj); - mirror::AbstractMethod* interface_method = - soa.Decode<mirror::AbstractMethod*>(interface_method_jobj); + mirror::ArtMethod* interface_method = + soa.Decode<mirror::ArtMethod*>(interface_method_jobj); mirror::Class* result_type = MethodHelper(interface_method).GetReturnType(); - mirror::AbstractMethod* proxy_method; + mirror::ArtMethod* proxy_method; if (interface_method->GetDeclaringClass()->IsInterface()) { proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(interface_method); } else { @@ -373,9 +371,9 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char mirror::Object* rcvr = soa.Decode<mirror::Object*>(rcvr_jobj); mirror::SynthesizedProxyClass* proxy_class = down_cast<mirror::SynthesizedProxyClass*>(rcvr->GetClass()); - mirror::AbstractMethod* interface_method = - soa.Decode<mirror::AbstractMethod*>(interface_method_jobj); - mirror::AbstractMethod* proxy_method = + mirror::ArtMethod* interface_method = + soa.Decode<mirror::ArtMethod*>(interface_method_jobj); + mirror::ArtMethod* proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(interface_method); int throws_index = -1; size_t num_virt_methods = proxy_class->NumVirtualMethods(); diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h index b6781c0..2b73af4 100644 --- a/runtime/entrypoints/entrypoint_utils.h +++ b/runtime/entrypoints/entrypoint_utils.h @@ -23,7 +23,7 @@ #include "indirect_reference_table.h" #include "invoke_type.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/throwable.h" @@ -34,7 +34,7 @@ namespace art { namespace mirror { class Class; - class Field; + class ArtField; class Object; } // namespace mirror @@ -42,7 +42,7 @@ namespace mirror { // cannot be resolved, throw an error. If it can, use it to create an instance. // When verification/compiler hasn't been able to verify access, optionally perform an access // check. -static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::ArtMethod* method, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -80,7 +80,7 @@ static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::Abs // it cannot be resolved, throw an error. If it can, use it to create an array. // When verification/compiler hasn't been able to verify access, optionally perform an access // check. -static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -107,7 +107,7 @@ static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::Abstr return mirror::Array::Alloc(self, klass, component_count); } -extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -125,17 +125,17 @@ enum FindFieldType { }; // Slow field find that can initialize classes and may throw exceptions. -extern mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, - Thread* self, FindFieldType type, size_t expected_size, - bool access_check) +extern mirror::ArtField* FindFieldFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, + Thread* self, FindFieldType type, size_t expected_size, + bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Fast path field resolution that can't initialize classes or throw exceptions. -static inline mirror::Field* FindFieldFast(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - FindFieldType type, size_t expected_size) +static inline mirror::ArtField* FindFieldFast(uint32_t field_idx, + const mirror::ArtMethod* referrer, + FindFieldType type, size_t expected_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* resolved_field = + mirror::ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx); if (UNLIKELY(resolved_field == NULL)) { return NULL; @@ -186,16 +186,16 @@ static inline mirror::Field* FindFieldFast(uint32_t field_idx, } // Fast path method resolution that can't throw exceptions. -static inline mirror::AbstractMethod* FindMethodFast(uint32_t method_idx, - mirror::Object* this_object, - const mirror::AbstractMethod* referrer, - bool access_check, InvokeType type) +static inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, + mirror::Object* this_object, + const mirror::ArtMethod* referrer, + bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { bool is_direct = type == kStatic || type == kDirect; if (UNLIKELY(this_object == NULL && !is_direct)) { return NULL; } - mirror::AbstractMethod* resolved_method = + mirror::ArtMethod* resolved_method = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedMethod(method_idx); if (UNLIKELY(resolved_method == NULL)) { return NULL; @@ -228,13 +228,13 @@ static inline mirror::AbstractMethod* FindMethodFast(uint32_t method_idx, } } -extern mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, - Thread* self, bool access_check, InvokeType type) +extern mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* referrer, + Thread* self, bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, bool can_run_clinit, bool verify_access) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -271,7 +271,7 @@ static inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, extern void ThrowStackOverflowError(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -static inline mirror::String* ResolveStringFromCode(const mirror::AbstractMethod* referrer, +static inline mirror::String* ResolveStringFromCode(const mirror::ArtMethod* referrer, uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -307,7 +307,7 @@ static inline void CheckReferenceResult(mirror::Object* o, Thread* self) if (o == NULL) { return; } - mirror::AbstractMethod* m = self->GetCurrentMethod(NULL); + mirror::ArtMethod* m = self->GetCurrentMethod(NULL); if (o == kInvalidIndirectRefObject) { JniAbortF(NULL, "invalid reference returned from %s", PrettyMethod(m).c_str()); } @@ -334,7 +334,7 @@ static inline void CheckSuspend(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mut } JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char* shorty, - jobject rcvr_jobj, jobject interface_method_jobj, + jobject rcvr_jobj, jobject interface_art_method_jobj, std::vector<jvalue>& args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -356,12 +356,12 @@ static inline uintptr_t GetQuickInstrumentationExitPc() { return reinterpret_cast<uintptr_t>(art_quick_instrumentation_exit); } -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); static inline const void* GetPortableToInterpreterBridge() { return reinterpret_cast<void*>(art_portable_to_interpreter_bridge); } -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); static inline const void* GetQuickToInterpreterBridge() { return reinterpret_cast<void*>(art_quick_to_interpreter_bridge); } diff --git a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc index 67f6d98..f319a00 100644 --- a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc +++ b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc @@ -17,7 +17,7 @@ #include "class_linker.h" #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "runtime.h" @@ -29,7 +29,7 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = shadow_frame->GetMethod(); + mirror::ArtMethod* method = shadow_frame->GetMethod(); // Ensure static methods are initialized. if (method->IsStatic()) { Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true); diff --git a/runtime/entrypoints/jni/jni_entrypoints.cc b/runtime/entrypoints/jni/jni_entrypoints.cc index 88b4936..83d3a58 100644 --- a/runtime/entrypoints/jni/jni_entrypoints.cc +++ b/runtime/entrypoints/jni/jni_entrypoints.cc @@ -16,7 +16,7 @@ #include "base/logging.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "scoped_thread_state_change.h" @@ -30,7 +30,7 @@ extern "C" void* artFindNativeMethod() { Locks::mutator_lock_->AssertNotHeld(self); // We come here as Native. ScopedObjectAccess soa(self); - mirror::AbstractMethod* method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* method = self->GetCurrentMethod(NULL); DCHECK(method != NULL); // Lookup symbol address for method, on failure we'll return NULL with an exception set, @@ -69,7 +69,7 @@ extern "C" const void* artWorkAroundAppJniBugs(Thread* self, intptr_t* sp) // | unused | // | unused | // | unused | <- sp - mirror::AbstractMethod* jni_method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* jni_method = self->GetCurrentMethod(NULL); DCHECK(jni_method->IsNative()) << PrettyMethod(jni_method); intptr_t* arg_ptr = sp + 4; // pointer to r1 on stack // Fix up this/jclass argument diff --git a/runtime/entrypoints/portable/portable_alloc_entrypoints.cc b/runtime/entrypoints/portable/portable_alloc_entrypoints.cc index 2869269..91b7353 100644 --- a/runtime/entrypoints/portable/portable_alloc_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_alloc_entrypoints.cc @@ -15,27 +15,27 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Object* art_portable_alloc_object_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return AllocObjectFromCode(type_idx, referrer, thread, false); } extern "C" mirror::Object* art_portable_alloc_object_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return AllocObjectFromCode(type_idx, referrer, thread, true); } extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -43,7 +43,7 @@ extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, } extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -51,7 +51,7 @@ extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check( } extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -59,7 +59,7 @@ extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t } extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc b/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc index bdab587..b37ebcf 100644 --- a/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc @@ -16,27 +16,27 @@ #include "entrypoints/entrypoint_utils.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Object* art_portable_initialize_static_storage_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveVerifyAndClinit(type_idx, referrer, thread, true, false); } extern "C" mirror::Object* art_portable_initialize_type_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveVerifyAndClinit(type_idx, referrer, thread, false, false); } extern "C" mirror::Object* art_portable_initialize_type_and_verify_access_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when caller isn't guaranteed to have access to a type and the dex cache may be @@ -44,7 +44,7 @@ extern "C" mirror::Object* art_portable_initialize_type_and_verify_access_from_c return ResolveVerifyAndClinit(type_idx, referrer, thread, false, true); } -extern "C" mirror::Object* art_portable_resolve_string_from_code(mirror::AbstractMethod* referrer, +extern "C" mirror::Object* art_portable_resolve_string_from_code(mirror::ArtMethod* referrer, uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveStringFromCode(referrer, string_idx); diff --git a/runtime/entrypoints/portable/portable_entrypoints.h b/runtime/entrypoints/portable/portable_entrypoints.h index ec9e4f8..d456447 100644 --- a/runtime/entrypoints/portable/portable_entrypoints.h +++ b/runtime/entrypoints/portable/portable_entrypoints.h @@ -22,7 +22,7 @@ namespace art { namespace mirror { - class AbstractMethod; + class ArtMethod; class Object; } // namespace mirror class Thread; @@ -35,8 +35,8 @@ class Thread; // compiler ABI. struct PACKED(4) PortableEntryPoints { // Invocation - void (*pPortableResolutionTrampoline)(mirror::AbstractMethod*); - void (*pPortableToInterpreterBridge)(mirror::AbstractMethod*); + void (*pPortableResolutionTrampoline)(mirror::ArtMethod*); + void (*pPortableToInterpreterBridge)(mirror::ArtMethod*); }; } // namespace art diff --git a/runtime/entrypoints/portable/portable_field_entrypoints.cc b/runtime/entrypoints/portable/portable_field_entrypoints.cc index aa0f03c..bd6f795 100644 --- a/runtime/entrypoints/portable/portable_field_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_field_entrypoints.cc @@ -15,17 +15,17 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/field-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" int32_t art_portable_set32_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, int32_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint32_t)); @@ -47,10 +47,10 @@ extern "C" int32_t art_portable_set32_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set64_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, int64_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t)); if (LIKELY(field != NULL)) { field->Set64(field->GetDeclaringClass(), new_value); return 0; @@ -69,11 +69,11 @@ extern "C" int32_t art_portable_set64_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { field->SetObj(field->GetDeclaringClass(), new_value); return 0; @@ -88,9 +88,9 @@ extern "C" int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_get32_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t)); if (LIKELY(field != NULL)) { return field->Get32(field->GetDeclaringClass()); } @@ -103,9 +103,9 @@ extern "C" int32_t art_portable_get32_static_from_code(uint32_t field_idx, } extern "C" int64_t art_portable_get64_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t)); if (LIKELY(field != NULL)) { return field->Get64(field->GetDeclaringClass()); } @@ -118,10 +118,10 @@ extern "C" int64_t art_portable_get64_static_from_code(uint32_t field_idx, } extern "C" mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } @@ -134,10 +134,10 @@ extern "C" mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_ } extern "C" int32_t art_portable_set32_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, uint32_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t)); if (LIKELY(field != NULL)) { field->Set32(obj, new_value); return 0; @@ -152,10 +152,10 @@ extern "C" int32_t art_portable_set32_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set64_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, int64_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t)); if (LIKELY(field != NULL)) { field->Set64(obj, new_value); return 0; @@ -170,12 +170,12 @@ extern "C" int32_t art_portable_set64_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, mirror::Object* new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { field->SetObj(obj, new_value); return 0; @@ -190,10 +190,10 @@ extern "C" int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_get32_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t)); if (LIKELY(field != NULL)) { return field->Get32(obj); } @@ -206,10 +206,10 @@ extern "C" int32_t art_portable_get32_instance_from_code(uint32_t field_idx, } extern "C" int64_t art_portable_get64_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t)); if (LIKELY(field != NULL)) { return field->Get64(obj); } @@ -222,11 +222,11 @@ extern "C" int64_t art_portable_get64_instance_from_code(uint32_t field_idx, } extern "C" mirror::Object* art_portable_get_obj_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(obj); } diff --git a/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc b/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc index 771608b..8cf4eed 100644 --- a/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc @@ -16,12 +16,12 @@ #include "dex_instruction.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { -extern "C" void art_portable_fill_array_data_from_code(mirror::AbstractMethod* method, +extern "C" void art_portable_fill_array_data_from_code(mirror::ArtMethod* method, uint32_t dex_pc, mirror::Array* array, uint32_t payload_offset) diff --git a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc index 5911ba3..14cbd84 100644 --- a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc @@ -15,20 +15,20 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/dex_cache-inl.h" #include "mirror/object-inl.h" namespace art { -static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, +static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, bool access_check, InvokeType type, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = FindMethodFast(method_idx, + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, @@ -55,7 +55,7 @@ static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kStatic, thread); @@ -63,7 +63,7 @@ extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kDirect, thread); @@ -71,7 +71,7 @@ extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kVirtual, thread); @@ -79,7 +79,7 @@ extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_acces extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kSuper, thread); @@ -87,7 +87,7 @@ extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kInterface, thread); @@ -95,7 +95,7 @@ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_acc extern "C" mirror::Object* art_portable_find_interface_method_from_code(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, false, kInterface, thread); diff --git a/runtime/entrypoints/portable/portable_jni_entrypoints.cc b/runtime/entrypoints/portable/portable_jni_entrypoints.cc index 8df16ae..de1e32e 100644 --- a/runtime/entrypoints/portable/portable_jni_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_jni_entrypoints.cc @@ -15,7 +15,7 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "thread-inl.h" diff --git a/runtime/entrypoints/portable/portable_thread_entrypoints.cc b/runtime/entrypoints/portable/portable_thread_entrypoints.cc index dac7388..8a2c899 100644 --- a/runtime/entrypoints/portable/portable_thread_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_thread_entrypoints.cc @@ -15,7 +15,7 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "verifier/dex_gc_map.h" #include "stack.h" @@ -31,7 +31,7 @@ class ShadowFrameCopyVisitor : public StackVisitor { if (IsShadowFrame()) { ShadowFrame* cur_frame = GetCurrentShadowFrame(); size_t num_regs = cur_frame->NumberOfVRegs(); - mirror::AbstractMethod* method = cur_frame->GetMethod(); + mirror::ArtMethod* method = cur_frame->GetMethod(); uint32_t dex_pc = cur_frame->GetDexPC(); ShadowFrame* new_frame = ShadowFrame::Create(num_regs, NULL, method, dex_pc); @@ -88,7 +88,7 @@ extern "C" void art_portable_test_suspend_from_code(Thread* self) extern "C" ShadowFrame* art_portable_push_shadow_frame_from_code(Thread* thread, ShadowFrame* new_shadow_frame, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t num_vregs) { ShadowFrame* old_frame = thread->PushShadowFrame(new_shadow_frame); new_shadow_frame->SetMethod(method); diff --git a/runtime/entrypoints/portable/portable_throw_entrypoints.cc b/runtime/entrypoints/portable/portable_throw_entrypoints.cc index 64a67eb..2a0df9b 100644 --- a/runtime/entrypoints/portable/portable_throw_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_throw_entrypoints.cc @@ -16,7 +16,7 @@ #include "dex_instruction.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { @@ -68,7 +68,7 @@ extern "C" void* art_portable_get_and_clear_exception(Thread* self) return exception; } -extern "C" int32_t art_portable_find_catch_block_from_code(mirror::AbstractMethod* current_method, +extern "C" int32_t art_portable_find_catch_block_from_code(mirror::ArtMethod* current_method, uint32_t ti_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Thread* self = Thread::Current(); // TODO: make an argument. diff --git a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc index c02ace8..e1ce11a 100644 --- a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc @@ -20,7 +20,7 @@ #include "dex_instruction-inl.h" #include "entrypoints/entrypoint_utils.h" #include "interpreter/interpreter.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "scoped_thread_state_change.h" @@ -52,7 +52,7 @@ class PortableArgumentVisitor { #define PORTABLE_STACK_ARG_SKIP 0 #endif - PortableArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp) + PortableArgumentVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : caller_mh_(caller_mh), args_in_regs_(ComputeArgsInRegs(caller_mh)), @@ -140,7 +140,7 @@ class PortableArgumentVisitor { // Visits arguments on the stack placing them into the shadow frame. class BuildPortableShadowFrameVisitor : public PortableArgumentVisitor { public: - BuildPortableShadowFrameVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, + BuildPortableShadowFrameVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp, ShadowFrame& sf, size_t first_arg_reg) : PortableArgumentVisitor(caller_mh, sp), sf_(sf), cur_reg_(first_arg_reg) { } virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -176,8 +176,8 @@ class BuildPortableShadowFrameVisitor : public PortableArgumentVisitor { DISALLOW_COPY_AND_ASSIGN(BuildPortableShadowFrameVisitor); }; -extern "C" uint64_t artPortableToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) +extern "C" uint64_t artPortableToInterpreterBridge(mirror::ArtMethod* method, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in the shadow // frame. @@ -225,7 +225,7 @@ extern "C" uint64_t artPortableToInterpreterBridge(mirror::AbstractMethod* metho // to jobjects. class BuildPortableArgumentVisitor : public PortableArgumentVisitor { public: - BuildPortableArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, + BuildPortableArgumentVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp, ScopedObjectAccessUnchecked& soa, std::vector<jvalue>& args) : PortableArgumentVisitor(caller_mh, sp), soa_(soa), args_(args) {} @@ -269,9 +269,9 @@ class BuildPortableArgumentVisitor : public PortableArgumentVisitor { // which is responsible for recording callee save registers. We explicitly place into jobjects the // incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a // field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_method, +extern "C" uint64_t artPortableProxyInvokeHandler(mirror::ArtMethod* proxy_method, mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in jobjects. const char* old_cause = @@ -292,7 +292,7 @@ extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_ args.erase(args.begin()); // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + mirror::ArtMethod* interface_method = proxy_method->FindOverriddenMethod(); DCHECK(interface_method != NULL); DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); jobject interface_method_jobj = soa.AddLocalReference<jobject>(interface_method); @@ -306,13 +306,13 @@ extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_ } // Lazily resolve a method for portable. Called by stub code. -extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, +extern "C" const void* artPortableResolutionTrampoline(mirror::ArtMethod* called, mirror::Object* receiver, Thread* thread, - mirror::AbstractMethod** called_addr) + mirror::ArtMethod** called_addr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t dex_pc; - mirror::AbstractMethod* caller = thread->GetCurrentMethod(&dex_pc); + mirror::ArtMethod* caller = thread->GetCurrentMethod(&dex_pc); ClassLinker* linker = Runtime::Current()->GetClassLinker(); InvokeType invoke_type; diff --git a/runtime/entrypoints/quick/callee_save_frame.h b/runtime/entrypoints/quick/callee_save_frame.h index 0cb578d..8f70049 100644 --- a/runtime/entrypoints/quick/callee_save_frame.h +++ b/runtime/entrypoints/quick/callee_save_frame.h @@ -22,11 +22,11 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; } // namespace mirror // Place a special frame at the TOS that will save the callee saves for the given type. -static void FinishCalleeSaveFrameSetup(Thread* self, mirror::AbstractMethod** sp, +static void FinishCalleeSaveFrameSetup(Thread* self, mirror::ArtMethod** sp, Runtime::CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Be aware the store below may well stomp on an incoming argument. diff --git a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc index 9ed802a..420e63a 100644 --- a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc @@ -16,61 +16,61 @@ #include "callee_save_frame.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" namespace art { -extern "C" mirror::Object* artAllocObjectFromCode(uint32_t type_idx, mirror::AbstractMethod* method, - Thread* self, mirror::AbstractMethod** sp) +extern "C" mirror::Object* artAllocObjectFromCode(uint32_t type_idx, mirror::ArtMethod* method, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocObjectFromCode(type_idx, method, self, false); } extern "C" mirror::Object* artAllocObjectFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocObjectFromCode(type_idx, method, self, true); } -extern "C" mirror::Array* artAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +extern "C" mirror::Array* artAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocArrayFromCode(type_idx, method, component_count, self, false); } extern "C" mirror::Array* artAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocArrayFromCode(type_idx, method, component_count, self, true); } extern "C" mirror::Array* artCheckAndAllocArrayFromCode(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, false); } extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, true); diff --git a/runtime/entrypoints/quick/quick_cast_entrypoints.cc b/runtime/entrypoints/quick/quick_cast_entrypoints.cc index b810bb7..9ffa736 100644 --- a/runtime/entrypoints/quick/quick_cast_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_cast_entrypoints.cc @@ -33,7 +33,7 @@ extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, // Check whether it is safe to cast one class to the other, throw exception and return -1 on failure extern "C" int artCheckCastFromCode(mirror::Class* src_type, mirror::Class* dest_type, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(src_type->IsClass()) << PrettyClass(src_type); DCHECK(dest_type->IsClass()) << PrettyClass(dest_type); @@ -50,7 +50,7 @@ extern "C" int artCheckCastFromCode(mirror::Class* src_type, mirror::Class* dest // Returns 0 on success and -1 if an exception is pending. extern "C" int artCanPutArrayElementFromCode(const mirror::Object* element, const mirror::Class* array_class, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(array_class != NULL); // element can't be NULL as we catch this is screened in runtime_support diff --git a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc index 43fc9d2..51c647a 100644 --- a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc @@ -17,7 +17,7 @@ #include "callee_save_frame.h" #include "dex_file-inl.h" #include "interpreter/interpreter.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -28,7 +28,7 @@ namespace art { -extern "C" void artDeoptimize(Thread* self, mirror::AbstractMethod** sp) +extern "C" void artDeoptimize(Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); self->SetException(ThrowLocation(), reinterpret_cast<mirror::Throwable*>(-1)); diff --git a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc index 6400161..003047a 100644 --- a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc @@ -19,16 +19,16 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called to ensure static storage base is initialized for direct static field reads and writes. // A class may be accessing another class' fields when it doesn't have access, as access has been @@ -38,8 +38,8 @@ extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, } extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when method->dex_cache_resolved_types_[] misses. FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); @@ -47,9 +47,9 @@ extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, } extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when caller isn't guaranteed to have access to a type and the dex cache may be // unpopulated. @@ -57,9 +57,9 @@ extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type return ResolveVerifyAndClinit(type_idx, referrer, self, false, true); } -extern "C" mirror::String* artResolveStringFromCode(mirror::AbstractMethod* referrer, +extern "C" mirror::String* artResolveStringFromCode(mirror::ArtMethod* referrer, int32_t string_idx, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return ResolveStringFromCode(referrer, string_idx); diff --git a/runtime/entrypoints/quick/quick_entrypoints.h b/runtime/entrypoints/quick/quick_entrypoints.h index e76679b..9d3b8ef 100644 --- a/runtime/entrypoints/quick/quick_entrypoints.h +++ b/runtime/entrypoints/quick/quick_entrypoints.h @@ -29,9 +29,9 @@ namespace art { namespace mirror { - class AbstractMethod; - class Class; - class Object; +class ArtMethod; +class Class; +class Object; } // namespace mirror class Thread; @@ -116,8 +116,8 @@ struct PACKED(4) QuickEntryPoints { void* (*pMemcpy)(void*, const void*, size_t); // Invocation - void (*pQuickResolutionTrampoline)(mirror::AbstractMethod*); - void (*pQuickToInterpreterBridge)(mirror::AbstractMethod*); + void (*pQuickResolutionTrampoline)(mirror::ArtMethod*); + void (*pQuickToInterpreterBridge)(mirror::ArtMethod*); void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*); void (*pInvokeInterfaceTrampoline)(uint32_t, void*); void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*); diff --git a/runtime/entrypoints/quick/quick_field_entrypoints.cc b/runtime/entrypoints/quick/quick_field_entrypoints.cc index a4e9dc9..0ec1eb7 100644 --- a/runtime/entrypoints/quick/quick_field_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_field_entrypoints.cc @@ -17,19 +17,20 @@ #include "callee_save_frame.h" #include "dex_file-inl.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include <stdint.h> namespace art { extern "C" uint32_t artGet32StaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, + sizeof(int32_t)); if (LIKELY(field != NULL)) { return field->Get32(field->GetDeclaringClass()); } @@ -42,10 +43,11 @@ extern "C" uint32_t artGet32StaticFromCode(uint32_t field_idx, } extern "C" uint64_t artGet64StaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, + sizeof(int64_t)); if (LIKELY(field != NULL)) { return field->Get64(field->GetDeclaringClass()); } @@ -58,16 +60,17 @@ extern "C" uint64_t artGet64StaticFromCode(uint32_t field_idx, } extern "C" mirror::Object* artGetObjStaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectRead, sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, StaticObjectRead, sizeof(mirror::Object*), true); + field = FindFieldFromCode(field_idx, referrer, self, StaticObjectRead, sizeof(mirror::Object*), + true); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } @@ -75,15 +78,17 @@ extern "C" mirror::Object* artGetObjStaticFromCode(uint32_t field_idx, } extern "C" uint32_t artGet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, + sizeof(int32_t)); if (LIKELY(field != NULL && obj != NULL)) { return field->Get32(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int32_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int32_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -96,15 +101,17 @@ extern "C" uint32_t artGet32InstanceFromCode(uint32_t field_idx, mirror::Object* } extern "C" uint64_t artGet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, + sizeof(int64_t)); if (LIKELY(field != NULL && obj != NULL)) { return field->Get64(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int64_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int64_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -117,16 +124,18 @@ extern "C" uint64_t artGet64InstanceFromCode(uint32_t field_idx, mirror::Object* } extern "C" mirror::Object* artGetObjInstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL && obj != NULL)) { return field->GetObj(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstanceObjectRead, sizeof(mirror::Object*), true); + field = FindFieldFromCode(field_idx, referrer, self, InstanceObjectRead, sizeof(mirror::Object*), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -139,10 +148,11 @@ extern "C" mirror::Object* artGetObjInstanceFromCode(uint32_t field_idx, mirror: } extern "C" int artSet32StaticFromCode(uint32_t field_idx, uint32_t new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, + sizeof(int32_t)); if (LIKELY(field != NULL)) { field->Set32(field->GetDeclaringClass(), new_value); return 0; // success @@ -156,10 +166,11 @@ extern "C" int artSet32StaticFromCode(uint32_t field_idx, uint32_t new_value, return -1; // failure } -extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, - uint64_t new_value, Thread* self, mirror::AbstractMethod** sp) +extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, + uint64_t new_value, Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, + sizeof(int64_t)); if (LIKELY(field != NULL)) { field->Set64(field->GetDeclaringClass(), new_value); return 0; // success @@ -174,11 +185,11 @@ extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::Abstract } extern "C" int artSetObjStaticFromCode(uint32_t field_idx, mirror::Object* new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { if (LIKELY(!FieldHelper(field).IsPrimitiveType())) { field->SetObj(field->GetDeclaringClass(), new_value); @@ -195,16 +206,18 @@ extern "C" int artSetObjStaticFromCode(uint32_t field_idx, mirror::Object* new_v } extern "C" int artSet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, uint32_t new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, + sizeof(int32_t)); if (LIKELY(field != NULL && obj != NULL)) { field->Set32(obj, new_value); return 0; // success } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int32_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int32_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -218,20 +231,21 @@ extern "C" int artSet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, } extern "C" int artSet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, uint64_t new_value, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); - mirror::AbstractMethod* referrer = - sp[callee_save->GetFrameSizeInBytes() / sizeof(mirror::AbstractMethod*)]; - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, - sizeof(int64_t)); + mirror::ArtMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); + mirror::ArtMethod* referrer = + sp[callee_save->GetFrameSizeInBytes() / sizeof(mirror::ArtMethod*)]; + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, + sizeof(int64_t)); if (LIKELY(field != NULL && obj != NULL)) { field->Set64(obj, new_value); return 0; // success } *sp = callee_save; self->SetTopOfStack(sp, 0); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int64_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int64_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -246,11 +260,11 @@ extern "C" int artSet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, extern "C" int artSetObjInstanceFromCode(uint32_t field_idx, mirror::Object* obj, mirror::Object* new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL && obj != NULL)) { field->SetObj(obj, new_value); return 0; // success diff --git a/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc b/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc index b81ad12..ca0c92e 100644 --- a/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc @@ -39,7 +39,7 @@ namespace art { */ extern "C" int artHandleFillArrayDataFromCode(mirror::Array* array, const Instruction::ArrayDataPayload* payload, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); DCHECK_EQ(payload->ident, static_cast<uint16_t>(Instruction::kArrayDataSignature)); diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc index 0e61942..633f580 100644 --- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc @@ -16,17 +16,17 @@ #include "callee_save_frame.h" #include "instrumentation.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "runtime.h" #include "thread-inl.h" namespace art { -extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMethod* method, +extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::ArtMethod* method, mirror::Object* this_object, Thread* self, - mirror::AbstractMethod** sp, + mirror::ArtMethod** sp, uintptr_t lr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); @@ -39,7 +39,7 @@ extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMet return result; } -extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::AbstractMethod** sp, +extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::ArtMethod** sp, uint64_t gpr_result, uint64_t fpr_result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // TODO: use FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly) not the hand inlined below. @@ -47,7 +47,7 @@ extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::A // stack. // Be aware the store below may well stomp on an incoming argument. Locks::mutator_lock_->AssertSharedHeld(self); - mirror::AbstractMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); + mirror::ArtMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); *sp = callee_save; uintptr_t* return_pc = reinterpret_cast<uintptr_t*>(reinterpret_cast<byte*>(sp) + callee_save->GetReturnPcOffsetInBytes()); diff --git a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc index 53b3628..1d8022f 100644 --- a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc @@ -17,21 +17,21 @@ #include "callee_save_frame.h" #include "dex_instruction-inl.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" namespace art { // Determine target of interface dispatch. This object is known non-null. -extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::AbstractMethod* interface_method, +extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::ArtMethod* interface_method, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, - Thread* self, mirror::AbstractMethod** sp) + mirror::ArtMethod* caller_method, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; if (LIKELY(interface_method->GetDexMethodIndex() != DexFile::kDexNoIndex16)) { method = this_object->GetClass()->FindVirtualMethodForInterface(interface_method); if (UNLIKELY(method == NULL)) { @@ -144,11 +144,11 @@ extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::AbstractMethod* interfa static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, - Thread* self, mirror::AbstractMethod** sp, bool access_check, + mirror::ArtMethod* caller_method, + Thread* self, mirror::ArtMethod** sp, bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = FindMethodFast(method_idx, this_object, caller_method, + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, type); if (UNLIKELY(method == NULL)) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); @@ -179,9 +179,9 @@ static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object // See comments in runtime_support_asm.S extern "C" uint64_t artInvokeInterfaceTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kInterface); } @@ -189,36 +189,36 @@ extern "C" uint64_t artInvokeInterfaceTrampolineWithAccessCheck(uint32_t method_ extern "C" uint64_t artInvokeDirectTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kDirect); } extern "C" uint64_t artInvokeStaticTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kStatic); } extern "C" uint64_t artInvokeSuperTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kSuper); } extern "C" uint64_t artInvokeVirtualTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kVirtual); } diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc index 9907c04..27ae59b 100644 --- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc @@ -16,8 +16,8 @@ #include "dex_file-inl.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" diff --git a/runtime/entrypoints/quick/quick_lock_entrypoints.cc b/runtime/entrypoints/quick/quick_lock_entrypoints.cc index 79bb7a6..36ca604 100644 --- a/runtime/entrypoints/quick/quick_lock_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_lock_entrypoints.cc @@ -20,7 +20,7 @@ namespace art { extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) UNLOCK_FUNCTION(monitor_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); DCHECK(obj != NULL); // Assumed to have been checked before entry @@ -29,7 +29,7 @@ extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, } extern "C" void artLockObjectFromCode(mirror::Object* obj, Thread* thread, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) EXCLUSIVE_LOCK_FUNCTION(monitor_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsOnly); DCHECK(obj != NULL); // Assumed to have been checked before entry diff --git a/runtime/entrypoints/quick/quick_thread_entrypoints.cc b/runtime/entrypoints/quick/quick_thread_entrypoints.cc index b4d6c0b..53e725e 100644 --- a/runtime/entrypoints/quick/quick_thread_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_thread_entrypoints.cc @@ -28,7 +28,7 @@ void CheckSuspendFromCode(Thread* thread) CheckSuspend(thread); } -extern "C" void artTestSuspendFromCode(Thread* thread, mirror::AbstractMethod** sp) +extern "C" void artTestSuspendFromCode(Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when suspend count check value is 0 and thread->suspend_count_ != 0 FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsOnly); diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc index 3bfa2f2..f67b2fc 100644 --- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc @@ -24,7 +24,7 @@ namespace art { // Deliver an exception that's pending on thread helping set up a callee save frame on the way. -extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::AbstractMethod** sp) +extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kSaveAll); thread->QuickDeliverException(); @@ -32,7 +32,7 @@ extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::Abstr // Called by generated call to throw an exception. extern "C" void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { /* * exception may be NULL, in which case this routine should @@ -54,7 +54,7 @@ extern "C" void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread // Called by generated call to throw a NPE exception. extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -64,7 +64,7 @@ extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, // Called by generated call to throw an arithmetic divide by zero exception. extern "C" void artThrowDivZeroFromCode(Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowArithmeticExceptionDivideByZero(); @@ -73,14 +73,14 @@ extern "C" void artThrowDivZeroFromCode(Thread* self, // Called by generated call to throw an array index out of bounds exception. extern "C" void artThrowArrayBoundsFromCode(int index, int length, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowArrayIndexOutOfBoundsException(index, length); self->QuickDeliverException(); } -extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::AbstractMethod** sp) +extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowStackOverflowError(self); @@ -88,7 +88,7 @@ extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::AbstractMeth } extern "C" void artThrowNoSuchMethodFromCode(int32_t method_idx, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowNoSuchMethodError(method_idx); diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 9bf02e8..392bcc5 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -19,7 +19,7 @@ #include "dex_instruction-inl.h" #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -100,18 +100,18 @@ class QuickArgumentVisitor { #define QUICK_STACK_ARG_SKIP 0 #endif - static mirror::AbstractMethod* GetCallingMethod(mirror::AbstractMethod** sp) { + static mirror::ArtMethod* GetCallingMethod(mirror::ArtMethod** sp) { byte* previous_sp = reinterpret_cast<byte*>(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE; - return *reinterpret_cast<mirror::AbstractMethod**>(previous_sp); + return *reinterpret_cast<mirror::ArtMethod**>(previous_sp); } - static uintptr_t GetCallingPc(mirror::AbstractMethod** sp) { + static uintptr_t GetCallingPc(mirror::ArtMethod** sp) { byte* lr = reinterpret_cast<byte*>(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET; return *reinterpret_cast<uintptr_t*>(lr); } - QuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, + QuickArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : is_static_(is_static), shorty_(shorty), shorty_len_(shorty_len), @@ -220,7 +220,7 @@ class QuickArgumentVisitor { // Visits arguments on the stack placing them into the shadow frame. class BuildShadowFrameVisitor : public QuickArgumentVisitor { public: - BuildShadowFrameVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + BuildShadowFrameVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ShadowFrame& sf, size_t first_arg_reg) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), sf_(sf), cur_reg_(first_arg_reg) {} @@ -261,8 +261,8 @@ class BuildShadowFrameVisitor : public QuickArgumentVisitor { DISALLOW_COPY_AND_ASSIGN(BuildShadowFrameVisitor); }; -extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) +extern "C" uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in the shadow // frame. @@ -311,7 +311,7 @@ extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, // to jobjects. class BuildQuickArgumentVisitor : public QuickArgumentVisitor { public: - BuildQuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + BuildQuickArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ScopedObjectAccessUnchecked* soa, std::vector<jvalue>* args) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa), args_(args) {} @@ -360,9 +360,9 @@ class BuildQuickArgumentVisitor : public QuickArgumentVisitor { // which is responsible for recording callee save registers. We explicitly place into jobjects the // incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a // field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_method, +extern "C" uint64_t artQuickProxyInvokeHandler(mirror::ArtMethod* proxy_method, mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in jobjects. const char* old_cause = @@ -389,7 +389,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_met args.erase(args.begin()); // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + mirror::ArtMethod* interface_method = proxy_method->FindOverriddenMethod(); DCHECK(interface_method != NULL); DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); jobject interface_method_jobj = soa.AddLocalReference<jobject>(interface_method); @@ -406,7 +406,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_met // so they don't get garbage collected. class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { public: - RememberFoGcArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + RememberFoGcArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa) {} @@ -423,9 +423,9 @@ class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { }; // Lazily resolve a method for quick. Called by stub code. -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, +extern "C" const void* artQuickResolutionTrampoline(mirror::ArtMethod* called, mirror::Object* receiver, - Thread* thread, mirror::AbstractMethod** sp) + Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsAndArgs); // Start new JNI local reference state @@ -436,7 +436,7 @@ extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* call // Compute details about the called method (avoid GCs) ClassLinker* linker = Runtime::Current()->GetClassLinker(); - mirror::AbstractMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); + mirror::ArtMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); InvokeType invoke_type; const DexFile* dex_file; uint32_t dex_method_idx; diff --git a/runtime/exception_test.cc b/runtime/exception_test.cc index 933b74a..e48208d 100644 --- a/runtime/exception_test.cc +++ b/runtime/exception_test.cc @@ -95,8 +95,8 @@ class ExceptionTest : public CommonTest { UnsignedLeb128EncodingVector fake_vmap_table_data_; std::vector<uint8_t> fake_gc_map_; - mirror::AbstractMethod* method_f_; - mirror::AbstractMethod* method_g_; + mirror::ArtMethod* method_f_; + mirror::ArtMethod* method_g_; private: mirror::Class* my_klass_; diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc index 0363acb..3bbc381 100644 --- a/runtime/gc/accounting/mod_union_table.cc +++ b/runtime/gc/accounting/mod_union_table.cc @@ -22,9 +22,9 @@ #include "gc/collector/mark_sweep-inl.h" #include "gc/heap.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" #include "mirror/object-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object_array-inl.h" #include "space_bitmap-inl.h" #include "thread.h" diff --git a/runtime/gc/accounting/space_bitmap.cc b/runtime/gc/accounting/space_bitmap.cc index 6edc067..702e162 100644 --- a/runtime/gc/accounting/space_bitmap.cc +++ b/runtime/gc/accounting/space_bitmap.cc @@ -17,8 +17,8 @@ #include "base/logging.h" #include "dex_file-inl.h" #include "heap_bitmap.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -182,10 +182,10 @@ static void WalkInstanceFields(SpaceBitmap* visited, SpaceBitmap::Callback* call WalkInstanceFields(visited, callback, obj, super, arg); } // Walk instance fields - mirror::ObjectArray<mirror::Field>* fields = klass->GetIFields(); + mirror::ObjectArray<mirror::ArtField>* fields = klass->GetIFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); FieldHelper fh(field); if (!fh.IsPrimitiveType()) { mirror::Object* value = field->GetObj(obj); @@ -212,10 +212,10 @@ static void WalkFieldsInOrder(SpaceBitmap* visited, SpaceBitmap::Callback* callb WalkInstanceFields(visited, callback, obj, klass, arg); // Walk static fields of a Class if (obj->IsClass()) { - mirror::ObjectArray<mirror::Field>* fields = klass->GetSFields(); + mirror::ObjectArray<mirror::ArtField>* fields = klass->GetSFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); FieldHelper fh(field); if (!fh.IsPrimitiveType()) { mirror::Object* value = field->GetObj(NULL); diff --git a/runtime/gc/collector/mark_sweep-inl.h b/runtime/gc/collector/mark_sweep-inl.h index 6b1b617..e158952 100644 --- a/runtime/gc/collector/mark_sweep-inl.h +++ b/runtime/gc/collector/mark_sweep-inl.h @@ -20,8 +20,8 @@ #include "gc/collector/mark_sweep.h" #include "gc/heap.h" +#include "mirror/art_field.h" #include "mirror/class.h" -#include "mirror/field.h" #include "mirror/object_array.h" namespace art { @@ -136,8 +136,8 @@ inline void MarkSweep::VisitFieldsReferences(const mirror::Object* obj, uint32_t ? klass->NumReferenceStaticFields() : klass->NumReferenceInstanceFields()); for (size_t i = 0; i < num_reference_fields; ++i) { - mirror::Field* field = (is_static ? klass->GetStaticField(i) - : klass->GetInstanceField(i)); + mirror::ArtField* field = (is_static ? klass->GetStaticField(i) + : klass->GetInstanceField(i)); MemberOffset field_offset = field->GetOffset(); const mirror::Object* ref = obj->GetFieldObject<const mirror::Object*>(field_offset, false); visitor(obj, ref, field_offset, is_static); diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 7b78720..61570ae 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -37,11 +37,11 @@ #include "jni_internal.h" #include "monitor.h" #include "mark_sweep-inl.h" +#include "mirror/art_field.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array.h" #include "mirror/object_array-inl.h" @@ -50,8 +50,8 @@ #include "thread_list.h" #include "verifier/method_verifier.h" +using ::art::mirror::ArtField; using ::art::mirror::Class; -using ::art::mirror::Field; using ::art::mirror::Object; using ::art::mirror::ObjectArray; @@ -1072,11 +1072,11 @@ void MarkSweep::CheckReference(const Object* obj, const Object* ref, MemberOffse const Class* klass = is_static ? obj->AsClass() : obj->GetClass(); DCHECK(klass != NULL); - const ObjectArray<Field>* fields = is_static ? klass->GetSFields() : klass->GetIFields(); + const ObjectArray<ArtField>* fields = is_static ? klass->GetSFields() : klass->GetIFields(); DCHECK(fields != NULL); bool found = false; for (int32_t i = 0; i < fields->GetLength(); ++i) { - const Field* cur = fields->Get(i); + const ArtField* cur = fields->Get(i); if (cur->GetOffset().Int32Value() == offset.Int32Value()) { LOG(WARNING) << "Field referencing the alloc space was " << PrettyField(cur); found = true; diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index df1f3fe..a2453b8 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -41,8 +41,8 @@ #include "gc/space/space-inl.h" #include "image.h" #include "invoke_arg_array_builder.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -1512,11 +1512,11 @@ class VerifyReferenceCardVisitor { if (!obj->IsObjectArray()) { const mirror::Class* klass = is_static ? obj->AsClass() : obj->GetClass(); CHECK(klass != NULL); - const mirror::ObjectArray<mirror::Field>* fields = is_static ? klass->GetSFields() - : klass->GetIFields(); + const mirror::ObjectArray<mirror::ArtField>* fields = is_static ? klass->GetSFields() + : klass->GetIFields(); CHECK(fields != NULL); for (int32_t i = 0; i < fields->GetLength(); ++i) { - const mirror::Field* cur = fields->Get(i); + const mirror::ArtField* cur = fields->Get(i); if (cur->GetOffset().Int32Value() == offset.Int32Value()) { LOG(ERROR) << (is_static ? "Static " : "") << "field in the live stack is " << PrettyField(cur); diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 8ff7025..22562df 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -22,7 +22,7 @@ #include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "gc/accounting/space_bitmap-inl.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "oat_file.h" @@ -187,14 +187,14 @@ ImageSpace* ImageSpace::Init(const std::string& image_file_name, bool validate_o Runtime* runtime = Runtime::Current(); mirror::Object* resolution_method = image_header.GetImageRoot(ImageHeader::kResolutionMethod); - runtime->SetResolutionMethod(down_cast<mirror::AbstractMethod*>(resolution_method)); + runtime->SetResolutionMethod(down_cast<mirror::ArtMethod*>(resolution_method)); mirror::Object* callee_save_method = image_header.GetImageRoot(ImageHeader::kCalleeSaveMethod); - runtime->SetCalleeSaveMethod(down_cast<mirror::AbstractMethod*>(callee_save_method), Runtime::kSaveAll); + runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kSaveAll); callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsOnlySaveMethod); - runtime->SetCalleeSaveMethod(down_cast<mirror::AbstractMethod*>(callee_save_method), Runtime::kRefsOnly); + runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kRefsOnly); callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod); - runtime->SetCalleeSaveMethod(down_cast<mirror::AbstractMethod*>(callee_save_method), Runtime::kRefsAndArgs); + runtime->SetCalleeSaveMethod(down_cast<mirror::ArtMethod*>(callee_save_method), Runtime::kRefsAndArgs); UniquePtr<ImageSpace> space(new ImageSpace(image_file_name, map.release())); diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index d3bb2e8..0b2e741 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -48,10 +48,9 @@ #include "gc/heap.h" #include "gc/space/space.h" #include "globals.h" +#include "mirror/art_field-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "os.h" @@ -922,7 +921,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { rec->AddId(CLASS_STATICS_ID(obj)); for (size_t i = 0; i < sFieldCount; ++i) { - mirror::Field* f = thisClass->GetStaticField(i); + mirror::ArtField* f = thisClass->GetStaticField(i); fh.ChangeField(f); size_t size; @@ -947,7 +946,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { int iFieldCount = thisClass->IsObjectClass() ? 0 : thisClass->NumInstanceFields(); rec->AddU2((uint16_t)iFieldCount); for (int i = 0; i < iFieldCount; ++i) { - mirror::Field* f = thisClass->GetInstanceField(i); + mirror::ArtField* f = thisClass->GetInstanceField(i); fh.ChangeField(f); HprofBasicType t = SignatureToBasicTypeAndSize(fh.GetTypeDescriptor(), NULL); rec->AddId(LookupStringId(fh.GetName())); @@ -1010,7 +1009,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { while (!sclass->IsObjectClass()) { int ifieldCount = sclass->NumInstanceFields(); for (int i = 0; i < ifieldCount; ++i) { - mirror::Field* f = sclass->GetInstanceField(i); + mirror::ArtField* f = sclass->GetInstanceField(i); fh.ChangeField(f); size_t size; SignatureToBasicTypeAndSize(fh.GetTypeDescriptor(), &size); diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index c3b66b3..ae3a165 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -23,9 +23,9 @@ #include "class_linker.h" #include "debugger.h" #include "dex_file-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "nth_caller_visitor.h" @@ -55,7 +55,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } bool is_initialized = klass->IsInitialized(); for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - mirror::AbstractMethod* method = klass->GetDirectMethod(i); + mirror::ArtMethod* method = klass->GetDirectMethod(i); if (!method->IsAbstract()) { const void* new_code; if (uninstall) { @@ -77,7 +77,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } } for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - mirror::AbstractMethod* method = klass->GetVirtualMethod(i); + mirror::ArtMethod* method = klass->GetVirtualMethod(i); if (!method->IsAbstract()) { const void* new_code; if (uninstall) { @@ -109,7 +109,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) instrumentation_exit_pc_(instrumentation_exit_pc), last_return_pc_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (GetCurrentQuickFrame() == NULL) { if (kVerboseInstrumentation) { LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId() @@ -169,7 +169,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) for (It it = thread->GetInstrumentationStack()->rbegin(), end = thread->GetInstrumentationStack()->rend(); it != end; ++it) { mirror::Object* this_object = (*it).this_object_; - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; uint32_t dex_pc = visitor.dex_pcs_.back(); visitor.dex_pcs_.pop_back(); instrumentation->MethodEnterEvent(thread, this_object, method, dex_pc); @@ -193,7 +193,7 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) if (instrumentation_stack_->size() == 0) { return false; // Stop. } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (GetCurrentQuickFrame() == NULL) { if (kVerboseInstrumentation) { LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId() << " Method=" << PrettyMethod(m); @@ -379,7 +379,7 @@ void Instrumentation::ConfigureStubs(bool require_entry_exit_stubs, bool require } } -void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const void* code) const { +void Instrumentation::UpdateMethodsCode(mirror::ArtMethod* method, const void* code) const { if (LIKELY(!instrumentation_stubs_installed_)) { method->SetEntryPointFromCompiledCode(code); } else { @@ -391,7 +391,7 @@ void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const vo } } -const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* method) const { +const void* Instrumentation::GetQuickCodeFor(const mirror::ArtMethod* method) const { Runtime* runtime = Runtime::Current(); if (LIKELY(!instrumentation_stubs_installed_)) { const void* code = method->GetEntryPointFromCompiledCode(); @@ -405,7 +405,7 @@ const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* metho } void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { typedef std::list<InstrumentationListener*>::const_iterator It; // TODO: C++0x auto It it = method_entry_listeners_.begin(); @@ -420,7 +420,7 @@ void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_ } void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const { typedef std::list<InstrumentationListener*>::const_iterator It; // TODO: C++0x auto It it = method_exit_listeners_.begin(); @@ -435,7 +435,7 @@ void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_o } void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { if (have_method_unwind_listeners_) { typedef std::list<InstrumentationListener*>::const_iterator It; // TODO: C++0x auto @@ -447,7 +447,7 @@ void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_obj } void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { // TODO: STL copy-on-write collection? The copy below is due to the debug listener having an // action where it can remove itself as a listener and break the iterator. The copy only works @@ -461,7 +461,7 @@ void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_o } void Instrumentation::ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) { if (have_exception_caught_listeners_) { @@ -489,7 +489,7 @@ static void CheckStackDepth(Thread* self, const InstrumentationStackFrame& instr } void Instrumentation::PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t lr, bool interpreter_entry) { // We have a callee-save frame meaning this value is guaranteed to never be 0. size_t frame_id = StackVisitor::ComputeNumFrames(self); @@ -516,7 +516,7 @@ uint64_t Instrumentation::PopInstrumentationStackFrame(Thread* self, uintptr_t* *return_pc = instrumentation_frame.return_pc_; CheckStackDepth(self, instrumentation_frame, 0); - mirror::AbstractMethod* method = instrumentation_frame.method_; + mirror::ArtMethod* method = instrumentation_frame.method_; char return_shorty = MethodHelper(method).GetShorty()[0]; JValue return_value; if (return_shorty == 'V') { @@ -567,7 +567,7 @@ void Instrumentation::PopMethodForUnwind(Thread* self, bool is_deoptimization) c // TODO: bring back CheckStackDepth(self, instrumentation_frame, 2); stack->pop_front(); - mirror::AbstractMethod* method = instrumentation_frame.method_; + mirror::ArtMethod* method = instrumentation_frame.method_; if (is_deoptimization) { if (kVerboseInstrumentation) { LOG(INFO) << "Popping for deoptimization " << PrettyMethod(method); diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index 798b7ab..6c80b41 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -25,10 +25,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class Class; -class Object; -class Throwable; + class ArtMethod; + class Class; + class Object; + class Throwable; } // namespace mirror union JValue; class Thread; @@ -47,30 +47,30 @@ struct InstrumentationListener { // Call-back for when a method is entered. virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when a method is exited. // TODO: its likely passing the return value would be useful, however, we may need to get and // parse the shorty to determine what kind of register holds the result. virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when a method is popped due to an exception throw. A method will either cause a // MethodExited call-back or a MethodUnwind call-back when its activation is removed. - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when the dex pc moves in a method. virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back when an exception is caught. virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; }; @@ -111,12 +111,12 @@ class Instrumentation { LOCKS_EXCLUDED(Locks::thread_list_lock_, Locks::classlinker_classes_lock_); // Update the code of a method respecting any installed stubs. - void UpdateMethodsCode(mirror::AbstractMethod* method, const void* code) const; + void UpdateMethodsCode(mirror::ArtMethod* method, const void* code) const; // Get the quick code for the given method. More efficient than asking the class linker as it // will short-cut to GetCode if instrumentation and static method resolution stubs aren't // installed. - const void* GetQuickCodeFor(const mirror::AbstractMethod* method) const + const void* GetQuickCodeFor(const mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ForceInterpretOnly() { @@ -124,7 +124,7 @@ class Instrumentation { forced_interpret_only_ = true; } - // Called by AbstractMethod::Invoke to determine dispatch mechanism. + // Called by ArtMethod::Invoke to determine dispatch mechanism. bool InterpretOnly() const { return interpret_only_; } @@ -152,7 +152,7 @@ class Instrumentation { // Inform listeners that a method has been entered. A dex PC is provided as we may install // listeners into executing code and get method enter events for methods already on the stack. void MethodEnterEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasMethodEntryListeners())) { MethodEnterEventImpl(thread, this_object, method, dex_pc); @@ -161,7 +161,7 @@ class Instrumentation { // Inform listeners that a method has been exited. void MethodExitEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasMethodExitListeners())) { @@ -171,12 +171,12 @@ class Instrumentation { // Inform listeners that a method has been exited due to an exception. void MethodUnwindEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Inform listeners that the dex pc has moved (only supported by the interpreter). void DexPcMovedEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasDexPcListeners())) { DexPcMovedEventImpl(thread, this_object, method, dex_pc); @@ -185,14 +185,14 @@ class Instrumentation { // Inform listeners that an exception was caught. void ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Called when an instrumented method is entered. The intended link register (lr) is saved so // that returning causes a branch to the method exit stub. Generates method enter events. void PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, - mirror::AbstractMethod* method, uintptr_t lr, + mirror::ArtMethod* method, uintptr_t lr, bool interpreter_entry) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -216,23 +216,23 @@ class Instrumentation { LOCKS_EXCLUDED(Locks::thread_list_lock_, Locks::classlinker_classes_lock_); void MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void MethodExitEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // Have we hijacked AbstractMethod::code_ so that it calls instrumentation/interpreter code? + // Have we hijacked ArtMethod::code_ so that it calls instrumentation/interpreter code? bool instrumentation_stubs_installed_; - // Have we hijacked AbstractMethod::code_ to reference the enter/exit stubs? + // Have we hijacked ArtMethod::code_ to reference the enter/exit stubs? bool entry_exit_stubs_installed_; - // Have we hijacked AbstractMethod::code_ to reference the enter interpreter stub? + // Have we hijacked ArtMethod::code_ to reference the enter interpreter stub? bool interpreter_stubs_installed_; // Do we need the fidelity of events that we only get from running within the interpreter? @@ -272,7 +272,7 @@ class Instrumentation { // An element in the instrumentation side stack maintained in art::Thread. struct InstrumentationStackFrame { - InstrumentationStackFrame(mirror::Object* this_object, mirror::AbstractMethod* method, + InstrumentationStackFrame(mirror::Object* this_object, mirror::ArtMethod* method, uintptr_t return_pc, size_t frame_id, bool interpreter_entry) : this_object_(this_object), method_(method), return_pc_(return_pc), frame_id_(frame_id), interpreter_entry_(interpreter_entry) { @@ -281,7 +281,7 @@ struct InstrumentationStackFrame { std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Object* this_object_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; const uintptr_t return_pc_; const size_t frame_id_; const bool interpreter_entry_; diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 6e35d93..59f0ac2 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -28,26 +28,27 @@ #include "gc/accounting/card_table-inl.h" #include "invoke_arg_array_builder.h" #include "nth_caller_visitor.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change.h" #include "thread.h" +#include "well_known_classes.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Array; using ::art::mirror::BooleanArray; using ::art::mirror::ByteArray; using ::art::mirror::CharArray; using ::art::mirror::Class; using ::art::mirror::ClassLoader; -using ::art::mirror::Field; using ::art::mirror::IntArray; using ::art::mirror::LongArray; using ::art::mirror::Object; @@ -82,22 +83,22 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, result->SetL(found); } else if (name == "java.lang.Object java.lang.Class.newInstance()") { Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); - AbstractMethod* c = klass->FindDeclaredDirectMethod("<init>", "()V"); + ArtMethod* c = klass->FindDeclaredDirectMethod("<init>", "()V"); CHECK(c != NULL); - Object* obj = klass->AllocObject(self); - CHECK(obj != NULL); - EnterInterpreterFromInvoke(self, c, obj, NULL, NULL); - result->SetL(obj); + SirtRef<Object> obj(self, klass->AllocObject(self)); + CHECK(obj.get() != NULL); + EnterInterpreterFromInvoke(self, c, obj.get(), NULL, NULL); + result->SetL(obj.get()); } else if (name == "java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String)") { // Special managed code cut-out to allow field lookup in a un-started runtime that'd fail // going the reflective Dex way. Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); String* name = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); - Field* found = NULL; + ArtField* found = NULL; FieldHelper fh; - ObjectArray<Field>* fields = klass->GetIFields(); + ObjectArray<ArtField>* fields = klass->GetIFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { - Field* f = fields->Get(i); + ArtField* f = fields->Get(i); fh.ChangeField(f); if (name->Equals(fh.GetName())) { found = f; @@ -106,7 +107,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, if (found == NULL) { fields = klass->GetSFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { - Field* f = fields->Get(i); + ArtField* f = fields->Get(i); fh.ChangeField(f); if (name->Equals(fh.GetName())) { found = f; @@ -118,7 +119,14 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, << name->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); // TODO: getDeclaredField calls GetType once the field is found to ensure a // NoClassDefFoundError is thrown if the field's type cannot be resolved. - result->SetL(found); + Class* jlr_Field = self->DecodeJObject(WellKnownClasses::java_lang_reflect_Field)->AsClass(); + SirtRef<Object> field(self, jlr_Field->AllocObject(self)); + CHECK(field.get() != NULL); + ArtMethod* c = jlr_Field->FindDeclaredDirectMethod("<init>", "(Ljava/lang/reflect/ArtField;)V"); + uint32_t args[1]; + args[0] = reinterpret_cast<uint32_t>(found); + EnterInterpreterFromInvoke(self, c, field.get(), args, NULL); + result->SetL(field.get()); } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)") { // Special case array copying without initializing System. Class* ctype = shadow_frame->GetVRegReference(arg_offset)->GetClass()->GetComponentType(); @@ -153,7 +161,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, } // Hand select a number of methods to be run in a not yet started runtime without using JNI. -static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, +static void UnstartedRuntimeJni(Thread* self, ArtMethod* method, Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string name(PrettyMethod(method)); @@ -215,7 +223,7 @@ static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, } } -static void InterpreterJni(Thread* self, AbstractMethod* method, StringPiece shorty, +static void InterpreterJni(Thread* self, ArtMethod* method, StringPiece shorty, Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // TODO: The following enters JNI code using a typedef-ed function rather than the JNI compiler, @@ -417,8 +425,8 @@ static bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); Object* receiver = (type == kStatic) ? NULL : shadow_frame.GetVRegReference(vregC); - AbstractMethod* method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, - do_access_check, type); + ArtMethod* method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, + do_access_check, type); if (UNLIKELY(method == NULL)) { CHECK(self->IsExceptionPending()); result->SetJ(0); @@ -438,7 +446,7 @@ static bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, num_ins = code_item->ins_size_; } else { DCHECK(method->IsNative() || method->IsProxyMethod()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -510,7 +518,7 @@ static bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, } uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); // TODO: use ObjectArray<T>::GetWithoutChecks ? - AbstractMethod* method = receiver->GetClass()->GetVTable()->Get(vtable_idx); + ArtMethod* method = receiver->GetClass()->GetVTable()->Get(vtable_idx); if (UNLIKELY(method == NULL)) { CHECK(self->IsExceptionPending()); result->SetJ(0); @@ -530,7 +538,7 @@ static bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, num_ins = code_item->ins_size_; } else { DCHECK(method->IsNative() || method->IsProxyMethod()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -601,9 +609,9 @@ static inline bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst) { bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, - find_type, Primitive::FieldSize(field_type), - do_access_check); + ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, + find_type, Primitive::FieldSize(field_type), + do_access_check); if (UNLIKELY(f == NULL)) { CHECK(self->IsExceptionPending()); return false; @@ -695,9 +703,9 @@ static inline bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst) { bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, - find_type, Primitive::FieldSize(field_type), - do_access_check); + ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, + find_type, Primitive::FieldSize(field_type), + do_access_check); if (UNLIKELY(f == NULL)) { CHECK(self->IsExceptionPending()); return false; @@ -3052,7 +3060,7 @@ static inline JValue Execute(Thread* self, MethodHelper& mh, const DexFile::Code } } -void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* receiver, +void EnterInterpreterFromInvoke(Thread* self, ArtMethod* method, Object* receiver, uint32_t* args, JValue* result) { DCHECK_EQ(self, Thread::Current()); if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEnd())) { @@ -3072,7 +3080,7 @@ void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* re return; } else { DCHECK(method->IsNative()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -3172,7 +3180,7 @@ extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh return; } - AbstractMethod* method = shadow_frame->GetMethod(); + ArtMethod* method = shadow_frame->GetMethod(); if (method->IsStatic() && !method->GetDeclaringClass()->IsInitializing()) { if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true)) { diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index af4a147..49e8de0 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -22,7 +22,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Object; } // namespace mirror @@ -33,8 +33,8 @@ class Thread; namespace interpreter { -// Called by AbstractMethod::Invoke, shadow frames arguments are taken from the args array. -extern void EnterInterpreterFromInvoke(Thread* self, mirror::AbstractMethod* method, +// Called by ArtMethod::Invoke, shadow frames arguments are taken from the args array. +extern void EnterInterpreterFromInvoke(Thread* self, mirror::ArtMethod* method, mirror::Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/invoke_arg_array_builder.h b/runtime/invoke_arg_array_builder.h index 084d005..f615e8e 100644 --- a/runtime/invoke_arg_array_builder.h +++ b/runtime/invoke_arg_array_builder.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ #define ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object.h" #include "scoped_thread_state_change.h" diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h index 010a207..a1657d0 100644 --- a/runtime/jdwp/jdwp.h +++ b/runtime/jdwp/jdwp.h @@ -32,7 +32,7 @@ struct iovec; namespace art { namespace mirror { -class AbstractMethod; + class ArtMethod; } // namespace mirror class Thread; diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h index 345f0ad..7f162ca 100644 --- a/runtime/jdwp/object_registry.h +++ b/runtime/jdwp/object_registry.h @@ -22,9 +22,9 @@ #include <map> #include "jdwp/jdwp.h" +#include "mirror/art_field-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "safe_map.h" diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index d1de6e6..852dd00 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -32,10 +32,10 @@ #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" #include "jni.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -49,7 +49,8 @@ #include "UniquePtr.h" #include "well_known_classes.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Array; using ::art::mirror::BooleanArray; using ::art::mirror::ByteArray; @@ -57,7 +58,6 @@ using ::art::mirror::CharArray; using ::art::mirror::Class; using ::art::mirror::ClassLoader; using ::art::mirror::DoubleArray; -using ::art::mirror::Field; using ::art::mirror::FloatArray; using ::art::mirror::IntArray; using ::art::mirror::LongArray; @@ -101,7 +101,7 @@ static bool IsBadJniVersion(int version) { return version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4 && version != JNI_VERSION_1_6; } -static void CheckMethodArguments(AbstractMethod* m, uint32_t* args) +static void CheckMethodArguments(ArtMethod* m, uint32_t* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); const DexFile::TypeList* params = mh.GetParameterTypeList(); @@ -144,7 +144,7 @@ static void CheckMethodArguments(AbstractMethod* m, uint32_t* args) } } -void InvokeWithArgArray(const ScopedObjectAccess& soa, AbstractMethod* method, +void InvokeWithArgArray(const ScopedObjectAccess& soa, ArtMethod* method, ArgArray* arg_array, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t* args = arg_array->GetArray(); @@ -157,7 +157,7 @@ void InvokeWithArgArray(const ScopedObjectAccess& soa, AbstractMethod* method, static JValue InvokeWithVarArgs(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, va_list args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = soa.DecodeMethod(mid); + ArtMethod* method = soa.DecodeMethod(mid); Object* receiver = method->IsStatic() ? NULL : soa.Decode<Object*>(obj); MethodHelper mh(method); JValue result; @@ -167,7 +167,7 @@ static JValue InvokeWithVarArgs(const ScopedObjectAccess& soa, jobject obj, return result; } -static AbstractMethod* FindVirtualMethod(Object* receiver, AbstractMethod* method) +static ArtMethod* FindVirtualMethod(Object* receiver, ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(method); } @@ -176,7 +176,7 @@ static JValue InvokeVirtualOrInterfaceWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, jvalue* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Object* receiver = soa.Decode<Object*>(obj); - AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); + ArtMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); MethodHelper mh(method); JValue result; ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); @@ -189,7 +189,7 @@ static JValue InvokeVirtualOrInterfaceWithVarArgs(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, va_list args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Object* receiver = soa.Decode<Object*>(obj); - AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); + ArtMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); MethodHelper mh(method); JValue result; ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); @@ -239,7 +239,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class, return NULL; } - AbstractMethod* method = NULL; + ArtMethod* method = NULL; if (is_static) { method = c->FindDirectMethod(name, sig); } else { @@ -261,7 +261,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class, static ClassLoader* GetClassLoader(const ScopedObjectAccess& soa) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = soa.Self()->GetCurrentMethod(NULL); + ArtMethod* method = soa.Self()->GetCurrentMethod(NULL); if (method == NULL || method == soa.DecodeMethod(WellKnownClasses::java_lang_Runtime_nativeLoad)) { return soa.Self()->GetClassLoaderOverride(); @@ -277,7 +277,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con return NULL; } - Field* field = NULL; + ArtField* field = NULL; Class* field_type; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); if (sig[1] != '\0') { @@ -290,7 +290,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con // Failed to find type from the signature of the field. DCHECK(soa.Self()->IsExceptionPending()); ThrowLocation throw_location; - SirtRef<mirror::Throwable> cause(soa.Self(), soa.Self()->GetException(&throw_location)); + SirtRef<Throwable> cause(soa.Self(), soa.Self()->GetException(&throw_location)); soa.Self()->ClearException(); soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;", "no type \"%s\" found and so no field \"%s\" could be found in class " @@ -561,7 +561,7 @@ class Libraries { } // See section 11.3 "Linking Native Methods" of the JNI spec. - void* FindNativeMethod(const AbstractMethod* m, std::string& detail) + void* FindNativeMethod(const ArtMethod* m, std::string& detail) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string jni_short_name(JniShortName(m)); std::string jni_long_name(JniLongName(m)); @@ -598,7 +598,7 @@ class Libraries { JValue InvokeWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, jvalue* args) { - AbstractMethod* method = soa.DecodeMethod(mid); + ArtMethod* method = soa.DecodeMethod(mid); Object* receiver = method->IsStatic() ? NULL : soa.Decode<Object*>(obj); MethodHelper mh(method); JValue result; @@ -620,10 +620,10 @@ class JNI { } static jclass FindClass(JNIEnv* env, const char* name) { - ScopedObjectAccess soa(env); Runtime* runtime = Runtime::Current(); ClassLinker* class_linker = runtime->GetClassLinker(); std::string descriptor(NormalizeJniClassDescriptor(name)); + ScopedObjectAccess soa(env); Class* c = NULL; if (runtime->IsStarted()) { ClassLoader* cl = GetClassLoader(soa); @@ -636,26 +636,50 @@ class JNI { static jmethodID FromReflectedMethod(JNIEnv* env, jobject java_method) { ScopedObjectAccess soa(env); - AbstractMethod* method = soa.Decode<AbstractMethod*>(java_method); + jobject art_method = env->GetObjectField(java_method, + WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + ArtMethod* method = soa.Decode<ArtMethod*>(art_method); + DCHECK(method != NULL); return soa.EncodeMethod(method); } static jfieldID FromReflectedField(JNIEnv* env, jobject java_field) { ScopedObjectAccess soa(env); - Field* field = soa.Decode<Field*>(java_field); + jobject art_field = env->GetObjectField(java_field, + WellKnownClasses::java_lang_reflect_Field_artField); + ArtField* field = soa.Decode<ArtField*>(art_field); + DCHECK(field != NULL); return soa.EncodeField(field); } static jobject ToReflectedMethod(JNIEnv* env, jclass, jmethodID mid, jboolean) { ScopedObjectAccess soa(env); - AbstractMethod* method = soa.DecodeMethod(mid); - return soa.AddLocalReference<jobject>(method); + ArtMethod* m = soa.DecodeMethod(mid); + jobject art_method = soa.AddLocalReference<jobject>(m); + jobject reflect_method = env->AllocObject(WellKnownClasses::java_lang_reflect_Method); + if (env->ExceptionCheck()) { + return NULL; + } + SetObjectField(env, + reflect_method, + WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod, + art_method); + return reflect_method; } static jobject ToReflectedField(JNIEnv* env, jclass, jfieldID fid, jboolean) { ScopedObjectAccess soa(env); - Field* field = soa.DecodeField(fid); - return soa.AddLocalReference<jobject>(field); + ArtField* f = soa.DecodeField(fid); + jobject art_field = soa.AddLocalReference<jobject>(f); + jobject reflect_field = env->AllocObject(WellKnownClasses::java_lang_reflect_Field); + if (env->ExceptionCheck()) { + return NULL; + } + SetObjectField(env, + reflect_field, + WellKnownClasses::java_lang_reflect_Field_artField, + art_field); + return reflect_field; } static jclass GetObjectClass(JNIEnv* env, jobject java_object) { @@ -678,7 +702,6 @@ class JNI { } static jboolean IsInstanceOf(JNIEnv* env, jobject jobj, jclass java_class) { - ScopedObjectAccess soa(env); if (java_class == NULL) { JniAbortF("IsInstanceOf", "null class (second argument)"); } @@ -686,6 +709,7 @@ class JNI { // Note: JNI is different from regular Java instanceof in this respect return JNI_TRUE; } else { + ScopedObjectAccess soa(env); Object* obj = soa.Decode<Object*>(jobj); Class* c = soa.Decode<Class*>(java_class); return obj->InstanceOf(c) ? JNI_TRUE : JNI_FALSE; @@ -718,13 +742,13 @@ class JNI { static void ExceptionDescribe(JNIEnv* env) { ScopedObjectAccess soa(env); - SirtRef<mirror::Object> old_throw_this_object(soa.Self(), NULL); - SirtRef<mirror::AbstractMethod> old_throw_method(soa.Self(), NULL); - SirtRef<mirror::Throwable> old_exception(soa.Self(), NULL); + SirtRef<Object> old_throw_this_object(soa.Self(), NULL); + SirtRef<ArtMethod> old_throw_method(soa.Self(), NULL); + SirtRef<Throwable> old_exception(soa.Self(), NULL); uint32_t old_throw_dex_pc; { ThrowLocation old_throw_location; - mirror::Throwable* old_exception_obj = soa.Self()->GetException(&old_throw_location); + Throwable* old_exception_obj = soa.Self()->GetException(&old_throw_location); old_throw_this_object.reset(old_throw_location.GetThis()); old_throw_method.reset(old_throw_location.GetMethod()); old_exception.reset(old_exception_obj); @@ -855,8 +879,12 @@ class JNI { } static jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) { - ScopedObjectAccess soa(env); - return (soa.Decode<Object*>(obj1) == soa.Decode<Object*>(obj2)) ? JNI_TRUE : JNI_FALSE; + if (obj1 == obj2) { + return JNI_TRUE; + } else { + ScopedObjectAccess soa(env); + return (soa.Decode<Object*>(obj1) == soa.Decode<Object*>(obj2)) ? JNI_TRUE : JNI_FALSE; + } } static jobject AllocObject(JNIEnv* env, jclass java_class) { @@ -1316,8 +1344,8 @@ class JNI { va_end(ap); } - static void CallNonvirtualVoidMethodV(JNIEnv* env, - jobject obj, jclass, jmethodID mid, va_list args) { + static void CallNonvirtualVoidMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, + va_list args) { ScopedObjectAccess soa(env); InvokeWithVarArgs(soa, obj, mid, args); } @@ -1342,13 +1370,13 @@ class JNI { static jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fid) { ScopedObjectAccess soa(env); Object* o = soa.Decode<Object*>(obj); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); return soa.AddLocalReference<jobject>(f->GetObject(o)); } static jobject GetStaticObjectField(JNIEnv* env, jclass, jfieldID fid) { ScopedObjectAccess soa(env); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); return soa.AddLocalReference<jobject>(f->GetObject(f->GetDeclaringClass())); } @@ -1356,37 +1384,37 @@ class JNI { ScopedObjectAccess soa(env); Object* o = soa.Decode<Object*>(java_object); Object* v = soa.Decode<Object*>(java_value); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); f->SetObject(o, v); } static void SetStaticObjectField(JNIEnv* env, jclass, jfieldID fid, jobject java_value) { ScopedObjectAccess soa(env); Object* v = soa.Decode<Object*>(java_value); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); f->SetObject(f->GetDeclaringClass(), v); } #define GET_PRIMITIVE_FIELD(fn, instance) \ ScopedObjectAccess soa(env); \ Object* o = soa.Decode<Object*>(instance); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ return f->fn(o) #define GET_STATIC_PRIMITIVE_FIELD(fn) \ ScopedObjectAccess soa(env); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ return f->fn(f->GetDeclaringClass()) #define SET_PRIMITIVE_FIELD(fn, instance, value) \ ScopedObjectAccess soa(env); \ Object* o = soa.Decode<Object*>(instance); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ f->fn(o, value) #define SET_STATIC_PRIMITIVE_FIELD(fn, value) \ ScopedObjectAccess soa(env); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ f->fn(f->GetDeclaringClass(), value) static jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fid) { @@ -1806,7 +1834,7 @@ class JNI { static jsize GetArrayLength(JNIEnv* env, jarray java_array) { ScopedObjectAccess soa(env); Object* obj = soa.Decode<Object*>(java_array); - if (!obj->IsArrayInstance()) { + if (UNLIKELY(!obj->IsArrayInstance())) { JniAbortF("GetArrayLength", "not an array: %s", PrettyTypeOf(obj).c_str()); } Array* array = obj->AsArray(); @@ -1863,12 +1891,12 @@ class JNI { } static jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) { - ScopedObjectAccess soa(env); if (length < 0) { JniAbortF("NewObjectArray", "negative array length: %d", length); } // Compute the array class corresponding to the given element class. + ScopedObjectAccess soa(env); Class* element_class = soa.Decode<Class*>(element_jclass); std::string descriptor; descriptor += "["; @@ -2080,7 +2108,7 @@ class JNI { ++sig; } - AbstractMethod* m = c->FindDirectMethod(name, sig); + ArtMethod* m = c->FindDirectMethod(name, sig); if (m == NULL) { m = c->FindVirtualMethod(name, sig); } @@ -2111,13 +2139,13 @@ class JNI { VLOG(jni) << "[Unregistering JNI native methods for " << PrettyClass(c) << "]"; for (size_t i = 0; i < c->NumDirectMethods(); ++i) { - AbstractMethod* m = c->GetDirectMethod(i); + ArtMethod* m = c->GetDirectMethod(i); if (m->IsNative()) { m->UnregisterNative(soa.Self()); } } for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { - AbstractMethod* m = c->GetVirtualMethod(i); + ArtMethod* m = c->GetVirtualMethod(i); if (m->IsNative()) { m->UnregisterNative(soa.Self()); } @@ -2899,7 +2927,7 @@ bool JavaVMExt::LoadNativeLibrary(const std::string& path, ClassLoader* class_lo return was_successful; } -void* JavaVMExt::FindCodeForNativeMethod(AbstractMethod* m) { +void* JavaVMExt::FindCodeForNativeMethod(ArtMethod* m) { CHECK(m->IsNative()); Class* c = m->GetDeclaringClass(); diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h index fcac481..e3ffc84 100644 --- a/runtime/jni_internal.h +++ b/runtime/jni_internal.h @@ -38,10 +38,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class ClassLoader; -class Field; -} + class ArtField; + class ArtMethod; + class ClassLoader; +} // namespace mirror class ArgArray; union JValue; class Libraries; @@ -55,7 +55,7 @@ void RegisterNativeMethods(JNIEnv* env, const char* jni_class_name, const JNINat JValue InvokeWithJValues(const ScopedObjectAccess&, jobject obj, jmethodID mid, jvalue* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void InvokeWithArgArray(const ScopedObjectAccess& soa, mirror::AbstractMethod* method, +void InvokeWithArgArray(const ScopedObjectAccess& soa, mirror::ArtMethod* method, ArgArray *arg_array, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -79,7 +79,7 @@ struct JavaVMExt : public JavaVM { * Returns a pointer to the code for the native method 'm', found * using dlsym(3) on every native library that's been loaded so far. */ - void* FindCodeForNativeMethod(mirror::AbstractMethod* m) + void* FindCodeForNativeMethod(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DumpForSigQuit(std::ostream& os); diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc index c8b9eb9..234e40a 100644 --- a/runtime/jni_internal_test.cc +++ b/runtime/jni_internal_test.cc @@ -22,7 +22,7 @@ #include "common_test.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -43,7 +43,8 @@ class JniInternalTest : public CommonTest { vm_->AttachCurrentThread(&env_, NULL); - ScopedLocalRef<jclass> aioobe(env_, env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); + ScopedLocalRef<jclass> aioobe(env_, + env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); CHECK(aioobe.get() != NULL); aioobe_ = reinterpret_cast<jclass>(env_->NewGlobalRef(aioobe.get())); @@ -51,7 +52,8 @@ class JniInternalTest : public CommonTest { CHECK(ase.get() != NULL); ase_ = reinterpret_cast<jclass>(env_->NewGlobalRef(ase.get())); - ScopedLocalRef<jclass> sioobe(env_, env_->FindClass("java/lang/StringIndexOutOfBoundsException")); + ScopedLocalRef<jclass> sioobe(env_, + env_->FindClass("java/lang/StringIndexOutOfBoundsException")); CHECK(sioobe.get() != NULL); sioobe_ = reinterpret_cast<jclass>(env_->NewGlobalRef(sioobe.get())); } @@ -76,7 +78,7 @@ class JniInternalTest : public CommonTest { CommonTest::TearDown(); } - void DoCompile(mirror::AbstractMethod*& method, + void DoCompile(mirror::ArtMethod*& method, mirror::Object*& receiver, bool is_static, const char* method_name, const char* method_signature) @@ -95,7 +97,8 @@ class JniInternalTest : public CommonTest { CompileVirtualMethod(class_loader.get(), class_name, method_name, method_signature); } - mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), class_loader.get()); + mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), + class_loader.get()); CHECK(c != NULL); method = is_static ? c->FindDirectMethod(method_name, method_signature) @@ -111,7 +114,7 @@ class JniInternalTest : public CommonTest { } void InvokeNopMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "nop", "()V"); @@ -127,7 +130,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityByteMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(I)I"); @@ -163,7 +166,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(I)I"); @@ -199,7 +202,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(D)D"); @@ -243,7 +246,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(II)I"); @@ -289,7 +292,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(III)I"); @@ -340,7 +343,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(IIII)I"); @@ -396,7 +399,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(IIIII)I"); @@ -457,7 +460,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DD)D"); @@ -523,7 +526,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDD)D"); @@ -578,7 +581,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDDD)D"); @@ -642,7 +645,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDDDD)D"); @@ -891,6 +894,11 @@ TEST_F(JniInternalTest, GetMethodID) { method = env_->GetMethodID(jlstring, "valueOf", "(I)Ljava/lang/String;"); EXPECT_EQ(static_cast<jmethodID>(NULL), method); EXPECT_EXCEPTION(jlnsme); + + // Check that GetMethodID for java.lang.NoSuchMethodError.<init>(String) finds the constructor + method = env_->GetMethodID(jlnsme, "<init>", "(Ljava/lang/String;)V"); + EXPECT_NE(static_cast<jmethodID>(NULL), method); + EXPECT_FALSE(env_->ExceptionCheck()); } TEST_F(JniInternalTest, GetStaticMethodID) { @@ -933,6 +941,9 @@ TEST_F(JniInternalTest, FromReflectedField_ToReflectedField) { // ...and back again. jfieldID fid2 = env_->FromReflectedField(field); ASSERT_TRUE(fid2 != NULL); + // Make sure we can actually use it. + jstring s = env_->NewStringUTF("poop"); + ASSERT_EQ(4, env_->GetIntField(s, fid2)); } TEST_F(JniInternalTest, FromReflectedMethod_ToReflectedMethod) { @@ -948,6 +959,13 @@ TEST_F(JniInternalTest, FromReflectedMethod_ToReflectedMethod) { // ...and back again. jmethodID mid2 = env_->FromReflectedMethod(method); ASSERT_TRUE(mid2 != NULL); + // Make sure we can actually use it. + jstring s = env_->NewStringUTF("poop"); + // TODO: this should return 4, but the runtime skips the method + // invoke because the runtime isn't started. In the future it would + // be nice to use interpretter for things like this. This still does + // validate that we have a sane jmethodID value. + ASSERT_EQ(0, env_->CallIntMethod(s, mid2)); } void BogusMethod() { @@ -986,7 +1004,13 @@ TEST_F(JniInternalTest, RegisterNatives) { env_->UnregisterNatives(jlobject); } -#define EXPECT_PRIMITIVE_ARRAY(new_fn, get_region_fn, set_region_fn, get_elements_fn, release_elements_fn, scalar_type, expected_class_descriptor) \ +#define EXPECT_PRIMITIVE_ARRAY(new_fn, \ + get_region_fn, \ + set_region_fn, \ + get_elements_fn, \ + release_elements_fn, \ + scalar_type, \ + expected_class_descriptor) \ jsize size = 4; \ /* Allocate an array and check it has the right type and length. */ \ scalar_type ## Array a = env_->new_fn(size); \ @@ -1017,47 +1041,60 @@ TEST_F(JniInternalTest, RegisterNatives) { env_->set_region_fn(a, 0, size, &src_buf[0]); \ /* Copy back only part. */ \ env_->get_region_fn(a, 1, size - 2, &dst_buf[1]); \ - EXPECT_NE(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "short copy equal"; \ + EXPECT_NE(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "short copy equal"; \ /* Copy the missing pieces. */ \ env_->get_region_fn(a, 0, 1, &dst_buf[0]); \ env_->get_region_fn(a, size - 1, 1, &dst_buf[size - 1]); \ - EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "fixed copy not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "fixed copy not equal"; \ /* Copy back the whole array. */ \ env_->get_region_fn(a, 0, size, &dst_buf[0]); \ - EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "full copy not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "full copy not equal"; \ /* GetPrimitiveArrayCritical */ \ void* v = env_->GetPrimitiveArrayCritical(a, NULL); \ - EXPECT_EQ(memcmp(&src_buf[0], v, size * sizeof(scalar_type)), 0) << "GetPrimitiveArrayCritical not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], v, size * sizeof(scalar_type)), 0) \ + << "GetPrimitiveArrayCritical not equal"; \ env_->ReleasePrimitiveArrayCritical(a, v, 0); \ /* GetXArrayElements */ \ scalar_type* xs = env_->get_elements_fn(a, NULL); \ - EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) << # get_elements_fn " not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) \ + << # get_elements_fn " not equal"; \ env_->release_elements_fn(a, xs, 0); \ EXPECT_EQ(reinterpret_cast<uintptr_t>(v), reinterpret_cast<uintptr_t>(xs)) TEST_F(JniInternalTest, BooleanArrays) { - EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, GetBooleanArrayElements, ReleaseBooleanArrayElements, jboolean, "[Z"); + EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, + GetBooleanArrayElements, ReleaseBooleanArrayElements, jboolean, "[Z"); } TEST_F(JniInternalTest, ByteArrays) { - EXPECT_PRIMITIVE_ARRAY(NewByteArray, GetByteArrayRegion, SetByteArrayRegion, GetByteArrayElements, ReleaseByteArrayElements, jbyte, "[B"); + EXPECT_PRIMITIVE_ARRAY(NewByteArray, GetByteArrayRegion, SetByteArrayRegion, + GetByteArrayElements, ReleaseByteArrayElements, jbyte, "[B"); } TEST_F(JniInternalTest, CharArrays) { - EXPECT_PRIMITIVE_ARRAY(NewCharArray, GetCharArrayRegion, SetCharArrayRegion, GetCharArrayElements, ReleaseCharArrayElements, jchar, "[C"); + EXPECT_PRIMITIVE_ARRAY(NewCharArray, GetCharArrayRegion, SetCharArrayRegion, + GetCharArrayElements, ReleaseCharArrayElements, jchar, "[C"); } TEST_F(JniInternalTest, DoubleArrays) { - EXPECT_PRIMITIVE_ARRAY(NewDoubleArray, GetDoubleArrayRegion, SetDoubleArrayRegion, GetDoubleArrayElements, ReleaseDoubleArrayElements, jdouble, "[D"); + EXPECT_PRIMITIVE_ARRAY(NewDoubleArray, GetDoubleArrayRegion, SetDoubleArrayRegion, + GetDoubleArrayElements, ReleaseDoubleArrayElements, jdouble, "[D"); } TEST_F(JniInternalTest, FloatArrays) { - EXPECT_PRIMITIVE_ARRAY(NewFloatArray, GetFloatArrayRegion, SetFloatArrayRegion, GetFloatArrayElements, ReleaseFloatArrayElements, jfloat, "[F"); + EXPECT_PRIMITIVE_ARRAY(NewFloatArray, GetFloatArrayRegion, SetFloatArrayRegion, + GetFloatArrayElements, ReleaseFloatArrayElements, jfloat, "[F"); } TEST_F(JniInternalTest, IntArrays) { - EXPECT_PRIMITIVE_ARRAY(NewIntArray, GetIntArrayRegion, SetIntArrayRegion, GetIntArrayElements, ReleaseIntArrayElements, jint, "[I"); + EXPECT_PRIMITIVE_ARRAY(NewIntArray, GetIntArrayRegion, SetIntArrayRegion, + GetIntArrayElements, ReleaseIntArrayElements, jint, "[I"); } TEST_F(JniInternalTest, LongArrays) { - EXPECT_PRIMITIVE_ARRAY(NewLongArray, GetLongArrayRegion, SetLongArrayRegion, GetLongArrayElements, ReleaseLongArrayElements, jlong, "[J"); + EXPECT_PRIMITIVE_ARRAY(NewLongArray, GetLongArrayRegion, SetLongArrayRegion, + GetLongArrayElements, ReleaseLongArrayElements, jlong, "[J"); } TEST_F(JniInternalTest, ShortArrays) { - EXPECT_PRIMITIVE_ARRAY(NewShortArray, GetShortArrayRegion, SetShortArrayRegion, GetShortArrayElements, ReleaseShortArrayElements, jshort, "[S"); + EXPECT_PRIMITIVE_ARRAY(NewShortArray, GetShortArrayRegion, SetShortArrayRegion, + GetShortArrayElements, ReleaseShortArrayElements, jshort, "[S"); } TEST_F(JniInternalTest, NewObjectArray) { @@ -1437,7 +1474,8 @@ TEST_F(JniInternalTest, DeleteLocalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteLocalRef(s); - std::string expected(StringPrintf("native code passing in reference to invalid local reference: %p", s)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid local reference: %p", s)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1520,7 +1558,8 @@ TEST_F(JniInternalTest, DeleteGlobalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteGlobalRef(o); - std::string expected(StringPrintf("native code passing in reference to invalid global reference: %p", o)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid global reference: %p", o)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1564,7 +1603,8 @@ TEST_F(JniInternalTest, DeleteWeakGlobalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteWeakGlobalRef(o); - std::string expected(StringPrintf("native code passing in reference to invalid weak global reference: %p", o)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid weak global reference: %p", o)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1588,7 +1628,7 @@ TEST_F(JniInternalTest, StaticMainMethod) { mirror::Class* klass = class_linker_->FindClass("LMain;", class_loader.get()); ASSERT_TRUE(klass != NULL); - mirror::AbstractMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); + mirror::ArtMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); ASSERT_TRUE(method != NULL); ArgArray arg_array(NULL, 0); diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/art_field-inl.h index 3e3d6db..d8c278c 100644 --- a/runtime/mirror/field-inl.h +++ b/runtime/mirror/art_field-inl.h @@ -14,10 +14,10 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_MIRROR_FIELD_INL_H_ -#define ART_RUNTIME_MIRROR_FIELD_INL_H_ +#ifndef ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ +#define ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ -#include "field.h" +#include "art_field.h" #include "base/logging.h" #include "gc/accounting/card_table-inl.h" @@ -29,117 +29,117 @@ namespace art { namespace mirror { -inline Class* Field::GetDeclaringClass() const { - Class* result = GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), false); +inline Class* ArtField::GetDeclaringClass() const { + Class* result = GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(ArtField, declaring_class_), false); DCHECK(result != NULL); DCHECK(result->IsLoaded() || result->IsErroneous()); return result; } -inline void Field::SetDeclaringClass(Class *new_declaring_class) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), new_declaring_class, false); +inline void ArtField::SetDeclaringClass(Class *new_declaring_class) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtField, declaring_class_), new_declaring_class, false); } -inline uint32_t Field::GetAccessFlags() const { +inline uint32_t ArtField::GetAccessFlags() const { DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, access_flags_), false); } -inline MemberOffset Field::GetOffset() const { +inline MemberOffset ArtField::GetOffset() const { DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); - return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), false)); + return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), false)); } -inline MemberOffset Field::GetOffsetDuringLinking() const { +inline MemberOffset ArtField::GetOffsetDuringLinking() const { DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), false)); + return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), false)); } -inline uint32_t Field::Get32(const Object* object) const { +inline uint32_t ArtField::Get32(const Object* object) const { DCHECK(object != NULL) << PrettyField(this); DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); return object->GetField32(GetOffset(), IsVolatile()); } -inline void Field::Set32(Object* object, uint32_t new_value) const { +inline void ArtField::Set32(Object* object, uint32_t new_value) const { DCHECK(object != NULL) << PrettyField(this); DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); object->SetField32(GetOffset(), new_value, IsVolatile()); } -inline uint64_t Field::Get64(const Object* object) const { +inline uint64_t ArtField::Get64(const Object* object) const { DCHECK(object != NULL) << PrettyField(this); DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); return object->GetField64(GetOffset(), IsVolatile()); } -inline void Field::Set64(Object* object, uint64_t new_value) const { +inline void ArtField::Set64(Object* object, uint64_t new_value) const { DCHECK(object != NULL) << PrettyField(this); DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); object->SetField64(GetOffset(), new_value, IsVolatile()); } -inline Object* Field::GetObj(const Object* object) const { +inline Object* ArtField::GetObj(const Object* object) const { DCHECK(object != NULL) << PrettyField(this); DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); return object->GetFieldObject<Object*>(GetOffset(), IsVolatile()); } -inline void Field::SetObj(Object* object, const Object* new_value) const { +inline void ArtField::SetObj(Object* object, const Object* new_value) const { DCHECK(object != NULL) << PrettyField(this); DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); object->SetFieldObject(GetOffset(), new_value, IsVolatile()); } -inline bool Field::GetBoolean(const Object* object) const { +inline bool ArtField::GetBoolean(const Object* object) const { DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); return Get32(object); } -inline void Field::SetBoolean(Object* object, bool z) const { +inline void ArtField::SetBoolean(Object* object, bool z) const { DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); Set32(object, z); } -inline int8_t Field::GetByte(const Object* object) const { +inline int8_t ArtField::GetByte(const Object* object) const { DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); return Get32(object); } -inline void Field::SetByte(Object* object, int8_t b) const { +inline void ArtField::SetByte(Object* object, int8_t b) const { DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); Set32(object, b); } -inline uint16_t Field::GetChar(const Object* object) const { +inline uint16_t ArtField::GetChar(const Object* object) const { DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); return Get32(object); } -inline void Field::SetChar(Object* object, uint16_t c) const { +inline void ArtField::SetChar(Object* object, uint16_t c) const { DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); Set32(object, c); } -inline int16_t Field::GetShort(const Object* object) const { +inline int16_t ArtField::GetShort(const Object* object) const { DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); return Get32(object); } -inline void Field::SetShort(Object* object, int16_t s) const { +inline void ArtField::SetShort(Object* object, int16_t s) const { DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); Set32(object, s); } -inline int32_t Field::GetInt(const Object* object) const { +inline int32_t ArtField::GetInt(const Object* object) const { #ifndef NDEBUG Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); @@ -147,7 +147,7 @@ inline int32_t Field::GetInt(const Object* object) const { return Get32(object); } -inline void Field::SetInt(Object* object, int32_t i) const { +inline void ArtField::SetInt(Object* object, int32_t i) const { #ifndef NDEBUG Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); @@ -155,7 +155,7 @@ inline void Field::SetInt(Object* object, int32_t i) const { Set32(object, i); } -inline int64_t Field::GetLong(const Object* object) const { +inline int64_t ArtField::GetLong(const Object* object) const { #ifndef NDEBUG Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); @@ -163,7 +163,7 @@ inline int64_t Field::GetLong(const Object* object) const { return Get64(object); } -inline void Field::SetLong(Object* object, int64_t j) const { +inline void ArtField::SetLong(Object* object, int64_t j) const { #ifndef NDEBUG Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); @@ -171,7 +171,7 @@ inline void Field::SetLong(Object* object, int64_t j) const { Set64(object, j); } -inline float Field::GetFloat(const Object* object) const { +inline float ArtField::GetFloat(const Object* object) const { DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); JValue bits; @@ -179,7 +179,7 @@ inline float Field::GetFloat(const Object* object) const { return bits.GetF(); } -inline void Field::SetFloat(Object* object, float f) const { +inline void ArtField::SetFloat(Object* object, float f) const { DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); JValue bits; @@ -187,7 +187,7 @@ inline void Field::SetFloat(Object* object, float f) const { Set32(object, bits.GetI()); } -inline double Field::GetDouble(const Object* object) const { +inline double ArtField::GetDouble(const Object* object) const { DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); JValue bits; @@ -195,7 +195,7 @@ inline double Field::GetDouble(const Object* object) const { return bits.GetD(); } -inline void Field::SetDouble(Object* object, double d) const { +inline void ArtField::SetDouble(Object* object, double d) const { DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); JValue bits; @@ -203,13 +203,13 @@ inline void Field::SetDouble(Object* object, double d) const { Set64(object, bits.GetJ()); } -inline Object* Field::GetObject(const Object* object) const { +inline Object* ArtField::GetObject(const Object* object) const { DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); return GetObj(object); } -inline void Field::SetObject(Object* object, const Object* l) const { +inline void ArtField::SetObject(Object* object, const Object* l) const { DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) << PrettyField(this); SetObj(object, l); @@ -218,4 +218,4 @@ inline void Field::SetObject(Object* object, const Object* l) const { } // namespace mirror } // namespace art -#endif // ART_RUNTIME_MIRROR_FIELD_INL_H_ +#endif // ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ diff --git a/runtime/mirror/field.cc b/runtime/mirror/art_field.cc index 12f395f..a8bbe4b 100644 --- a/runtime/mirror/field.cc +++ b/runtime/mirror/art_field.cc @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "field.h" +#include "art_field.h" -#include "field-inl.h" +#include "art_field-inl.h" #include "gc/accounting/card_table-inl.h" #include "object-inl.h" #include "object_utils.h" @@ -27,20 +27,20 @@ namespace art { namespace mirror { // TODO: get global references for these -Class* Field::java_lang_reflect_Field_ = NULL; +Class* ArtField::java_lang_reflect_ArtField_ = NULL; -void Field::SetClass(Class* java_lang_reflect_Field) { - CHECK(java_lang_reflect_Field_ == NULL); - CHECK(java_lang_reflect_Field != NULL); - java_lang_reflect_Field_ = java_lang_reflect_Field; +void ArtField::SetClass(Class* java_lang_reflect_ArtField) { + CHECK(java_lang_reflect_ArtField_ == NULL); + CHECK(java_lang_reflect_ArtField != NULL); + java_lang_reflect_ArtField_ = java_lang_reflect_ArtField; } -void Field::ResetClass() { - CHECK(java_lang_reflect_Field_ != NULL); - java_lang_reflect_Field_ = NULL; +void ArtField::ResetClass() { + CHECK(java_lang_reflect_ArtField_ != NULL); + java_lang_reflect_ArtField_ = NULL; } -void Field::SetOffset(MemberOffset num_bytes) { +void ArtField::SetOffset(MemberOffset num_bytes) { DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); #if 0 // TODO enable later in boot and under !NDEBUG FieldHelper fh(this); @@ -49,7 +49,7 @@ void Field::SetOffset(MemberOffset num_bytes) { DCHECK_ALIGNED(num_bytes.Uint32Value(), 8); } #endif - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), num_bytes.Uint32Value(), false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), num_bytes.Uint32Value(), false); } } // namespace mirror diff --git a/runtime/mirror/field.h b/runtime/mirror/art_field.h index 6e508a3..ae34cb1 100644 --- a/runtime/mirror/field.h +++ b/runtime/mirror/art_field.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_MIRROR_FIELD_H_ -#define ART_RUNTIME_MIRROR_FIELD_H_ +#ifndef ART_RUNTIME_MIRROR_ART_FIELD_H_ +#define ART_RUNTIME_MIRROR_ART_FIELD_H_ #include "class.h" #include "modifiers.h" @@ -23,13 +23,12 @@ namespace art { -struct FieldClassOffsets; -struct FieldOffsets; +struct ArtFieldOffsets; namespace mirror { -// C++ mirror of java.lang.reflect.Field -class MANAGED Field : public Object { +// C++ mirror of java.lang.reflect.ArtField +class MANAGED ArtField : public Object { public: Class* GetDeclaringClass() const; @@ -38,7 +37,7 @@ class MANAGED Field : public Object { uint32_t GetAccessFlags() const; void SetAccessFlags(uint32_t new_access_flags) { - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_), new_access_flags, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, access_flags_), new_access_flags, false); } bool IsPublic() const { @@ -54,18 +53,18 @@ class MANAGED Field : public Object { } uint32_t GetDexFieldIndex() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, field_dex_idx_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, field_dex_idx_), false); } void SetDexFieldIndex(uint32_t new_idx) { - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, field_dex_idx_), new_idx, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, field_dex_idx_), new_idx, false); } // Offset to field within an Object MemberOffset GetOffset() const; static MemberOffset OffsetOffset() { - return MemberOffset(OFFSETOF_MEMBER(Field, offset_)); + return MemberOffset(OFFSETOF_MEMBER(ArtField, offset_)); } MemberOffset GetOffsetDuringLinking() const; @@ -124,12 +123,12 @@ class MANAGED Field : public Object { void SetObj(Object* object, const Object* new_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static Class* GetJavaLangReflectField() { - DCHECK(java_lang_reflect_Field_ != NULL); - return java_lang_reflect_Field_; + static Class* GetJavaLangReflectArtField() { + DCHECK(java_lang_reflect_ArtField_ != NULL); + return java_lang_reflect_ArtField_; } - static void SetClass(Class* java_lang_reflect_Field); + static void SetClass(Class* java_lang_reflect_ArtField); static void ResetClass(); bool IsVolatile() const { @@ -149,20 +148,18 @@ class MANAGED Field : public Object { // Offset of field within an instance or in the Class' static fields uint32_t offset_; - static Class* java_lang_reflect_Field_; + static Class* java_lang_reflect_ArtField_; - friend struct art::FieldOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(Field); + friend struct art::ArtFieldOffsets; // for verifying offset information + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtField); }; -class MANAGED FieldClass : public Class { +class MANAGED ArtFieldClass : public Class { private: - Object* ORDER_BY_NAME_AND_DECLARING_CLASS_; - friend struct art::FieldClassOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(FieldClass); + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtFieldClass); }; } // namespace mirror } // namespace art -#endif // ART_RUNTIME_MIRROR_FIELD_H_ +#endif // ART_RUNTIME_MIRROR_ART_FIELD_H_ diff --git a/runtime/mirror/abstract_method-inl.h b/runtime/mirror/art_method-inl.h index d47b3eb..4d8aa6f 100644 --- a/runtime/mirror/abstract_method-inl.h +++ b/runtime/mirror/art_method-inl.h @@ -14,10 +14,10 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ +#ifndef ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ +#define ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ -#include "abstract_method.h" +#include "art_method.h" #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" @@ -27,54 +27,54 @@ namespace art { namespace mirror { -inline Class* AbstractMethod::GetDeclaringClass() const { - Class* result = GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, declaring_class_), false); +inline Class* ArtMethod::GetDeclaringClass() const { + Class* result = GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, declaring_class_), false); DCHECK(result != NULL) << this; DCHECK(result->IsIdxLoaded() || result->IsErroneous()) << this; return result; } -inline void AbstractMethod::SetDeclaringClass(Class *new_declaring_class) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, declaring_class_), new_declaring_class, false); +inline void ArtMethod::SetDeclaringClass(Class *new_declaring_class) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, declaring_class_), new_declaring_class, false); } -inline uint32_t AbstractMethod::GetAccessFlags() const { +inline uint32_t ArtMethod::GetAccessFlags() const { DCHECK(GetDeclaringClass()->IsIdxLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, access_flags_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), false); } -inline uint16_t AbstractMethod::GetMethodIndex() const { +inline uint16_t ArtMethod::GetMethodIndex() const { DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), false); } -inline uint32_t AbstractMethod::GetDexMethodIndex() const { +inline uint32_t ArtMethod::GetDexMethodIndex() const { DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), false); } -inline ObjectArray<String>* AbstractMethod::GetDexCacheStrings() const { +inline ObjectArray<String>* ArtMethod::GetDexCacheStrings() const { return GetFieldObject<ObjectArray<String>*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), false); + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), false); } -inline ObjectArray<AbstractMethod>* AbstractMethod::GetDexCacheResolvedMethods() const { - return GetFieldObject<ObjectArray<AbstractMethod>*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), false); +inline ObjectArray<ArtMethod>* ArtMethod::GetDexCacheResolvedMethods() const { + return GetFieldObject<ObjectArray<ArtMethod>*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), false); } -inline ObjectArray<Class>* AbstractMethod::GetDexCacheResolvedTypes() const { +inline ObjectArray<Class>* ArtMethod::GetDexCacheResolvedTypes() const { return GetFieldObject<ObjectArray<Class>*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), false); + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_), false); } -inline ObjectArray<StaticStorageBase>* AbstractMethod::GetDexCacheInitializedStaticStorage() const { +inline ObjectArray<StaticStorageBase>* ArtMethod::GetDexCacheInitializedStaticStorage() const { return GetFieldObject<ObjectArray<StaticStorageBase>*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_), false); } -inline uint32_t AbstractMethod::GetCodeSize() const { +inline uint32_t ArtMethod::GetCodeSize() const { DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this); uintptr_t code = reinterpret_cast<uintptr_t>(GetEntryPointFromCompiledCode()); if (code == 0) { @@ -85,7 +85,7 @@ inline uint32_t AbstractMethod::GetCodeSize() const { return reinterpret_cast<uint32_t*>(code)[-1]; } -inline bool AbstractMethod::CheckIncompatibleClassChange(InvokeType type) { +inline bool ArtMethod::CheckIncompatibleClassChange(InvokeType type) { switch (type) { case kStatic: return !IsStatic(); @@ -107,7 +107,7 @@ inline bool AbstractMethod::CheckIncompatibleClassChange(InvokeType type) { } } -inline void AbstractMethod::AssertPcIsWithinCode(uintptr_t pc) const { +inline void ArtMethod::AssertPcIsWithinCode(uintptr_t pc) const { if (!kIsDebugBuild) { return; } @@ -132,51 +132,51 @@ inline void AbstractMethod::AssertPcIsWithinCode(uintptr_t pc) const { << " size=" << GetCodeSize(); } -inline uint32_t AbstractMethod::GetOatCodeOffset() const { +inline uint32_t ArtMethod::GetOatCodeOffset() const { DCHECK(!Runtime::Current()->IsStarted()); return reinterpret_cast<uint32_t>(GetEntryPointFromCompiledCode()); } -inline void AbstractMethod::SetOatCodeOffset(uint32_t code_offset) { +inline void ArtMethod::SetOatCodeOffset(uint32_t code_offset) { DCHECK(!Runtime::Current()->IsStarted()); SetEntryPointFromCompiledCode(reinterpret_cast<void*>(code_offset)); } -inline uint32_t AbstractMethod::GetOatMappingTableOffset() const { +inline uint32_t ArtMethod::GetOatMappingTableOffset() const { DCHECK(!Runtime::Current()->IsStarted()); return reinterpret_cast<uint32_t>(GetMappingTable()); } -inline void AbstractMethod::SetOatMappingTableOffset(uint32_t mapping_table_offset) { +inline void ArtMethod::SetOatMappingTableOffset(uint32_t mapping_table_offset) { DCHECK(!Runtime::Current()->IsStarted()); SetMappingTable(reinterpret_cast<const uint8_t*>(mapping_table_offset)); } -inline uint32_t AbstractMethod::GetOatVmapTableOffset() const { +inline uint32_t ArtMethod::GetOatVmapTableOffset() const { DCHECK(!Runtime::Current()->IsStarted()); return reinterpret_cast<uint32_t>(GetVmapTable()); } -inline void AbstractMethod::SetOatVmapTableOffset(uint32_t vmap_table_offset) { +inline void ArtMethod::SetOatVmapTableOffset(uint32_t vmap_table_offset) { DCHECK(!Runtime::Current()->IsStarted()); SetVmapTable(reinterpret_cast<uint8_t*>(vmap_table_offset)); } -inline void AbstractMethod::SetOatNativeGcMapOffset(uint32_t gc_map_offset) { +inline void ArtMethod::SetOatNativeGcMapOffset(uint32_t gc_map_offset) { DCHECK(!Runtime::Current()->IsStarted()); SetNativeGcMap(reinterpret_cast<uint8_t*>(gc_map_offset)); } -inline uint32_t AbstractMethod::GetOatNativeGcMapOffset() const { +inline uint32_t ArtMethod::GetOatNativeGcMapOffset() const { DCHECK(!Runtime::Current()->IsStarted()); return reinterpret_cast<uint32_t>(GetNativeGcMap()); } -inline bool AbstractMethod::IsRuntimeMethod() const { +inline bool ArtMethod::IsRuntimeMethod() const { return GetDexMethodIndex() == DexFile::kDexNoIndex16; } -inline bool AbstractMethod::IsCalleeSaveMethod() const { +inline bool ArtMethod::IsCalleeSaveMethod() const { if (!IsRuntimeMethod()) { return false; } @@ -191,7 +191,7 @@ inline bool AbstractMethod::IsCalleeSaveMethod() const { return result; } -inline bool AbstractMethod::IsResolutionMethod() const { +inline bool ArtMethod::IsResolutionMethod() const { bool result = this == Runtime::Current()->GetResolutionMethod(); // Check that if we do think it is phony it looks like the resolution method. DCHECK(!result || IsRuntimeMethod()); @@ -200,4 +200,4 @@ inline bool AbstractMethod::IsResolutionMethod() const { } // namespace mirror } // namespace art -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ +#endif // ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ diff --git a/runtime/mirror/abstract_method.cc b/runtime/mirror/art_method.cc index b3db5c2..cd05f41 100644 --- a/runtime/mirror/abstract_method.cc +++ b/runtime/mirror/art_method.cc @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "abstract_method.h" +#include "art_method.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "base/stringpiece.h" #include "class-inl.h" #include "dex_file-inl.h" @@ -34,14 +34,13 @@ namespace art { namespace mirror { -extern "C" void art_portable_invoke_stub(AbstractMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); -extern "C" void art_quick_invoke_stub(AbstractMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); +extern "C" void art_portable_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); +extern "C" void art_quick_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); // TODO: get global references for these -Class* AbstractMethod::java_lang_reflect_Constructor_ = NULL; -Class* AbstractMethod::java_lang_reflect_Method_ = NULL; +Class* ArtMethod::java_lang_reflect_ArtMethod_ = NULL; -InvokeType AbstractMethod::GetInvokeType() const { +InvokeType ArtMethod::GetInvokeType() const { // TODO: kSuper? if (GetDeclaringClass()->IsInterface()) { return kInterface; @@ -54,45 +53,38 @@ InvokeType AbstractMethod::GetInvokeType() const { } } -void AbstractMethod::SetClasses(Class* java_lang_reflect_Constructor, Class* java_lang_reflect_Method) { - CHECK(java_lang_reflect_Constructor_ == NULL); - CHECK(java_lang_reflect_Constructor != NULL); - java_lang_reflect_Constructor_ = java_lang_reflect_Constructor; - - CHECK(java_lang_reflect_Method_ == NULL); - CHECK(java_lang_reflect_Method != NULL); - java_lang_reflect_Method_ = java_lang_reflect_Method; +void ArtMethod::SetClass(Class* java_lang_reflect_ArtMethod) { + CHECK(java_lang_reflect_ArtMethod_ == NULL); + CHECK(java_lang_reflect_ArtMethod != NULL); + java_lang_reflect_ArtMethod_ = java_lang_reflect_ArtMethod; } -void AbstractMethod::ResetClasses() { - CHECK(java_lang_reflect_Constructor_ != NULL); - java_lang_reflect_Constructor_ = NULL; - - CHECK(java_lang_reflect_Method_ != NULL); - java_lang_reflect_Method_ = NULL; +void ArtMethod::ResetClass() { + CHECK(java_lang_reflect_ArtMethod_ != NULL); + java_lang_reflect_ArtMethod_ = NULL; } -void AbstractMethod::SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), +void ArtMethod::SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), new_dex_cache_strings, false); } -void AbstractMethod::SetDexCacheResolvedMethods(ObjectArray<AbstractMethod>* new_dex_cache_methods) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), +void ArtMethod::SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), new_dex_cache_methods, false); } -void AbstractMethod::SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_classes) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), +void ArtMethod::SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_classes) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_), new_dex_cache_classes, false); } -void AbstractMethod::SetDexCacheInitializedStaticStorage(ObjectArray<StaticStorageBase>* new_value) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), +void ArtMethod::SetDexCacheInitializedStaticStorage(ObjectArray<StaticStorageBase>* new_value) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_), new_value, false); } -size_t AbstractMethod::NumArgRegisters(const StringPiece& shorty) { +size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) { CHECK_LE(1, shorty.length()); uint32_t num_registers = 0; for (int i = 1; i < shorty.length(); ++i) { @@ -106,19 +98,19 @@ size_t AbstractMethod::NumArgRegisters(const StringPiece& shorty) { return num_registers; } -bool AbstractMethod::IsProxyMethod() const { +bool ArtMethod::IsProxyMethod() const { return GetDeclaringClass()->IsProxyClass(); } -AbstractMethod* AbstractMethod::FindOverriddenMethod() const { +ArtMethod* ArtMethod::FindOverriddenMethod() const { if (IsStatic()) { return NULL; } Class* declaring_class = GetDeclaringClass(); Class* super_class = declaring_class->GetSuperClass(); uint16_t method_index = GetMethodIndex(); - ObjectArray<AbstractMethod>* super_class_vtable = super_class->GetVTable(); - AbstractMethod* result = NULL; + ObjectArray<ArtMethod>* super_class_vtable = super_class->GetVTable(); + ArtMethod* result = NULL; // Did this method override a super class method? If so load the result from the super class' // vtable if (super_class_vtable != NULL && method_index < super_class_vtable->GetLength()) { @@ -136,7 +128,7 @@ AbstractMethod* AbstractMethod::FindOverriddenMethod() const { for (size_t i = 0; i < iftable->Count() && result == NULL; i++) { Class* interface = iftable->GetInterface(i); for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - AbstractMethod* interface_method = interface->GetVirtualMethod(j); + ArtMethod* interface_method = interface->GetVirtualMethod(j); interface_mh.ChangeMethod(interface_method); if (mh.HasSameNameAndSignature(&interface_mh)) { result = interface_method; @@ -153,12 +145,12 @@ AbstractMethod* AbstractMethod::FindOverriddenMethod() const { return result; } -uintptr_t AbstractMethod::NativePcOffset(const uintptr_t pc) const { +uintptr_t ArtMethod::NativePcOffset(const uintptr_t pc) const { const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); return pc - reinterpret_cast<uintptr_t>(code); } -uint32_t AbstractMethod::ToDexPc(const uintptr_t pc) const { +uint32_t ArtMethod::ToDexPc(const uintptr_t pc) const { #if !defined(ART_USE_PORTABLE_COMPILER) MappingTable table(GetMappingTable()); if (table.TotalSize() == 0) { @@ -191,7 +183,7 @@ uint32_t AbstractMethod::ToDexPc(const uintptr_t pc) const { #endif } -uintptr_t AbstractMethod::ToNativePc(const uint32_t dex_pc) const { +uintptr_t ArtMethod::ToNativePc(const uint32_t dex_pc) const { MappingTable table(GetMappingTable()); if (table.TotalSize() == 0) { DCHECK_EQ(dex_pc, 0U); @@ -218,8 +210,8 @@ uintptr_t AbstractMethod::ToNativePc(const uint32_t dex_pc) const { return 0; } -uint32_t AbstractMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, - bool* has_no_move_exception) const { +uint32_t ArtMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, + bool* has_no_move_exception) const { MethodHelper mh(this); const DexFile::CodeItem* code_item = mh.GetCodeItem(); // Default to handler not found. @@ -251,8 +243,8 @@ uint32_t AbstractMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, return found_dex_pc; } -void AbstractMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, - char result_type) { +void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, + char result_type) { if (kIsDebugBuild) { self->AssertThreadSuspensionIsAllowable(); CHECK_EQ(kRunnable, self->GetState()); @@ -306,15 +298,15 @@ void AbstractMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JV self->PopManagedStackFragment(fragment); } -bool AbstractMethod::IsRegistered() const { - void* native_method = GetFieldPtr<void*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_), false); +bool ArtMethod::IsRegistered() const { + void* native_method = GetFieldPtr<void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_), false); CHECK(native_method != NULL); void* jni_stub = GetJniDlsymLookupStub(); return native_method != jni_stub; } extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject); -void AbstractMethod::RegisterNative(Thread* self, const void* native_method) { +void ArtMethod::RegisterNative(Thread* self, const void* native_method) { DCHECK(Thread::Current() == self); CHECK(IsNative()) << PrettyMethod(this); CHECK(native_method != NULL) << PrettyMethod(this); @@ -330,19 +322,19 @@ void AbstractMethod::RegisterNative(Thread* self, const void* native_method) { #else SetNativeMethod(reinterpret_cast<void*>(art_work_around_app_jni_bugs)); #endif - SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), + SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), reinterpret_cast<const uint8_t*>(native_method), false); } } -void AbstractMethod::UnregisterNative(Thread* self) { +void ArtMethod::UnregisterNative(Thread* self) { CHECK(IsNative()) << PrettyMethod(this); // restore stub to lookup native pointer via dlsym RegisterNative(self, GetJniDlsymLookupStub()); } -void AbstractMethod::SetNativeMethod(const void* native_method) { - SetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_), +void ArtMethod::SetNativeMethod(const void* native_method) { + SetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_), native_method, false); } diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/art_method.h index 5b8c61c..7301f23 100644 --- a/runtime/mirror/abstract_method.h +++ b/runtime/mirror/art_method.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ +#ifndef ART_RUNTIME_MIRROR_ART_METHOD_H_ +#define ART_RUNTIME_MIRROR_ART_METHOD_H_ #include "class.h" #include "dex_file.h" @@ -26,12 +26,11 @@ namespace art { -struct AbstractMethodOffsets; +struct ArtMethodOffsets; struct ConstructorMethodOffsets; union JValue; struct MethodClassOffsets; class MethodHelper; -struct MethodOffsets; class StringPiece; class ShadowFrame; @@ -43,24 +42,24 @@ typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); // C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor -class MANAGED AbstractMethod : public Object { +class MANAGED ArtMethod : public Object { public: Class* GetDeclaringClass() const; void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset DeclaringClassOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_)); + return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_)); } static MemberOffset EntryPointFromCompiledCodeOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_compiled_code_)); + return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_compiled_code_)); } uint32_t GetAccessFlags() const; void SetAccessFlags(uint32_t new_access_flags) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, access_flags_), new_access_flags, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags, false); } // Approximate what kind of method call would be used for this method. @@ -140,19 +139,19 @@ class MANAGED AbstractMethod : public Object { } void SetMethodIndex(uint16_t new_method_index) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_), new_method_index, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index, false); } static MemberOffset MethodIndexOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); } uint32_t GetCodeItemOffset() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, code_item_offset_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), false); } void SetCodeItemOffset(uint32_t new_code_off) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, code_item_offset_), new_code_off, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), new_code_off, false); } // Number of 32bit registers that would be required to hold all the arguments @@ -161,7 +160,7 @@ class MANAGED AbstractMethod : public Object { uint32_t GetDexMethodIndex() const; void SetDexMethodIndex(uint32_t new_idx) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), new_idx, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), new_idx, false); } ObjectArray<String>* GetDexCacheStrings() const; @@ -169,24 +168,24 @@ class MANAGED AbstractMethod : public Object { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset DexCacheStringsOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_); } static MemberOffset DexCacheResolvedMethodsOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_); } static MemberOffset DexCacheResolvedTypesOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_); } static MemberOffset DexCacheInitializedStaticStorageOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_); } - ObjectArray<AbstractMethod>* GetDexCacheResolvedMethods() const; - void SetDexCacheResolvedMethods(ObjectArray<AbstractMethod>* new_dex_cache_methods) + ObjectArray<ArtMethod>* GetDexCacheResolvedMethods() const; + void SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ObjectArray<Class>* GetDexCacheResolvedTypes() const; @@ -198,25 +197,25 @@ class MANAGED AbstractMethod : public Object { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Find the method that this method overrides - AbstractMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); EntryPointFromInterpreter* GetEntryPointFromInterpreter() const { - return GetFieldPtr<EntryPointFromInterpreter*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_interpreter_), false); + return GetFieldPtr<EntryPointFromInterpreter*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), false); } void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) { - SetFieldPtr<EntryPointFromInterpreter*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false); + SetFieldPtr<EntryPointFromInterpreter*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false); } const void* GetEntryPointFromCompiledCode() const { - return GetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_), false); + return GetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), false); } void SetEntryPointFromCompiledCode(const void* entry_point_from_compiled_code) { - SetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false); + SetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false); } uint32_t GetCodeSize() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -243,16 +242,16 @@ class MANAGED AbstractMethod : public Object { void SetOatCodeOffset(uint32_t code_offset); static MemberOffset GetEntryPointFromCompiledCodeOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_); } // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. const uint8_t* GetMappingTable() const { - return GetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, mapping_table_), false); + return GetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), false); } void SetMappingTable(const uint8_t* mapping_table) { - SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, mapping_table_), + SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), mapping_table, false); } @@ -262,11 +261,11 @@ class MANAGED AbstractMethod : public Object { // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. const uint8_t* GetVmapTable() const { - return GetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, vmap_table_), false); + return GetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), false); } void SetVmapTable(const uint8_t* vmap_table) { - SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, vmap_table_), vmap_table, false); + SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), vmap_table, false); } uint32_t GetOatVmapTableOffset() const; @@ -274,10 +273,10 @@ class MANAGED AbstractMethod : public Object { void SetOatVmapTableOffset(uint32_t vmap_table_offset); const uint8_t* GetNativeGcMap() const { - return GetFieldPtr<uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), false); + return GetFieldPtr<uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), false); } void SetNativeGcMap(const uint8_t* data) { - SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), data, false); + SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), data, false); } // When building the oat need a convenient place to stuff the offset of the native GC map. @@ -286,14 +285,14 @@ class MANAGED AbstractMethod : public Object { size_t GetFrameSizeInBytes() const { DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); - size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, frame_size_in_bytes_), false); + size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), false); DCHECK_LE(static_cast<size_t>(kStackAlignment), result); return result; } void SetFrameSizeInBytes(size_t new_frame_size_in_bytes) { DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, frame_size_in_bytes_), + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), new_frame_size_in_bytes, false); } @@ -314,7 +313,7 @@ class MANAGED AbstractMethod : public Object { void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset NativeMethodOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_); } const void* GetNativeMethod() const { @@ -324,25 +323,25 @@ class MANAGED AbstractMethod : public Object { void SetNativeMethod(const void*); static MemberOffset GetMethodIndexOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_); + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); } uint32_t GetCoreSpillMask() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, core_spill_mask_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), false); } void SetCoreSpillMask(uint32_t core_spill_mask) { // Computed during compilation - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, core_spill_mask_), core_spill_mask, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), core_spill_mask, false); } uint32_t GetFpSpillMask() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, fp_spill_mask_), false); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), false); } void SetFpSpillMask(uint32_t fp_spill_mask) { // Computed during compilation - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, fp_spill_mask_), fp_spill_mask, false); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), fp_spill_mask, false); } // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal @@ -368,17 +367,13 @@ class MANAGED AbstractMethod : public Object { uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static void SetClasses(Class* java_lang_reflect_Constructor, Class* java_lang_reflect_Method); + static void SetClass(Class* java_lang_reflect_ArtMethod); - static Class* GetConstructorClass() { - return java_lang_reflect_Constructor_; + static Class* GetJavaLangReflectArtMethod() { + return java_lang_reflect_ArtMethod_; } - static Class* GetMethodClass() { - return java_lang_reflect_Method_; - } - - static void ResetClasses(); + static void ResetClass(); protected: // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". @@ -389,7 +384,7 @@ class MANAGED AbstractMethod : public Object { ObjectArray<StaticStorageBase>* dex_cache_initialized_static_storage_; // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray<AbstractMethod>* dex_cache_resolved_methods_; + ObjectArray<ArtMethod>* dex_cache_resolved_methods_; // short cuts to declaring_class_->dex_cache_ member for fast compiled code access ObjectArray<Class>* dex_cache_resolved_types_; @@ -445,27 +440,18 @@ class MANAGED AbstractMethod : public Object { // is vmap_table_[N]. vmap_table_[0] holds the length of the table. const uint16_t* vmap_table_; - static Class* java_lang_reflect_Constructor_; - static Class* java_lang_reflect_Method_; + static Class* java_lang_reflect_ArtMethod_; - friend struct art::AbstractMethodOffsets; // for verifying offset information - friend struct art::ConstructorMethodOffsets; // for verifying offset information - friend struct art::MethodOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod); + friend struct art::ArtMethodOffsets; // for verifying offset information + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod); }; -class MANAGED Method : public AbstractMethod {}; - -class MANAGED Constructor : public AbstractMethod {}; - -class MANAGED AbstractMethodClass : public Class { +class MANAGED ArtMethodClass : public Class { private: - Object* ORDER_BY_SIGNATURE_; - friend struct art::MethodClassOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethodClass); + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethodClass); }; } // namespace mirror } // namespace art -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ +#endif // ART_RUNTIME_MIRROR_ART_METHOD_H_ diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 52906a2..1e11387 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -19,10 +19,10 @@ #include "class.h" -#include "abstract_method.h" +#include "art_field.h" +#include "art_method.h" #include "class_loader.h" #include "dex_cache.h" -#include "field.h" #include "iftable.h" #include "object_array-inl.h" #include "runtime.h" @@ -54,30 +54,30 @@ inline DexCache* Class::GetDexCache() const { return GetFieldObject<DexCache*>(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), false); } -inline ObjectArray<AbstractMethod>* Class::GetDirectMethods() const { +inline ObjectArray<ArtMethod>* Class::GetDirectMethods() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject<ObjectArray<AbstractMethod>*>( + return GetFieldObject<ObjectArray<ArtMethod>*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false); } -inline void Class::SetDirectMethods(ObjectArray<AbstractMethod>* new_direct_methods) +inline void Class::SetDirectMethods(ObjectArray<ArtMethod>* new_direct_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject<ObjectArray<AbstractMethod>*>( + DCHECK(NULL == GetFieldObject<ObjectArray<ArtMethod>*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false)); DCHECK_NE(0, new_direct_methods->GetLength()); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), new_direct_methods, false); } -inline AbstractMethod* Class::GetDirectMethod(int32_t i) const +inline ArtMethod* Class::GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetDirectMethods()->Get(i); } -inline void Class::SetDirectMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t +inline void Class::SetDirectMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray<AbstractMethod>* direct_methods = - GetFieldObject<ObjectArray<AbstractMethod>*>( + ObjectArray<ArtMethod>* direct_methods = + GetFieldObject<ObjectArray<ArtMethod>*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false); direct_methods->Set(i, f); } @@ -87,13 +87,13 @@ inline size_t Class::NumDirectMethods() const { return (GetDirectMethods() != NULL) ? GetDirectMethods()->GetLength() : 0; } -inline ObjectArray<AbstractMethod>* Class::GetVirtualMethods() const { +inline ObjectArray<ArtMethod>* Class::GetVirtualMethods() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject<ObjectArray<AbstractMethod>*>( + return GetFieldObject<ObjectArray<ArtMethod>*>( OFFSET_OF_OBJECT_MEMBER(Class, virtual_methods_), false); } -inline void Class::SetVirtualMethods(ObjectArray<AbstractMethod>* new_virtual_methods) { +inline void Class::SetVirtualMethods(ObjectArray<ArtMethod>* new_virtual_methods) { // TODO: we reassign virtual methods to grow the table for miranda // methods.. they should really just be assigned once DCHECK_NE(0, new_virtual_methods->GetLength()); @@ -105,37 +105,37 @@ inline size_t Class::NumVirtualMethods() const { return (GetVirtualMethods() != NULL) ? GetVirtualMethods()->GetLength() : 0; } -inline AbstractMethod* Class::GetVirtualMethod(uint32_t i) const +inline ArtMethod* Class::GetVirtualMethod(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(IsResolved() || IsErroneous()); return GetVirtualMethods()->Get(i); } -inline AbstractMethod* Class::GetVirtualMethodDuringLinking(uint32_t i) const +inline ArtMethod* Class::GetVirtualMethodDuringLinking(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(IsLoaded() || IsErroneous()); return GetVirtualMethods()->Get(i); } -inline void Class::SetVirtualMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t +inline void Class::SetVirtualMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray<AbstractMethod>* virtual_methods = - GetFieldObject<ObjectArray<AbstractMethod>*>( + ObjectArray<ArtMethod>* virtual_methods = + GetFieldObject<ObjectArray<ArtMethod>*>( OFFSET_OF_OBJECT_MEMBER(Class, virtual_methods_), false); virtual_methods->Set(i, f); } -inline ObjectArray<AbstractMethod>* Class::GetVTable() const { +inline ObjectArray<ArtMethod>* Class::GetVTable() const { DCHECK(IsResolved() || IsErroneous()); - return GetFieldObject<ObjectArray<AbstractMethod>*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); + return GetFieldObject<ObjectArray<ArtMethod>*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); } -inline ObjectArray<AbstractMethod>* Class::GetVTableDuringLinking() const { +inline ObjectArray<ArtMethod>* Class::GetVTableDuringLinking() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject<ObjectArray<AbstractMethod>*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); + return GetFieldObject<ObjectArray<ArtMethod>*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); } -inline void Class::SetVTable(ObjectArray<AbstractMethod>* new_vtable) +inline void Class::SetVTable(ObjectArray<ArtMethod>* new_vtable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), new_vtable, false); } @@ -208,7 +208,7 @@ inline bool Class::IsSubClass(const Class* klass) const { return false; } -inline AbstractMethod* Class::FindVirtualMethodForInterface(AbstractMethod* method) const { +inline ArtMethod* Class::FindVirtualMethodForInterface(ArtMethod* method) const { Class* declaring_class = method->GetDeclaringClass(); DCHECK(declaring_class != NULL) << PrettyClass(this); DCHECK(declaring_class->IsInterface()) << PrettyMethod(method); @@ -223,7 +223,7 @@ inline AbstractMethod* Class::FindVirtualMethodForInterface(AbstractMethod* meth return NULL; } -inline AbstractMethod* Class::FindVirtualMethodForVirtual(AbstractMethod* method) const +inline ArtMethod* Class::FindVirtualMethodForVirtual(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(!method->GetDeclaringClass()->IsInterface() || method->IsMiranda()); // The argument method may from a super class. @@ -231,13 +231,13 @@ inline AbstractMethod* Class::FindVirtualMethodForVirtual(AbstractMethod* method return GetVTable()->Get(method->GetMethodIndex()); } -inline AbstractMethod* Class::FindVirtualMethodForSuper(AbstractMethod* method) const +inline ArtMethod* Class::FindVirtualMethodForSuper(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(!method->GetDeclaringClass()->IsInterface()); return GetSuperClass()->GetVTable()->Get(method->GetMethodIndex()); } -inline AbstractMethod* Class::FindVirtualMethodForVirtualOrInterface(AbstractMethod* method) const { +inline ArtMethod* Class::FindVirtualMethodForVirtualOrInterface(ArtMethod* method) const { if (method->IsDirect()) { return method; } @@ -263,26 +263,26 @@ inline void Class::SetIfTable(IfTable* new_iftable) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, iftable_), new_iftable, false); } -inline ObjectArray<Field>* Class::GetIFields() const { +inline ObjectArray<ArtField>* Class::GetIFields() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject<ObjectArray<Field>*>(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); + return GetFieldObject<ObjectArray<ArtField>*>(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); } -inline void Class::SetIFields(ObjectArray<Field>* new_ifields) +inline void Class::SetIFields(ObjectArray<ArtField>* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject<ObjectArray<Field>*>( + DCHECK(NULL == GetFieldObject<ObjectArray<ArtField>*>( OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false)); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), new_ifields, false); } -inline ObjectArray<Field>* Class::GetSFields() const { +inline ObjectArray<ArtField>* Class::GetSFields() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject<ObjectArray<Field>*>(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); + return GetFieldObject<ObjectArray<ArtField>*>(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); } -inline void Class::SetSFields(ObjectArray<Field>* new_sfields) +inline void Class::SetSFields(ObjectArray<ArtField>* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject<ObjectArray<Field>*>( + DCHECK(NULL == GetFieldObject<ObjectArray<ArtField>*>( OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false)); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), new_sfields, false); } @@ -291,14 +291,14 @@ inline size_t Class::NumStaticFields() const { return (GetSFields() != NULL) ? GetSFields()->GetLength() : 0; } -inline Field* Class::GetStaticField(uint32_t i) const // TODO: uint16_t +inline ArtField* Class::GetStaticField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetSFields()->Get(i); } -inline void Class::SetStaticField(uint32_t i, Field* f) // TODO: uint16_t +inline void Class::SetStaticField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray<Field>* sfields= GetFieldObject<ObjectArray<Field>*>( + ObjectArray<ArtField>* sfields= GetFieldObject<ObjectArray<ArtField>*>( OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); sfields->Set(i, f); } @@ -307,15 +307,15 @@ inline size_t Class::NumInstanceFields() const { return (GetIFields() != NULL) ? GetIFields()->GetLength() : 0; } -inline Field* Class::GetInstanceField(uint32_t i) const // TODO: uint16_t +inline ArtField* Class::GetInstanceField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK_NE(NumInstanceFields(), 0U); return GetIFields()->Get(i); } -inline void Class::SetInstanceField(uint32_t i, Field* f) // TODO: uint16_t +inline void Class::SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray<Field>* ifields= GetFieldObject<ObjectArray<Field>*>( + ObjectArray<ArtField>* ifields= GetFieldObject<ObjectArray<ArtField>*>( OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); ifields->Set(i, f); } @@ -330,9 +330,8 @@ inline uint32_t Class::GetAccessFlags() const { // circularity issue during loading the names of its members DCHECK(IsLoaded() || IsErroneous() || this == String::GetJavaLangString() || - this == Field::GetJavaLangReflectField() || - this == AbstractMethod::GetConstructorClass() || - this == AbstractMethod::GetMethodClass()); + this == ArtField::GetJavaLangReflectArtField() || + this == ArtMethod::GetJavaLangReflectArtMethod()); return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_), false); } diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index e490d97..29025f2 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -16,13 +16,13 @@ #include "class.h" -#include "abstract_method-inl.h" +#include "art_field-inl.h" +#include "art_method-inl.h" #include "class-inl.h" #include "class_linker.h" #include "class_loader.h" #include "dex_cache.h" #include "dex_file-inl.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "object-inl.h" #include "object_array-inl.h" @@ -63,7 +63,7 @@ void Class::SetStatus(Status new_status) { // Stash current exception. Thread* self = Thread::Current(); SirtRef<mirror::Object> old_throw_this_object(self, NULL); - SirtRef<mirror::AbstractMethod> old_throw_method(self, NULL); + SirtRef<mirror::ArtMethod> old_throw_method(self, NULL); SirtRef<mirror::Throwable> old_exception(self, NULL); uint32_t old_throw_dex_pc; { @@ -316,24 +316,23 @@ bool Class::IsThrowableClass() const { return WellKnownClasses::ToClass(WellKnownClasses::java_lang_Throwable)->IsAssignableFrom(this); } -bool Class::IsFieldClass() const { +bool Class::IsArtFieldClass() const { Class* java_lang_Class = GetClass(); - Class* java_lang_reflect_Field = java_lang_Class->GetInstanceField(0)->GetClass(); - return this == java_lang_reflect_Field; + Class* java_lang_reflect_ArtField = java_lang_Class->GetInstanceField(0)->GetClass(); + return this == java_lang_reflect_ArtField; } -bool Class::IsMethodClass() const { - return (this == AbstractMethod::GetMethodClass()) || - (this == AbstractMethod::GetConstructorClass()); +bool Class::IsArtMethodClass() const { + return this == ArtMethod::GetJavaLangReflectArtMethod(); } void Class::SetClassLoader(ClassLoader* new_class_loader) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), new_class_loader, false); } -AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const { // Check the current class before checking the interfaces. - AbstractMethod* method = FindDeclaredVirtualMethod(name, signature); + ArtMethod* method = FindDeclaredVirtualMethod(name, signature); if (method != NULL) { return method; } @@ -349,9 +348,9 @@ AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const String return NULL; } -AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { // Check the current class before checking the interfaces. - AbstractMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); + ArtMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -368,10 +367,10 @@ AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t d } -AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { MethodHelper mh; for (size_t i = 0; i < NumDirectMethods(); ++i) { - AbstractMethod* method = GetDirectMethod(i); + ArtMethod* method = GetDirectMethod(i); mh.ChangeMethod(method); if (name == mh.GetName() && signature == mh.GetSignature()) { return method; @@ -380,10 +379,10 @@ AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const S return NULL; } -AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumDirectMethods(); ++i) { - AbstractMethod* method = GetDirectMethod(i); + ArtMethod* method = GetDirectMethod(i); if (method->GetDexMethodIndex() == dex_method_idx) { return method; } @@ -392,9 +391,9 @@ AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint3 return NULL; } -AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredDirectMethod(name, signature); + ArtMethod* method = klass->FindDeclaredDirectMethod(name, signature); if (method != NULL) { return method; } @@ -402,9 +401,9 @@ AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPie return NULL; } -AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); + ArtMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -412,11 +411,11 @@ AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_ return NULL; } -AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, +ArtMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const { MethodHelper mh; for (size_t i = 0; i < NumVirtualMethods(); ++i) { - AbstractMethod* method = GetVirtualMethod(i); + ArtMethod* method = GetVirtualMethod(i); mh.ChangeMethod(method); if (name == mh.GetName() && signature == mh.GetSignature()) { return method; @@ -425,10 +424,10 @@ AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, return NULL; } -AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumVirtualMethods(); ++i) { - AbstractMethod* method = GetVirtualMethod(i); + ArtMethod* method = GetVirtualMethod(i); if (method->GetDexMethodIndex() == dex_method_idx) { return method; } @@ -437,9 +436,9 @@ AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint return NULL; } -AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredVirtualMethod(name, signature); + ArtMethod* method = klass->FindDeclaredVirtualMethod(name, signature); if (method != NULL) { return method; } @@ -447,9 +446,9 @@ AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPi return NULL; } -AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); + ArtMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -457,12 +456,12 @@ AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex return NULL; } -Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { // Is the field in this class? // Interfaces are not relevant because they can't contain instance fields. FieldHelper fh; for (size_t i = 0; i < NumInstanceFields(); ++i) { - Field* f = GetInstanceField(i); + ArtField* f = GetInstanceField(i); fh.ChangeField(f); if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { return f; @@ -471,10 +470,10 @@ Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPie return NULL; } -Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumInstanceFields(); ++i) { - Field* f = GetInstanceField(i); + ArtField* f = GetInstanceField(i); if (f->GetDexFieldIndex() == dex_field_idx) { return f; } @@ -483,11 +482,11 @@ Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_ return NULL; } -Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { // Is the field in this class, or any of its superclasses? // Interfaces are not relevant because they can't contain instance fields. for (Class* c = this; c != NULL; c = c->GetSuperClass()) { - Field* f = c->FindDeclaredInstanceField(name, type); + ArtField* f = c->FindDeclaredInstanceField(name, type); if (f != NULL) { return f; } @@ -495,11 +494,11 @@ Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type return NULL; } -Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { // Is the field in this class, or any of its superclasses? // Interfaces are not relevant because they can't contain instance fields. for (Class* c = this; c != NULL; c = c->GetSuperClass()) { - Field* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); + ArtField* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); if (f != NULL) { return f; } @@ -507,11 +506,11 @@ Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_id return NULL; } -Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { DCHECK(type != NULL); FieldHelper fh; for (size_t i = 0; i < NumStaticFields(); ++i) { - Field* f = GetStaticField(i); + ArtField* f = GetStaticField(i); fh.ChangeField(f); if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { return f; @@ -520,10 +519,10 @@ Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece return NULL; } -Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { if (dex_cache == GetDexCache()) { for (size_t i = 0; i < NumStaticFields(); ++i) { - Field* f = GetStaticField(i); + ArtField* f = GetStaticField(i); if (f->GetDexFieldIndex() == dex_field_idx) { return f; } @@ -532,13 +531,13 @@ Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_fi return NULL; } -Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { // Is the field in this class (or its interfaces), or any of its // superclasses (or their interfaces)? ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredStaticField(name, type); + ArtField* f = k->FindDeclaredStaticField(name, type); if (f != NULL) { return f; } @@ -555,11 +554,11 @@ Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) return NULL; } -Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); + ArtField* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); if (f != NULL) { return f; } @@ -576,12 +575,12 @@ Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) return NULL; } -Field* Class::FindField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindField(const StringPiece& name, const StringPiece& type) { // Find a field using the JLS field resolution order ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredInstanceField(name, type); + ArtField* f = k->FindDeclaredInstanceField(name, type); if (f != NULL) { return f; } @@ -602,11 +601,11 @@ Field* Class::FindField(const StringPiece& name, const StringPiece& type) { return NULL; } -static void SetPreverifiedFlagOnMethods(mirror::ObjectArray<mirror::AbstractMethod>* methods) +static void SetPreverifiedFlagOnMethods(mirror::ObjectArray<mirror::ArtMethod>* methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (methods != NULL) { for (int32_t index = 0, end = methods->GetLength(); index < end; ++index) { - mirror::AbstractMethod* method = methods->GetWithoutChecks(index); + mirror::ArtMethod* method = methods->GetWithoutChecks(index); DCHECK(method != NULL); method->SetPreverified(); } diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 1dd02c0..638b67f 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -63,9 +63,9 @@ class StringPiece; namespace mirror { +class ArtField; class ClassLoader; class DexCache; -class Field; class IfTable; // Type for the InitializedStaticStorage table. Currently the Class @@ -341,9 +341,9 @@ class MANAGED Class : public StaticStorageBase { bool IsThrowableClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool IsArtFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsMethodClass() const; + bool IsArtMethodClass() const; Class* GetComponentType() const { return GetFieldObject<Class*>(OFFSET_OF_OBJECT_MEMBER(Class, component_type_), false); @@ -502,42 +502,42 @@ class MANAGED Class : public StaticStorageBase { void SetDexCache(DexCache* new_dex_cache) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray<AbstractMethod>* GetDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ObjectArray<ArtMethod>* GetDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDirectMethods(ObjectArray<AbstractMethod>* new_direct_methods) + void SetDirectMethods(ObjectArray<ArtMethod>* new_direct_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtMethod* GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDirectMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t + void SetDirectMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of static, private, and constructor methods. size_t NumDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray<AbstractMethod>* GetVirtualMethods() const + ObjectArray<ArtMethod>* GetVirtualMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVirtualMethods(ObjectArray<AbstractMethod>* new_virtual_methods) + void SetVirtualMethods(ObjectArray<ArtMethod>* new_virtual_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of non-inherited virtual methods. size_t NumVirtualMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetVirtualMethod(uint32_t i) const + ArtMethod* GetVirtualMethod(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetVirtualMethodDuringLinking(uint32_t i) const + ArtMethod* GetVirtualMethodDuringLinking(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVirtualMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t + void SetVirtualMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray<AbstractMethod>* GetVTable() const; + ObjectArray<ArtMethod>* GetVTable() const; - ObjectArray<AbstractMethod>* GetVTableDuringLinking() const; + ObjectArray<ArtMethod>* GetVTableDuringLinking() const; - void SetVTable(ObjectArray<AbstractMethod>* new_vtable) + void SetVTable(ObjectArray<ArtMethod>* new_vtable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset VTableOffset() { @@ -546,51 +546,51 @@ class MANAGED Class : public StaticStorageBase { // Given a method implemented by this class but potentially from a super class, return the // specific implementation method for this class. - AbstractMethod* FindVirtualMethodForVirtual(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Given a method implemented by this class' super class, return the specific implementation // method for this class. - AbstractMethod* FindVirtualMethodForSuper(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForSuper(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Given a method implemented by this class, but potentially from a // super class or interface, return the specific implementation // method for this class. - AbstractMethod* FindVirtualMethodForInterface(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForInterface(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE; - AbstractMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& descriptor) const + ArtMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& descriptor) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethodForVirtualOrInterface(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& descriptor) const + ArtMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& descriptor) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); int32_t GetIfTableCount() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -600,16 +600,16 @@ class MANAGED Class : public StaticStorageBase { void SetIfTable(IfTable* new_iftable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get instance fields of the class (See also GetSFields). - ObjectArray<Field>* GetIFields() const; + ObjectArray<ArtField>* GetIFields() const; - void SetIFields(ObjectArray<Field>* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetIFields(ObjectArray<ArtField>* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t NumInstanceFields() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* GetInstanceField(uint32_t i) const // TODO: uint16_t + ArtField* GetInstanceField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetInstanceField(uint32_t i, Field* f) // TODO: uint16_t + void SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of instance fields containing reference types. @@ -662,15 +662,15 @@ class MANAGED Class : public StaticStorageBase { } // Gets the static fields of the class. - ObjectArray<Field>* GetSFields() const; + ObjectArray<ArtField>* GetSFields() const; - void SetSFields(ObjectArray<Field>* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetSFields(ObjectArray<ArtField>* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t NumStaticFields() const; - Field* GetStaticField(uint32_t i) const; // TODO: uint16_t + ArtField* GetStaticField(uint32_t i) const; // TODO: uint16_t - void SetStaticField(uint32_t i, Field* f); // TODO: uint16_t + void SetStaticField(uint32_t i, ArtField* f); // TODO: uint16_t uint32_t GetReferenceStaticOffsets() const { return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_static_offsets_), false); @@ -679,37 +679,37 @@ class MANAGED Class : public StaticStorageBase { void SetReferenceStaticOffsets(uint32_t new_reference_offsets); // Find a static or instance field using the JLS resolution order - Field* FindField(const StringPiece& name, const StringPiece& type) + ArtField* FindField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given instance field in this class or a superclass. - Field* FindInstanceField(const StringPiece& name, const StringPiece& type) + ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given instance field in this class or a superclass, only searches classes that // have the same dex cache. - Field* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) + ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given static field in this class or a superclass. - Field* FindStaticField(const StringPiece& name, const StringPiece& type) + ArtField* FindStaticField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given static field in this class or superclass, only searches classes that // have the same dex cache. - Field* FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) + ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); pid_t GetClinitThreadId() const { @@ -768,7 +768,7 @@ class MANAGED Class : public StaticStorageBase { DexCache* dex_cache_; // static, private, and <init> methods - ObjectArray<AbstractMethod>* direct_methods_; + ObjectArray<ArtMethod>* direct_methods_; // instance fields // @@ -780,7 +780,7 @@ class MANAGED Class : public StaticStorageBase { // All instance fields that refer to objects are guaranteed to be at // the beginning of the field list. num_reference_instance_fields_ // specifies the number of reference fields. - ObjectArray<Field>* ifields_; + ObjectArray<ArtField>* ifields_; // The interface table (iftable_) contains pairs of a interface class and an array of the // interface methods. There is one pair per interface supported by this class. That means one @@ -799,7 +799,7 @@ class MANAGED Class : public StaticStorageBase { String* name_; // Static fields - ObjectArray<Field>* sfields_; + ObjectArray<ArtField>* sfields_; // The superclass, or NULL if this is java.lang.Object, an interface or primitive type. Class* super_class_; @@ -808,13 +808,13 @@ class MANAGED Class : public StaticStorageBase { Class* verify_error_class_; // virtual methods defined in this class; invoked through vtable - ObjectArray<AbstractMethod>* virtual_methods_; + ObjectArray<ArtMethod>* virtual_methods_; // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is // copied in, and virtual methods from our class either replace those from the super or are // appended. For abstract classes, methods may be created in the vtable that aren't in // virtual_ methods_ for miranda methods. - ObjectArray<AbstractMethod>* vtable_; + ObjectArray<ArtMethod>* vtable_; // access flags; low 16 bits are defined by VM spec uint32_t access_flags_; diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 369dc49..da26be5 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -22,9 +22,9 @@ namespace art { namespace mirror { -inline AbstractMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const +inline ArtMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = GetResolvedMethods()->Get(method_idx); + ArtMethod* method = GetResolvedMethods()->Get(method_idx); // Hide resolution trampoline methods from the caller if (method != NULL && method->IsRuntimeMethod()) { DCHECK(method == Runtime::Current()->GetResolutionMethod()); diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc index 239dc5e..00531e3 100644 --- a/runtime/mirror/dex_cache.cc +++ b/runtime/mirror/dex_cache.cc @@ -16,7 +16,7 @@ #include "dex_cache.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "base/logging.h" #include "class_linker.h" #include "gc/accounting/card_table-inl.h" @@ -35,8 +35,8 @@ void DexCache::Init(const DexFile* dex_file, String* location, ObjectArray<String>* strings, ObjectArray<Class>* resolved_types, - ObjectArray<AbstractMethod>* resolved_methods, - ObjectArray<Field>* resolved_fields, + ObjectArray<ArtMethod>* resolved_methods, + ObjectArray<ArtField>* resolved_fields, ObjectArray<StaticStorageBase>* initialized_static_storage) { CHECK(dex_file != NULL); CHECK(location != NULL); @@ -58,7 +58,7 @@ void DexCache::Init(const DexFile* dex_file, Runtime* runtime = Runtime::Current(); if (runtime->HasResolutionMethod()) { // Initialize the resolve methods array to contain trampolines for resolution. - AbstractMethod* trampoline = runtime->GetResolutionMethod(); + ArtMethod* trampoline = runtime->GetResolutionMethod(); size_t length = resolved_methods->GetLength(); for (size_t i = 0; i < length; i++) { resolved_methods->SetWithoutChecks(i, trampoline); @@ -66,10 +66,10 @@ void DexCache::Init(const DexFile* dex_file, } } -void DexCache::Fixup(AbstractMethod* trampoline) { +void DexCache::Fixup(ArtMethod* trampoline) { // Fixup the resolve methods array to contain trampoline for resolution. CHECK(trampoline != NULL); - ObjectArray<AbstractMethod>* resolved_methods = GetResolvedMethods(); + ObjectArray<ArtMethod>* resolved_methods = GetResolvedMethods(); size_t length = resolved_methods->GetLength(); for (size_t i = 0; i < length; i++) { if (resolved_methods->GetWithoutChecks(i) == NULL) { diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 9c0f09b..6cfab9e 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_MIRROR_DEX_CACHE_H_ #define ART_RUNTIME_MIRROR_DEX_CACHE_H_ -#include "abstract_method.h" +#include "art_method.h" #include "class.h" #include "object.h" #include "object_array.h" @@ -32,8 +32,8 @@ union JValue; namespace mirror { +class ArtField; class Class; -class Field; class MANAGED DexCacheClass : public Class { private: @@ -46,12 +46,12 @@ class MANAGED DexCache : public Object { String* location, ObjectArray<String>* strings, ObjectArray<Class>* types, - ObjectArray<AbstractMethod>* methods, - ObjectArray<Field>* fields, + ObjectArray<ArtMethod>* methods, + ObjectArray<ArtField>* fields, ObjectArray<StaticStorageBase>* initialized_static_storage) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Fixup(AbstractMethod* trampoline) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Fixup(ArtMethod* trampoline) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); String* GetLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetFieldObject<String*>(OFFSET_OF_OBJECT_MEMBER(DexCache, location_), false); @@ -110,20 +110,20 @@ class MANAGED DexCache : public Object { GetResolvedTypes()->Set(type_idx, resolved); } - AbstractMethod* GetResolvedMethod(uint32_t method_idx) const + ArtMethod* GetResolvedMethod(uint32_t method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetResolvedMethod(uint32_t method_idx, AbstractMethod* resolved) + void SetResolvedMethod(uint32_t method_idx, ArtMethod* resolved) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { GetResolvedMethods()->Set(method_idx, resolved); } - Field* GetResolvedField(uint32_t field_idx) const + ArtField* GetResolvedField(uint32_t field_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetResolvedFields()->Get(field_idx); } - void SetResolvedField(uint32_t field_idx, Field* resolved) + void SetResolvedField(uint32_t field_idx, ArtField* resolved) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { GetResolvedFields()->Set(field_idx, resolved); } @@ -139,14 +139,14 @@ class MANAGED DexCache : public Object { OFFSET_OF_OBJECT_MEMBER(DexCache, resolved_types_), false); } - ObjectArray<AbstractMethod>* GetResolvedMethods() const + ObjectArray<ArtMethod>* GetResolvedMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return GetFieldObject< ObjectArray<AbstractMethod>* >(ResolvedMethodsOffset(), false); + return GetFieldObject< ObjectArray<ArtMethod>* >(ResolvedMethodsOffset(), false); } - ObjectArray<Field>* GetResolvedFields() const + ObjectArray<ArtField>* GetResolvedFields() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return GetFieldObject< ObjectArray<Field>* >(ResolvedFieldsOffset(), false); + return GetFieldObject< ObjectArray<ArtField>* >(ResolvedFieldsOffset(), false); } ObjectArray<StaticStorageBase>* GetInitializedStaticStorage() const @@ -166,8 +166,8 @@ class MANAGED DexCache : public Object { private: ObjectArray<StaticStorageBase>* initialized_static_storage_; String* location_; - ObjectArray<Object>* resolved_fields_; - ObjectArray<AbstractMethod>* resolved_methods_; + ObjectArray<ArtField>* resolved_fields_; + ObjectArray<ArtMethod>* resolved_methods_; ObjectArray<Class>* resolved_types_; ObjectArray<String>* strings_; uint32_t dex_file_; diff --git a/runtime/mirror/iftable.h b/runtime/mirror/iftable.h index aea8fdd..421893d 100644 --- a/runtime/mirror/iftable.h +++ b/runtime/mirror/iftable.h @@ -32,24 +32,24 @@ class MANAGED IfTable : public ObjectArray<Object> { void SetInterface(int32_t i, Class* interface) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray<AbstractMethod>* GetMethodArray(int32_t i) const + ObjectArray<ArtMethod>* GetMethodArray(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray<AbstractMethod>* method_array = - down_cast<ObjectArray<AbstractMethod>*>(Get((i * kMax) + kMethodArray)); + ObjectArray<ArtMethod>* method_array = + down_cast<ObjectArray<ArtMethod>*>(Get((i * kMax) + kMethodArray)); DCHECK(method_array != NULL); return method_array; } size_t GetMethodArrayCount(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray<AbstractMethod>* method_array = - down_cast<ObjectArray<AbstractMethod>*>(Get((i * kMax) + kMethodArray)); + ObjectArray<ArtMethod>* method_array = + down_cast<ObjectArray<ArtMethod>*>(Get((i * kMax) + kMethodArray)); if (method_array == NULL) { return 0; } return method_array->GetLength(); } - void SetMethodArray(int32_t i, ObjectArray<AbstractMethod>* new_ma) + void SetMethodArray(int32_t i, ObjectArray<ArtMethod>* new_ma) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_ma != NULL); DCHECK(Get((i * kMax) + kMethodArray) == NULL); diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index 5818a80..63396d2 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -19,10 +19,10 @@ #include "object.h" -#include "abstract_method.h" +#include "art_field.h" +#include "art_method.h" #include "atomic.h" #include "array-inl.h" -#include "field.h" #include "class.h" #include "monitor.h" #include "runtime.h" @@ -112,32 +112,32 @@ inline bool Object::IsArrayInstance() const { return GetClass()->IsArrayClass(); } -inline bool Object::IsField() const { - return GetClass()->IsFieldClass(); +inline bool Object::IsArtField() const { + return GetClass()->IsArtFieldClass(); } -inline Field* Object::AsField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(IsField()); - return down_cast<Field*>(this); +inline ArtField* Object::AsArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(IsArtField()); + return down_cast<ArtField*>(this); } -inline const Field* Object::AsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(IsField()); - return down_cast<const Field*>(this); +inline const ArtField* Object::AsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(IsArtField()); + return down_cast<const ArtField*>(this); } -inline bool Object::IsMethod() const { - return GetClass()->IsMethodClass(); +inline bool Object::IsArtMethod() const { + return GetClass()->IsArtMethodClass(); } -inline AbstractMethod* Object::AsMethod() { - DCHECK(IsMethod()); - return down_cast<AbstractMethod*>(this); +inline ArtMethod* Object::AsArtMethod() { + DCHECK(IsArtMethod()); + return down_cast<ArtMethod*>(this); } -inline const AbstractMethod* Object::AsMethod() const { - DCHECK(IsMethod()); - return down_cast<const AbstractMethod*>(this); +inline const ArtMethod* Object::AsArtMethod() const { + DCHECK(IsArtMethod()); + return down_cast<const ArtMethod*>(this); } inline bool Object::IsReferenceInstance() const { @@ -227,8 +227,8 @@ inline size_t Object::SizeOf() const { } else { result = GetClass()->GetObjectSize(); } - DCHECK(!IsField() || result == sizeof(Field)); - DCHECK(!IsMethod() || result == sizeof(AbstractMethod)); + DCHECK(!IsArtField() || result == sizeof(ArtField)); + DCHECK(!IsArtMethod() || result == sizeof(ArtMethod)); return result; } diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc index b2d6e71..92c05b2 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -16,12 +16,12 @@ #include "object.h" +#include "art_field.h" +#include "art_field-inl.h" #include "array-inl.h" #include "class.h" #include "class-inl.h" #include "class_linker-inl.h" -#include "field.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" #include "iftable-inl.h" @@ -67,7 +67,7 @@ Object* Object::Clone(Thread* self) { for (const Class* klass = c; klass != NULL; klass = klass->GetSuperClass()) { size_t num_reference_fields = klass->NumReferenceInstanceFields(); for (size_t i = 0; i < num_reference_fields; ++i) { - Field* field = klass->GetInstanceField(i); + ArtField* field = klass->GetInstanceField(i); MemberOffset field_offset = field->GetOffset(); const Object* ref = copy->GetFieldObject<const Object*>(field_offset, false); heap->WriteBarrierField(copy.get(), field_offset, ref); @@ -90,11 +90,11 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* n return; } for (const Class* cur = c; cur != NULL; cur = cur->GetSuperClass()) { - ObjectArray<Field>* fields = cur->GetIFields(); + ObjectArray<ArtField>* fields = cur->GetIFields(); if (fields != NULL) { size_t num_ref_ifields = cur->NumReferenceInstanceFields(); for (size_t i = 0; i < num_ref_ifields; ++i) { - Field* field = fields->Get(i); + ArtField* field = fields->Get(i); if (field->GetOffset().Int32Value() == field_offset.Int32Value()) { FieldHelper fh(field); CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass())); @@ -108,11 +108,11 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* n return; } if (IsClass()) { - ObjectArray<Field>* fields = AsClass()->GetSFields(); + ObjectArray<ArtField>* fields = AsClass()->GetSFields(); if (fields != NULL) { size_t num_ref_sfields = AsClass()->NumReferenceStaticFields(); for (size_t i = 0; i < num_ref_sfields; ++i) { - Field* field = fields->Get(i); + ArtField* field = fields->Get(i); if (field->GetOffset().Int32Value() == field_offset.Int32Value()) { FieldHelper fh(field); CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass())); diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index a40c906..28a91dd 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -31,10 +31,10 @@ class Thread; namespace mirror { -class AbstractMethod; +class ArtField; +class ArtMethod; class Array; class Class; -class Field; template<class T> class ObjectArray; template<class T> class PrimitiveArray; typedef PrimitiveArray<uint8_t> BooleanArray; @@ -144,17 +144,17 @@ class MANAGED Object { Throwable* AsThrowable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsMethod() const; + bool IsArtMethod() const; - AbstractMethod* AsMethod(); + ArtMethod* AsArtMethod(); - const AbstractMethod* AsMethod() const; + const ArtMethod* AsArtMethod() const; - bool IsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool IsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* AsField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* AsArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const Field* AsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const ArtField* AsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsReferenceInstance() const; diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index 8675c31..6f22618 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -20,8 +20,8 @@ #include "object_array.h" #include "gc/heap.h" +#include "mirror/art_field.h" #include "mirror/class.h" -#include "mirror/field.h" #include "runtime.h" #include "thread.h" diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index 540ff9f..814305c 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -20,6 +20,7 @@ #include <stdio.h> #include "array-inl.h" +#include "art_field-inl.h" #include "asm_support.h" #include "class-inl.h" #include "class_linker.h" @@ -27,11 +28,10 @@ #include "common_test.h" #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" #include "iftable-inl.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "object-inl.h" #include "object_array-inl.h" #include "sirt_ref.h" @@ -75,7 +75,7 @@ TEST_F(ObjectTest, AsmConstants) { ASSERT_EQ(STRING_OFFSET_OFFSET, String::OffsetOffset().Int32Value()); ASSERT_EQ(STRING_DATA_OFFSET, Array::DataOffset(sizeof(uint16_t)).Int32Value()); - ASSERT_EQ(METHOD_CODE_OFFSET, AbstractMethod::EntryPointFromCompiledCodeOffset().Int32Value()); + ASSERT_EQ(METHOD_CODE_OFFSET, ArtMethod::EntryPointFromCompiledCodeOffset().Int32Value()); } TEST_F(ObjectTest, IsInSamePackage) { @@ -204,7 +204,7 @@ TEST_F(ObjectTest, CheckAndAllocArrayFromCode) { // pretend we are trying to call 'new char[3]' from String.toCharArray ScopedObjectAccess soa(Thread::Current()); Class* java_util_Arrays = class_linker_->FindSystemClass("Ljava/util/Arrays;"); - AbstractMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V"); + ArtMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V"); const DexFile::StringId* string_id = java_lang_dex_file_->FindStringId("[I"); ASSERT_TRUE(string_id != NULL); const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId( @@ -261,7 +261,7 @@ TEST_F(ObjectTest, StaticFieldFromCode) { Class* klass = class_linker_->FindClass("LStaticsFromCode;", soa.Decode<ClassLoader*>(class_loader)); - AbstractMethod* clinit = klass->FindDirectMethod("<clinit>", "()V"); + ArtMethod* clinit = klass->FindDirectMethod("<clinit>", "()V"); const DexFile::StringId* klass_string_id = dex_file->FindStringId("LStaticsFromCode;"); ASSERT_TRUE(klass_string_id != NULL); const DexFile::TypeId* klass_type_id = dex_file->FindTypeId( @@ -282,8 +282,8 @@ TEST_F(ObjectTest, StaticFieldFromCode) { ASSERT_TRUE(field_id != NULL); uint32_t field_idx = dex_file->GetIndexForFieldId(*field_id); - Field* field = FindFieldFromCode(field_idx, clinit, Thread::Current(), StaticObjectRead, - sizeof(Object*), true); + ArtField* field = FindFieldFromCode(field_idx, clinit, Thread::Current(), StaticObjectRead, + sizeof(Object*), true); Object* s0 = field->GetObj(klass); EXPECT_TRUE(s0 != NULL); @@ -294,7 +294,7 @@ TEST_F(ObjectTest, StaticFieldFromCode) { field->SetObj(field->GetDeclaringClass(), NULL); EXPECT_EQ(NULL, field->GetObj(klass)); - // TODO: more exhaustive tests of all 6 cases of Field::*FromCode + // TODO: more exhaustive tests of all 6 cases of ArtField::*FromCode } TEST_F(ObjectTest, String) { @@ -395,29 +395,29 @@ TEST_F(ObjectTest, DescriptorCompare) { Class* klass2 = linker->FindClass("LProtoCompare2;", class_loader_2.get()); ASSERT_TRUE(klass2 != NULL); - AbstractMethod* m1_1 = klass1->GetVirtualMethod(0); + ArtMethod* m1_1 = klass1->GetVirtualMethod(0); MethodHelper mh(m1_1); EXPECT_STREQ(mh.GetName(), "m1"); - AbstractMethod* m2_1 = klass1->GetVirtualMethod(1); + ArtMethod* m2_1 = klass1->GetVirtualMethod(1); mh.ChangeMethod(m2_1); EXPECT_STREQ(mh.GetName(), "m2"); - AbstractMethod* m3_1 = klass1->GetVirtualMethod(2); + ArtMethod* m3_1 = klass1->GetVirtualMethod(2); mh.ChangeMethod(m3_1); EXPECT_STREQ(mh.GetName(), "m3"); - AbstractMethod* m4_1 = klass1->GetVirtualMethod(3); + ArtMethod* m4_1 = klass1->GetVirtualMethod(3); mh.ChangeMethod(m4_1); EXPECT_STREQ(mh.GetName(), "m4"); - AbstractMethod* m1_2 = klass2->GetVirtualMethod(0); + ArtMethod* m1_2 = klass2->GetVirtualMethod(0); mh.ChangeMethod(m1_2); EXPECT_STREQ(mh.GetName(), "m1"); - AbstractMethod* m2_2 = klass2->GetVirtualMethod(1); + ArtMethod* m2_2 = klass2->GetVirtualMethod(1); mh.ChangeMethod(m2_2); EXPECT_STREQ(mh.GetName(), "m2"); - AbstractMethod* m3_2 = klass2->GetVirtualMethod(2); + ArtMethod* m3_2 = klass2->GetVirtualMethod(2); mh.ChangeMethod(m3_2); EXPECT_STREQ(mh.GetName(), "m3"); - AbstractMethod* m4_2 = klass2->GetVirtualMethod(3); + ArtMethod* m4_2 = klass2->GetVirtualMethod(3); mh.ChangeMethod(m4_2); EXPECT_STREQ(mh.GetName(), "m4"); @@ -593,8 +593,8 @@ TEST_F(ObjectTest, FindInstanceField) { EXPECT_TRUE(c->FindInstanceField("Count", "I") == NULL); // Right name and type. - Field* f1 = c->FindDeclaredInstanceField("count", "I"); - Field* f2 = c->FindInstanceField("count", "I"); + ArtField* f1 = c->FindDeclaredInstanceField("count", "I"); + ArtField* f2 = c->FindInstanceField("count", "I"); EXPECT_TRUE(f1 != NULL); EXPECT_TRUE(f2 != NULL); EXPECT_EQ(f1, f2); @@ -626,8 +626,8 @@ TEST_F(ObjectTest, FindStaticField) { EXPECT_TRUE(c->FindStaticField("cASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;") == NULL); // Right name and type. - Field* f1 = c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); - Field* f2 = c->FindStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); + ArtField* f1 = c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); + ArtField* f2 = c->FindStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); EXPECT_TRUE(f1 != NULL); EXPECT_TRUE(f2 != NULL); EXPECT_EQ(f1, f2); diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc index 78b76dc..961f6de 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -16,7 +16,7 @@ #include "throwable.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "class-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" @@ -65,7 +65,7 @@ std::string Throwable::Dump() const { IntArray* pc_trace = down_cast<IntArray*>(method_trace->Get(depth)); MethodHelper mh; for (int32_t i = 0; i < depth; ++i) { - AbstractMethod* method = down_cast<AbstractMethod*>(method_trace->Get(i)); + ArtMethod* method = down_cast<ArtMethod*>(method_trace->Get(i)); mh.ChangeMethod(method); uint32_t dex_pc = pc_trace->Get(i); int32_t line_number = mh.GetLineNumFromDexPC(dex_pc); diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 09a952b..48c0569 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -23,7 +23,7 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "dex_instruction.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -204,7 +204,7 @@ void Monitor::Lock(Thread* self) { uint64_t waitStart = 0; uint64_t waitEnd = 0; uint32_t wait_threshold = lock_profiling_threshold_; - const mirror::AbstractMethod* current_locking_method = NULL; + const mirror::ArtMethod* current_locking_method = NULL; uint32_t current_locking_dex_pc = 0; { ScopedThreadStateChange tsc(self, kBlocked); @@ -433,7 +433,7 @@ void Monitor::WaitWithLock(Thread* self, int64_t ms, int32_t ns, int prev_lock_count = lock_count_; lock_count_ = 0; owner_ = NULL; - const mirror::AbstractMethod* saved_method = locking_method_; + const mirror::ArtMethod* saved_method = locking_method_; locking_method_ = NULL; uintptr_t saved_dex_pc = locking_dex_pc_; locking_dex_pc_ = 0; @@ -888,7 +888,7 @@ mirror::Object* Monitor::GetContendedMonitor(Thread* thread) { void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::Object*, void*), void* callback_context) { - mirror::AbstractMethod* m = stack_visitor->GetMethod(); + mirror::ArtMethod* m = stack_visitor->GetMethod(); CHECK(m != NULL); // Native methods are an easy special case. @@ -948,7 +948,7 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O } } -void Monitor::TranslateLocation(const mirror::AbstractMethod* method, uint32_t dex_pc, +void Monitor::TranslateLocation(const mirror::ArtMethod* method, uint32_t dex_pc, const char*& source_file, uint32_t& line_number) const { // If method is null, location is unknown if (method == NULL) { diff --git a/runtime/monitor.h b/runtime/monitor.h index 3b06217..02c10a7 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -56,8 +56,8 @@ namespace art { #define LW_LOCK_OWNER(x) (((x) >> LW_LOCK_OWNER_SHIFT) & LW_LOCK_OWNER_MASK) namespace mirror { -class AbstractMethod; -class Object; + class ArtMethod; + class Object; } // namespace mirror class Thread; class StackVisitor; @@ -141,7 +141,7 @@ class Monitor { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Translates the provided method and pc into its declaring class' source file and line number. - void TranslateLocation(const mirror::AbstractMethod* method, uint32_t pc, + void TranslateLocation(const mirror::ArtMethod* method, uint32_t pc, const char*& source_file, uint32_t& line_number) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -165,7 +165,7 @@ class Monitor { // Method and dex pc where the lock owner acquired the lock, used when lock // sampling is enabled. locking_method_ may be null if the lock is currently // unlocked, or if the lock is acquired by the system when the stack is empty. - const mirror::AbstractMethod* locking_method_ GUARDED_BY(monitor_lock_); + const mirror::ArtMethod* locking_method_ GUARDED_BY(monitor_lock_); uint32_t locking_dex_pc_ GUARDED_BY(monitor_lock_); friend class MonitorInfo; diff --git a/runtime/monitor_android.cc b/runtime/monitor_android.cc index 9265cd6..8efa072 100644 --- a/runtime/monitor_android.cc +++ b/runtime/monitor_android.cc @@ -78,7 +78,7 @@ void Monitor::LogContentionEvent(Thread* self, uint32_t wait_ms, uint32_t sample // Emit the source code file name, <= 37 bytes. uint32_t pc; - mirror::AbstractMethod* m = self->GetCurrentMethod(&pc); + mirror::ArtMethod* m = self->GetCurrentMethod(&pc); const char* filename; uint32_t line_number; TranslateLocation(m, pc, filename, line_number); diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc index 1a80d62..eaf67b8 100644 --- a/runtime/native/dalvik_system_VMStack.cc +++ b/runtime/native/dalvik_system_VMStack.cc @@ -16,7 +16,7 @@ #include "jni_internal.h" #include "nth_caller_visitor.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc index 9180217..85556ac 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -16,13 +16,14 @@ #include "class_linker.h" #include "jni_internal.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" +#include "well_known_classes.h" namespace art { @@ -35,7 +36,10 @@ namespace art { */ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectArray javaArgs) { ScopedObjectAccess soa(env); - mirror::AbstractMethod* m = soa.Decode<mirror::Object*>(javaMethod)->AsMethod(); + jobject art_method = soa.Env()->GetObjectField( + javaMethod, WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + + mirror::ArtMethod* m = soa.Decode<mirror::Object*>(art_method)->AsArtMethod(); mirror::Class* c = m->GetDeclaringClass(); if (UNLIKELY(c->IsAbstract())) { ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow(); diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc index b0daa91..00f89b6 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -19,16 +19,15 @@ #include "common_throws.h" #include "dex_file-inl.h" #include "jni_internal.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" namespace art { -static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirror::Field* f, +static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirror::ArtField* f, JValue& value, bool allow_references) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK_EQ(value.GetJ(), 0LL); @@ -78,7 +77,7 @@ static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirr return false; } -static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror::Field* f, +static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror::ArtField* f, mirror::Object*& class_or_rcvr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (f->IsStatic()) { @@ -96,7 +95,7 @@ static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror: static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return NULL; @@ -111,9 +110,10 @@ static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) { soa.AddLocalReference<jobject>(BoxPrimitive(FieldHelper(f).GetTypeAsPrimitiveType(), value)); } -static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char dst_descriptor) { +static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, + char dst_descriptor) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return JValue(); @@ -127,7 +127,8 @@ static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, // Widen it if necessary (and possible). JValue wide_value; - mirror::Class* dst_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor); + mirror::Class* dst_type = + Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor); if (!ConvertPrimitiveValue(NULL, false, FieldHelper(f).GetTypeAsPrimitiveType(), dst_type->GetPrimitiveType(), field_value, wide_value)) { return JValue(); @@ -167,7 +168,7 @@ static jshort Field_getShort(JNIEnv* env, jobject javaField, jobject javaObj) { return GetPrimitiveField(env, javaField, javaObj, 'S').GetS(); } -static void SetFieldValue(mirror::Object* o, mirror::Field* f, const JValue& new_value, +static void SetFieldValue(mirror::Object* o, mirror::ArtField* f, const JValue& new_value, bool allow_references) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(), @@ -221,7 +222,7 @@ static void SetFieldValue(mirror::Object* o, mirror::Field* f, const JValue& new static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); // Unbox the value, if necessary. mirror::Object* boxed_value = soa.Decode<mirror::Object*>(javaValue); @@ -242,7 +243,7 @@ static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject j static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char src_descriptor, const JValue& new_value) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return; diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc index 14dc6a4..d29de3d 100644 --- a/runtime/native/java_lang_reflect_Method.cc +++ b/runtime/native/java_lang_reflect_Method.cc @@ -16,26 +16,31 @@ #include "class_linker.h" #include "jni_internal.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" +#include "well_known_classes.h" namespace art { -static jobject Method_invoke(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { +static jobject Method_invoke(JNIEnv* env, + jobject javaMethod, jobject javaReceiver, jobject javaArgs) { ScopedObjectAccess soa(env); return InvokeMethod(soa, javaMethod, javaReceiver, javaArgs); } static jobject Method_getExceptionTypesNative(JNIEnv* env, jobject javaMethod) { ScopedObjectAccess soa(env); - mirror::AbstractMethod* proxy_method = soa.Decode<mirror::Object*>(javaMethod)->AsMethod(); + jobject art_method = soa.Env()->GetObjectField( + javaMethod, WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + + mirror::ArtMethod* proxy_method = soa.Decode<mirror::Object*>(art_method)->AsArtMethod(); CHECK(proxy_method->GetDeclaringClass()->IsProxyClass()); mirror::SynthesizedProxyClass* proxy_class = down_cast<mirror::SynthesizedProxyClass*>(proxy_method->GetDeclaringClass()); @@ -48,20 +53,14 @@ static jobject Method_getExceptionTypesNative(JNIEnv* env, jobject javaMethod) { } } CHECK_NE(throws_index, -1); - mirror::ObjectArray<mirror::Class>* declared_exceptions = proxy_class->GetThrows()->Get(throws_index); + mirror::ObjectArray<mirror::Class>* declared_exceptions = + proxy_class->GetThrows()->Get(throws_index); return soa.AddLocalReference<jobject>(declared_exceptions->Clone(soa.Self())); } -static jobject Method_findOverriddenMethodNative(JNIEnv* env, jobject javaMethod) { - ScopedObjectAccess soa(env); - mirror::AbstractMethod* method = soa.Decode<mirror::Object*>(javaMethod)->AsMethod(); - return soa.AddLocalReference<jobject>(method->FindOverriddenMethod()); -} - static JNINativeMethod gMethods[] = { NATIVE_METHOD(Method, invoke, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"), NATIVE_METHOD(Method, getExceptionTypesNative, "()[Ljava/lang/Class;"), - NATIVE_METHOD(Method, findOverriddenMethodNative, "()Ljava/lang/reflect/Method;"), }; void register_java_lang_reflect_Method(JNIEnv* env) { diff --git a/runtime/native/java_lang_reflect_Proxy.cc b/runtime/native/java_lang_reflect_Proxy.cc index 547ce7b..a92823a 100644 --- a/runtime/native/java_lang_reflect_Proxy.cc +++ b/runtime/native/java_lang_reflect_Proxy.cc @@ -31,8 +31,8 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, mirror::ObjectArray<mirror::Class>* interfaces = soa.Decode<mirror::ObjectArray<mirror::Class>*>(javaInterfaces); mirror::ClassLoader* loader = soa.Decode<mirror::ClassLoader*>(javaLoader); - mirror::ObjectArray<mirror::AbstractMethod>* methods = - soa.Decode<mirror::ObjectArray<mirror::AbstractMethod>*>(javaMethods); + mirror::ObjectArray<mirror::ArtMethod>* methods = + soa.Decode<mirror::ObjectArray<mirror::ArtMethod>*>(javaMethods); mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws = soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >*>(javaThrows); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -41,7 +41,7 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, } static JNINativeMethod gMethods[] = { - NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"), + NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/ArtMethod;[[Ljava/lang/Class;)Ljava/lang/Class;"), }; void register_java_lang_reflect_Proxy(JNIEnv* env) { diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h index e3593d8..794878a 100644 --- a/runtime/nth_caller_visitor.h +++ b/runtime/nth_caller_visitor.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_NTH_CALLER_VISITOR_H_ #define ART_RUNTIME_NTH_CALLER_VISITOR_H_ -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "locks.h" #include "stack.h" @@ -31,7 +31,7 @@ struct NthCallerVisitor : public StackVisitor { count(0), caller(NULL) {} bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); bool do_count = false; if (m == NULL || m->IsRuntimeMethod()) { // Upcall. @@ -53,7 +53,7 @@ struct NthCallerVisitor : public StackVisitor { const size_t n; const bool include_runtime_and_upcalls_; size_t count; - mirror::AbstractMethod* caller; + mirror::ArtMethod* caller; }; } // namespace art diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 93e98ad..1f34317 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -22,9 +22,9 @@ #include "base/unix_file/fd_file.h" #include "elf_file.h" #include "oat.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "os.h" #include "utils.h" @@ -453,7 +453,7 @@ uint32_t OatFile::OatMethod::GetCodeSize() const { #endif } -void OatFile::OatMethod::LinkMethod(mirror::AbstractMethod* method) const { +void OatFile::OatMethod::LinkMethod(mirror::ArtMethod* method) const { CHECK(method != NULL); method->SetEntryPointFromCompiledCode(GetCode()); method->SetFrameSizeInBytes(frame_size_in_bytes_); diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 6503014..325ebb2 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -23,7 +23,7 @@ #include "dex_file.h" #include "invoke_type.h" #include "mem_map.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "oat.h" #include "os.h" @@ -70,7 +70,7 @@ class OatFile { class OatMethod { public: - void LinkMethod(mirror::AbstractMethod* method) const; + void LinkMethod(mirror::ArtMethod* method) const; uint32_t GetCodeOffset() const { return code_offset_; diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 68595c8..74b5da9 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -15,7 +15,7 @@ */ #include "compiler/oat_writer.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -28,7 +28,7 @@ namespace art { class OatTest : public CommonTest { protected: - void CheckMethod(mirror::AbstractMethod* method, + void CheckMethod(mirror::ArtMethod* method, const OatFile::OatMethod& oat_method, const DexFile* dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/object_utils.h b/runtime/object_utils.h index 3639a80..2910243 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -20,10 +20,10 @@ #include "class_linker-inl.h" #include "dex_file.h" #include "monitor.h" -#include "mirror/abstract_method.h" +#include "mirror/art_field.h" +#include "mirror/art_method.h" #include "mirror/class.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" #include "mirror/iftable.h" #include "mirror/string.h" @@ -256,11 +256,11 @@ class ClassHelper { class FieldHelper { public: FieldHelper() : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(NULL) {} - explicit FieldHelper(const mirror::Field* f) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(f) {} - FieldHelper(const mirror::Field* f, ClassLinker* l) + explicit FieldHelper(const mirror::ArtField* f) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(f) {} + FieldHelper(const mirror::ArtField* f, ClassLinker* l) : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), field_(f) {} - void ChangeField(const mirror::Field* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void ChangeField(const mirror::ArtField* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_f != NULL); if (dex_cache_ != NULL) { mirror::DexCache* new_f_dex_cache = new_f->GetDeclaringClass()->GetDexCache(); @@ -366,7 +366,7 @@ class FieldHelper { ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; - const mirror::Field* field_; + const mirror::ArtField* field_; std::string declaring_class_descriptor_; DISALLOW_COPY_AND_ASSIGN(FieldHelper); @@ -378,21 +378,21 @@ class MethodHelper { : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) {} - explicit MethodHelper(const mirror::AbstractMethod* m) + explicit MethodHelper(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) { SetMethod(m); } - MethodHelper(const mirror::AbstractMethod* m, ClassLinker* l) + MethodHelper(const mirror::ArtMethod* m, ClassLinker* l) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) { SetMethod(m); } - void ChangeMethod(mirror::AbstractMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_m != NULL); if (dex_cache_ != NULL) { mirror::Class* klass = new_m->GetDeclaringClass(); @@ -411,7 +411,7 @@ class MethodHelper { shorty_ = NULL; } - const mirror::AbstractMethod* GetMethod() const { + const mirror::ArtMethod* GetMethod() const { return method_; } @@ -653,11 +653,11 @@ class MethodHelper { private: // Set the method_ field, for proxy methods looking up the interface method via the resolved // methods table. - void SetMethod(const mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void SetMethod(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (method != NULL) { mirror::Class* klass = method->GetDeclaringClass(); if (UNLIKELY(klass->IsProxyClass())) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex()); DCHECK(interface_method != NULL); DCHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method)); @@ -679,7 +679,7 @@ class MethodHelper { ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; - const mirror::AbstractMethod* method_; + const mirror::ArtMethod* method_; const char* shorty_; uint32_t shorty_len_; diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 8e478ff..3e58b4b 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -21,11 +21,10 @@ #include "dex_file-inl.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object_array.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -37,7 +36,7 @@ namespace art { jobject InvokeMethod(const ScopedObjectAccess& soa, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { jmethodID mid = soa.Env()->FromReflectedMethod(javaMethod); - mirror::AbstractMethod* m = soa.DecodeMethod(mid); + mirror::ArtMethod* m = soa.DecodeMethod(mid); mirror::Class* declaring_class = m->GetDeclaringClass(); if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(declaring_class, true, true)) { @@ -267,7 +266,7 @@ mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value) { return result.GetL(); } -static std::string UnboxingFailureKind(mirror::AbstractMethod* m, int index, mirror::Field* f) +static std::string UnboxingFailureKind(mirror::ArtMethod* m, int index, mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (m != NULL && index != -1) { ++index; // Humans count from 1. @@ -281,7 +280,7 @@ static std::string UnboxingFailureKind(mirror::AbstractMethod* m, int index, mir static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, int index, mirror::Field* f) + mirror::ArtMethod* m, int index, mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { bool unbox_for_result = (f == NULL) && (index == -1); if (!dst_class->IsPrimitive()) { @@ -327,7 +326,7 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* std::string src_descriptor(ClassHelper(o->GetClass()).GetDescriptor()); mirror::Class* src_class = NULL; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Field* primitive_field = o->GetClass()->GetIFields()->Get(0); + mirror::ArtField* primitive_field = o->GetClass()->GetIFields()->Get(0); if (src_descriptor == "Ljava/lang/Boolean;") { src_class = class_linker->FindPrimitiveClass('Z'); boxed_value.SetZ(primitive_field->GetBoolean(o)); @@ -367,13 +366,13 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* } bool UnboxPrimitiveForArgument(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, size_t index) { + mirror::ArtMethod* m, size_t index) { CHECK(m != NULL); return UnboxPrimitive(NULL, o, dst_class, unboxed_value, m, index, NULL); } bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::Field* f) { + mirror::ArtField* f) { CHECK(f != NULL); return UnboxPrimitive(NULL, o, dst_class, unboxed_value, NULL, -1, f); } diff --git a/runtime/reflection.h b/runtime/reflection.h index 56ab471..13c90af 100644 --- a/runtime/reflection.h +++ b/runtime/reflection.h @@ -22,10 +22,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class Class; -class Field; -class Object; + class ArtField; + class ArtMethod; + class Class; + class Object; } // namespace mirror union JValue; class ScopedObjectAccess; @@ -34,10 +34,10 @@ class ThrowLocation; mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForArgument(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, size_t index) + mirror::ArtMethod* m, size_t index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::Field* f) + mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForResult(const ThrowLocation& throw_location, mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value) diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 70d8816..7b12870 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -42,12 +42,11 @@ #include "intern_table.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/throwable.h" #include "monitor.h" #include "oat_file.h" @@ -654,7 +653,7 @@ static void CreateSystemClassLoader() { soa.Decode<mirror::Class*>(WellKnownClasses::java_lang_ClassLoader); CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(class_loader_class, true, true)); - mirror::AbstractMethod* getSystemClassLoader = + mirror::ArtMethod* getSystemClassLoader = class_loader_class->FindDirectMethod("getSystemClassLoader", "()Ljava/lang/ClassLoader;"); CHECK(getSystemClassLoader != NULL); @@ -669,8 +668,8 @@ static void CreateSystemClassLoader() { mirror::Class* thread_class = soa.Decode<mirror::Class*>(WellKnownClasses::java_lang_Thread); CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(thread_class, true, true)); - mirror::Field* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader", - "Ljava/lang/ClassLoader;"); + mirror::ArtField* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader", + "Ljava/lang/ClassLoader;"); CHECK(contextClassLoader != NULL); contextClassLoader->SetObject(soa.Self()->GetPeer(), class_loader); @@ -1125,11 +1124,11 @@ void Runtime::VisitRoots(RootVisitor* visitor, void* arg, bool only_dirty, bool VisitNonConcurrentRoots(visitor, arg); } -mirror::AbstractMethod* Runtime::CreateResolutionMethod() { - mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass(); +mirror::ArtMethod* Runtime::CreateResolutionMethod() { + mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod(); Thread* self = Thread::Current(); - SirtRef<mirror::AbstractMethod> - method(self, down_cast<mirror::AbstractMethod*>(method_class->AllocObject(self))); + SirtRef<mirror::ArtMethod> + method(self, down_cast<mirror::ArtMethod*>(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for resolution method saves method->SetDexMethodIndex(DexFile::kDexNoIndex16); @@ -1140,12 +1139,12 @@ mirror::AbstractMethod* Runtime::CreateResolutionMethod() { return method.get(); } -mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set, +mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set, CalleeSaveType type) { - mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass(); + mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod(); Thread* self = Thread::Current(); - SirtRef<mirror::AbstractMethod> - method(self, down_cast<mirror::AbstractMethod*>(method_class->AllocObject(self))); + SirtRef<mirror::ArtMethod> + method(self, down_cast<mirror::ArtMethod*>(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for callee saves method->SetDexMethodIndex(DexFile::kDexNoIndex16); @@ -1205,7 +1204,7 @@ mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instructi return method.get(); } -void Runtime::SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type) { +void Runtime::SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type) { DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastCalleeSaveType)); callee_save_methods_[type] = method; } diff --git a/runtime/runtime.h b/runtime/runtime.h index d67265a..b93ae9d 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -43,7 +43,7 @@ namespace gc { class Heap; } namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; template<class T> class PrimitiveArray; typedef PrimitiveArray<int8_t> ByteArray; @@ -310,7 +310,7 @@ class Runtime { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns a special method that calls into a trampoline for runtime method resolution - mirror::AbstractMethod* GetResolutionMethod() const { + mirror::ArtMethod* GetResolutionMethod() const { CHECK(HasResolutionMethod()); return resolution_method_; } @@ -319,11 +319,11 @@ class Runtime { return resolution_method_ != NULL; } - void SetResolutionMethod(mirror::AbstractMethod* method) { + void SetResolutionMethod(mirror::ArtMethod* method) { resolution_method_ = method; } - mirror::AbstractMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns a special method that describes all callee saves being spilled to the stack. enum CalleeSaveType { @@ -337,21 +337,21 @@ class Runtime { return callee_save_methods_[type] != NULL; } - mirror::AbstractMethod* GetCalleeSaveMethod(CalleeSaveType type) const { + mirror::ArtMethod* GetCalleeSaveMethod(CalleeSaveType type) const { DCHECK(HasCalleeSaveMethod(type)); return callee_save_methods_[type]; } - void SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type); + void SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type); - mirror::AbstractMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, + mirror::ArtMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) + mirror::ArtMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) + mirror::ArtMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); int32_t GetStat(int kind); @@ -451,9 +451,9 @@ class Runtime { mirror::Throwable* pre_allocated_OutOfMemoryError_; - mirror::AbstractMethod* callee_save_methods_[kLastCalleeSaveType]; + mirror::ArtMethod* callee_save_methods_[kLastCalleeSaveType]; - mirror::AbstractMethod* resolution_method_; + mirror::ArtMethod* resolution_method_; // As returned by ClassLoader.getSystemClassLoader() mirror::ClassLoader* system_class_loader_; diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h index 965e6b8..5f649b1 100644 --- a/runtime/scoped_thread_state_change.h +++ b/runtime/scoped_thread_state_change.h @@ -204,7 +204,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { return down_cast<T>(Self()->DecodeJObject(obj)); } - mirror::Field* DecodeField(jfieldID fid) const + mirror::ArtField* DecodeField(jfieldID fid) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -214,10 +214,10 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { // TODO: we should make these unique weak globals if Field instances can ever move. UNIMPLEMENTED(WARNING); #endif - return reinterpret_cast<mirror::Field*>(fid); + return reinterpret_cast<mirror::ArtField*>(fid); } - jfieldID EncodeField(mirror::Field* field) const + jfieldID EncodeField(mirror::ArtField* field) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -229,7 +229,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { return reinterpret_cast<jfieldID>(field); } - mirror::AbstractMethod* DecodeMethod(jmethodID mid) const + mirror::ArtMethod* DecodeMethod(jmethodID mid) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -239,10 +239,10 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { // TODO: we should make these unique weak globals if Method instances can ever move. UNIMPLEMENTED(WARNING); #endif - return reinterpret_cast<mirror::AbstractMethod*>(mid); + return reinterpret_cast<mirror::ArtMethod*>(mid); } - jmethodID EncodeMethod(mirror::AbstractMethod* method) const + jmethodID EncodeMethod(mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Locks::mutator_lock_->AssertSharedHeld(Self()); DCHECK_EQ(thread_state_, kRunnable); // Don't work with raw objects in non-runnable states. diff --git a/runtime/stack.cc b/runtime/stack.cc index e1a752a..206bff3 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -16,7 +16,7 @@ #include "stack.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" @@ -29,7 +29,7 @@ namespace art { mirror::Object* ShadowFrame::GetThisObject() const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else if (m->IsNative()) { @@ -43,7 +43,7 @@ mirror::Object* ShadowFrame::GetThisObject() const { } mirror::Object* ShadowFrame::GetThisObject(uint16_t num_ins) const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else { @@ -101,7 +101,7 @@ uint32_t StackVisitor::GetDexPc() const { } mirror::Object* StackVisitor::GetThisObject() const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else if (m->IsNative()) { @@ -132,7 +132,7 @@ size_t StackVisitor::GetNativePcOffset() const { return GetMethod()->NativePcOffset(cur_quick_frame_pc_); } -uint32_t StackVisitor::GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKind kind) const { +uint32_t StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably read registers without a context. DCHECK(m == GetMethod()); @@ -156,7 +156,7 @@ uint32_t StackVisitor::GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKin } } -void StackVisitor::SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t new_value, +void StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably write registers without a context. @@ -195,14 +195,14 @@ void StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { } uintptr_t StackVisitor::GetReturnPc() const { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); DCHECK(sp != NULL); byte* pc_addr = reinterpret_cast<byte*>(sp) + GetMethod()->GetReturnPcOffsetInBytes(); return *reinterpret_cast<uintptr_t*>(pc_addr); } void StackVisitor::SetReturnPc(uintptr_t new_ret_pc) { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); CHECK(sp != NULL); byte* pc_addr = reinterpret_cast<byte*>(sp) + GetMethod()->GetReturnPcOffsetInBytes(); *reinterpret_cast<uintptr_t*>(pc_addr) = new_ret_pc; @@ -241,7 +241,7 @@ void StackVisitor::DescribeStack(Thread* thread) { std::string StackVisitor::DescribeLocation() const { std::string result("Visiting method '"); - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m == NULL) { return "upcall"; } @@ -259,9 +259,8 @@ instrumentation::InstrumentationStackFrame StackVisitor::GetInstrumentationStack void StackVisitor::SanityCheckFrame() const { #ifndef NDEBUG - mirror::AbstractMethod* method = GetMethod(); - CHECK(method->GetClass() == mirror::AbstractMethod::GetMethodClass() || - method->GetClass() == mirror::AbstractMethod::GetConstructorClass()); + mirror::ArtMethod* method = GetMethod(); + CHECK(method->GetClass() == mirror::ArtMethod::GetJavaLangReflectArtMethod()); if (cur_quick_frame_ != NULL) { method->AssertPcIsWithinCode(cur_quick_frame_pc_); // Frame sanity. @@ -291,7 +290,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (cur_quick_frame_ != NULL) { // Handle quick stack frames. // Can't be both a shadow and a quick fragment. DCHECK(current_fragment->GetTopShadowFrame() == NULL); - mirror::AbstractMethod* method = *cur_quick_frame_; + mirror::ArtMethod* method = *cur_quick_frame_; while (method != NULL) { SanityCheckFrame(); bool should_continue = VisitFrame(); @@ -316,7 +315,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (GetMethod() == Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveAll)) { // Skip runtime save all callee frames which are used to deliver exceptions. } else if (instrumentation_frame.interpreter_entry_) { - mirror::AbstractMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); + mirror::ArtMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: " << PrettyMethod(GetMethod()); } else if (instrumentation_frame.method_ != GetMethod()) { @@ -335,7 +334,7 @@ void StackVisitor::WalkStack(bool include_transitions) { } cur_quick_frame_pc_ = return_pc; byte* next_frame = reinterpret_cast<byte*>(cur_quick_frame_) + frame_size; - cur_quick_frame_ = reinterpret_cast<mirror::AbstractMethod**>(next_frame); + cur_quick_frame_ = reinterpret_cast<mirror::ArtMethod**>(next_frame); cur_depth_++; method = *cur_quick_frame_; } diff --git a/runtime/stack.h b/runtime/stack.h index 388e401..8ecf8f0 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -28,8 +28,8 @@ namespace art { namespace mirror { -class AbstractMethod; -class Object; + class ArtMethod; + class Object; } // namespace mirror class Context; @@ -66,7 +66,7 @@ class ShadowFrame { // Create ShadowFrame in heap for deoptimization. static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, - mirror::AbstractMethod* method, uint32_t dex_pc) { + mirror::ArtMethod* method, uint32_t dex_pc) { uint8_t* memory = new uint8_t[ComputeSize(num_vregs)]; ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); return sf; @@ -74,7 +74,7 @@ class ShadowFrame { // Create ShadowFrame for interpreter using provided memory. static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, - mirror::AbstractMethod* method, uint32_t dex_pc, void* memory) { + mirror::ArtMethod* method, uint32_t dex_pc, void* memory) { ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); return sf; } @@ -195,7 +195,7 @@ class ShadowFrame { } } - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { DCHECK_NE(method_, static_cast<void*>(NULL)); return method_; } @@ -206,7 +206,7 @@ class ShadowFrame { ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetMethod(mirror::AbstractMethod* method) { + void SetMethod(mirror::ArtMethod* method) { #if defined(ART_USE_PORTABLE_COMPILER) DCHECK_NE(method, static_cast<void*>(NULL)); method_ = method; @@ -248,7 +248,7 @@ class ShadowFrame { } private: - ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::AbstractMethod* method, + ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method, uint32_t dex_pc, bool has_reference_array) : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) { if (has_reference_array) { @@ -285,9 +285,9 @@ class ShadowFrame { ShadowFrame* link_; #if defined(ART_USE_PORTABLE_COMPILER) // TODO: make const in the portable case. - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; #else - mirror::AbstractMethod* const method_; + mirror::ArtMethod* const method_; #endif uint32_t dex_pc_; uint32_t vregs_[0]; @@ -323,11 +323,11 @@ class PACKED(4) ManagedStack { return link_; } - mirror::AbstractMethod** GetTopQuickFrame() const { + mirror::ArtMethod** GetTopQuickFrame() const { return top_quick_frame_; } - void SetTopQuickFrame(mirror::AbstractMethod** top) { + void SetTopQuickFrame(mirror::ArtMethod** top) { DCHECK(top_shadow_frame_ == NULL); top_quick_frame_ = top; } @@ -385,7 +385,7 @@ class PACKED(4) ManagedStack { private: ManagedStack* link_; ShadowFrame* top_shadow_frame_; - mirror::AbstractMethod** top_quick_frame_; + mirror::ArtMethod** top_quick_frame_; uintptr_t top_quick_frame_pc_; }; @@ -402,7 +402,7 @@ class StackVisitor { void WalkStack(bool include_transitions = false) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { if (cur_shadow_frame_ != NULL) { return cur_shadow_frame_->GetMethod(); } else if (cur_quick_frame_ != NULL) { @@ -450,16 +450,16 @@ class StackVisitor { return num_frames_; } - uint32_t GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKind kind) const + uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) + void SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uintptr_t GetGPR(uint32_t reg) const; void SetGPR(uint32_t reg, uintptr_t value); - uint32_t GetVReg(mirror::AbstractMethod** cur_quick_frame, const DexFile::CodeItem* code_item, + uint32_t GetVReg(mirror::ArtMethod** cur_quick_frame, const DexFile::CodeItem* code_item, uint32_t core_spills, uint32_t fp_spills, size_t frame_size, uint16_t vreg) const { int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg); @@ -533,7 +533,7 @@ class StackVisitor { return cur_quick_frame_pc_; } - mirror::AbstractMethod** GetCurrentQuickFrame() const { + mirror::ArtMethod** GetCurrentQuickFrame() const { return cur_quick_frame_; } @@ -542,7 +542,7 @@ class StackVisitor { } StackIndirectReferenceTable* GetCurrentSirt() const { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); ++sp; // Skip Method*; SIRT comes next; return reinterpret_cast<StackIndirectReferenceTable*>(sp); } @@ -560,7 +560,7 @@ class StackVisitor { Thread* const thread_; ShadowFrame* cur_shadow_frame_; - mirror::AbstractMethod** cur_quick_frame_; + mirror::ArtMethod** cur_quick_frame_; uintptr_t cur_quick_frame_pc_; // Lazily computed, number of frames in the stack. size_t num_frames_; diff --git a/runtime/thread.cc b/runtime/thread.cc index 07a003d..7e3afb5 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -45,10 +45,10 @@ #include "gc/space/space.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" #include "mirror/object_array-inl.h" #include "mirror/stack_trace_element.h" #include "monitor.h" @@ -168,7 +168,7 @@ void* Thread::CreateCallback(void* arg) { // Invoke the 'run' method of our java.lang.Thread. mirror::Object* receiver = self->opeer_; jmethodID mid = WellKnownClasses::java_lang_Thread_run; - mirror::AbstractMethod* m = + mirror::ArtMethod* m = receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(soa.DecodeMethod(mid)); JValue result; ArgArray arg_array(NULL, 0); @@ -183,7 +183,7 @@ void* Thread::CreateCallback(void* arg) { Thread* Thread::FromManagedThread(const ScopedObjectAccessUnchecked& soa, mirror::Object* thread_peer) { - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_nativePeer); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_nativePeer); Thread* result = reinterpret_cast<Thread*>(static_cast<uintptr_t>(f->GetInt(thread_peer))); // Sanity check that if we have a result it is either suspended or we hold the thread_list_lock_ // to stop it from going away. @@ -488,7 +488,7 @@ void Thread::Dump(std::ostream& os) const { } mirror::String* Thread::GetThreadName(const ScopedObjectAccessUnchecked& soa) const { - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); return (opeer_ != NULL) ? reinterpret_cast<mirror::String*>(f->GetObject(opeer_)) : NULL; } @@ -678,7 +678,7 @@ void Thread::DumpState(std::ostream& os, const Thread* thread, pid_t tid) { soa.DecodeField(WellKnownClasses::java_lang_Thread_group)->GetObject(thread->opeer_); if (thread_group != NULL) { - mirror::Field* group_name_field = + mirror::ArtField* group_name_field = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_name); mirror::String* group_name_string = reinterpret_cast<mirror::String*>(group_name_field->GetObject(thread_group)); @@ -776,7 +776,7 @@ struct StackDumpVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { return true; } @@ -831,7 +831,7 @@ struct StackDumpVisitor : public StackVisitor { const Thread* thread; const bool can_allocate; MethodHelper mh; - mirror::AbstractMethod* last_method; + mirror::ArtMethod* last_method; int last_line_number; int repetition_count; int frame_count; @@ -855,7 +855,7 @@ static bool ShouldShowNativeStack(const Thread* thread) // We don't just check kNative because native methods will be in state kSuspended if they're // calling back into the VM, or kBlocked if they're blocked on a monitor, or one of the // thread-startup states if it's early enough in their life cycle (http://b/7432159). - mirror::AbstractMethod* current_method = thread->GetCurrentMethod(NULL); + mirror::ArtMethod* current_method = thread->GetCurrentMethod(NULL); return current_method != NULL && current_method->IsNative(); } @@ -1238,7 +1238,7 @@ class CountStackDepthVisitor : public StackVisitor { // We want to skip frames up to and including the exception's constructor. // Note we also skip the frame if it doesn't have a method (namely the callee // save frame) - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (skipping_ && !m->IsRuntimeMethod() && !mirror::Throwable::GetJavaLangThrowable()->IsAssignableFrom(m->GetDeclaringClass())) { skipping_ = false; @@ -1313,7 +1313,7 @@ class BuildInternalStackTraceVisitor : public StackVisitor { skip_depth_--; return true; } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { return true; // Ignore runtime frames (in particular callee save). } @@ -1398,7 +1398,7 @@ jobjectArray Thread::InternalStackTraceToStackTraceElementArray(JNIEnv* env, job MethodHelper mh; for (int32_t i = 0; i < depth; ++i) { // Prepare parameters for StackTraceElement(String cls, String method, String file, int line) - mirror::AbstractMethod* method = down_cast<mirror::AbstractMethod*>(method_trace->Get(i)); + mirror::ArtMethod* method = down_cast<mirror::ArtMethod*>(method_trace->Get(i)); mh.ChangeMethod(method); uint32_t dex_pc = pc_trace->Get(i); int32_t line_number = mh.GetLineNumFromDexPC(dex_pc); @@ -1472,7 +1472,7 @@ void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location, DCHECK_EQ(this, Thread::Current()); // Ensure we don't forget arguments over object allocation. SirtRef<mirror::Object> saved_throw_this(this, throw_location.GetThis()); - SirtRef<mirror::AbstractMethod> saved_throw_method(this, throw_location.GetMethod()); + SirtRef<mirror::ArtMethod> saved_throw_method(this, throw_location.GetMethod()); // Ignore the cause throw location. TODO: should we report this as a re-throw? SirtRef<mirror::Throwable> cause(this, GetException(NULL)); ClearException(); @@ -1520,7 +1520,7 @@ void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location, signature = "(Ljava/lang/Throwable;)V"; } } - mirror::AbstractMethod* exception_init_method = + mirror::ArtMethod* exception_init_method = exception_class->FindDeclaredDirectMethod("<init>", signature); CHECK(exception_init_method != NULL) << "No <init>" << signature << " in " @@ -1740,7 +1740,7 @@ class CatchBlockStackVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = GetMethod(); + mirror::ArtMethod* method = GetMethod(); if (method == NULL) { // This is the upcall, we remember the frame and last pc so that we may long jump to them. handler_quick_frame_pc_ = GetCurrentQuickFramePc(); @@ -1764,7 +1764,7 @@ class CatchBlockStackVisitor : public StackVisitor { } } - bool HandleTryItems(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + bool HandleTryItems(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t dex_pc = DexFile::kDexNoIndex; if (method->IsNative()) { native_method_count_++; @@ -1783,7 +1783,7 @@ class CatchBlockStackVisitor : public StackVisitor { return true; // Continue stack walk. } - bool HandleDeoptimization(mirror::AbstractMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + bool HandleDeoptimization(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); const DexFile::CodeItem* code_item = mh.GetCodeItem(); CHECK(code_item != NULL); @@ -1825,7 +1825,7 @@ class CatchBlockStackVisitor : public StackVisitor { } void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* catch_method = *handler_quick_frame_; + mirror::ArtMethod* catch_method = *handler_quick_frame_; if (catch_method == NULL) { if (kDebugExceptionDelivery) { LOG(INFO) << "Handler is upcall"; @@ -1880,7 +1880,7 @@ class CatchBlockStackVisitor : public StackVisitor { // Location of the throw. const ThrowLocation& throw_location_; // Quick frame with found handler or last frame if no handler found. - mirror::AbstractMethod** handler_quick_frame_; + mirror::ArtMethod** handler_quick_frame_; // PC to branch to for the handler. uintptr_t handler_quick_frame_pc_; // Associated dex PC. @@ -1940,7 +1940,7 @@ struct CurrentMethodVisitor : public StackVisitor { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : StackVisitor(thread, context), this_object_(NULL), method_(NULL), dex_pc_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { // Continue if this is a runtime method. return true; @@ -1953,11 +1953,11 @@ struct CurrentMethodVisitor : public StackVisitor { return false; } mirror::Object* this_object_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; uint32_t dex_pc_; }; -mirror::AbstractMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const { +mirror::ArtMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const { CurrentMethodVisitor visitor(const_cast<Thread*>(this), NULL); visitor.WalkStack(false); if (dex_pc != NULL) { @@ -1996,7 +1996,7 @@ class ReferenceMapVisitor : public StackVisitor { } ShadowFrame* shadow_frame = GetCurrentShadowFrame(); if (shadow_frame != NULL) { - mirror::AbstractMethod* m = shadow_frame->GetMethod(); + mirror::ArtMethod* m = shadow_frame->GetMethod(); size_t num_regs = shadow_frame->NumberOfVRegs(); if (m->IsNative() || shadow_frame->HasReferenceArray()) { // SIRT for JNI or References for interpreter. @@ -2030,7 +2030,7 @@ class ReferenceMapVisitor : public StackVisitor { } } } else { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); // Process register map (which native and runtime methods don't have) if (!m->IsNative() && !m->IsRuntimeMethod() && !m->IsProxyMethod()) { const uint8_t* native_gc_map = m->GetNativeGcMap(); @@ -2049,7 +2049,7 @@ class ReferenceMapVisitor : public StackVisitor { uint32_t fp_spills = m->GetFpSpillMask(); size_t frame_size = m->GetFrameSizeInBytes(); // For all dex registers in the bitmap - mirror::AbstractMethod** cur_quick_frame = GetCurrentQuickFrame(); + mirror::ArtMethod** cur_quick_frame = GetCurrentQuickFrame(); DCHECK(cur_quick_frame != NULL); for (size_t reg = 0; reg < num_regs; ++reg) { // Does this register hold a reference? @@ -2164,7 +2164,7 @@ void Thread::VerifyRoots(VerifyRootVisitor* visitor, void* arg) { if (this_object != NULL) { VerifyRootWrapperCallback(this_object, &wrapperArg); } - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; VerifyRootWrapperCallback(method, &wrapperArg); } } @@ -2199,7 +2199,7 @@ void Thread::VisitRoots(RootVisitor* visitor, void* arg) { if (this_object != NULL) { visitor(this_object, arg); } - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; visitor(method, arg); } } diff --git a/runtime/thread.h b/runtime/thread.h index 8b6771e..b9b93dd 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -45,7 +45,7 @@ namespace art { namespace mirror { - class AbstractMethod; + class ArtMethod; class Array; class Class; class ClassLoader; @@ -318,13 +318,13 @@ class PACKED(4) Thread { long_jump_context_ = context; } - mirror::AbstractMethod* GetCurrentMethod(uint32_t* dex_pc) const + mirror::ArtMethod* GetCurrentMethod(uint32_t* dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ThrowLocation GetCurrentLocationForThrow() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void SetTopOfStack(void* stack, uintptr_t pc) { - mirror::AbstractMethod** top_method = reinterpret_cast<mirror::AbstractMethod**>(stack); + mirror::ArtMethod** top_method = reinterpret_cast<mirror::ArtMethod**>(stack); managed_stack_.SetTopQuickFrame(top_method); managed_stack_.SetTopQuickFramePc(pc); } diff --git a/runtime/throw_location.cc b/runtime/throw_location.cc index 84d2c9b..6d1ca1b 100644 --- a/runtime/throw_location.cc +++ b/runtime/throw_location.cc @@ -16,7 +16,7 @@ #include "throw_location.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" diff --git a/runtime/throw_location.h b/runtime/throw_location.h index b2cd4d5..5da446e 100644 --- a/runtime/throw_location.h +++ b/runtime/throw_location.h @@ -26,7 +26,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Object; } // mirror @@ -36,7 +36,7 @@ class PACKED(4) ThrowLocation { Clear(); } - ThrowLocation(mirror::Object* throw_this_object, mirror::AbstractMethod* throw_method, + ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method, uint32_t throw_dex_pc) : this_object_(throw_this_object), method_(throw_method), @@ -46,7 +46,7 @@ class PACKED(4) ThrowLocation { return this_object_; } - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { return method_; } @@ -68,7 +68,7 @@ class PACKED(4) ThrowLocation { // The 'this' reference of the throwing method. mirror::Object* this_object_; // The throwing method. - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; // The instruction within the throwing method. uint32_t dex_pc_; }; diff --git a/runtime/trace.cc b/runtime/trace.cc index 2bce70f..84df6a9 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -24,7 +24,7 @@ #include "debugger.h" #include "dex_file-inl.h" #include "instrumentation.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" #include "mirror/object_array-inl.h" @@ -98,15 +98,15 @@ ProfilerClockSource Trace::default_clock_source_ = kProfilerClockSourceWall; Trace* Trace::the_trace_ = NULL; -static mirror::AbstractMethod* DecodeTraceMethodId(uint32_t tmid) { - return reinterpret_cast<mirror::AbstractMethod*>(tmid & ~kTraceMethodActionMask); +static mirror::ArtMethod* DecodeTraceMethodId(uint32_t tmid) { + return reinterpret_cast<mirror::ArtMethod*>(tmid & ~kTraceMethodActionMask); } static TraceAction DecodeTraceAction(uint32_t tmid) { return static_cast<TraceAction>(tmid & kTraceMethodActionMask); } -static uint32_t EncodeTraceMethodAndAction(const mirror::AbstractMethod* method, +static uint32_t EncodeTraceMethodAndAction(const mirror::ArtMethod* method, TraceAction action) { uint32_t tmid = reinterpret_cast<uint32_t>(method) | action; DCHECK_EQ(method, DecodeTraceMethodId(tmid)); @@ -311,7 +311,7 @@ static void DumpBuf(uint8_t* buf, size_t buf_size, ProfilerClockSource clock_sou while (ptr < end) { uint32_t tmid = ptr[2] | (ptr[3] << 8) | (ptr[4] << 16) | (ptr[5] << 24); - mirror::AbstractMethod* method = DecodeTraceMethodId(tmid); + mirror::ArtMethod* method = DecodeTraceMethodId(tmid); TraceAction action = DecodeTraceAction(tmid); LOG(INFO) << PrettyMethod(method) << " " << static_cast<int>(action); ptr += GetRecordSize(clock_source); @@ -329,7 +329,7 @@ void Trace::FinishTracing() { Runtime::Current()->SetStatsEnabled(false); } - std::set<mirror::AbstractMethod*> visited_methods; + std::set<mirror::ArtMethod*> visited_methods; GetVisitedMethods(final_offset, &visited_methods); std::ostringstream os; @@ -386,35 +386,35 @@ void Trace::FinishTracing() { } void Trace::DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) { + const mirror::ArtMethod* method, uint32_t new_dex_pc) { // We're not recorded to listen to this kind of event, so complain. LOG(ERROR) << "Unexpected dex PC event in tracing " << PrettyMethod(method) << " " << new_dex_pc; }; void Trace::MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) { + const mirror::ArtMethod* method, uint32_t dex_pc) { LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodEntered); } void Trace::MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) { UNUSED(return_value); LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodExited); } -void Trace::MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, uint32_t dex_pc) { +void Trace::MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) { LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodUnwind); } void Trace::ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { LOG(ERROR) << "Unexpected exception caught event in tracing"; } -void Trace::LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* method, +void Trace::LogMethodTraceEvent(Thread* thread, const mirror::ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event) { // Advance cur_offset_ atomically. int32_t new_offset; @@ -473,24 +473,24 @@ void Trace::LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* me } void Trace::GetVisitedMethods(size_t buf_size, - std::set<mirror::AbstractMethod*>* visited_methods) { + std::set<mirror::ArtMethod*>* visited_methods) { uint8_t* ptr = buf_.get() + kTraceHeaderLength; uint8_t* end = buf_.get() + buf_size; while (ptr < end) { uint32_t tmid = ptr[2] | (ptr[3] << 8) | (ptr[4] << 16) | (ptr[5] << 24); - mirror::AbstractMethod* method = DecodeTraceMethodId(tmid); + mirror::ArtMethod* method = DecodeTraceMethodId(tmid); visited_methods->insert(method); ptr += GetRecordSize(clock_source_); } } void Trace::DumpMethodList(std::ostream& os, - const std::set<mirror::AbstractMethod*>& visited_methods) { - typedef std::set<mirror::AbstractMethod*>::const_iterator It; // TODO: C++0x auto + const std::set<mirror::ArtMethod*>& visited_methods) { + typedef std::set<mirror::ArtMethod*>::const_iterator It; // TODO: C++0x auto MethodHelper mh; for (It it = visited_methods.begin(); it != visited_methods.end(); ++it) { - mirror::AbstractMethod* method = *it; + mirror::ArtMethod* method = *it; mh.ChangeMethod(method); os << StringPrintf("%p\t%s\t%s\t%s\t%s\n", method, PrettyDescriptor(mh.GetDeclaringClassDescriptor()).c_str(), mh.GetName(), diff --git a/runtime/trace.h b/runtime/trace.h index bd9c140..ae583ca 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -31,7 +31,7 @@ namespace art { namespace mirror { -class AbstractMethod; + class ArtMethod; } // namespace mirror class Thread; @@ -63,19 +63,19 @@ class Trace : public instrumentation::InstrumentationListener { bool UseThreadCpuClock(); virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, uint32_t dex_pc) + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -84,12 +84,12 @@ class Trace : public instrumentation::InstrumentationListener { void FinishTracing() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* method, + void LogMethodTraceEvent(Thread* thread, const mirror::ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event); // Methods to output traced methods and threads. - void GetVisitedMethods(size_t end_offset, std::set<mirror::AbstractMethod*>* visited_methods); - void DumpMethodList(std::ostream& os, const std::set<mirror::AbstractMethod*>& visited_methods) + void GetVisitedMethods(size_t end_offset, std::set<mirror::ArtMethod*>* visited_methods); + void DumpMethodList(std::ostream& os, const std::set<mirror::ArtMethod*>& visited_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DumpThreadList(std::ostream& os) LOCKS_EXCLUDED(Locks::thread_list_lock_); diff --git a/runtime/utils.cc b/runtime/utils.cc index 71e502d..87cd21c 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -25,11 +25,10 @@ #include "UniquePtr.h" #include "base/unix_file/fd_file.h" #include "dex_file-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/string.h" @@ -295,7 +294,7 @@ std::string PrettyDescriptor(Primitive::Type type) { return PrettyDescriptor(descriptor_string); } -std::string PrettyField(const mirror::Field* f, bool with_type) { +std::string PrettyField(const mirror::ArtField* f, bool with_type) { if (f == NULL) { return "null"; } @@ -370,7 +369,7 @@ std::string PrettyReturnType(const char* signature) { return PrettyDescriptor(return_type); } -std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature) { +std::string PrettyMethod(const mirror::ArtMethod* m, bool with_signature) { if (m == NULL) { return "null"; } @@ -629,7 +628,7 @@ std::string DescriptorToName(const char* descriptor) { return descriptor; } -std::string JniShortName(const mirror::AbstractMethod* m) { +std::string JniShortName(const mirror::ArtMethod* m) { MethodHelper mh(m); std::string class_name(mh.GetDeclaringClassDescriptor()); // Remove the leading 'L' and trailing ';'... @@ -648,7 +647,7 @@ std::string JniShortName(const mirror::AbstractMethod* m) { return short_name; } -std::string JniLongName(const mirror::AbstractMethod* m) { +std::string JniLongName(const mirror::ArtMethod* m) { std::string long_name; long_name += JniShortName(m); long_name += "__"; diff --git a/runtime/utils.h b/runtime/utils.h index 1c45048..9e724d0 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -33,9 +33,9 @@ namespace art { class DexFile; namespace mirror { +class ArtField; +class ArtMethod; class Class; -class Field; -class AbstractMethod; class Object; class String; } // namespace mirror @@ -195,13 +195,13 @@ std::string PrettyDescriptor(const mirror::Class* klass) // Returns a human-readable signature for 'f'. Something like "a.b.C.f" or // "int a.b.C.f" (depending on the value of 'with_type'). -std::string PrettyField(const mirror::Field* f, bool with_type = true) +std::string PrettyField(const mirror::ArtField* f, bool with_type = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_type = true); // Returns a human-readable signature for 'm'. Something like "a.b.C.m" or // "a.b.C.m(II)V" (depending on the value of 'with_signature'). -std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature = true) +std::string PrettyMethod(const mirror::ArtMethod* m, bool with_signature = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature = true); @@ -265,10 +265,10 @@ bool IsValidDescriptor(const char* s); // "Ljava/lang/String;" bool IsValidMemberName(const char* s); // Returns the JNI native function name for the non-overloaded method 'm'. -std::string JniShortName(const mirror::AbstractMethod* m) +std::string JniShortName(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the JNI native function name for the overloaded method 'm'. -std::string JniLongName(const mirror::AbstractMethod* m) +std::string JniLongName(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool ReadFileToString(const std::string& file_name, std::string* result); diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc index 0966e71..2633964 100644 --- a/runtime/utils_test.cc +++ b/runtime/utils_test.cc @@ -130,7 +130,7 @@ TEST_F(UtilsTest, PrettyField) { mirror::Class* java_lang_String = class_linker_->FindSystemClass("Ljava/lang/String;"); - mirror::Field* f; + mirror::ArtField* f; f = java_lang_String->FindDeclaredInstanceField("count", "I"); EXPECT_EQ("int java.lang.String.count", PrettyField(f)); EXPECT_EQ("java.lang.String.count", PrettyField(f, false)); @@ -199,7 +199,7 @@ TEST_F(UtilsTest, JniShortName_JniLongName) { ScopedObjectAccess soa(Thread::Current()); mirror::Class* c = class_linker_->FindSystemClass("Ljava/lang/String;"); ASSERT_TRUE(c != NULL); - mirror::AbstractMethod* m; + mirror::ArtMethod* m; m = c->FindVirtualMethod("charAt", "(I)C"); ASSERT_TRUE(m != NULL); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index fc595d9..0216844 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -29,11 +29,11 @@ #include "indenter.h" #include "intern_table.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -139,7 +139,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, } previous_direct_method_idx = method_idx; InvokeType type = it.GetMethodInvokeType(class_def); - mirror::AbstractMethod* method = + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -181,7 +181,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, } previous_virtual_method_idx = method_idx; InvokeType type = it.GetMethodInvokeType(class_def); - mirror::AbstractMethod* method = + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -225,7 +225,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) { MethodVerifier::FailureKind result = kNoFailure; @@ -266,7 +266,7 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t method_access_flags) { MethodVerifier verifier(dex_file, dex_cache, class_loader, class_def_idx, code_item, dex_method_idx, method, method_access_flags, true, true); @@ -279,7 +279,7 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - uint32_t dex_method_idx, mirror::AbstractMethod* method, + uint32_t dex_method_idx, mirror::ArtMethod* method, uint32_t method_access_flags, bool can_load_classes, bool allow_soft_failures) : reg_types_(can_load_classes), @@ -305,7 +305,7 @@ MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_ca has_virtual_or_interface_invokes_(false) { } -void MethodVerifier::FindLocksAtDexPc(mirror::AbstractMethod* m, uint32_t dex_pc, +void MethodVerifier::FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector<uint32_t>& monitor_enter_dex_pcs) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -327,7 +327,7 @@ void MethodVerifier::FindLocksAtDexPc() { Verify(); } -mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(mirror::AbstractMethod* m, +mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -336,7 +336,7 @@ mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(mirror::AbstractMethod* return verifier.FindAccessedFieldAtDexPc(dex_pc); } -mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { +mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { CHECK(code_item_ != NULL); // This only makes sense for methods with code. // Strictly speaking, we ought to be able to get away with doing a subset of the full method @@ -355,7 +355,7 @@ mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { return GetQuickFieldAccess(inst, register_line); } -mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::AbstractMethod* m, +mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -364,7 +364,7 @@ mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::Abstrac return verifier.FindInvokedMethodAtDexPc(dex_pc); } -mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(uint32_t dex_pc) { +mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(uint32_t dex_pc) { CHECK(code_item_ != NULL); // This only makes sense for methods with code. // Strictly speaking, we ought to be able to get away with doing a subset of the full method @@ -2113,7 +2113,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { inst->Opcode() == Instruction::INVOKE_SUPER_RANGE); bool is_super = (inst->Opcode() == Instruction::INVOKE_SUPER || inst->Opcode() == Instruction::INVOKE_SUPER_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, METHOD_VIRTUAL, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_VIRTUAL, is_range, is_super); const char* descriptor; if (called_method == NULL) { @@ -2136,7 +2136,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_DIRECT: case Instruction::INVOKE_DIRECT_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_DIRECT_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, METHOD_DIRECT, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_DIRECT, is_range, false); const char* return_type_descriptor; bool is_constructor; @@ -2203,7 +2203,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_STATIC: case Instruction::INVOKE_STATIC_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_STATIC_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_STATIC, is_range, false); @@ -2228,7 +2228,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_INTERFACE: case Instruction::INVOKE_INTERFACE_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_INTERFACE_RANGE); - mirror::AbstractMethod* abs_method = VerifyInvocationArgs(inst, + mirror::ArtMethod* abs_method = VerifyInvocationArgs(inst, METHOD_INTERFACE, is_range, false); @@ -2536,7 +2536,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_VIRTUAL_QUICK: case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { bool is_range = (inst->Opcode() == Instruction::INVOKE_VIRTUAL_RANGE_QUICK); - mirror::AbstractMethod* called_method = VerifyInvokeVirtualQuickArgs(inst, is_range); + mirror::ArtMethod* called_method = VerifyInvokeVirtualQuickArgs(inst, is_range); if (called_method != NULL) { const char* descriptor = MethodHelper(called_method).GetReturnTypeDescriptor(); const RegType& return_type = reg_types_.FromDescriptor(class_loader_, descriptor, false); @@ -2871,7 +2871,7 @@ const RegType& MethodVerifier::GetCaughtExceptionType() { return *common_super; } -mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex_method_idx, +mirror::ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex_method_idx, MethodType method_type) { const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx); const RegType& klass_type = ResolveClassAndCheckAccess(method_id.class_idx_); @@ -2886,7 +2886,7 @@ mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex } mirror::Class* klass = klass_type.GetClass(); const RegType& referrer = GetDeclaringClass(); - mirror::AbstractMethod* res_method = dex_cache_->GetResolvedMethod(dex_method_idx); + mirror::ArtMethod* res_method = dex_cache_->GetResolvedMethod(dex_method_idx); if (res_method == NULL) { const char* name = dex_file_->GetMethodName(method_id); std::string signature(dex_file_->CreateMethodSignature(method_id.proto_idx_, NULL)); @@ -2963,14 +2963,14 @@ mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex return res_method; } -mirror::AbstractMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* inst, MethodType method_type, bool is_range, bool is_super) { // Resolve the method. This could be an abstract or concrete method depending on what sort of call // we're making. const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); - mirror::AbstractMethod* res_method = ResolveMethodAndCheckAccess(method_idx, method_type); + mirror::ArtMethod* res_method = ResolveMethodAndCheckAccess(method_idx, method_type); if (res_method == NULL) { // error or class is unresolved return NULL; } @@ -3078,7 +3078,7 @@ mirror::AbstractMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* } } -mirror::AbstractMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, RegisterLine* reg_line, bool is_range) { DCHECK(inst->Opcode() == Instruction::INVOKE_VIRTUAL_QUICK || @@ -3103,19 +3103,19 @@ mirror::AbstractMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* if (this_class == NULL) { return NULL; } - mirror::ObjectArray<mirror::AbstractMethod>* vtable = this_class->GetVTable(); + mirror::ObjectArray<mirror::ArtMethod>* vtable = this_class->GetVTable(); CHECK(vtable != NULL); uint16_t vtable_index = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); CHECK(vtable_index < vtable->GetLength()); - mirror::AbstractMethod* res_method = vtable->Get(vtable_index); + mirror::ArtMethod* res_method = vtable->Get(vtable_index); CHECK(!Thread::Current()->IsExceptionPending()); return res_method; } -mirror::AbstractMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) { DCHECK(Runtime::Current()->IsStarted()); - mirror::AbstractMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), + mirror::ArtMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), is_range); if (res_method == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer method from " << inst->Name(); @@ -3368,7 +3368,7 @@ void MethodVerifier::VerifyAPut(const Instruction* inst, } } -mirror::Field* MethodVerifier::GetStaticField(int field_idx) { +mirror::ArtField* MethodVerifier::GetStaticField(int field_idx) { const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClassAndCheckAccess(field_id.class_idx_); @@ -3381,7 +3381,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { if (klass_type.IsUnresolvedTypes()) { return NULL; // Can't resolve Class so no more to do here, will do checking at runtime. } - mirror::Field* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, field_idx, dex_cache_, class_loader_); @@ -3405,7 +3405,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { } } -mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { +mirror::ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClassAndCheckAccess(field_id.class_idx_); @@ -3418,7 +3418,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie if (klass_type.IsUnresolvedTypes()) { return NULL; // Can't resolve Class so no more to do here } - mirror::Field* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, field_idx, dex_cache_, class_loader_); @@ -3471,7 +3471,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_type, bool is_primitive, bool is_static) { uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - mirror::Field* field; + mirror::ArtField* field; if (is_static) { field = GetStaticField(field_idx); } else { @@ -3525,7 +3525,7 @@ void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_ty void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_type, bool is_primitive, bool is_static) { uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - mirror::Field* field; + mirror::ArtField* field; if (is_static) { field = GetStaticField(field_idx); } else { @@ -3567,13 +3567,13 @@ void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_ty // Look for an instance field with this offset. // TODO: we may speed up the search if offsets are sorted by doing a quick search. -static mirror::Field* FindInstanceFieldWithOffset(const mirror::Class* klass, +static mirror::ArtField* FindInstanceFieldWithOffset(const mirror::Class* klass, uint32_t field_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::ObjectArray<mirror::Field>* instance_fields = klass->GetIFields(); + const mirror::ObjectArray<mirror::ArtField>* instance_fields = klass->GetIFields(); if (instance_fields != NULL) { for (int32_t i = 0, e = instance_fields->GetLength(); i < e; ++i) { - mirror::Field* field = instance_fields->Get(i); + mirror::ArtField* field = instance_fields->Get(i); if (field->GetOffset().Uint32Value() == field_offset) { return field; } @@ -3589,7 +3589,7 @@ static mirror::Field* FindInstanceFieldWithOffset(const mirror::Class* klass, // Returns the access field of a quick field access (iget/iput-quick) or NULL // if it cannot be found. -mirror::Field* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, +mirror::ArtField* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) { DCHECK(inst->Opcode() == Instruction::IGET_QUICK || inst->Opcode() == Instruction::IGET_WIDE_QUICK || @@ -3624,7 +3624,7 @@ mirror::Field* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& insn_type, bool is_primitive) { DCHECK(Runtime::Current()->IsStarted()); - mirror::Field* field = GetQuickFieldAccess(inst, work_line_.get()); + mirror::ArtField* field = GetQuickFieldAccess(inst, work_line_.get()); if (field == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer field from " << inst->Name(); return; @@ -3668,7 +3668,7 @@ void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& ins void MethodVerifier::VerifyIPutQuick(const Instruction* inst, const RegType& insn_type, bool is_primitive) { DCHECK(Runtime::Current()->IsStarted()); - mirror::Field* field = GetQuickFieldAccess(inst, work_line_.get()); + mirror::ArtField* field = GetQuickFieldAccess(inst, work_line_.get()); if (field == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer field from " << inst->Name(); return; @@ -3922,7 +3922,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { // We can't devirtualize abstract classes except on arrays of abstract classes. continue; } - mirror::AbstractMethod* abstract_method = + mirror::ArtMethod* abstract_method = dex_cache_->GetResolvedMethod(is_range ? inst->VRegB_3rc() : inst->VRegB_35c()); if (abstract_method == NULL) { // If the method is not found in the cache this means that it was never found @@ -3930,7 +3930,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { continue; } // Find the concrete method. - mirror::AbstractMethod* concrete_method = NULL; + mirror::ArtMethod* concrete_method = NULL; if (is_interface) { concrete_method = reg_type.GetClass()->FindVirtualMethodForInterface(abstract_method); } diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index e01f2c0..6171943 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -156,7 +156,7 @@ class MethodVerifier { static void VerifyMethodAndDump(std::ostream& os, uint32_t method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, uint32_t method_access_flags) + mirror::ArtMethod* method, uint32_t method_access_flags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uint8_t EncodePcToReferenceMapData() const; @@ -197,20 +197,18 @@ class MethodVerifier { // Fills 'monitor_enter_dex_pcs' with the dex pcs of the monitor-enter instructions corresponding // to the locks held at 'dex_pc' in method 'm'. - static void FindLocksAtDexPc(mirror::AbstractMethod* m, uint32_t dex_pc, + static void FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector<uint32_t>& monitor_enter_dex_pcs) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the accessed field corresponding to the quick instruction's field // offset at 'dex_pc' in method 'm'. - static mirror::Field* FindAccessedFieldAtDexPc(mirror::AbstractMethod* m, - uint32_t dex_pc) + static mirror::ArtField* FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the invoked method corresponding to the quick instruction's vtable // index at 'dex_pc' in method 'm'. - static mirror::AbstractMethod* FindInvokedMethodAtDexPc(mirror::AbstractMethod* m, - uint32_t dex_pc) + static mirror::ArtMethod* FindInvokedMethodAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void Init() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -226,7 +224,7 @@ class MethodVerifier { MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - uint32_t method_idx, mirror::AbstractMethod* method, + uint32_t method_idx, mirror::ArtMethod* method, uint32_t access_flags, bool can_load_classes, bool allow_soft_failures) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -266,16 +264,16 @@ class MethodVerifier { mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, uint32_t method_access_flags, + mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FindLocksAtDexPc() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* FindAccessedFieldAtDexPc(uint32_t dex_pc) + mirror::ArtField* FindAccessedFieldAtDexPc(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* FindInvokedMethodAtDexPc(uint32_t dex_pc) + mirror::ArtMethod* FindInvokedMethodAtDexPc(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -496,11 +494,11 @@ class MethodVerifier { bool is_primitive) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Lookup instance field and fail for resolution violations - mirror::Field* GetInstanceField(const RegType& obj_type, int field_idx) + mirror::ArtField* GetInstanceField(const RegType& obj_type, int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Lookup static field and fail for resolution violations - mirror::Field* GetStaticField(int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtField* GetStaticField(int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Perform verification of an iget or sget instruction. void VerifyISGet(const Instruction* inst, const RegType& insn_type, @@ -514,7 +512,7 @@ class MethodVerifier { // Returns the access field of a quick field access (iget/iput-quick) or NULL // if it cannot be found. - mirror::Field* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) + mirror::ArtField* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Perform verification of an iget-quick instruction. @@ -545,7 +543,7 @@ class MethodVerifier { * the referrer can access the resolved method. * Does not throw exceptions. */ - mirror::AbstractMethod* ResolveMethodAndCheckAccess(uint32_t method_idx, MethodType method_type) + mirror::ArtMethod* ResolveMethodAndCheckAccess(uint32_t method_idx, MethodType method_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -570,18 +568,17 @@ class MethodVerifier { * Returns the resolved method on success, NULL on failure (with *failure * set appropriately). */ - mirror::AbstractMethod* VerifyInvocationArgs(const Instruction* inst, - MethodType method_type, - bool is_range, bool is_super) + mirror::ArtMethod* VerifyInvocationArgs(const Instruction* inst, + MethodType method_type, + bool is_range, bool is_super) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* GetQuickInvokedMethod(const Instruction* inst, - RegisterLine* reg_line, - bool is_range) + mirror::ArtMethod* GetQuickInvokedMethod(const Instruction* inst, + RegisterLine* reg_line, + bool is_range) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* VerifyInvokeVirtualQuickArgs(const Instruction* inst, - bool is_range) + mirror::ArtMethod* VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -686,7 +683,7 @@ class MethodVerifier { const uint32_t dex_method_idx_; // The method we're working on. // Its object representation if known. - mirror::AbstractMethod* mirror_method_ GUARDED_BY(Locks::mutator_lock_); + mirror::ArtMethod* mirror_method_ GUARDED_BY(Locks::mutator_lock_); const uint32_t method_access_flags_; // Method's access flags. const DexFile* const dex_file_; // The dex file containing the method. // The dex_cache for the declaring class of the method. diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index 434fcf0..8de020a 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -32,8 +32,11 @@ jclass WellKnownClasses::java_lang_ClassNotFoundException; jclass WellKnownClasses::java_lang_Daemons; jclass WellKnownClasses::java_lang_Error; jclass WellKnownClasses::java_lang_Object; -jclass WellKnownClasses::java_lang_reflect_InvocationHandler; jclass WellKnownClasses::java_lang_reflect_AbstractMethod; +jclass WellKnownClasses::java_lang_reflect_ArtMethod; +jclass WellKnownClasses::java_lang_reflect_Constructor; +jclass WellKnownClasses::java_lang_reflect_Field; +jclass WellKnownClasses::java_lang_reflect_Method; jclass WellKnownClasses::java_lang_reflect_Proxy; jclass WellKnownClasses::java_lang_RuntimeException; jclass WellKnownClasses::java_lang_StackOverflowError; @@ -61,7 +64,7 @@ jmethodID WellKnownClasses::java_lang_Integer_valueOf; jmethodID WellKnownClasses::java_lang_Long_valueOf; jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add; jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add; -jmethodID WellKnownClasses::java_lang_reflect_InvocationHandler_invoke; +jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke; jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad; jmethodID WellKnownClasses::java_lang_Short_valueOf; jmethodID WellKnownClasses::java_lang_System_runFinalization = NULL; @@ -83,6 +86,8 @@ jfieldID WellKnownClasses::java_lang_Thread_nativePeer; jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup; jfieldID WellKnownClasses::java_lang_ThreadGroup_name; jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup; +jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; +jfieldID WellKnownClasses::java_lang_reflect_Field_artField; jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; @@ -121,7 +126,7 @@ static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const c StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str()); } -void WellKnownClasses::InitClasses(JNIEnv* env) { +void WellKnownClasses::Init(JNIEnv* env) { com_android_dex_Dex = CacheClass(env, "com/android/dex/Dex"); dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader"); java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader"); @@ -129,8 +134,11 @@ void WellKnownClasses::InitClasses(JNIEnv* env) { java_lang_Daemons = CacheClass(env, "java/lang/Daemons"); java_lang_Object = CacheClass(env, "java/lang/Object"); java_lang_Error = CacheClass(env, "java/lang/Error"); - java_lang_reflect_InvocationHandler = CacheClass(env, "java/lang/reflect/InvocationHandler"); java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); + java_lang_reflect_ArtMethod = CacheClass(env, "java/lang/reflect/ArtMethod"); + java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); + java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); + java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException"); java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError"); @@ -142,10 +150,6 @@ void WellKnownClasses::InitClasses(JNIEnv* env) { java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer"); org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk"); org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer"); -} - -void WellKnownClasses::Init(JNIEnv* env) { - InitClasses(env); com_android_dex_Dex_create = CacheMethod(env, com_android_dex_Dex, true, "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); java_lang_ClassNotFoundException_init = CacheMethod(env, java_lang_ClassNotFoundException, false, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); @@ -160,7 +164,7 @@ void WellKnownClasses::Init(JNIEnv* env) { ScopedLocalRef<jclass> java_lang_ref_ReferenceQueue(env, env->FindClass("java/lang/ref/ReferenceQueue")); java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); - java_lang_reflect_InvocationHandler_invoke = CacheMethod(env, java_lang_reflect_InvocationHandler, false, "invoke", "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"); + java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/ArtMethod;[Ljava/lang/Object;)Ljava/lang/Object;"); java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "<init>", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); java_lang_Thread$UncaughtExceptionHandler_uncaughtException = CacheMethod(env, java_lang_Thread$UncaughtExceptionHandler, false, "uncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); @@ -179,6 +183,8 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_ThreadGroup_mainThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;"); java_lang_ThreadGroup_name = CacheField(env, java_lang_ThreadGroup, false, "name", "Ljava/lang/String;"); java_lang_ThreadGroup_systemThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "systemThreadGroup", "Ljava/lang/ThreadGroup;"); + java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "Ljava/lang/reflect/ArtMethod;"); + java_lang_reflect_Field_artField = CacheField(env, java_lang_reflect_Field, false, "artField", "Ljava/lang/reflect/ArtField;"); java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;"); java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "effectiveDirectAddress", "J"); diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h index fc2bffb..bc928d0 100644 --- a/runtime/well_known_classes.h +++ b/runtime/well_known_classes.h @@ -32,7 +32,7 @@ class Class; jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); struct WellKnownClasses { - static void InitClasses(JNIEnv* env); + public: static void Init(JNIEnv* env); // Run before native methods are registered. static void LateInit(JNIEnv* env); // Run after native methods are registered. @@ -46,8 +46,11 @@ struct WellKnownClasses { static jclass java_lang_Daemons; static jclass java_lang_Error; static jclass java_lang_Object; - static jclass java_lang_reflect_InvocationHandler; static jclass java_lang_reflect_AbstractMethod; + static jclass java_lang_reflect_ArtMethod; + static jclass java_lang_reflect_Constructor; + static jclass java_lang_reflect_Field; + static jclass java_lang_reflect_Method; static jclass java_lang_reflect_Proxy; static jclass java_lang_RuntimeException; static jclass java_lang_StackOverflowError; @@ -75,7 +78,7 @@ struct WellKnownClasses { static jmethodID java_lang_Long_valueOf; static jmethodID java_lang_ref_FinalizerReference_add; static jmethodID java_lang_ref_ReferenceQueue_add; - static jmethodID java_lang_reflect_InvocationHandler_invoke; + static jmethodID java_lang_reflect_Proxy_invoke; static jmethodID java_lang_Runtime_nativeLoad; static jmethodID java_lang_Short_valueOf; static jmethodID java_lang_System_runFinalization; @@ -87,6 +90,8 @@ struct WellKnownClasses { static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; + static jfieldID java_lang_reflect_AbstractMethod_artMethod; + static jfieldID java_lang_reflect_Field_artField; static jfieldID java_lang_reflect_Proxy_h; static jfieldID java_lang_Thread_daemon; static jfieldID java_lang_Thread_group; |