diff options
| author | 2011-09-08 17:32:34 -0700 | |
|---|---|---|
| committer | 2011-09-08 17:32:34 -0700 | |
| commit | 8ba4fa861d75aaa765d00336b877c41291bb36f2 (patch) | |
| tree | a1e2211069e09fd2a60a066daa15d5e74bc951db | |
| parent | 34cd9e58431504c36d0cb2a8fd0f3fac16dcb406 (diff) | |
| parent | 7540ff4b6ad0ff5d8c5f60658b66155caf3a7cbc (diff) | |
Merge "Small change to make CompilerTest.CompileDexLibCore pass" into dalvik-dev
| -rw-r--r-- | src/class_linker.cc | 6 | ||||
| -rw-r--r-- | src/compiler_test.cc | 24 | ||||
| -rw-r--r-- | src/dex_file.h | 11 |
3 files changed, 31 insertions, 10 deletions
diff --git a/src/class_linker.cc b/src/class_linker.cc index 0df0cb778a..01e283e753 100644 --- a/src/class_linker.cc +++ b/src/class_linker.cc @@ -2114,10 +2114,10 @@ Method* ClassLinker::ResolveMethod(const DexFile& dex_file, const char* name = dex_file.dexStringById(method_id.name_idx_); std::string signature(dex_file.CreateMethodDescriptor(method_id.proto_idx_, NULL)); - if (klass->IsInterface()) { - resolved = klass->FindInterfaceMethod(name, signature); - } else if (is_direct) { + if (is_direct) { resolved = klass->FindDirectMethod(name, signature); + } else if (klass->IsInterface()) { + resolved = klass->FindInterfaceMethod(name, signature); } else { resolved = klass->FindVirtualMethod(name, signature); } diff --git a/src/compiler_test.cc b/src/compiler_test.cc index e232858bec..5766a4f77d 100644 --- a/src/compiler_test.cc +++ b/src/compiler_test.cc @@ -56,7 +56,7 @@ class CompilerTest : public CommonTest { } }; -// TODO renenable when compiler can handle libcore +// Disabled due to 10 second runtime on host TEST_F(CompilerTest, DISABLED_CompileDexLibCore) { Compiler compiler; compiler.CompileAll(NULL); @@ -67,22 +67,27 @@ TEST_F(CompilerTest, DISABLED_CompileDexLibCore) { EXPECT_EQ(dex->NumStringIds(), dex_cache->NumStrings()); for (size_t i = 0; i < dex_cache->NumStrings(); i++) { const String* string = dex_cache->GetResolvedString(i); - EXPECT_TRUE(string != NULL); + EXPECT_TRUE(string != NULL) << "string_idx=" << i; } EXPECT_EQ(dex->NumTypeIds(), dex_cache->NumResolvedTypes()); for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) { Class* type = dex_cache->GetResolvedType(i); - EXPECT_TRUE(type != NULL); + EXPECT_TRUE(type != NULL) << "type_idx=" << i + << " " << dex->GetTypeDescriptor(dex->GetTypeId(i)); } EXPECT_EQ(dex->NumMethodIds(), dex_cache->NumResolvedMethods()); for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) { Method* method = dex_cache->GetResolvedMethod(i); - EXPECT_TRUE(method != NULL); + EXPECT_TRUE(method != NULL) << "method_idx=" << i + << " " << dex->GetMethodClassDescriptor(dex->GetMethodId(i)) + << " " << dex->GetMethodName(dex->GetMethodId(i)); } EXPECT_EQ(dex->NumFieldIds(), dex_cache->NumResolvedFields()); for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) { Field* field = dex_cache->GetResolvedField(i); - EXPECT_TRUE(field != NULL); + EXPECT_TRUE(field != NULL) << "field_idx=" << i + << " " << dex->GetFieldClassDescriptor(dex->GetFieldId(i)) + << " " << dex->GetFieldName(dex->GetFieldId(i)); } // TODO check Class::IsVerified for all classes @@ -93,8 +98,13 @@ TEST_F(CompilerTest, DISABLED_CompileDexLibCore) { CodeAndDirectMethods* code_and_direct_methods = dex_cache->GetCodeAndDirectMethods(); for (size_t i = 0; i < dex_cache->NumCodeAndDirectMethods(); i++) { Method* method = dex_cache->GetResolvedMethod(i); - EXPECT_EQ(method->GetCode(), code_and_direct_methods->GetResolvedCode(i)); - EXPECT_EQ(method, code_and_direct_methods->GetResolvedMethod(i)); + if (method->IsDirect()) { + EXPECT_EQ(method->GetCode(), code_and_direct_methods->GetResolvedCode(i)); + EXPECT_EQ(method, code_and_direct_methods->GetResolvedMethod(i)); + } else { + EXPECT_EQ(0U, code_and_direct_methods->GetResolvedCode(i)); + EXPECT_TRUE(code_and_direct_methods->GetResolvedMethod(i) == NULL); + } } } diff --git a/src/dex_file.h b/src/dex_file.h index 98e79a7ed5..cf0bf204d0 100644 --- a/src/dex_file.h +++ b/src/dex_file.h @@ -428,6 +428,17 @@ class DexFile { return dexStringById(field_id.name_idx_); } + // Returns the class descriptor string of a method id. + const char* GetMethodClassDescriptor(const MethodId& method_id) const { + const DexFile::TypeId& type_id = GetTypeId(method_id.class_idx_); + return GetTypeDescriptor(type_id); + } + + // Returns the name of a method id. + const char* GetMethodName(const MethodId& method_id) const { + return dexStringById(method_id.name_idx_); + } + // Returns the StringId at the specified index. const StringId& GetStringId(uint32_t idx) const { CHECK_LT(idx, NumStringIds()); |