OSDN Git Service

ART: Fix GetArgumentsSize
authorAndreas Gampe <agampe@google.com>
Thu, 13 Apr 2017 04:11:28 +0000 (21:11 -0700)
committerAndreas Gampe <agampe@google.com>
Thu, 13 Apr 2017 17:27:18 +0000 (10:27 -0700)
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
test/910-methods/expected.txt

index bc73029..01bf21d 100644 (file)
@@ -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<jint>(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);
   }
 
index 8e6b6e7..a2f1a23 100644 (file)
@@ -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