summaryrefslogtreecommitdiff
path: root/compiler/driver
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/driver')
-rw-r--r--compiler/driver/compiler_driver.cc85
-rw-r--r--compiler/driver/compiler_driver.h27
-rw-r--r--compiler/driver/dex_compilation_unit.cc2
-rw-r--r--compiler/driver/dex_compilation_unit.h6
4 files changed, 68 insertions, 52 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index cbd9020df4..6eabeed34b 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -293,7 +293,7 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
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 @@ extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver& compi
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 @@ extern "C" art::CompiledMethod* ArtCompileDEX(art::CompilerDriver& compiler,
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 @@ extern "C" art::CompiledMethod* SeaIrCompileMethod(art::CompilerDriver& compiler
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 @@ void CompilerDriver::CompileOne(const mirror::ArtMethod* method, base::TimingLog
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 @@ bool CompilerDriver::IsSafeCast(const MethodReference& mr, uint32_t dex_pc) {
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 @@ void CompilerDriver::AddCodePatch(const DexFile* dex_file,
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,
@@ -1467,6 +1471,24 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag
// generated code.
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
if (!SkipClass(class_linker, jclass_loader, dex_file, class_def)) {
+ ScopedObjectAccess soa(self);
+ mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(jclass_loader);
+ mirror::DexCache* dex_cache = class_linker->FindDexCache(dex_file);
+
+ // Resolve the class.
+ mirror::Class* klass = class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache,
+ class_loader);
+
+ bool resolve_fields_and_methods;
+ if (klass == NULL) {
+ // Class couldn't be resolved, for example, super-class is in a different dex file. Don't
+ // attempt to resolve methods and fields when there is no declaring class.
+ CHECK(soa.Self()->IsExceptionPending());
+ soa.Self()->ClearException();
+ resolve_fields_and_methods = false;
+ } else {
+ resolve_fields_and_methods = manager->GetCompiler()->IsImage();
+ }
// Note the class_data pointer advances through the headers,
// static fields, instance fields, direct methods, and virtual
// methods.
@@ -1475,24 +1497,6 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag
// Empty class such as a marker interface.
requires_constructor_barrier = false;
} else {
- ScopedObjectAccess soa(self);
- mirror::ClassLoader* class_loader = soa.Decode<mirror::ClassLoader*>(jclass_loader);
- mirror::DexCache* dex_cache = class_linker->FindDexCache(dex_file);
-
- // Resolve the class.
- mirror::Class* klass = class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache,
- class_loader);
-
- bool resolve_fields_and_methods;
- if (klass == NULL) {
- // Class couldn't be resolved, for example, super-class is in a different dex file. Don't
- // attempt to resolve methods and fields when there is no declaring class.
- CHECK(soa.Self()->IsExceptionPending());
- soa.Self()->ClearException();
- resolve_fields_and_methods = false;
- } else {
- resolve_fields_and_methods = manager->GetCompiler()->IsImage();
- }
ClassDataItemIterator it(dex_file, class_data);
while (it.HasNextStaticField()) {
if (resolve_fields_and_methods) {
@@ -1624,10 +1628,12 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_
*/
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 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl
}
// 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::CompileDexFile(jobject class_loader, const DexFile& dex_fil
}
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::SetBitcodeFileName(std::string const& filename) {
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;
}
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index cd6b5fab02..3852acfd3b 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -145,8 +145,9 @@ class CompilerDriver {
CompiledMethod* GetCompiledMethod(MethodReference ref) const
LOCKS_EXCLUDED(compiled_methods_lock_);
- void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index);
- bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index);
+ void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file,
+ uint16_t class_def_index);
+ bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, uint16_t class_def_index);
// Callbacks from compiler to see what runtime checks must be generated.
@@ -191,6 +192,7 @@ class CompilerDriver {
// Record patch information for later fix up.
void AddCodePatch(const DexFile* dex_file,
+ uint16_t referrer_class_def_idx,
uint32_t referrer_method_idx,
InvokeType referrer_invoke_type,
uint32_t target_method_idx,
@@ -198,6 +200,7 @@ class CompilerDriver {
size_t literal_offset)
LOCKS_EXCLUDED(compiled_methods_lock_);
void AddMethodPatch(const DexFile* dex_file,
+ uint16_t referrer_class_def_idx,
uint32_t referrer_method_idx,
InvokeType referrer_invoke_type,
uint32_t target_method_idx,
@@ -248,6 +251,9 @@ class CompilerDriver {
const DexFile& GetDexFile() const {
return *dex_file_;
}
+ uint16_t GetReferrerClassDefIdx() const {
+ return referrer_class_def_idx_;
+ }
uint32_t GetReferrerMethodIdx() const {
return referrer_method_idx_;
}
@@ -266,12 +272,14 @@ class CompilerDriver {
private:
PatchInformation(const DexFile* dex_file,
+ 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)
: dex_file_(dex_file),
+ referrer_class_def_idx_(referrer_class_def_idx),
referrer_method_idx_(referrer_method_idx),
referrer_invoke_type_(referrer_invoke_type),
target_method_idx_(target_method_idx),
@@ -280,12 +288,13 @@ class CompilerDriver {
CHECK(dex_file_ != NULL);
}
- 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_;
+ const DexFile* const dex_file_;
+ const uint16_t referrer_class_def_idx_;
+ const uint32_t referrer_method_idx_;
+ const InvokeType referrer_invoke_type_;
+ const uint32_t target_method_idx_;
+ const InvokeType target_invoke_type_;
+ const size_t literal_offset_;
friend class CompilerDriver;
DISALLOW_COPY_AND_ASSIGN(PatchInformation);
@@ -357,7 +366,7 @@ class CompilerDriver {
ThreadPool& thread_pool, base::TimingLogger& timings)
LOCKS_EXCLUDED(Locks::mutator_lock_);
void CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags,
- InvokeType invoke_type, uint32_t class_def_idx, uint32_t method_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)
LOCKS_EXCLUDED(compiled_methods_lock_);
diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc
index eb8941b15f..c441d09ab2 100644
--- a/compiler/driver/dex_compilation_unit.cc
+++ b/compiler/driver/dex_compilation_unit.cc
@@ -39,7 +39,7 @@ DexCompilationUnit::DexCompilationUnit(CompilationUnit* cu,
ClassLinker* class_linker,
const DexFile& dex_file,
const DexFile::CodeItem* code_item,
- uint32_t class_def_idx,
+ uint16_t class_def_idx,
uint32_t method_idx,
uint32_t access_flags)
: cu_(cu),
diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h
index 465139b34f..3df50ffec6 100644
--- a/compiler/driver/dex_compilation_unit.h
+++ b/compiler/driver/dex_compilation_unit.h
@@ -36,7 +36,7 @@ class DexCompilationUnit {
DexCompilationUnit(CompilationUnit* cu, jobject class_loader, ClassLinker* class_linker,
const DexFile& dex_file, const DexFile::CodeItem* code_item,
- uint32_t class_def_idx, uint32_t method_idx, uint32_t access_flags);
+ uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags);
CompilationUnit* GetCompilationUnit() const {
return cu_;
@@ -54,7 +54,7 @@ class DexCompilationUnit {
return dex_file_;
}
- uint32_t GetClassDefIndex() const {
+ uint16_t GetClassDefIndex() const {
return class_def_idx_;
}
@@ -108,7 +108,7 @@ class DexCompilationUnit {
const DexFile* const dex_file_;
const DexFile::CodeItem* const code_item_;
- const uint32_t class_def_idx_;
+ const uint16_t class_def_idx_;
const uint32_t dex_method_idx_;
const uint32_t access_flags_;