# HG changeset patch # User Thomas Wuerthinger # Date 1363219783 -3600 # Node ID ff91c7101ed0af8ee2b99a4982835d3f3ee556ae # Parent 53683dc2815ec57d555285538df64800644918f0# Parent 1d40b7e8823b62c3cc33b8b62a24c47d92d43593 Merge. diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Mar 14 01:09:43 2013 +0100 @@ -149,6 +149,10 @@ new PartialEscapeAnalysisPhase(runtime, assumptions, true).apply(graph); } + if (GraalOptions.OptConvertDeoptsToGuards) { + new ConvertDeoptimizeToGuardPhase().apply(graph); + } + new LockEliminationPhase().apply(graph); if (GraalOptions.OptLoopTransform) { diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_idea.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_idea.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_idea.java Thu Mar 14 01:09:43 2013 +0100 @@ -372,7 +372,7 @@ /* * private int mul(int a, int b) throws ArithmeticException { long p; // Large enough to catch 16-bit multiply // - * without hitting sign bit. if (a != 0) { if(b != 0) { p = (long) a * b; b = (int) p & 0xFFFF; // Lower 16 bits. a + * without hitting sign bit. if (a != 0) { if (b != 0) { p = (long) a * b; b = (int) p & 0xFFFF; // Lower 16 bits. a * = (int) p >>> 16; // Upper 16 bits. * * return (b - a + (b < a ? 1 : 0) & 0xFFFF); } else return ((1 - a) & 0xFFFF); // If b = 0, then same as // 0x10001 diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/CFGVerifier.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/CFGVerifier.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/CFGVerifier.java Thu Mar 14 01:09:43 2013 +0100 @@ -67,6 +67,7 @@ if (!(block.isLoopHeader() && block.getLoop() == loop)) { for (Block pred : block.getPredecessors()) { if (!loop.blocks.contains(pred)) { + assert false : "Loop " + loop + " does not contain " + pred; return false; } } diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java Thu Mar 14 01:09:43 2013 +0100 @@ -80,7 +80,7 @@ @Override public boolean verify() { for (Node usage : usages()) { - assertTrue(usage instanceof IfNode || usage instanceof ConditionalNode, "unsupported usage: ", usage); + assertTrue(usage instanceof IfNode || usage instanceof ConditionalNode, "unsupported usage: %s", usage); } return super.verify(); } diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java Thu Mar 14 01:09:43 2013 +0100 @@ -80,26 +80,24 @@ IfNode ifNode = (IfNode) deoptBegin.predecessor(); BeginNode otherBegin = ifNode.trueSuccessor(); LogicNode conditionNode = ifNode.condition(); - if (conditionNode instanceof InstanceOfNode) { + if (conditionNode instanceof InstanceOfNode || conditionNode instanceof InstanceOfDynamicNode) { // TODO The lowering currently does not support a FixedGuard as the usage of an // InstanceOfNode. Relax this restriction. return; } + FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor(); boolean negated = false; if (deoptBegin == ifNode.trueSuccessor()) { negated = true; - otherBegin = ifNode.falseSuccessor(); + graph.removeSplitPropagate(ifNode, ifNode.falseSuccessor()); + } else { + graph.removeSplitPropagate(ifNode, ifNode.trueSuccessor()); } - BeginNode ifBlockBegin = findBeginNode(ifNode); - Debug.log("Converting %s on %-5s branch of %s to guard for remaining branch %s. IfBegin=%s", deopt, deoptBegin == ifNode.trueSuccessor() ? "true" : "false", ifNode, otherBegin, - ifBlockBegin); + Debug.log("Converting %s on %-5s branch of %s to guard for remaining branch %s.", deopt, deoptBegin == ifNode.trueSuccessor() ? "true" : "false", ifNode, otherBegin); FixedGuardNode guard = graph.add(new FixedGuardNode(conditionNode, deopt.reason(), deopt.action(), negated)); - otherBegin.replaceAtUsages(ifBlockBegin); - FixedNode next = otherBegin.next(); - otherBegin.setNext(null); + FixedNode next = pred.next(); + pred.setNext(guard); guard.setNext(next); - ifNode.replaceAtPredecessor(guard); - GraphUtil.killCFG(ifNode); } } } diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Thu Mar 14 01:09:43 2013 +0100 @@ -83,8 +83,8 @@ public ValueNode createGuard(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { if (GraalOptions.OptEliminateGuards) { for (Node usage : condition.usages()) { - if (!activeGuards.isNew(usage) && activeGuards.isMarked(usage)) { - return (ValueNode) usage; + if (!activeGuards.isNew(usage) && activeGuards.isMarked(usage) && ((GuardNode) usage).negated() == negated && ((GuardNode) usage).dependencies().contains(guardAnchor)) { + return (GuardNode) usage; } } } diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Thu Mar 14 01:09:43 2013 +0100 @@ -185,6 +185,7 @@ public static boolean SupportJsrBytecodes = true; public static boolean OptAssumptions = true; + public static boolean OptConvertDeoptsToGuards = true; public static boolean OptReadElimination = true; public static boolean OptCanonicalizer = true; public static boolean OptScheduleOutOfLoops = true; diff -r 1d40b7e8823b -r ff91c7101ed0 graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Wed Mar 13 23:54:01 2013 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu Mar 14 01:09:43 2013 +0100 @@ -247,15 +247,17 @@ } else { comparison = new IntegerLessThanNode(a, b); } - ConditionalNode materialize = graph.unique(new ConditionalNode(graph.unique(comparison), ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph))); - ValueNode op; + ConstantNode trueValue = ConstantNode.forInt(1, graph); + ConstantNode falseValue = ConstantNode.forInt(0, graph); + if (condition.canonicalNegate()) { - op = (ValueNode) materialize.negate(); - } else { - op = materialize; + ConstantNode temp = trueValue; + trueValue = falseValue; + falseValue = temp; } - return op; + ConditionalNode materialize = graph.unique(new ConditionalNode(graph.unique(comparison), trueValue, falseValue)); + return materialize; } private static ValueNode readOp(StructuredGraph graph, ValueNode base, ValueNode offset, Invoke invoke, Kind readKind, Object locationIdentity) { diff -r 1d40b7e8823b -r ff91c7101ed0 src/share/vm/code/nmethod.cpp --- a/src/share/vm/code/nmethod.cpp Wed Mar 13 23:54:01 2013 +0100 +++ b/src/share/vm/code/nmethod.cpp Thu Mar 14 01:09:43 2013 +0100 @@ -1923,7 +1923,7 @@ } #ifdef GRAAL - if(_graal_installed_code != NULL) { + if (_graal_installed_code != NULL) { f->do_oop((oop*) &_graal_installed_code); } if (_triggered_deoptimizations != NULL) { diff -r 1d40b7e8823b -r ff91c7101ed0 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Wed Mar 13 23:54:01 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Thu Mar 14 01:09:43 2013 +0100 @@ -85,7 +85,7 @@ memcpy(reconstituted_code, (jbyte *) method->code_base(), code_size); } BytecodeStream s(method); - while(!s.is_last_bytecode()) { + while (!s.is_last_bytecode()) { s.next(); Bytecodes::Code opcode = s.raw_code(); if (!Bytecodes::is_java_code(opcode)) { @@ -962,7 +962,7 @@ // XXX: Attention: it seEms that the line number table of a method just contains lines that are important, means that // empty lines are left out or lines that can't have a breakpoint on it; eg int a; or try { Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); - if(!method->has_linenumber_table()) { + if (!method->has_linenumber_table()) { return NULL; } u2 num_entries = 0; @@ -991,7 +991,7 @@ ResourceMark rm; Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); - if(!method->has_localvariable_table()) { + if (!method->has_localvariable_table()) { return NULL; } int localvariable_table_length = method->localvariable_table_length();