summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2017-11-10 18:07:56 -0800
committer Mathieu Chartier <mathieuc@google.com> 2017-11-10 18:07:56 -0800
commitb7c273cb44fcbdab3c17ec69124fe4bbea2696b1 (patch)
tree11242e0bd24427183dd630780825214737ccbda1 /compiler/driver/compiler_driver.cc
parent27f5fefeb4a7e87e9537fbdd0ed392d5c1de59df (diff)
Add ClassDataItemIterator::HasNextMethod
Returns true if there are either static of virtual methods remaining, changed most places to use this where possible. Slight behavioral change for duplicate method checking, we not persist the method index across the static method / virtual method boundary. Motivation: Generic cleanup to remove copy paste. Test: test-art-host Change-Id: I7a1b507e681b2c40452f8a9913b53a96b181e171
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
-rw-r--r--compiler/driver/compiler_driver.cc76
1 files changed, 12 insertions, 64 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 32d0bbe495..f4700d4040 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -762,31 +762,17 @@ static void ResolveConstStrings(CompilerDriver* driver,
continue;
}
- // Direct methods.
- int64_t previous_direct_method_idx = -1;
- while (it.HasNextDirectMethod()) {
+ // Direct and virtual methods.
+ int64_t previous_method_idx = -1;
+ while (it.HasNextMethod()) {
uint32_t method_idx = it.GetMemberIndex();
- if (method_idx == previous_direct_method_idx) {
+ if (method_idx == previous_method_idx) {
// smali can create dex files with two encoded_methods sharing the same method_idx
// http://code.google.com/p/smali/issues/detail?id=119
it.Next();
continue;
}
- previous_direct_method_idx = method_idx;
- ResolveConstStrings(dex_cache, *dex_file, it.GetMethodCodeItem());
- it.Next();
- }
- // Virtual methods.
- int64_t previous_virtual_method_idx = -1;
- while (it.HasNextVirtualMethod()) {
- uint32_t method_idx = it.GetMemberIndex();
- if (method_idx == previous_virtual_method_idx) {
- // smali can create dex files with two encoded_methods sharing the same method_idx
- // http://code.google.com/p/smali/issues/detail?id=119
- it.Next();
- continue;
- }
- previous_virtual_method_idx = method_idx;
+ previous_method_idx = method_idx;
ResolveConstStrings(dex_cache, *dex_file, it.GetMethodCodeItem());
it.Next();
}
@@ -1702,16 +1688,7 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor {
it.Next();
}
if (resolve_fields_and_methods) {
- while (it.HasNextDirectMethod()) {
- ArtMethod* method = class_linker->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- dex_file, it.GetMemberIndex(), dex_cache, class_loader, nullptr,
- it.GetMethodInvokeType(class_def));
- if (method == nullptr) {
- CheckAndClearResolveException(soa.Self());
- }
- it.Next();
- }
- while (it.HasNextVirtualMethod()) {
+ while (it.HasNextMethod()) {
ArtMethod* method = class_linker->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
dex_file, it.GetMemberIndex(), dex_cache, class_loader, nullptr,
it.GetMethodInvokeType(class_def));
@@ -1820,12 +1797,7 @@ static void PopulateVerifiedMethods(const DexFile& dex_file,
ClassDataItemIterator it(dex_file, class_data);
it.SkipAllFields();
- while (it.HasNextDirectMethod()) {
- verification_results->CreateVerifiedMethodFor(MethodReference(&dex_file, it.GetMemberIndex()));
- it.Next();
- }
-
- while (it.HasNextVirtualMethod()) {
+ while (it.HasNextMethod()) {
verification_results->CreateVerifiedMethodFor(MethodReference(&dex_file, it.GetMemberIndex()));
it.Next();
}
@@ -2752,17 +2724,17 @@ class CompileClassVisitor : public CompilationVisitor {
bool compilation_enabled = driver->IsClassToCompile(
dex_file.StringByTypeIdx(class_def.class_idx_));
- // Compile direct methods
- int64_t previous_direct_method_idx = -1;
- while (it.HasNextDirectMethod()) {
+ // Compile direct and virtual methods.
+ int64_t previous_method_idx = -1;
+ while (it.HasNextMethod()) {
uint32_t method_idx = it.GetMemberIndex();
- if (method_idx == previous_direct_method_idx) {
+ if (method_idx == previous_method_idx) {
// smali can create dex files with two encoded_methods sharing the same method_idx
// http://code.google.com/p/smali/issues/detail?id=119
it.Next();
continue;
}
- previous_direct_method_idx = method_idx;
+ previous_method_idx = method_idx;
CompileMethod(soa.Self(),
driver,
it.GetMethodCodeItem(),
@@ -2777,30 +2749,6 @@ class CompileClassVisitor : public CompilationVisitor {
dex_cache);
it.Next();
}
- // Compile virtual methods
- int64_t previous_virtual_method_idx = -1;
- while (it.HasNextVirtualMethod()) {
- uint32_t method_idx = it.GetMemberIndex();
- if (method_idx == previous_virtual_method_idx) {
- // smali can create dex files with two encoded_methods sharing the same method_idx
- // http://code.google.com/p/smali/issues/detail?id=119
- it.Next();
- continue;
- }
- previous_virtual_method_idx = method_idx;
- CompileMethod(soa.Self(),
- driver, it.GetMethodCodeItem(),
- it.GetMethodAccessFlags(),
- it.GetMethodInvokeType(class_def),
- class_def_index,
- method_idx,
- class_loader,
- dex_file,
- dex_to_dex_compilation_level,
- compilation_enabled,
- dex_cache);
- it.Next();
- }
DCHECK(!it.HasNext());
}