Use class def index from java.lang.Class.
Bug: 10244719
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.
(cherry-picked from 8b2c0b9abc3f520495f4387ea040132ba85cae69)
Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index cbd9020..1c831cf 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -293,7 +293,7 @@
const art::DexFile::CodeItem* code_item,
uint32_t access_flags,
art::InvokeType invoke_type,
- uint32_t class_def_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
jobject class_loader,
const art::DexFile& dex_file);
@@ -301,7 +301,7 @@
const art::DexFile::CodeItem* code_item,
uint32_t access_flags,
art::InvokeType invoke_type,
- uint32_t class_def_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
jobject class_loader,
const art::DexFile& dex_file);
@@ -310,7 +310,7 @@
const art::DexFile::CodeItem* code_item,
uint32_t access_flags,
art::InvokeType invoke_type,
- uint32_t class_def_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
jobject class_loader,
const art::DexFile& dex_file);
@@ -319,7 +319,7 @@
const art::DexFile::CodeItem* code_item,
uint32_t access_flags,
art::InvokeType invoke_type,
- uint32_t class_def_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
jobject class_loader,
const art::DexFile& dex_file);
@@ -536,7 +536,7 @@
Thread* self = Thread::Current();
jobject jclass_loader;
const DexFile* dex_file;
- uint32_t class_def_idx;
+ uint16_t class_def_idx;
{
ScopedObjectAccessUnchecked soa(self);
ScopedLocalRef<jobject>
@@ -1301,13 +1301,15 @@
void CompilerDriver::AddCodePatch(const DexFile* dex_file,
- uint32_t referrer_method_idx,
- InvokeType referrer_invoke_type,
- uint32_t target_method_idx,
- InvokeType target_invoke_type,
- size_t literal_offset) {
+ uint16_t referrer_class_def_idx,
+ uint32_t referrer_method_idx,
+ InvokeType referrer_invoke_type,
+ uint32_t target_method_idx,
+ InvokeType target_invoke_type,
+ size_t literal_offset) {
MutexLock mu(Thread::Current(), compiled_methods_lock_);
code_to_patch_.push_back(new PatchInformation(dex_file,
+ referrer_class_def_idx,
referrer_method_idx,
referrer_invoke_type,
target_method_idx,
@@ -1315,13 +1317,15 @@
literal_offset));
}
void CompilerDriver::AddMethodPatch(const DexFile* dex_file,
- uint32_t referrer_method_idx,
- InvokeType referrer_invoke_type,
- uint32_t target_method_idx,
- InvokeType target_invoke_type,
- size_t literal_offset) {
+ uint16_t referrer_class_def_idx,
+ uint32_t referrer_method_idx,
+ InvokeType referrer_invoke_type,
+ uint32_t target_method_idx,
+ InvokeType target_invoke_type,
+ size_t literal_offset) {
MutexLock mu(Thread::Current(), compiled_methods_lock_);
methods_to_patch_.push_back(new PatchInformation(dex_file,
+ referrer_class_def_idx,
referrer_method_idx,
referrer_invoke_type,
target_method_idx,
@@ -1624,10 +1628,12 @@
*/
mirror::DexCache* dex_cache = manager->GetClassLinker()->FindDexCache(*manager->GetDexFile());
std::string error_msg;
- if (verifier::MethodVerifier::VerifyClass(manager->GetDexFile(),
+ const DexFile* dex_file = manager->GetDexFile();
+ const DexFile::ClassDef* class_def = &dex_file->GetClassDef(class_def_index);
+ if (verifier::MethodVerifier::VerifyClass(dex_file,
dex_cache,
soa.Decode<mirror::ClassLoader*>(manager->GetClassLoader()),
- class_def_index, error_msg, true) ==
+ class_def, true, &error_msg) ==
verifier::MethodVerifier::kHardFailure) {
const DexFile::ClassDef& class_def = manager->GetDexFile()->GetClassDef(class_def_index);
LOG(ERROR) << "Verification failed on class "
@@ -2137,7 +2143,8 @@
}
// If successfully initialized place in SSB array.
if (klass->IsInitialized()) {
- klass->GetDexCache()->GetInitializedStaticStorage()->Set(klass->GetDexTypeIndex(), klass);
+ int32_t ssb_index = klass->GetDexTypeIndex();
+ klass->GetDexCache()->GetInitializedStaticStorage()->Set(ssb_index, klass);
}
}
// Record the final class status if necessary.
@@ -2266,7 +2273,7 @@
}
void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags,
- InvokeType invoke_type, uint32_t class_def_idx,
+ InvokeType invoke_type, uint16_t class_def_idx,
uint32_t method_idx, jobject class_loader,
const DexFile& dex_file,
DexToDexCompilationLevel dex_to_dex_compilation_level) {
@@ -2389,13 +2396,13 @@
void CompilerDriver::AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file,
- size_t class_def_index) {
+ uint16_t class_def_index) {
WriterMutexLock mu(self, freezing_constructor_lock_);
freezing_constructor_classes_.insert(ClassReference(dex_file, class_def_index));
}
bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex_file,
- size_t class_def_index) {
+ uint16_t class_def_index) {
ReaderMutexLock mu(self, freezing_constructor_lock_);
return freezing_constructor_classes_.count(ClassReference(dex_file, class_def_index)) != 0;
}