diff options
| author | 2015-12-17 13:55:59 -0800 | |
|---|---|---|
| committer | 2015-12-17 14:18:45 -0800 | |
| commit | 51a64d5d4fe91842cc2a5f2a412441147c145683 (patch) | |
| tree | dca598e01c333bce50b50d931516027987b4f343 | |
| parent | fae1db92d8433d0f75258c190bcf2c940731f036 (diff) | |
Make use of new method iterators.
Change-Id: I1f82f17951339b2054a1dac87bde79f9e803fc4a
| -rw-r--r-- | runtime/art_method.cc | 11 | ||||
| -rw-r--r-- | runtime/class_linker.cc | 13 | ||||
| -rw-r--r-- | runtime/debugger.cc | 17 | ||||
| -rw-r--r-- | runtime/instrumentation.cc | 7 |
4 files changed, 17 insertions, 31 deletions
diff --git a/runtime/art_method.cc b/runtime/art_method.cc index 238d9f3fe2..effa1c5d3f 100644 --- a/runtime/art_method.cc +++ b/runtime/art_method.cc @@ -146,10 +146,9 @@ ArtMethod* ArtMethod::FindOverriddenMethod(size_t pointer_size) { mirror::IfTable* iftable = GetDeclaringClass()->GetIfTable(); for (size_t i = 0; i < iftable->Count() && result == nullptr; i++) { mirror::Class* interface = iftable->GetInterface(i); - for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - ArtMethod* interface_method = interface->GetVirtualMethod(j, pointer_size); - if (HasSameNameAndSignature(interface_method->GetInterfaceMethodIfProxy(sizeof(void*)))) { - result = interface_method; + for (ArtMethod& interface_method : interface->GetVirtualMethods(pointer_size)) { + if (HasSameNameAndSignature(interface_method.GetInterfaceMethodIfProxy(pointer_size))) { + result = &interface_method; break; } } @@ -157,8 +156,8 @@ ArtMethod* ArtMethod::FindOverriddenMethod(size_t pointer_size) { } } DCHECK(result == nullptr || - GetInterfaceMethodIfProxy(sizeof(void*))->HasSameNameAndSignature( - result->GetInterfaceMethodIfProxy(sizeof(void*)))); + GetInterfaceMethodIfProxy(pointer_size)->HasSameNameAndSignature( + result->GetInterfaceMethodIfProxy(pointer_size))); return result; } diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 06f40e4d03..b9228f5945 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1874,12 +1874,10 @@ const OatFile::OatMethod ClassLinker::FindOatMethodFor(ArtMethod* method, bool* // We're invoking a virtual method directly (thanks to sharpening), compute the oat_method_index // by search for its position in the declared virtual methods. oat_method_index = declaring_class->NumDirectMethods(); - size_t end = declaring_class->NumVirtualMethods(); bool found_virtual = false; - for (size_t i = 0; i < end; i++) { + for (ArtMethod& art_method : declaring_class->GetVirtualMethods(image_pointer_size_)) { // Check method index instead of identity in case of duplicate method definitions. - if (method->GetDexMethodIndex() == - declaring_class->GetVirtualMethod(i, image_pointer_size_)->GetDexMethodIndex()) { + if (method->GetDexMethodIndex() == art_method.GetDexMethodIndex()) { found_virtual = true; break; } @@ -3213,11 +3211,8 @@ bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, void ClassLinker::ResolveClassExceptionHandlerTypes(const DexFile& dex_file, Handle<mirror::Class> klass) { - for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - ResolveMethodExceptionHandlerTypes(dex_file, klass->GetDirectMethod(i, image_pointer_size_)); - } - for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - ResolveMethodExceptionHandlerTypes(dex_file, klass->GetVirtualMethod(i, image_pointer_size_)); + for (ArtMethod& method : klass->GetMethods(image_pointer_size_)) { + ResolveMethodExceptionHandlerTypes(dex_file, &method); } } diff --git a/runtime/debugger.cc b/runtime/debugger.cc index e5d648bd19..c32331f28b 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -1491,25 +1491,20 @@ JDWP::JdwpError Dbg::OutputDeclaredMethods(JDWP::RefTypeId class_id, bool with_g return error; } - size_t direct_method_count = c->NumDirectMethods(); - size_t virtual_method_count = c->NumVirtualMethods(); - - expandBufAdd4BE(pReply, direct_method_count + virtual_method_count); + expandBufAdd4BE(pReply, c->NumMethods()); auto* cl = Runtime::Current()->GetClassLinker(); auto ptr_size = cl->GetImagePointerSize(); - for (size_t i = 0; i < direct_method_count + virtual_method_count; ++i) { - ArtMethod* m = i < direct_method_count ? - c->GetDirectMethod(i, ptr_size) : c->GetVirtualMethod(i - direct_method_count, ptr_size); - expandBufAddMethodId(pReply, ToMethodId(m)); - expandBufAddUtf8String(pReply, m->GetInterfaceMethodIfProxy(sizeof(void*))->GetName()); + for (ArtMethod& m : c->GetMethods(ptr_size)) { + expandBufAddMethodId(pReply, ToMethodId(&m)); + expandBufAddUtf8String(pReply, m.GetInterfaceMethodIfProxy(sizeof(void*))->GetName()); expandBufAddUtf8String(pReply, - m->GetInterfaceMethodIfProxy(sizeof(void*))->GetSignature().ToString()); + m.GetInterfaceMethodIfProxy(sizeof(void*))->GetSignature().ToString()); if (with_generic) { const char* generic_signature = ""; expandBufAddUtf8String(pReply, generic_signature); } - expandBufAdd4BE(pReply, MangleAccessFlags(m->GetAccessFlags())); + expandBufAdd4BE(pReply, MangleAccessFlags(m.GetAccessFlags())); } return JDWP::ERR_NONE; } diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index 264cd2c785..9f6144998a 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -93,11 +93,8 @@ void Instrumentation::InstallStubsForClass(mirror::Class* klass) { // We need the class to be resolved to install/uninstall stubs. Otherwise its methods // could not be initialized or linked with regards to class inheritance. } else { - for (size_t i = 0, e = klass->NumDirectMethods(); i < e; i++) { - InstallStubsForMethod(klass->GetDirectMethod(i, sizeof(void*))); - } - for (size_t i = 0, e = klass->NumVirtualMethods(); i < e; i++) { - InstallStubsForMethod(klass->GetVirtualMethod(i, sizeof(void*))); + for (ArtMethod& method : klass->GetMethods(sizeof(void*))) { + InstallStubsForMethod(&method); } } } |