diff options
-rw-r--r-- | compiler/dex/quick/gen_common.cc | 10 | ||||
-rw-r--r-- | compiler/image_writer.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 4 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 3 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 3 | ||||
-rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 3 | ||||
-rw-r--r-- | runtime/asm_support.h | 4 | ||||
-rw-r--r-- | runtime/class_linker-inl.h | 4 | ||||
-rw-r--r-- | runtime/class_linker.cc | 3 | ||||
-rw-r--r-- | runtime/class_linker_test.cc | 10 | ||||
-rw-r--r-- | runtime/interpreter/interpreter_common.h | 5 | ||||
-rw-r--r-- | runtime/mirror/art_method-inl.h | 16 | ||||
-rw-r--r-- | runtime/mirror/art_method.h | 44 | ||||
-rw-r--r-- | runtime/mirror/class-inl.h | 8 | ||||
-rw-r--r-- | runtime/mirror/class.h | 10 | ||||
-rw-r--r-- | runtime/oat.cc | 2 |
16 files changed, 77 insertions, 54 deletions
diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index 0af0ca8840..9be8719b5d 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -1068,7 +1068,11 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { r_method = TargetReg(kArg2, kRef); LoadCurrMethodDirect(r_method); } - LoadRefDisp(r_method, mirror::ArtMethod::DexCacheStringsOffset().Int32Value(), + // Method to declaring class. + LoadRefDisp(r_method, mirror::ArtMethod::DeclaringClassOffset().Int32Value(), + TargetReg(kArg0, kRef), kNotVolatile); + // Declaring class to dex cache strings. + LoadRefDisp(TargetReg(kArg0, kRef), mirror::Class::DexCacheStringsOffset().Int32Value(), TargetReg(kArg0, kRef), kNotVolatile); // Might call out to helper, which will return resolved string in kRet0 @@ -1106,7 +1110,9 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { RegLocation rl_method = LoadCurrMethod(); RegStorage res_reg = AllocTempRef(); RegLocation rl_result = EvalLoc(rl_dest, kRefReg, true); - LoadRefDisp(rl_method.reg, mirror::ArtMethod::DexCacheStringsOffset().Int32Value(), res_reg, + LoadRefDisp(rl_method.reg, mirror::ArtMethod::DeclaringClassOffset().Int32Value(), res_reg, + kNotVolatile); + LoadRefDisp(res_reg, mirror::Class::DexCacheStringsOffset().Int32Value(), res_reg, kNotVolatile); LoadRefDisp(res_reg, offset_of_string, rl_result.reg, kNotVolatile); StoreValue(rl_dest, rl_result); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 03899cc755..3b1d914f6e 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -967,7 +967,7 @@ void ImageWriter::CopyAndFixupObjectsCallback(Object* obj, void* arg) { if (obj->IsArtMethod()) { // Size without pointer fields since we don't want to overrun the buffer if target art method // is 32 bits but source is 64 bits. - n = mirror::ArtMethod::SizeWithoutPointerFields(); + n = mirror::ArtMethod::SizeWithoutPointerFields(sizeof(void*)); } else { n = obj->SizeOf(); } diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index a204e21495..890cfdd0e6 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -3135,8 +3135,8 @@ void InstructionCodeGeneratorARM::VisitLoadString(HLoadString* load) { Register out = load->GetLocations()->Out().As<Register>(); codegen_->LoadCurrentMethod(out); - __ LoadFromOffset( - kLoadWord, out, out, mirror::ArtMethod::DexCacheStringsOffset().Int32Value()); + __ LoadFromOffset(kLoadWord, out, out, mirror::ArtMethod::DeclaringClassOffset().Int32Value()); + __ LoadFromOffset(kLoadWord, out, out, mirror::Class::DexCacheStringsOffset().Int32Value()); __ LoadFromOffset(kLoadWord, out, out, CodeGenerator::GetCacheOffset(load->GetStringIndex())); __ cmp(out, ShifterOperand(0)); __ b(slow_path->GetEntryLabel(), EQ); diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 7a8b941c22..0fc430750d 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -1553,7 +1553,8 @@ void InstructionCodeGeneratorARM64::VisitLoadString(HLoadString* load) { Register out = OutputRegister(load); codegen_->LoadCurrentMethod(out); - __ Ldr(out, HeapOperand(out, mirror::ArtMethod::DexCacheStringsOffset())); + __ Ldr(out, HeapOperand(out, mirror::ArtMethod::DeclaringClassOffset())); + __ Ldr(out, HeapOperand(out, mirror::Class::DexCacheStringsOffset())); __ Ldr(out, MemOperand(out.X(), CodeGenerator::GetCacheOffset(load->GetStringIndex()))); __ Cbz(out, slow_path->GetEntryLabel()); __ Bind(slow_path->GetExitLabel()); diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 917b7dd2bb..3689452234 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -3306,7 +3306,8 @@ void InstructionCodeGeneratorX86::VisitLoadString(HLoadString* load) { Register out = load->GetLocations()->Out().As<Register>(); codegen_->LoadCurrentMethod(out); - __ movl(out, Address(out, mirror::ArtMethod::DexCacheStringsOffset().Int32Value())); + __ movl(out, Address(out, mirror::ArtMethod::DeclaringClassOffset().Int32Value())); + __ movl(out, Address(out, mirror::Class::DexCacheStringsOffset().Int32Value())); __ movl(out, Address(out, CodeGenerator::GetCacheOffset(load->GetStringIndex()))); __ testl(out, out); __ j(kEqual, slow_path->GetEntryLabel()); diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 83d04b1a58..34fa1e7a3b 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -3211,7 +3211,8 @@ void InstructionCodeGeneratorX86_64::VisitLoadString(HLoadString* load) { CpuRegister out = load->GetLocations()->Out().As<CpuRegister>(); codegen_->LoadCurrentMethod(CpuRegister(out)); - __ movl(out, Address(out, mirror::ArtMethod::DexCacheStringsOffset().Int32Value())); + __ movl(out, Address(out, mirror::ArtMethod::DeclaringClassOffset().Int32Value())); + __ movl(out, Address(out, mirror::Class::DexCacheStringsOffset().Int32Value())); __ movl(out, Address(out, CodeGenerator::GetCacheOffset(load->GetStringIndex()))); __ testl(out, out); __ j(kEqual, slow_path->GetEntryLabel()); diff --git a/runtime/asm_support.h b/runtime/asm_support.h index c737ec93a2..7454cca65a 100644 --- a/runtime/asm_support.h +++ b/runtime/asm_support.h @@ -148,11 +148,11 @@ ADD_TEST_EQ(MIRROR_STRING_OFFSET_OFFSET, art::mirror::String::OffsetOffset().Int ADD_TEST_EQ(MIRROR_ART_METHOD_DEX_CACHE_METHODS_OFFSET, art::mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value()) -#define MIRROR_ART_METHOD_PORTABLE_CODE_OFFSET_32 (44 + MIRROR_OBJECT_HEADER_SIZE) +#define MIRROR_ART_METHOD_PORTABLE_CODE_OFFSET_32 (40 + MIRROR_OBJECT_HEADER_SIZE) ADD_TEST_EQ(MIRROR_ART_METHOD_PORTABLE_CODE_OFFSET_32, art::mirror::ArtMethod::EntryPointFromPortableCompiledCodeOffset(4).Int32Value()) -#define MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32 (40 + MIRROR_OBJECT_HEADER_SIZE) +#define MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32 (36 + MIRROR_OBJECT_HEADER_SIZE) ADD_TEST_EQ(MIRROR_ART_METHOD_QUICK_CODE_OFFSET_32, art::mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset(4).Int32Value()) diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index ead3fa5139..51987692d1 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -58,9 +58,9 @@ inline mirror::Class* ClassLinker::FindArrayClass(Thread* self, mirror::Class** inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, mirror::ArtMethod* referrer) { - mirror::String* resolved_string = referrer->GetDexCacheStrings()->Get(string_idx); + mirror::Class* declaring_class = referrer->GetDeclaringClass(); + mirror::String* resolved_string = declaring_class->GetDexCacheStrings()->Get(string_idx); if (UNLIKELY(resolved_string == NULL)) { - mirror::Class* declaring_class = referrer->GetDeclaringClass(); StackHandleScope<1> hs(Thread::Current()); Handle<mirror::DexCache> dex_cache(hs.NewHandle(declaring_class->GetDexCache())); const DexFile& dex_file = *dex_cache->GetDexFile(); diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 677fdc9462..f092772239 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2780,6 +2780,7 @@ void ClassLinker::LoadClass(Thread* self, const DexFile& dex_file, klass->SetDexClassDefIndex(dex_file.GetIndexForClassDef(dex_class_def)); klass->SetDexTypeIndex(dex_class_def.class_idx_); + klass->SetDexCacheStrings(klass->GetDexCache()->GetStrings()); const uint8_t* class_data = dex_file.GetClassData(dex_class_def); if (class_data == nullptr) { @@ -2935,7 +2936,6 @@ mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file dst->SetDeclaringClass(klass.Get()); dst->SetCodeItemOffset(it.GetMethodCodeItemOffset()); - dst->SetDexCacheStrings(klass->GetDexCache()->GetStrings()); dst->SetDexCacheResolvedMethods(klass->GetDexCache()->GetResolvedMethods()); dst->SetDexCacheResolvedTypes(klass->GetDexCache()->GetResolvedTypes()); @@ -4063,7 +4063,6 @@ static void CheckProxyMethod(Handle<mirror::ArtMethod> method, // The proxy method doesn't have its own dex cache or dex file and so it steals those of its // interface prototype. The exception to this are Constructors and the Class of the Proxy itself. - CHECK_EQ(prototype->GetDexCacheStrings(), method->GetDexCacheStrings()); CHECK(prototype->HasSameDexCacheResolvedMethods(method.Get())); CHECK(prototype->HasSameDexCacheResolvedTypes(method.Get())); CHECK_EQ(prototype->GetDexMethodIndex(), method->GetDexMethodIndex()); diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 0c86761979..99d0746962 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -164,11 +164,8 @@ class ClassLinkerTest : public CommonRuntimeTest { EXPECT_TRUE(method->GetName() != nullptr); EXPECT_TRUE(method->GetSignature() != Signature::NoSignature()); - EXPECT_TRUE(method->GetDexCacheStrings() != nullptr); EXPECT_TRUE(method->HasDexCacheResolvedMethods()); EXPECT_TRUE(method->HasDexCacheResolvedTypes()); - EXPECT_EQ(method->GetDeclaringClass()->GetDexCache()->GetStrings(), - method->GetDexCacheStrings()); EXPECT_TRUE(method->HasSameDexCacheResolvedMethods( method->GetDeclaringClass()->GetDexCache()->GetResolvedMethods())); EXPECT_TRUE(method->HasSameDexCacheResolvedTypes( @@ -205,6 +202,8 @@ class ClassLinkerTest : public CommonRuntimeTest { EXPECT_FALSE(klass->IsArrayClass()); EXPECT_TRUE(klass->GetComponentType() == nullptr); EXPECT_TRUE(klass->IsInSamePackage(klass.Get())); + EXPECT_TRUE(klass->GetDexCacheStrings() != nullptr); + EXPECT_EQ(klass->GetDexCacheStrings(), klass->GetDexCache()->GetStrings()); std::string temp2; EXPECT_TRUE(mirror::Class::IsInSamePackage(klass->GetDescriptor(&temp), klass->GetDescriptor(&temp2))); @@ -399,7 +398,8 @@ struct CheckOffsets { bool error = false; - if (!klass->IsClassClass() && !is_static) { + // Art method have a different size due to the padding field. + if (!klass->IsArtMethodClass() && !klass->IsClassClass() && !is_static) { size_t expected_size = is_static ? klass->GetClassSize(): klass->GetObjectSize(); if (sizeof(T) != expected_size) { LOG(ERROR) << "Class size mismatch:" @@ -496,7 +496,6 @@ struct ArtMethodOffsets : public CheckOffsets<mirror::ArtMethod> { offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, declaring_class_), "declaringClass")); 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")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_code_item_offset_), "dexCodeItemOffset")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_method_index_), "dexMethodIndex")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_index_), "methodIndex")); @@ -511,6 +510,7 @@ struct ClassOffsets : public CheckOffsets<mirror::Class> { offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, clinit_thread_id_), "clinitThreadId")); 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, dex_cache_strings_), "dexCacheStrings")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_class_def_idx_), "dexClassDefIndex")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_type_idx_), "dexTypeIndex")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, direct_methods_), "directMethods")); diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index 7f6303ab9a..f88d56a30a 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -201,10 +201,11 @@ static inline String* ResolveString(Thread* self, ShadowFrame& shadow_frame, uin } } mirror::ArtMethod* method = shadow_frame.GetMethod(); - mirror::String* s = method->GetDexCacheStrings()->Get(string_idx); + mirror::Class* declaring_class = method->GetDeclaringClass(); + mirror::String* s = declaring_class->GetDexCacheStrings()->Get(string_idx); if (UNLIKELY(s == nullptr)) { StackHandleScope<1> hs(self); - Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache())); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(declaring_class->GetDexCache())); s = Runtime::Current()->GetClassLinker()->ResolveString(*method->GetDexFile(), string_idx, dex_cache); } diff --git a/runtime/mirror/art_method-inl.h b/runtime/mirror/art_method-inl.h index 62ef6f861c..22d55e2a39 100644 --- a/runtime/mirror/art_method-inl.h +++ b/runtime/mirror/art_method-inl.h @@ -82,11 +82,6 @@ inline uint32_t ArtMethod::GetDexMethodIndex() { return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_method_index_)); } -inline ObjectArray<String>* ArtMethod::GetDexCacheStrings() { - return GetFieldObject<ObjectArray<String>>( - OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_)); -} - inline ObjectArray<ArtMethod>* ArtMethod::GetDexCacheResolvedMethods() { return GetFieldObject<ObjectArray<ArtMethod>>( OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_)); @@ -460,11 +455,6 @@ inline ArtMethod* ArtMethod::GetInterfaceMethodIfProxy() { return interface_method; } -inline void ArtMethod::SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) { - SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), - new_dex_cache_strings); -} - inline void ArtMethod::SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods) { SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), new_dex_cache_methods); @@ -492,7 +482,11 @@ inline mirror::Class* ArtMethod::GetReturnType(bool resolve) { inline void ArtMethod::CheckObjectSizeEqualsMirrorSize() { // Using the default, check the class object size to make sure it matches the size of the // object. - DCHECK_EQ(GetClass()->GetObjectSize(), sizeof(*this)); + size_t this_size = sizeof(*this); +#ifdef ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT + this_size += sizeof(void*) - sizeof(uint32_t); +#endif + DCHECK_EQ(GetClass()->GetObjectSize(), this_size); } } // namespace mirror diff --git a/runtime/mirror/art_method.h b/runtime/mirror/art_method.h index f5c14547b2..da494e0ec9 100644 --- a/runtime/mirror/art_method.h +++ b/runtime/mirror/art_method.h @@ -42,6 +42,8 @@ namespace mirror { typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper* mh, const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); +#define ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT + // C++ mirror of java.lang.reflect.ArtMethod. class MANAGED ArtMethod FINAL : public Object { public: @@ -208,14 +210,6 @@ class MANAGED ArtMethod FINAL : public Object { SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_method_index_), new_idx); } - ObjectArray<String>* GetDexCacheStrings() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset DexCacheStringsOffset() { - return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_); - } - static MemberOffset DexCacheResolvedMethodsOffset() { return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_); } @@ -278,7 +272,7 @@ class MANAGED ArtMethod FINAL : public Object { } ALWAYS_INLINE static MemberOffset EntryPointFromPortableCompiledCodeOffset(size_t pointer_size) { - return MemberOffset(PtrSizedFieldsOffset() + OFFSETOF_MEMBER( + return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( PtrSizedFields, entry_point_from_portable_compiled_code_) / sizeof(void*) * pointer_size); } @@ -445,17 +439,17 @@ class MANAGED ArtMethod FINAL : public Object { void UnregisterNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset EntryPointFromInterpreterOffset(size_t pointer_size) { - return MemberOffset(PtrSizedFieldsOffset() + OFFSETOF_MEMBER( + return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( PtrSizedFields, entry_point_from_interpreter_) / sizeof(void*) * pointer_size); } static MemberOffset EntryPointFromJniOffset(size_t pointer_size) { - return MemberOffset(PtrSizedFieldsOffset() + OFFSETOF_MEMBER( + return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( PtrSizedFields, entry_point_from_jni_) / sizeof(void*) * pointer_size); } static MemberOffset EntryPointFromQuickCompiledCodeOffset(size_t pointer_size) { - return MemberOffset(PtrSizedFieldsOffset() + OFFSETOF_MEMBER( + return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( PtrSizedFields, entry_point_from_quick_compiled_code_) / sizeof(void*) * pointer_size); } @@ -581,13 +575,19 @@ class MANAGED ArtMethod FINAL : public Object { ALWAYS_INLINE ArtMethod* GetInterfaceMethodIfProxy() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static size_t SizeWithoutPointerFields() { - return sizeof(ArtMethod) - sizeof(PtrSizedFields); + static size_t SizeWithoutPointerFields(size_t pointer_size) { + size_t total = sizeof(ArtMethod) - sizeof(PtrSizedFields); +#ifdef ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT + // Add 4 bytes if 64 bit, otherwise 0. + total += pointer_size - sizeof(uint32_t); +#endif + return total; } // Size of an instance of java.lang.reflect.ArtMethod not including its value array. static size_t InstanceSize(size_t pointer_size) { - return SizeWithoutPointerFields() + (sizeof(PtrSizedFields) / sizeof(void*)) * pointer_size; + return SizeWithoutPointerFields(pointer_size) + + (sizeof(PtrSizedFields) / sizeof(void*)) * pointer_size; } protected: @@ -601,9 +601,6 @@ class MANAGED ArtMethod FINAL : public Object { // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access. HeapReference<ObjectArray<Class>> dex_cache_resolved_types_; - // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access. - HeapReference<ObjectArray<String>> dex_cache_strings_; - // Access flags; low 16 bits are defined by spec. uint32_t access_flags_; @@ -622,7 +619,7 @@ class MANAGED ArtMethod FINAL : public Object { // ifTable. uint32_t method_index_; - // Add alignment word here if necessary. + // Fake padding field gets inserted here. // Must be the last fields in the method. struct PACKED(4) PtrSizedFields { @@ -653,8 +650,13 @@ class MANAGED ArtMethod FINAL : public Object { ALWAYS_INLINE ObjectArray<Class>* GetDexCacheResolvedTypes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static size_t PtrSizedFieldsOffset() { - return OFFSETOF_MEMBER(ArtMethod, ptr_sized_fields_); + static size_t PtrSizedFieldsOffset(size_t pointer_size) { + size_t offset = OFFSETOF_MEMBER(ArtMethod, ptr_sized_fields_); +#ifdef ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT + // Add 4 bytes if 64 bit, otherwise 0. + offset += pointer_size - sizeof(uint32_t); +#endif + return offset; } friend struct art::ArtMethodOffsets; // for verifying offset information diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index a69d37e7d2..599f178cbf 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -800,6 +800,14 @@ inline uint32_t Class::NumDirectInterfaces() { } } +inline void Class::SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) { + SetFieldObject<false>(DexCacheStringsOffset(), new_dex_cache_strings); +} + +inline ObjectArray<String>* Class::GetDexCacheStrings() { + return GetFieldObject<ObjectArray<String>>(DexCacheStringsOffset()); +} + } // namespace mirror } // namespace art diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 82425b559d..a77972efc5 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -1020,6 +1020,13 @@ class MANAGED Class FINAL : public Object { bool GetSlowPathEnabled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void SetSlowPath(bool enabled) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ObjectArray<String>* GetDexCacheStrings() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + static MemberOffset DexCacheStringsOffset() { + return OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_strings_); + } + // Used to initialize a class in the allocation code path to ensure it is guarded by a StoreStore // fence. class InitializeClassVisitor { @@ -1065,6 +1072,9 @@ class MANAGED Class FINAL : public Object { // runtime such as arrays and primitive classes). HeapReference<DexCache> dex_cache_; + // Short cuts to dex_cache_ member for fast compiled code access. + HeapReference<ObjectArray<String>> dex_cache_strings_; + // static, private, and <init> methods HeapReference<ObjectArray<ArtMethod>> direct_methods_; diff --git a/runtime/oat.cc b/runtime/oat.cc index 8a595ac296..eab34f7e17 100644 --- a/runtime/oat.cc +++ b/runtime/oat.cc @@ -25,7 +25,7 @@ namespace art { const uint8_t OatHeader::kOatMagic[] = { 'o', 'a', 't', '\n' }; -const uint8_t OatHeader::kOatVersion[] = { '0', '5', '0', '\0' }; +const uint8_t OatHeader::kOatVersion[] = { '0', '5', '1', '\0' }; static size_t ComputeOatHeaderSize(const SafeMap<std::string, std::string>* variable_data) { size_t estimate = 0U; |