# HG changeset patch # User Doug Simon # Date 1368043066 -7200 # Node ID 0eda2b7df7484040f29e1f2f0ce2d39e5fd308c9 # Parent 5e3c8dd8063252f7ba9bee27ad0a508e6d48867e fixed debug scope processing so that -G:MethodFilter option works as expected diff -r 5e3c8dd80632 -r 0eda2b7df748 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java --- 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; } } diff -r 5e3c8dd80632 -r 0eda2b7df748 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java --- 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.*; diff -r 5e3c8dd80632 -r 0eda2b7df748 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- 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); diff -r 5e3c8dd80632 -r 0eda2b7df748 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java --- 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 getInlineContext() { List 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()) {