changeset 9620:0eda2b7df748

fixed debug scope processing so that -G:MethodFilter option works as expected
author Doug Simon <doug.simon@oracle.com>
date Wed, 08 May 2013 21:57:46 +0200
parents 5e3c8dd80632
children e97dc9bbfedc
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java
diffstat 4 files changed, 32 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Wed May 08 21:09:38 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Wed May 08 21:57:46 2013 +0200
@@ -29,6 +29,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.phases.*;
 
@@ -94,6 +95,24 @@
         return filter != null && filter.matches(currentScope);
     }
 
+    /**
+     * Extracts a {@link JavaMethod} from an opaque debug context.
+     * 
+     * @return the {@link JavaMethod} represented by {@code context} or null
+     */
+    public static JavaMethod asJavaMethod(Object context) {
+        if (context instanceof JavaMethod) {
+            return (JavaMethod) context;
+        }
+        if (context instanceof StructuredGraph) {
+            ResolvedJavaMethod method = ((StructuredGraph) context).method();
+            if (method != null) {
+                return method;
+            }
+        }
+        return null;
+    }
+
     private boolean checkMethodFilter() {
         if (methodFilter == null && extraFilters.isEmpty()) {
             return true;
@@ -102,9 +121,10 @@
                 if (extraFilters.contains(o)) {
                     return true;
                 } else if (methodFilter != null) {
-                    if (o instanceof JavaMethod) {
+                    JavaMethod method = asJavaMethod(o);
+                    if (method != null) {
                         for (MethodFilter filter : methodFilter) {
-                            if (filter.matches((JavaMethod) o)) {
+                            if (filter.matches(method)) {
                                 return true;
                             }
                         }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Wed May 08 21:09:38 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Wed May 08 21:57:46 2013 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.compiler.target;
 
 import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.lir.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed May 08 21:09:38 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed May 08 21:57:46 2013 +0200
@@ -141,17 +141,21 @@
      */
     protected abstract ResolvedJavaMethod getInstallationMethod();
 
+    protected Object debugScopeContext() {
+        return getInstallationMethod();
+    }
+
     /**
      * Gets the code for this stub, compiling it first if necessary.
      */
     public synchronized InstalledCode getCode(final Backend backend) {
         if (code == null) {
-            final StructuredGraph graph = getGraph();
-            Debug.sandbox("CompilingStub", new Object[]{runtime, graph}, DebugScope.getConfig(), new Runnable() {
+            Debug.sandbox("CompilingStub", new Object[]{runtime, debugScopeContext()}, DebugScope.getConfig(), new Runnable() {
 
                 @Override
                 public void run() {
 
+                    final StructuredGraph graph = getGraph();
                     StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
                     newStart.setStateAfter(graph.start().stateAfter());
                     graph.replaceFixed(graph.start(), newStart);
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed May 08 21:09:38 2013 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed May 08 21:57:46 2013 +0200
@@ -30,9 +30,9 @@
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.schedule.*;
 
@@ -182,13 +182,9 @@
     private static List<String> getInlineContext() {
         List<String> result = new ArrayList<>();
         for (Object o : Debug.context()) {
-            if (o instanceof StructuredGraph) {
-                ResolvedJavaMethod method = ((StructuredGraph) o).method();
-                if (method != null) {
-                    result.add(MetaUtil.format("%H::%n(%p)", method));
-                } else {
-                    result.add(String.valueOf(o));
-                }
+            JavaMethod method = GraalDebugConfig.asJavaMethod(o);
+            if (method != null) {
+                result.add(MetaUtil.format("%H::%n(%p)", method));
             } else if (o instanceof DebugDumpScope) {
                 DebugDumpScope debugDumpScope = (DebugDumpScope) o;
                 if (debugDumpScope.decorator && !result.isEmpty()) {