# HG changeset patch # User Doug Simon # Date 1337026009 -7200 # Node ID 17cddac1f2da52a965f9f010253b51bb10bc458b # Parent a3d6ea4241e5bc3be11d00148d8fce1c947642c5 fixed bug in compiled call to slow typecheck stub in VM enabled HIR lowering of all checkcasts by default diff -r a3d6ea4241e5 -r 17cddac1f2da graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Mon May 14 22:05:15 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Mon May 14 22:06:49 2012 +0200 @@ -260,9 +260,9 @@ /** * Use HIR lowering instead of LIR lowering for checkcast instructions. * Only checkcasts in methods whose fully qualified name contains this option will be HIR lowered. - * TDOD (dnsimon) remove once HIR checkcast lowering works reliably + * TODO (dnsimon) remove once HIR checkcast lowering works reliably */ - public static String HIRLowerCheckcast; + public static String HIRLowerCheckcast = ""; /** * The profiling info cache directory. diff -r a3d6ea4241e5 -r 17cddac1f2da graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Mon May 14 22:05:15 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/util/InliningUtil.java Mon May 14 22:06:49 2012 +0200 @@ -40,7 +40,6 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; -import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; import com.oracle.max.cri.ci.*; @@ -909,7 +908,6 @@ /** * Performs replacement of a node with a snippet graph. - * * @param replacee the node that will be replaced * @param anchor the control flow replacee * @param snippetGraph the graph that the replacee will be replaced with @@ -922,12 +920,11 @@ final StructuredGraph snippetGraph, final boolean explodeLoops, final IsImmutablePredicate immutabilityPredicate, - final CiLoweringTool tool, final Object... args) { Debug.scope("InliningSnippet", snippetGraph.method(), new Runnable() { @Override public void run() { - inlineSnippet0(runtime, replacee, anchor, snippetGraph, explodeLoops, immutabilityPredicate, tool, args); + inlineSnippet0(runtime, replacee, anchor, snippetGraph, explodeLoops, immutabilityPredicate, args); } }); } @@ -937,7 +934,7 @@ StructuredGraph snippetGraph, boolean explodeLoops, IsImmutablePredicate immutabilityPredicate, - CiLoweringTool tool, Object... args) { + Object... args) { Debug.dump(replacee.graph(), "Before lowering %s", replacee); @@ -1016,22 +1013,22 @@ Map duplicates = graph.addDuplicates(nodes, replacements); Debug.dump(graph, "After inlining snippet %s", snippetCopy.method()); +// if (tool != null) { +// boolean innerLowering = false; +// for (Node node : duplicates.values()) { +// if (node instanceof Lowerable) { +// innerLowering = true; +// ((Lowerable) node).lower(tool); +// +// } +// } +// if (innerLowering) { +// Debug.dump(graph, "After inner lowering"); +// } +// } + // Remove all frame states from the inlined snippet graph. Snippets must be atomic (i.e. free // of side-effects that prevent deoptimizing to a point before the snippet). - if (tool != null) { - boolean innerLowering = false; - for (Node node : duplicates.values()) { - if (node instanceof Lowerable) { - innerLowering = true; - ((Lowerable) node).lower(tool); - - } - } - if (innerLowering) { - Debug.dump(graph, "After inner lowering"); - } - } - for (Node node : graph.getNewNodes(mark)) { if (node instanceof StateSplit) { StateSplit stateSplit = (StateSplit) node; diff -r a3d6ea4241e5 -r 17cddac1f2da graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TypeCheckSlowPath.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TypeCheckSlowPath.java Mon May 14 22:05:15 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TypeCheckSlowPath.java Mon May 14 22:06:49 2012 +0200 @@ -25,6 +25,7 @@ import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.hotspot.target.amd64.*; +import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.type.*; @@ -48,7 +49,7 @@ } public TypeCheckSlowPath(ValueNode objectHub, ValueNode hub) { - super(StampFactory.forKind(CiKind.Object)); + super(StampFactory.forKind(CiKind.Boolean)); this.objectHub = objectHub; this.hub = hub; } @@ -56,14 +57,20 @@ @Override public void generate(LIRGenerator gen) { CiValue objectHubOpr = gen.operand(objectHub); - AMD64TypeCheckSlowPathOp op = new AMD64TypeCheckSlowPathOp(objectHubOpr, gen.operand(hub)); + Variable result = gen.newVariable(CiKind.Boolean); + AMD64TypeCheckSlowPathOp op = new AMD64TypeCheckSlowPathOp(result, objectHubOpr, gen.operand(hub)); gen.append(op); - gen.setResult(this, objectHubOpr); + gen.setResult(this, result); } + /** + * Checks if {@code objectHub} is a subclass of {@code hub}. + * + * @return {@code true} if {@code objectHub} is a subclass of {@code hub}, {@code false} otherwise + */ @SuppressWarnings("unused") @NodeIntrinsic - public static Object check(Object objectHub, Object hub) { + public static boolean check(Object objectHub, Object hub) { throw new UnsupportedOperationException("This method may only be compiled with the Graal compiler"); } diff -r a3d6ea4241e5 -r 17cddac1f2da graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Mon May 14 22:05:15 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Mon May 14 22:06:49 2012 +0200 @@ -412,7 +412,7 @@ memoryRead.dependencies().add(tool.createGuard(graph.unique(new NullCheckNode(objectClassNode.object(), false)), RiDeoptReason.NullCheckException, RiDeoptAction.InvalidateReprofile, StructuredGraph.INVALID_GRAPH_ID)); graph.replaceFixed(objectClassNode, memoryRead); } else if (n instanceof CheckCastNode) { - if (GraalOptions.HIRLowerCheckcast != null && graph.method() != null && CiUtil.format("%H.%n", graph.method()).contains(GraalOptions.HIRLowerCheckcast)) { + if (shouldLowerCheckcast(graph)) { final Map hintHubsSet = new IdentityHashMap<>(); IsImmutablePredicate immutabilityPredicate = new IsImmutablePredicate() { public boolean apply(CiConstant constant) { @@ -433,7 +433,7 @@ hintHubsSet.put(hintHubsConst, hintHubsConst); Debug.log("Lowering checkcast in %s: node=%s, hintsHubs=%s, exact=%b", graph, checkcast, Arrays.toString(hints.types), hints.exact); - InliningUtil.inlineSnippet(this, checkcast, checkcast, snippetGraph, true, immutabilityPredicate, tool, hub, object, hintHubsConst, CiConstant.forBoolean(hints.exact)); + InliningUtil.inlineSnippet(this, checkcast, checkcast, snippetGraph, true, immutabilityPredicate, hub, object, hintHubsConst, CiConstant.forBoolean(hints.exact)); new DeadCodeEliminationPhase().apply(graph); } } else { @@ -441,6 +441,18 @@ } } + private static boolean shouldLowerCheckcast(StructuredGraph graph) { + String option = GraalOptions.HIRLowerCheckcast; + if (option != null) { + if (option.length() == 0) { + return true; + } + RiResolvedMethod method = graph.method(); + return method != null && CiUtil.format("%H.%n", method).contains(option); + } + return false; + } + private IndexedLocationNode createArrayLocation(Graph graph, CiKind elementKind, ValueNode index) { return IndexedLocationNode.create(LocationNode.getArrayLocation(elementKind), elementKind, config.getArrayOffset(elementKind), index, graph); } diff -r a3d6ea4241e5 -r 17cddac1f2da graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java Mon May 14 22:05:15 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java Mon May 14 22:06:49 2012 +0200 @@ -46,7 +46,7 @@ return object; } } - if (hintsAreExact || TypeCheckSlowPath.check(objectHub, hub) == null) { + if (hintsAreExact || !TypeCheckSlowPath.check(objectHub, hub)) { DeoptimizeNode.deopt(RiDeoptAction.InvalidateReprofile, RiDeoptReason.ClassCastException); } return object; diff -r a3d6ea4241e5 -r 17cddac1f2da graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TypeCheckSlowPathOp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TypeCheckSlowPathOp.java Mon May 14 22:05:15 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TypeCheckSlowPathOp.java Mon May 14 22:06:49 2012 +0200 @@ -38,8 +38,8 @@ */ public class AMD64TypeCheckSlowPathOp extends AMD64LIRInstruction { - public AMD64TypeCheckSlowPathOp(CiValue objectHub, CiValue hub) { - super("TYPECHECK_SLOW", new CiValue[] {objectHub}, null, new CiValue[] {objectHub, hub}, NO_OPERANDS, NO_OPERANDS); + public AMD64TypeCheckSlowPathOp(CiValue result, CiValue objectHub, CiValue hub) { + super("TYPECHECK_SLOW", new CiValue[] {result}, null, new CiValue[] {objectHub, hub}, NO_OPERANDS, NO_OPERANDS); } @Override