From e1f79b62f37e8008fe1889f0a7c783be367a0cef Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Wed, 12 Apr 2017 21:11:28 -0700 Subject: [PATCH] ART: Fix GetArgumentsSize Fix the copy-paste mistake in GetArgumentsSize for abstract and proxy methods. Use the usual computation derived from the shorty. Bug: 34163329 Test: art/test/testrunner/testrunner.py --host -t 910 Change-Id: I71eaab70063303bea8eaa391ea067ebf8027820f --- runtime/openjdkjvmti/ti_method.cc | 15 ++++++++++----- test/910-methods/expected.txt | 12 ++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/runtime/openjdkjvmti/ti_method.cc b/runtime/openjdkjvmti/ti_method.cc index bc73029f4..01bf21d53 100644 --- a/runtime/openjdkjvmti/ti_method.cc +++ b/runtime/openjdkjvmti/ti_method.cc @@ -61,8 +61,13 @@ jvmtiError MethodUtil::GetArgumentsSize(jvmtiEnv* env ATTRIBUTE_UNUSED, art::ScopedObjectAccess soa(art::Thread::Current()); if (art_method->IsProxyMethod() || art_method->IsAbstract()) { - // This isn't specified as an error case, so return 0. - *size_ptr = 0; + // Use the shorty. + art::ArtMethod* base_method = art_method->GetInterfaceMethodIfProxy(art::kRuntimePointerSize); + size_t arg_count = art::ArtMethod::NumArgRegisters(base_method->GetShorty()); + if (!base_method->IsStatic()) { + arg_count++; + } + *size_ptr = static_cast(arg_count); return ERR(NONE); } @@ -203,9 +208,9 @@ jvmtiError MethodUtil::GetMethodLocation(jvmtiEnv* env ATTRIBUTE_UNUSED, art::ScopedObjectAccess soa(art::Thread::Current()); if (art_method->IsProxyMethod() || art_method->IsAbstract()) { - // This isn't specified as an error case, so return 0/0. - *start_location_ptr = 0; - *end_location_ptr = 0; + // This isn't specified as an error case, so return -1/-1 as the RI does. + *start_location_ptr = -1; + *end_location_ptr = -1; return ERR(NONE); } diff --git a/test/910-methods/expected.txt b/test/910-methods/expected.txt index 8e6b6e76d..a2f1a230c 100644 --- a/test/910-methods/expected.txt +++ b/test/910-methods/expected.txt @@ -32,9 +32,9 @@ Is synthetic: false interface java.util.List 1025 Max locals: 0 -Argument size: 0 -Location start: 0 -Location end: 0 +Argument size: 2 +Location start: -1 +Location end: -1 Is native: false Is obsolete: false Is synthetic: false @@ -42,9 +42,9 @@ Is synthetic: false class $Proxy0 17 Max locals: 0 -Argument size: 0 -Location start: 0 -Location end: 0 +Argument size: 1 +Location start: -1 +Location end: -1 Is native: false Is obsolete: false Is synthetic: false -- 2.11.0