Use class def index from java.lang.Class.
Bug: 10244719
Depends on:
https://googleplex-android-review.git.corp.google.com/362363
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.
Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
diff --git a/compiler/dex/compiler_ir.h b/compiler/dex/compiler_ir.h
index 26d0923..6607562 100644
--- a/compiler/dex/compiler_ir.h
+++ b/compiler/dex/compiler_ir.h
@@ -77,7 +77,7 @@
ClassLinker* class_linker; // Linker to resolve fields and methods.
const DexFile* dex_file; // DexFile containing the method being compiled.
jobject class_loader; // compiling method's class loader.
- uint32_t class_def_idx; // compiling method's defining class definition index.
+ uint16_t class_def_idx; // compiling method's defining class definition index.
uint32_t method_idx; // compiling method's index into method_ids of DexFile.
const DexFile::CodeItem* code_item; // compiling method's DexFile code_item.
uint32_t access_flags; // compiling method's access flags.
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index ffd7905..abafbc5 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -280,7 +280,7 @@
extern "C" void ArtCompileDEX(art::CompilerDriver& compiler, const art::DexFile::CodeItem* code_item,
uint32_t access_flags, art::InvokeType invoke_type,
- uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
+ uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
const art::DexFile& dex_file,
art::DexToDexCompilationLevel dex_to_dex_compilation_level) {
if (dex_to_dex_compilation_level != art::kDontDexToDexCompile) {
diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc
index 2303649..fefcab9 100644
--- a/compiler/dex/frontend.cc
+++ b/compiler/dex/frontend.cc
@@ -110,7 +110,7 @@
const CompilerBackend compiler_backend,
const DexFile::CodeItem* code_item,
uint32_t access_flags, InvokeType invoke_type,
- uint32_t class_def_idx, uint32_t method_idx,
+ uint16_t class_def_idx, uint32_t method_idx,
jobject class_loader, const DexFile& dex_file
#if defined(ART_USE_PORTABLE_COMPILER)
, llvm::LlvmCompilationUnit* llvm_compilation_unit
@@ -273,7 +273,7 @@
const DexFile::CodeItem* code_item,
uint32_t access_flags,
InvokeType invoke_type,
- uint32_t class_def_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
jobject class_loader,
const DexFile& dex_file,
@@ -292,7 +292,7 @@
ArtQuickCompileMethod(art::CompilerDriver& compiler,
const art::DexFile::CodeItem* code_item,
uint32_t access_flags, art::InvokeType invoke_type,
- uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
+ uint16_t class_def_idx, uint32_t method_idx, jobject class_loader,
const art::DexFile& dex_file) {
// TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default
art::CompilerBackend backend = compiler.GetCompilerBackend();
diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h
index bafa468..6c33d10 100644
--- a/compiler/dex/frontend.h
+++ b/compiler/dex/frontend.h
@@ -117,7 +117,7 @@
const art::DexFile::CodeItem* code_item,
uint32_t access_flags,
art::InvokeType invoke_type,
- uint32_t class_dex_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
jobject class_loader,
const art::DexFile& dex_file);
diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc
index c72283e..c234298 100644
--- a/compiler/dex/mir_graph.cc
+++ b/compiler/dex/mir_graph.cc
@@ -504,7 +504,7 @@
/* Parse a Dex method and insert it into the MIRGraph at the current insert point. */
void MIRGraph::InlineMethod(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) {
current_code_item_ = code_item;
method_stack_.push_back(std::make_pair(current_method_, current_offset_));
diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h
index 0244dae..9d4ab98 100644
--- a/compiler/dex/mir_graph.h
+++ b/compiler/dex/mir_graph.h
@@ -357,7 +357,7 @@
* actually the index of the method in the m_units_ array).
*/
void InlineMethod(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);
/* Find existing block */
diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc
index f13ab2d..4ce752f 100644
--- a/compiler/dex/quick/codegen_util.cc
+++ b/compiler/dex/quick/codegen_util.cc
@@ -385,11 +385,12 @@
while (data_lir != NULL) {
uint32_t target = data_lir->operands[0];
cu_->compiler_driver->AddCodePatch(cu_->dex_file,
- cu_->method_idx,
- cu_->invoke_type,
- target,
- static_cast<InvokeType>(data_lir->operands[1]),
- code_buffer_.size());
+ cu_->class_def_idx,
+ cu_->method_idx,
+ cu_->invoke_type,
+ target,
+ static_cast<InvokeType>(data_lir->operands[1]),
+ code_buffer_.size());
const DexFile::MethodId& id = cu_->dex_file->GetMethodId(target);
// unique based on target to ensure code deduplication works
uint32_t unique_patch_value = reinterpret_cast<uint32_t>(&id);
@@ -400,11 +401,12 @@
while (data_lir != NULL) {
uint32_t target = data_lir->operands[0];
cu_->compiler_driver->AddMethodPatch(cu_->dex_file,
- cu_->method_idx,
- cu_->invoke_type,
- target,
- static_cast<InvokeType>(data_lir->operands[1]),
- code_buffer_.size());
+ cu_->class_def_idx,
+ cu_->method_idx,
+ cu_->invoke_type,
+ target,
+ static_cast<InvokeType>(data_lir->operands[1]),
+ code_buffer_.size());
const DexFile::MethodId& id = cu_->dex_file->GetMethodId(target);
// unique based on target to ensure code deduplication works
uint32_t unique_patch_value = reinterpret_cast<uint32_t>(&id);