diff options
| author | 2016-06-29 08:39:47 +0000 | |
|---|---|---|
| committer | 2016-06-29 08:39:47 +0000 | |
| commit | d4ceecc85a5aab2ec23ea1bd010692ba8c8aaa0c (patch) | |
| tree | 982948a67a88a1f9a734c935f919f8d307969f48 | |
| parent | 50706437d8216e41f0fea1e413cda7891324d397 (diff) | |
Revert "Refactor GetIMTIndex"
I need to revert this to get https://android-review.googlesource.com/#/c/244190/ to cleanly revert. Matthew, do you mind rewriting it?
This reverts commit 50706437d8216e41f0fea1e413cda7891324d397.
Change-Id: I5c1435f5dffb46dbb5b613b22adb88c7770304f2
| -rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_mips.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_mips64.cc | 2 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_x86_64.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/inliner.cc | 2 | ||||
| -rw-r--r-- | compiler/optimizing/instruction_builder.cc | 3 | ||||
| -rw-r--r-- | runtime/art_method-inl.h | 4 | ||||
| -rw-r--r-- | runtime/art_method.h | 2 | ||||
| -rw-r--r-- | runtime/class_linker.cc | 11 | ||||
| -rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 4 | ||||
| -rw-r--r-- | runtime/entrypoints/quick/quick_trampoline_entrypoints.cc | 9 |
13 files changed, 28 insertions, 29 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index eca9e2c299..4fc3b5434b 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -1901,7 +1901,7 @@ void InstructionCodeGeneratorARM::VisitInvokeInterface(HInvokeInterface* invoke) __ LoadFromOffset(kLoadWord, temp, temp, mirror::Class::ImtPtrOffset(kArmPointerSize).Uint32Value()); uint32_t method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - invoke->GetImtIndex(), kArmPointerSize)); + invoke->GetImtIndex() % ImTable::kSize, kArmPointerSize)); // temp = temp->GetImtEntryAt(method_offset); __ LoadFromOffset(kLoadWord, temp, temp, method_offset); uint32_t entry_point = @@ -6783,7 +6783,7 @@ void InstructionCodeGeneratorARM::VisitClassTableGet(HClassTableGet* instruction locations->InAt(0).AsRegister<Register>(), mirror::Class::ImtPtrOffset(kArmPointerSize).Uint32Value()); method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - instruction->GetIndex(), kArmPointerSize)); + instruction->GetIndex() % ImTable::kSize, kArmPointerSize)); } __ LoadFromOffset(kLoadWord, locations->Out().AsRegister<Register>(), diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 5d3c8c5590..b63a3d4c1a 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -3522,7 +3522,7 @@ void InstructionCodeGeneratorARM64::VisitInvokeInterface(HInvokeInterface* invok __ Ldr(temp, MemOperand(temp, mirror::Class::ImtPtrOffset(kArm64PointerSize).Uint32Value())); uint32_t method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - invoke->GetImtIndex(), kArm64PointerSize)); + invoke->GetImtIndex() % ImTable::kSize, kArm64PointerSize)); // temp = temp->GetImtEntryAt(method_offset); __ Ldr(temp, MemOperand(temp, method_offset)); // lr = temp->GetEntryPoint(); @@ -5153,7 +5153,7 @@ void InstructionCodeGeneratorARM64::VisitClassTableGet(HClassTableGet* instructi __ Ldr(XRegisterFrom(locations->Out()), MemOperand(XRegisterFrom(locations->InAt(0)), mirror::Class::ImtPtrOffset(kArm64PointerSize).Uint32Value())); method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - instruction->GetIndex(), kArm64PointerSize)); + instruction->GetIndex() % ImTable::kSize, kArm64PointerSize)); } __ Ldr(XRegisterFrom(locations->Out()), MemOperand(XRegisterFrom(locations->InAt(0)), method_offset)); diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc index d5bad28dab..c8e927d026 100644 --- a/compiler/optimizing/code_generator_mips.cc +++ b/compiler/optimizing/code_generator_mips.cc @@ -3720,7 +3720,7 @@ void InstructionCodeGeneratorMIPS::VisitInvokeInterface(HInvokeInterface* invoke __ LoadFromOffset(kLoadWord, temp, temp, mirror::Class::ImtPtrOffset(kMipsPointerSize).Uint32Value()); uint32_t method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - invoke->GetImtIndex(), kMipsPointerSize)); + invoke->GetImtIndex() % ImTable::kSize, kMipsPointerSize)); // temp = temp->GetImtEntryAt(method_offset); __ LoadFromOffset(kLoadWord, temp, temp, method_offset); // T9 = temp->GetEntryPoint(); @@ -5169,7 +5169,7 @@ void InstructionCodeGeneratorMIPS::VisitClassTableGet(HClassTableGet* instructio locations->InAt(0).AsRegister<Register>(), mirror::Class::ImtPtrOffset(kMipsPointerSize).Uint32Value()); method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - instruction->GetIndex(), kMipsPointerSize)); + instruction->GetIndex() % ImTable::kSize, kMipsPointerSize)); } __ LoadFromOffset(kLoadWord, locations->Out().AsRegister<Register>(), diff --git a/compiler/optimizing/code_generator_mips64.cc b/compiler/optimizing/code_generator_mips64.cc index 539abf1de8..8d5dc84df9 100644 --- a/compiler/optimizing/code_generator_mips64.cc +++ b/compiler/optimizing/code_generator_mips64.cc @@ -2954,7 +2954,7 @@ void InstructionCodeGeneratorMIPS64::VisitInvokeInterface(HInvokeInterface* invo __ LoadFromOffset(kLoadDoubleword, temp, temp, mirror::Class::ImtPtrOffset(kMips64PointerSize).Uint32Value()); uint32_t method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - invoke->GetImtIndex(), kMips64PointerSize)); + invoke->GetImtIndex() % ImTable::kSize, kMips64PointerSize)); // temp = temp->GetImtEntryAt(method_offset); __ LoadFromOffset(kLoadDoubleword, temp, temp, method_offset); // T9 = temp->GetEntryPoint(); diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index a21c295274..9d0092b674 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -2043,7 +2043,7 @@ void InstructionCodeGeneratorX86::VisitInvokeInterface(HInvokeInterface* invoke) Address(temp, mirror::Class::ImtPtrOffset(kX86PointerSize).Uint32Value())); // temp = temp->GetImtEntryAt(method_offset); uint32_t method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - invoke->GetImtIndex(), kX86PointerSize)); + invoke->GetImtIndex() % ImTable::kSize, kX86PointerSize)); __ movl(temp, Address(temp, method_offset)); // call temp->GetEntryPoint(); __ call(Address(temp, @@ -4068,7 +4068,7 @@ void InstructionCodeGeneratorX86::VisitClassTableGet(HClassTableGet* instruction mirror::Class::ImtPtrOffset(kX86PointerSize).Uint32Value())); // temp = temp->GetImtEntryAt(method_offset); method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - instruction->GetIndex(), kX86PointerSize)); + instruction->GetIndex() % ImTable::kSize, kX86PointerSize)); } __ movl(locations->Out().AsRegister<Register>(), Address(locations->InAt(0).AsRegister<Register>(), method_offset)); diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 135f0c40d0..a8da5f2ea5 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -2258,7 +2258,7 @@ void InstructionCodeGeneratorX86_64::VisitInvokeInterface(HInvokeInterface* invo Address(temp, mirror::Class::ImtPtrOffset(kX86_64PointerSize).Uint32Value())); // temp = temp->GetImtEntryAt(method_offset); uint32_t method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - invoke->GetImtIndex(), kX86_64PointerSize)); + invoke->GetImtIndex() % ImTable::kSize, kX86_64PointerSize)); // temp = temp->GetImtEntryAt(method_offset); __ movq(temp, Address(temp, method_offset)); // call temp->GetEntryPoint(); @@ -3986,7 +3986,7 @@ void InstructionCodeGeneratorX86_64::VisitClassTableGet(HClassTableGet* instruct Address(locations->InAt(0).AsRegister<CpuRegister>(), mirror::Class::ImtPtrOffset(kX86_64PointerSize).Uint32Value())); method_offset = static_cast<uint32_t>(ImTable::OffsetOfElement( - instruction->GetIndex(), kX86_64PointerSize)); + instruction->GetIndex() % ImTable::kSize, kX86_64PointerSize)); } __ movq(locations->Out().AsRegister<CpuRegister>(), Address(locations->InAt(0).AsRegister<CpuRegister>(), method_offset)); diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index d5e80b4759..27b6896150 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -657,7 +657,7 @@ bool HInliner::TryInlinePolymorphicCallToSameTarget(HInvoke* invoke_instruction, ArtMethod* new_method = nullptr; if (invoke_instruction->IsInvokeInterface()) { new_method = ic.GetTypeAt(i)->GetImt(pointer_size)->Get( - method_index, pointer_size); + method_index % ImTable::kSize, pointer_size); if (new_method->IsRuntimeMethod()) { // Bail out as soon as we see a conflict trampoline in one of the target's // interface table. diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 1c67bcc878..f2286e46e6 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -16,7 +16,6 @@ #include "instruction_builder.h" -#include "art_method-inl.h" #include "bytecode_utils.h" #include "class_linker.h" #include "driver/compiler_options.h" @@ -891,7 +890,7 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, return_type, dex_pc, method_idx, - resolved_method->GetImtIndex()); + resolved_method->GetDexMethodIndex()); } return HandleInvoke(invoke, diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index 9f63bca655..7647ad6e57 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -120,10 +120,6 @@ inline uint32_t ArtMethod::GetDexMethodIndex() { return dex_method_index_; } -inline uint32_t ArtMethod::GetImtIndex() { - return GetDexMethodIndex() % ImTable::kSize; -} - inline ArtMethod** ArtMethod::GetDexCacheResolvedMethods(size_t pointer_size) { return GetNativePointer<ArtMethod**>(DexCacheResolvedMethodsOffset(pointer_size), pointer_size); diff --git a/runtime/art_method.h b/runtime/art_method.h index 2c40d6d78c..b65cb23516 100644 --- a/runtime/art_method.h +++ b/runtime/art_method.h @@ -418,8 +418,6 @@ class ArtMethod FINAL { ALWAYS_INLINE uint32_t GetDexMethodIndex() SHARED_REQUIRES(Locks::mutator_lock_); - ALWAYS_INLINE uint32_t GetImtIndex() SHARED_REQUIRES(Locks::mutator_lock_); - void SetDexMethodIndex(uint32_t new_idx) { // Not called within a transaction. dex_method_index_ = new_idx; diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 4259aea187..4406c0aee4 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -6167,6 +6167,11 @@ void ClassLinker::FillIMTAndConflictTables(mirror::Class* klass) { } } +static inline uint32_t GetIMTIndex(ArtMethod* interface_method) + SHARED_REQUIRES(Locks::mutator_lock_) { + return interface_method->GetDexMethodIndex() % ImTable::kSize; +} + ImtConflictTable* ClassLinker::CreateImtConflictTable(size_t count, LinearAlloc* linear_alloc, size_t image_pointer_size) { @@ -6218,7 +6223,7 @@ void ClassLinker::FillIMTFromIfTable(mirror::IfTable* if_table, // or interface methods in the IMT here they will not create extra conflicts since we compare // names and signatures in SetIMTRef. ArtMethod* interface_method = interface->GetVirtualMethod(j, image_pointer_size_); - const uint32_t imt_index = interface_method->GetImtIndex(); + const uint32_t imt_index = GetIMTIndex(interface_method); // There is only any conflicts if all of the interface methods for an IMT slot don't have // the same implementation method, keep track of this to avoid creating a conflict table in @@ -6272,7 +6277,7 @@ void ClassLinker::FillIMTFromIfTable(mirror::IfTable* if_table, } DCHECK(implementation_method != nullptr); ArtMethod* interface_method = interface->GetVirtualMethod(j, image_pointer_size_); - const uint32_t imt_index = interface_method->GetImtIndex(); + const uint32_t imt_index = GetIMTIndex(interface_method); if (!imt[imt_index]->IsRuntimeMethod() || imt[imt_index] == unimplemented_method || imt[imt_index] == imt_conflict_method) { @@ -6678,7 +6683,7 @@ bool ClassLinker::LinkInterfaceMethods( auto* interface_method = iftable->GetInterface(i)->GetVirtualMethod(j, image_pointer_size_); MethodNameAndSignatureComparator interface_name_comparator( interface_method->GetInterfaceMethodIfProxy(image_pointer_size_)); - uint32_t imt_index = interface_method->GetImtIndex(); + uint32_t imt_index = GetIMTIndex(interface_method); ArtMethod** imt_ptr = &out_imt[imt_index]; // For each method listed in the interface's method list, find the // matching method in our class's method list. We want to favor the diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index db3f88ff6e..916ca29319 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -19,7 +19,7 @@ #include "entrypoint_utils.h" -#include "art_method-inl.h" +#include "art_method.h" #include "class_linker-inl.h" #include "common_throws.h" #include "dex_file.h" @@ -559,7 +559,7 @@ inline ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object** this_ } } case kInterface: { - uint32_t imt_index = resolved_method->GetImtIndex(); + uint32_t imt_index = resolved_method->GetDexMethodIndex() % ImTable::kSize; size_t pointer_size = class_linker->GetImagePointerSize(); ArtMethod* imt_method = (*this_object)->GetClass()->GetImt(pointer_size)-> Get(imt_index, pointer_size); diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 0a70be1c95..7175d5436b 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -2174,7 +2174,8 @@ extern "C" TwoWordReturn artInvokeInterfaceTrampoline(uint32_t deadbeef ATTRIBUT if (LIKELY(interface_method->GetDexMethodIndex() != DexFile::kDexNoIndex)) { // If the dex cache already resolved the interface method, look whether we have // a match in the ImtConflictTable. - ArtMethod* conflict_method = imt->Get(interface_method->GetImtIndex(), sizeof(void*)); + uint32_t imt_index = interface_method->GetDexMethodIndex(); + ArtMethod* conflict_method = imt->Get(imt_index % ImTable::kSize, sizeof(void*)); if (LIKELY(conflict_method->IsRuntimeMethod())) { ImtConflictTable* current_table = conflict_method->GetImtConflictTable(sizeof(void*)); DCHECK(current_table != nullptr); @@ -2225,8 +2226,8 @@ extern "C" TwoWordReturn artInvokeInterfaceTrampoline(uint32_t deadbeef ATTRIBUT // We arrive here if we have found an implementation, and it is not in the ImtConflictTable. // We create a new table with the new pair { interface_method, method }. - uint32_t imt_index = interface_method->GetImtIndex(); - ArtMethod* conflict_method = imt->Get(imt_index, sizeof(void*)); + uint32_t imt_index = interface_method->GetDexMethodIndex(); + ArtMethod* conflict_method = imt->Get(imt_index % ImTable::kSize, sizeof(void*)); if (conflict_method->IsRuntimeMethod()) { ArtMethod* new_conflict_method = Runtime::Current()->GetClassLinker()->AddMethodToConflictTable( cls.Get(), @@ -2237,7 +2238,7 @@ extern "C" TwoWordReturn artInvokeInterfaceTrampoline(uint32_t deadbeef ATTRIBUT if (new_conflict_method != conflict_method) { // Update the IMT if we create a new conflict method. No fence needed here, as the // data is consistent. - imt->Set(imt_index, + imt->Set(imt_index % ImTable::kSize, new_conflict_method, sizeof(void*)); } |