changeset 5173:6bf22ac8141e

made MethodFilter patterns a little more flexible with respect to parameters
author Doug Simon <doug.simon@oracle.com>
date Thu, 29 Mar 2012 13:21:22 +0200
parents 8c9f7d19fbc1
children 9afe7747f988
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java
diffstat 2 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java	Thu Mar 29 13:20:43 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java	Thu Mar 29 13:21:22 2012 +0200
@@ -25,13 +25,12 @@
 import java.util.*;
 import java.util.regex.*;
 
-import com.oracle.max.cri.ci.*;
-import com.oracle.max.cri.ri.*;
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.printer.*;
-
+import com.oracle.max.cri.ci.*;
+import com.oracle.max.cri.ri.*;
 
 public class HotSpotDebugConfig implements DebugConfig {
 
@@ -54,7 +53,7 @@
             this.methodFilter = new MethodFilter[filters.length];
             for (int i = 0; i < filters.length; i++) {
                 this.methodFilter[i] = new MethodFilter(filters[i]);
-                // TTY.println(this.methodFilter[i].toString());
+                // com.oracle.max.criutils.TTY.println(this.methodFilter[i].toString());
             }
         }
         if (GraalOptions.PrintIdealGraphFile) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java	Thu Mar 29 13:20:43 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java	Thu Mar 29 13:21:22 2012 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot;
 
+import java.util.*;
 import java.util.regex.*;
 
 import com.oracle.max.cri.ci.*;
@@ -44,6 +45,9 @@
  * <li><pre>visit(Argument;BlockScope)</pre>
  * Matches all methods named "visit", with the first parameter of type "Argument", and the second parameter of type "BlockScope".
  * The packages of the parameter types are irrelevant.</li>
+ * <li><pre>arraycopy(Object;;;;)</pre>
+ * Matches all methods named "arraycopy", with the first parameter of type "Object", and four more parameters of any type.
+ * The packages of the parameter types are irrelevant.</li>
  * <li><pre>com.oracle.graal.compiler.graph.PostOrderNodeIterator.*</pre>
  * Matches all methods in the class "com.oracle.graal.compiler.graph.PostOrderNodeIterator".</li>
  * <li><pre>*</pre>
@@ -51,7 +55,6 @@
  * <li><pre>com.oracle.graal.compiler.graph.*.visit</pre>
  * Matches all methods named "visit" in classes in the package "com.oracle.graal.compiler.graph".</pre>
  * </ul>
- *
  */
 public class MethodFilter {
 
@@ -68,7 +71,7 @@
             if (pattern.charAt(pattern.length() - 1) != ')') {
                 throw new IllegalArgumentException("missing ')' at end of method filter pattern: " + pattern);
             }
-            String[] signatureClasses = pattern.substring(pos + 1, pattern.length() - 1).split(";");
+            String[] signatureClasses = pattern.substring(pos + 1, pattern.length() - 1).split(";", -1);
             signature = new Pattern[signatureClasses.length];
             for (int i = 0; i < signatureClasses.length; i++) {
                 signature[i] = createClassGlobPattern(signatureClasses[i].trim());
@@ -95,10 +98,12 @@
     }
 
     private static Pattern createClassGlobPattern(String pattern) {
-        if (pattern.contains(".")) {
+        if (pattern.length() == 0) {
+            return null;
+        } else if (pattern.contains(".")) {
             return Pattern.compile(createGlobString(pattern));
         } else {
-            return Pattern.compile("([^\\.]\\.)*" + createGlobString(pattern));
+            return Pattern.compile("([^\\.]*\\.)*" + createGlobString(pattern));
         }
     }
 
@@ -117,7 +122,8 @@
             }
             for (int i = 0; i < signature.length; i++) {
                 RiType type = sig.argumentTypeAt(i, null);
-                if (!signature[i].matcher(CiUtil.toJavaName(type)).matches()) {
+                String javaName = CiUtil.toJavaName(type);
+                if (signature[i] != null && !signature[i].matcher(javaName).matches()) {
                     return false;
                 }
             }
@@ -138,7 +144,7 @@
             sep = ", ";
         }
         if (signature != null) {
-            buf.append(sep).append("signature=").append(signature);
+            buf.append(sep).append("signature=").append(Arrays.toString(signature));
             sep = ", ";
         }
         return buf.append("]").toString();