# HG changeset patch # User Thomas Wuerthinger # Date 1433157588 -7200 # Node ID 0a203897b1126bd0416188071d6144259053a9c9 # Parent dcf65e8b9fd9ac28c689221258559988e27be195# Parent ed013f4d38e59385448d79d03d17f85fd5a12dad Merge. diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java Mon Jun 01 13:19:48 2015 +0200 @@ -120,21 +120,13 @@ } } // total : root = 1 exit, nested = 6, innermost = 4 - private static boolean a() { - return false; - } + private static native boolean a(); - private static boolean b() { - return false; - } + private static native boolean b(); - private static boolean c() { - return false; - } + private static native boolean c(); - private static boolean d() { - return false; - } + private static native boolean d(); private static Invoke getInvoke(String name, StructuredGraph graph) { for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) { @@ -150,7 +142,7 @@ Debug.dump(graph, "Graph"); ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true); - Assert.assertTrue(cfg.getLoops().size() == 3); + Assert.assertEquals(3, cfg.getLoops().size()); Loop rootLoop = cfg.getLoops().get(0); Loop nestedLoop = cfg.getLoops().get(1); Loop innerMostLoop = cfg.getLoops().get(2); diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java Mon Jun 01 13:19:48 2015 +0200 @@ -77,7 +77,7 @@ public static final OptionValue TraceBytecodeParserLevel = new OptionValue<>(0); @Option(help = "Inlines trivial methods during bytecode parsing.", type = OptionType.Expert)// - public static final StableOptionValue InlineDuringParsing = new StableOptionValue<>(false); + public static final StableOptionValue InlineDuringParsing = new StableOptionValue<>(true); @Option(help = "Inlines intrinsic methods during bytecode parsing.", type = OptionType.Expert)// public static final StableOptionValue InlineIntrinsicsDuringParsing = new StableOptionValue<>(true); @@ -377,7 +377,7 @@ stream.setBCI(0); BciBlock startBlock = blockMap.getStartBlock(); - if (startInstruction == graph.start()) { + if (this.parent == null) { StartNode startNode = graph.start(); if (method.isSynchronized()) { assert !parsingIntrinsic(); diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Mon Jun 01 13:19:48 2015 +0200 @@ -113,7 +113,7 @@ nodeToBlock = n -> schedule.getNodeToBlockMap().get(n); startBlock = cfg.getStartBlock(); } else { - ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true); + ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true); cfg.computePostdominators(); BlockMap> nodes = new BlockMap<>(cfg); for (Block b : cfg.getBlocks()) { @@ -136,8 +136,8 @@ private static class Instance { - private final NodeMap map; - private final Deque loopExits; + private NodeMap map; + private Deque loopExits; private final Function> blockToNodes; private final Function nodeToBlock; @@ -187,6 +187,18 @@ LoopExitNode loopExitNode = (LoopExitNode) beginNode; this.loopExits.push(loopExitNode); undoOperations.add(() -> loopExits.pop()); + } else if (block.getDominator() != null && + (block.getDominator().getLoopDepth() > block.getLoopDepth() || (block.getDominator().getLoopDepth() == block.getLoopDepth() && block.getDominator().getLoop() != block.getLoop()))) { + // We are exiting the loop, but there is not a single loop exit block along our + // dominator tree (e.g., we are a merge of two loop exits). + final NodeMap oldMap = map; + final Deque oldLoopExits = loopExits; + map = map.graph().createNodeMap(); + loopExits = new ArrayDeque<>(); + undoOperations.add(() -> { + map = oldMap; + loopExits = oldLoopExits; + }); } for (Node n : blockToNodes.apply(block)) { if (n.isAlive()) { diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Jun 01 13:19:48 2015 +0200 @@ -202,8 +202,8 @@ } private static boolean checkLatestEarliestRelation(Node currentNode, Block earliestBlock, Block latestBlock) { - assert AbstractControlFlowGraph.dominates(earliestBlock, latestBlock) || (currentNode instanceof VirtualState && latestBlock == earliestBlock.getDominator()) : String.format("%s %s %s", - currentNode, earliestBlock, latestBlock); + assert AbstractControlFlowGraph.dominates(earliestBlock, latestBlock) || (currentNode instanceof VirtualState && latestBlock == earliestBlock.getDominator()) : String.format( + "%s %s (%s) %s (%s)", currentNode, earliestBlock, earliestBlock.getBeginNode(), latestBlock, latestBlock.getBeginNode()); return true; } diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java Mon Jun 01 13:19:48 2015 +0200 @@ -48,8 +48,8 @@ return graph; } - private static void raiseException(String s) { - throw new RuntimeException(s); + private static void raiseExceptionSimple(String s) { + throw new RuntimeException("Raising exception with message \"" + s + "\""); } @Test @@ -67,7 +67,7 @@ public static String test1Snippet(String message) { if (message != null) { try { - raiseException(message); + raiseExceptionSimple(message); } catch (Exception e) { return message + e.getMessage(); } diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InlineDuringParsingPlugin.java Mon Jun 01 13:19:48 2015 +0200 @@ -33,9 +33,14 @@ @Override public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType) { - if (method.hasBytecodes() && !method.isSynchronized() && method.getCode().length <= TrivialInliningSize.getValue() && b.getDepth() < InlineDuringParsingMaxDepth.getValue()) { + if (method.hasBytecodes() && method.canBeInlined() && !method.isSynchronized() && checkSize(method, args) && b.getDepth() < InlineDuringParsingMaxDepth.getValue()) { return new InlineInfo(method, false); } return null; } + + private static boolean checkSize(ResolvedJavaMethod method, @SuppressWarnings("unused") ValueNode[] args) { + int bonus = 1; + return method.getCode().length <= TrivialInliningSize.getValue() * bonus; + } } diff -r ed013f4d38e5 -r 0a203897b112 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java Mon Jun 01 12:29:48 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MethodHandlePlugin.java Mon Jun 01 13:19:48 2015 +0200 @@ -57,11 +57,10 @@ } else { CallTargetNode callTarget = invoke.callTarget(); NodeInputList argumentsList = callTarget.arguments(); - ValueNode[] newArgs = argumentsList.toArray(new ValueNode[argumentsList.size()]); - for (ValueNode arg : newArgs) { - b.recursiveAppend(arg); + for (int i = 0; i < argumentsList.size(); ++i) { + argumentsList.initialize(i, b.recursiveAppend(argumentsList.get(i))); } - b.handleReplacedInvoke(invoke.getInvokeKind(), callTarget.targetMethod(), newArgs); + b.handleReplacedInvoke(invoke.getInvokeKind(), callTarget.targetMethod(), argumentsList.toArray(new ValueNode[argumentsList.size()])); } return true; }