# HG changeset patch # User Doug Simon # Date 1363369918 -3600 # Node ID 338b0d2382b366b402a4e0626c1b95923ac14783 # Parent 02a3fd8a83083e39163e6b634fb8170a6bb8ee46# Parent a1558c08d990ef654f6a53de5d99782555ddde70 Merge. diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64DeoptimizationStub.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64DeoptimizationStub.java Fri Mar 15 18:50:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.amd64; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.RuntimeCallTarget.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.amd64.*; -import com.oracle.graal.lir.asm.*; - -public class AMD64DeoptimizationStub extends AMD64Code { - - public static final Descriptor DEOPTIMIZE = new Descriptor("deoptimize", true, void.class); - - public final Label label = new Label(); - public final LIRFrameState info; - public final DeoptimizationAction action; - public final DeoptimizationReason reason; - - public AMD64DeoptimizationStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info) { - this.action = action; - this.reason = reason; - this.info = info; - } - - @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - Register scratch = tasm.frameMap.registerConfig.getScratchRegister(); - masm.bind(label); - masm.movl(scratch, tasm.runtime.encodeDeoptActionAndReason(action, reason)); - AMD64Call.directCall(tasm, masm, tasm.runtime.lookupRuntimeCall(DEOPTIMIZE), info); - } - - @Override - public String description() { - return "deopt stub[reason=" + reason + ", action=" + action + "]"; - } -} diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Fri Mar 15 18:51:58 2013 +0100 @@ -67,7 +67,6 @@ import com.oracle.graal.lir.amd64.AMD64Move.MembarOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp; -import com.oracle.graal.lir.amd64.AMD64Move.NullCheckOp; import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreOp; @@ -255,23 +254,23 @@ } @Override - public void emitJump(LabelRef label, LIRFrameState info) { - append(new JumpOp(label, info)); + public void emitJump(LabelRef label) { + append(new JumpOp(label)); } @Override - public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info) { + public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label) { boolean mirrored = emitCompare(left, right); Condition finalCondition = mirrored ? cond.mirror() : cond; switch (left.getKind().getStackKind()) { case Int: case Long: case Object: - append(new BranchOp(finalCondition, label, info)); + append(new BranchOp(finalCondition, label)); break; case Float: case Double: - append(new FloatBranchOp(finalCondition, unorderedIsTrue, label, info)); + append(new FloatBranchOp(finalCondition, unorderedIsTrue, label)); break; default: throw GraalInternalError.shouldNotReachHere("" + left.getKind()); @@ -279,14 +278,14 @@ } @Override - public void emitOverflowCheckBranch(LabelRef destination, LIRFrameState info, boolean negated) { - append(new BranchOp(negated ? ConditionFlag.NoOverflow : ConditionFlag.Overflow, destination, info)); + public void emitOverflowCheckBranch(LabelRef destination, boolean negated) { + append(new BranchOp(negated ? ConditionFlag.NoOverflow : ConditionFlag.Overflow, destination)); } @Override - public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label, LIRFrameState info) { + public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label) { emitIntegerTest(left, right); - append(new BranchOp(negated ? Condition.NE : Condition.EQ, label, info)); + append(new BranchOp(negated ? Condition.NE : Condition.EQ, label)); } @Override @@ -773,13 +772,6 @@ } @Override - public void emitDeoptimizeOnOverflow(DeoptimizationAction action, DeoptimizationReason reason) { - LIRFrameState info = state(reason); - LabelRef stubEntry = createDeoptStub(action, reason, info); - append(new BranchOp(ConditionFlag.Overflow, stubEntry, info)); - } - - @Override public void emitMembar(int barriers) { int necessaryBarriers = target.arch.requiredBarriers(barriers); if (target.isMP && necessaryBarriers != 0) { @@ -899,29 +891,6 @@ } @Override - protected LabelRef createDeoptStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info) { - assert info.topFrame.getBCI() >= 0 : "invalid bci for deopt framestate"; - AMD64DeoptimizationStub stub = new AMD64DeoptimizationStub(action, reason, info); - lir.stubs.add(stub); - return LabelRef.forLabel(stub.label); - } - - @Override - public void emitGuardCheck(LogicNode comp, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { - if (comp instanceof IsNullNode && negated) { - emitNullCheckGuard(((IsNullNode) comp).object()); - } else { - super.emitGuardCheck(comp, deoptReason, action, negated); - } - } - - private void emitNullCheckGuard(ValueNode object) { - Variable value = load(operand(object)); - LIRFrameState info = state(); - append(new NullCheckOp(value, info)); - } - - @Override public void visitCompareAndSwap(CompareAndSwapNode node) { Kind kind = node.newValue().kind(); assert kind == node.expected().kind(); diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXDeoptimizationStub.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXDeoptimizationStub.java Fri Mar 15 18:50:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.compiler.ptx; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.RuntimeCallTarget.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.asm.ptx.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.ptx.*; -import com.oracle.graal.lir.asm.*; - -public class PTXDeoptimizationStub extends PTXCode { - - public static final Descriptor DEOPTIMIZE = new Descriptor("deoptimize", true, void.class); - public static final Descriptor SET_DEOPT_INFO = new Descriptor("setDeoptInfo", true, void.class, Object.class); - - public final Label label = new Label(); - public final LIRFrameState info; - public final DeoptimizationAction action; - public final DeoptimizationReason reason; - - public PTXDeoptimizationStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info) { - this.action = action; - this.reason = reason; - this.info = info; - } - - @Override - public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { - masm.exit(); - } - - @Override - public String description() { - return "deopt stub[reason=" + reason + ", action=" + action + "]"; - } -} diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Fri Mar 15 18:51:58 2013 +0100 @@ -179,20 +179,20 @@ } @Override - public void emitJump(LabelRef label, LIRFrameState info) { - append(new JumpOp(label, info)); + public void emitJump(LabelRef label) { + append(new JumpOp(label)); } @Override - public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info) { + public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label) { switch (left.getKind().getStackKind()) { case Int: append(new CompareOp(ICMP, cond, left, right)); - append(new BranchOp(cond, label, info)); + append(new BranchOp(cond, label)); break; case Object: append(new CompareOp(ACMP, cond, left, right)); - append(new BranchOp(cond, label, info)); + append(new BranchOp(cond, label)); break; default: throw GraalInternalError.shouldNotReachHere("" + left.getKind()); @@ -200,12 +200,12 @@ } @Override - public void emitOverflowCheckBranch(LabelRef label, LIRFrameState info, boolean negated) { + public void emitOverflowCheckBranch(LabelRef label, boolean negated) { throw new InternalError("NYI"); } @Override - public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label, LIRFrameState info) { + public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label) { throw new InternalError("NYI"); } @@ -349,11 +349,6 @@ } @Override - public void emitDeoptimizeOnOverflow(DeoptimizationAction action, DeoptimizationReason reason) { - throw new InternalError("NYI"); - } - - @Override public void emitDeoptimize(DeoptimizationAction action, DeoptimizationReason reason) { append(new ReturnOp(Value.ILLEGAL)); } @@ -453,14 +448,6 @@ } @Override - protected LabelRef createDeoptStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info) { - assert info.topFrame.getBCI() >= 0 : "invalid bci for deopt framestate"; - PTXDeoptimizationStub stub = new PTXDeoptimizationStub(action, reason, info); - lir.stubs.add(stub); - return LabelRef.forLabel(stub.label); - } - - @Override public void visitCompareAndSwap(CompareAndSwapNode node) { throw new InternalError("NYI"); } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Fri Mar 15 18:51:58 2013 +0100 @@ -62,7 +62,7 @@ } @Override - public void emitJump(LabelRef label, LIRFrameState info) { + public void emitJump(LabelRef label) { @SuppressWarnings("unused") SPARCLIRInstruction instruction = null; // SPARC: Auto-generated method stub @@ -70,19 +70,19 @@ } @Override - public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info) { + public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label) { // SPARC: Auto-generated method stub } @Override - public void emitOverflowCheckBranch(LabelRef label, LIRFrameState info, boolean negated) { + public void emitOverflowCheckBranch(LabelRef label, boolean negated) { // SPARC: Auto-generated method stub } @Override - public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label, LIRFrameState info) { + public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label) { // SPARC: Auto-generated method stub } @@ -118,12 +118,6 @@ } @Override - protected LabelRef createDeoptStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info) { - // SPARC: Auto-generated method stub - return null; - } - - @Override protected void emitSequentialSwitch(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key) { // SPARC: Auto-generated method stub @@ -340,12 +334,6 @@ } @Override - public void emitDeoptimizeOnOverflow(DeoptimizationAction action, DeoptimizationReason reason) { - // SPARC: Auto-generated method stub - - } - - @Override public void emitDeoptimize(DeoptimizationAction action, DeoptimizationReason reason) { // SPARC: Auto-generated method stub diff -r 02a3fd8a8308 -r 338b0d2382b3 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 Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Fri Mar 15 18:51:58 2013 +0100 @@ -204,7 +204,7 @@ plan.runPhases(PhasePosition.LOW_LEVEL, graph); - new GuardLoweringPhase().apply(graph); + new GuardLoweringPhase(target).apply(graph); // Add safepoints to loops new SafepointInsertionPhase().apply(graph); diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Fri Mar 15 18:51:58 2013 +0100 @@ -350,27 +350,6 @@ List nodes = lir.nodesFor(block); for (int i = 0; i < nodes.size(); i++) { Node instr = nodes.get(i); - - if (GraalOptions.OptImplicitNullChecks) { - Node nextInstr = null; - if (i < nodes.size() - 1) { - nextInstr = nodes.get(i + 1); - } - - if (instr instanceof GuardNode) { - GuardNode guardNode = (GuardNode) instr; - if (guardNode.condition() instanceof IsNullNode && guardNode.negated()) { - IsNullNode isNullNode = (IsNullNode) guardNode.condition(); - if (nextInstr instanceof Access) { - Access access = (Access) nextInstr; - if (isNullNode.object() == access.object() && canBeNullCheck(access.location())) { - access.setNullCheck(true); - continue; - } - } - } - } - } if (GraalOptions.TraceLIRGeneratorLevel >= 3) { TTY.println("LIRGen for " + instr); } @@ -411,7 +390,7 @@ NodeClassIterable successors = block.getEndNode().successors(); assert successors.isNotEmpty() : "should have at least one successor : " + block.getEndNode(); - emitJump(getLIRBlock((FixedNode) successors.first()), null); + emitJump(getLIRBlock((FixedNode) successors.first())); } if (GraalOptions.TraceLIRGeneratorLevel >= 1) { @@ -470,10 +449,6 @@ ((LIRLowerable) node).generate(this); } - private boolean canBeNullCheck(LocationNode location) { - return !(location instanceof IndexedLocationNode) && location.displacement() < this.target().implicitNullCheckLimit; - } - protected CallingConvention createCallingConvention() { return frameMap.registerConfig.getCallingConvention(JavaCallee, method.getSignature().getReturnType(null), MetaUtil.signatureToTypes(method), target, false); } @@ -572,7 +547,7 @@ } resolver.dispose(); - append(new JumpOp(getLIRBlock(merge), null)); + append(new JumpOp(getLIRBlock(merge))); } private Value operandForPhi(PhiNode phi) { @@ -590,89 +565,46 @@ @Override public void emitIf(IfNode x) { - emitBranch(x.condition(), getLIRBlock(x.trueSuccessor()), getLIRBlock(x.falseSuccessor()), null); + emitBranch(x.condition(), getLIRBlock(x.trueSuccessor()), getLIRBlock(x.falseSuccessor())); } - @Override - public void emitGuardCheck(LogicNode comp, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { - if (comp instanceof LogicConstantNode && ((LogicConstantNode) comp).getValue() != negated) { - // True constant, nothing to emit. - // False constants are handled within emitBranch. - } else { - // Fall back to a normal branch. - LIRFrameState info = state(deoptReason); - LabelRef stubEntry = createDeoptStub(action, deoptReason, info); - if (negated) { - emitBranch(comp, stubEntry, null, info); - } else { - emitBranch(comp, null, stubEntry, info); - } - } - } - - public void emitBranch(LogicNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, LIRFrameState info) { + public void emitBranch(LogicNode node, LabelRef trueSuccessor, LabelRef falseSuccessor) { if (node instanceof IsNullNode) { - emitNullCheckBranch((IsNullNode) node, trueSuccessor, falseSuccessor, info); + emitNullCheckBranch((IsNullNode) node, trueSuccessor, falseSuccessor); } else if (node instanceof CompareNode) { - emitCompareBranch((CompareNode) node, trueSuccessor, falseSuccessor, info); + emitCompareBranch((CompareNode) node, trueSuccessor, falseSuccessor); } else if (node instanceof LogicConstantNode) { - emitConstantBranch(((LogicConstantNode) node).getValue(), trueSuccessor, falseSuccessor, info); + emitConstantBranch(((LogicConstantNode) node).getValue(), trueSuccessor, falseSuccessor); } else if (node instanceof IntegerTestNode) { - emitIntegerTestBranch((IntegerTestNode) node, trueSuccessor, falseSuccessor, info); + emitIntegerTestBranch((IntegerTestNode) node, trueSuccessor, falseSuccessor); } else { throw GraalInternalError.unimplemented(node.toString()); } } - private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, LIRFrameState info) { - if (falseSuccessor != null) { - emitCompareBranch(operand(node.object()), Constant.NULL_OBJECT, Condition.NE, false, falseSuccessor, info); - if (trueSuccessor != null) { - emitJump(trueSuccessor, null); - } - } else { - emitCompareBranch(operand(node.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueSuccessor, info); - } + private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor) { + emitCompareBranch(operand(node.object()), Constant.NULL_OBJECT, Condition.NE, false, falseSuccessor); + emitJump(trueSuccessor); } - public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock, LIRFrameState info) { - if (falseSuccessorBlock != null) { - emitCompareBranch(operand(compare.x()), operand(compare.y()), compare.condition().negate(), !compare.unorderedIsTrue(), falseSuccessorBlock, info); - if (trueSuccessorBlock != null) { - emitJump(trueSuccessorBlock, null); - } - } else { - emitCompareBranch(operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueSuccessorBlock, info); - } + public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock) { + emitCompareBranch(operand(compare.x()), operand(compare.y()), compare.condition().negate(), !compare.unorderedIsTrue(), falseSuccessorBlock); + emitJump(trueSuccessorBlock); } - public void emitOverflowCheckBranch(LabelRef noOverflowBlock, LabelRef overflowBlock, LIRFrameState info) { - if (overflowBlock != null) { - emitOverflowCheckBranch(overflowBlock, info, false); - if (noOverflowBlock != null) { - emitJump(noOverflowBlock, null); - } - } else { - emitOverflowCheckBranch(noOverflowBlock, info, true); - } + public void emitOverflowCheckBranch(LabelRef noOverflowBlock, LabelRef overflowBlock) { + emitOverflowCheckBranch(overflowBlock, false); + emitJump(noOverflowBlock); } - public void emitIntegerTestBranch(IntegerTestNode test, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock, LIRFrameState info) { - if (falseSuccessorBlock != null) { - emitIntegerTestBranch(operand(test.x()), operand(test.y()), true, falseSuccessorBlock, info); - if (trueSuccessorBlock != null) { - emitJump(trueSuccessorBlock, null); - } - } else { - emitIntegerTestBranch(operand(test.x()), operand(test.y()), false, trueSuccessorBlock, info); - } + public void emitIntegerTestBranch(IntegerTestNode test, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock) { + emitIntegerTestBranch(operand(test.x()), operand(test.y()), true, falseSuccessorBlock); + emitJump(trueSuccessorBlock); } - public void emitConstantBranch(boolean value, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock, LIRFrameState info) { + public void emitConstantBranch(boolean value, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock) { LabelRef block = value ? trueSuccessorBlock : falseSuccessorBlock; - if (block != null) { - emitJump(block, info); - } + emitJump(block); } @Override @@ -699,13 +631,13 @@ } } - public abstract void emitJump(LabelRef label, LIRFrameState info); + public abstract void emitJump(LabelRef label); - public abstract void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info); + public abstract void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label); - public abstract void emitOverflowCheckBranch(LabelRef label, LIRFrameState info, boolean negated); + public abstract void emitOverflowCheckBranch(LabelRef label, boolean negated); - public abstract void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label, LIRFrameState info); + public abstract void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label); public abstract Variable emitConditionalMove(Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue); @@ -777,8 +709,6 @@ return result; } - protected abstract LabelRef createDeoptStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info); - @Override public Variable emitCall(RuntimeCallTarget callTarget, CallingConvention cc, boolean canTrap, Value... args) { LIRFrameState info = canTrap ? state() : null; @@ -847,7 +777,7 @@ public void emitSwitch(SwitchNode x) { int keyCount = x.keyCount(); if (keyCount == 0) { - emitJump(getLIRBlock(x.defaultSuccessor()), null); + emitJump(getLIRBlock(x.defaultSuccessor())); } else { Variable value = load(operand(x.value())); LabelRef defaultTarget = x.defaultSuccessor() == null ? null : getLIRBlock(x.defaultSuccessor()); @@ -859,7 +789,7 @@ long valueRange = x.keyAt(keyCount - 1).asLong() - x.keyAt(0).asLong() + 1; int switchRangeCount = switchRangeCount(x); if (switchRangeCount == 0) { - emitJump(getLIRBlock(x.defaultSuccessor()), null); + emitJump(getLIRBlock(x.defaultSuccessor())); } else if (switchRangeCount >= GraalOptions.MinimumJumpTableSize && keyCount / (double) valueRange >= GraalOptions.MinTableSwitchDensity) { int minValue = x.keyAt(0).asInt(); assert valueRange < Integer.MAX_VALUE; diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Code.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Code.java Fri Mar 15 18:50:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.amd64; - -import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.asm.*; - -/** - * Convenience class to provide AMD64MacroAssembler for the {@link #emitCode} method. - */ -public abstract class AMD64Code implements LIR.Code { - - @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (AMD64MacroAssembler) tasm.asm); - } - - public abstract void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm); -} diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Fri Mar 15 18:51:58 2013 +0100 @@ -63,16 +63,14 @@ public static class BranchOp extends AMD64LIRInstruction implements StandardOp.BranchOp { protected ConditionFlag condition; protected LabelRef destination; - @State protected LIRFrameState state; - public BranchOp(Condition condition, LabelRef destination, LIRFrameState info) { - this(intCond(condition), destination, info); + public BranchOp(Condition condition, LabelRef destination) { + this(intCond(condition), destination); } - public BranchOp(ConditionFlag condition, LabelRef destination, LIRFrameState state) { + public BranchOp(ConditionFlag condition, LabelRef destination) { this.condition = condition; this.destination = destination; - this.state = state; } @Override @@ -96,8 +94,8 @@ public static class FloatBranchOp extends BranchOp { protected boolean unorderedIsTrue; - public FloatBranchOp(Condition condition, boolean unorderedIsTrue, LabelRef destination, LIRFrameState info) { - super(floatCond(condition), destination, info); + public FloatBranchOp(Condition condition, boolean unorderedIsTrue, LabelRef destination) { + super(floatCond(condition), destination); this.unorderedIsTrue = unorderedIsTrue; } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCode.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCode.java Fri Mar 15 18:50:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.ptx; - -import com.oracle.graal.asm.ptx.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.asm.*; - -/** - * Convenience class to provide PTXAssembler for the {@link #emitCode} method. - */ -public abstract class PTXCode implements LIR.Code { - - @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (PTXAssembler) tasm.asm); - } - - public abstract void emitCode(TargetMethodAssembler tasm, PTXAssembler masm); -} diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Fri Mar 15 18:51:58 2013 +0100 @@ -54,12 +54,10 @@ protected Condition condition; protected LabelRef destination; - @State protected LIRFrameState state; - public BranchOp(Condition condition, LabelRef destination, LIRFrameState state) { + public BranchOp(Condition condition, LabelRef destination) { this.condition = condition; this.destination = destination; - this.state = state; } @Override diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Fri Mar 15 18:51:58 2013 +0100 @@ -56,12 +56,6 @@ */ private final List codeEmittingOrder; - /** - * Various out-of-line stubs to be emitted near the end of the method after all other LIR code - * has been emitted. - */ - public final List stubs; - private int numVariables; public SpillMoveFactory spillMoveFactory; @@ -78,19 +72,6 @@ private final SpeculationLog speculationLog; /** - * An opaque chunk of machine code. - */ - public interface Code { - - void emitCode(TargetMethodAssembler tasm); - - /** - * A description of this code stub useful for commenting the code in a disassembly. - */ - String description(); - } - - /** * Creates a new LIR instance for the specified compilation. */ public LIR(ControlFlowGraph cfg, BlockMap> blockToNodesMap, List linearScanOrder, List codeEmittingOrder, SpeculationLog speculationLog) { @@ -99,8 +80,6 @@ this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; this.lirInstructions = new BlockMap<>(cfg); - - stubs = new ArrayList<>(); this.speculationLog = speculationLog; } @@ -167,11 +146,6 @@ for (Block b : codeEmittingOrder()) { emitBlock(tasm, b); } - - // generate code stubs - for (Code c : stubs) { - emitCodeStub(tasm, c); - } } private void emitBlock(TargetMethodAssembler tasm, Block block) { @@ -202,13 +176,6 @@ } } - private static void emitCodeStub(TargetMethodAssembler tasm, Code code) { - if (Debug.isDumpEnabled()) { - tasm.blockComment(String.format("code stub: %s", code.description())); - } - code.emitCode(tasm); - } - public void setHasArgInCallerFrame() { hasArgInCallerFrame = true; } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Fri Mar 15 18:51:58 2013 +0100 @@ -80,11 +80,9 @@ public static class JumpOp extends LIRInstruction { private final LabelRef destination; - @State protected LIRFrameState state; - public JumpOp(LabelRef destination, LIRFrameState state) { + public JumpOp(LabelRef destination) { this.destination = destination; - this.state = state; } @Override diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -29,7 +29,7 @@ import com.oracle.graal.nodes.type.*; @NodeInfo(nameTemplate = "FixedGuard(!={p#negated}) {p#reason/s}") -public final class FixedGuardNode extends FixedWithNextNode implements Simplifiable, Lowerable, LIRLowerable, Node.IterableNodeType, Negatable { +public final class FixedGuardNode extends FixedWithNextNode implements Simplifiable, Lowerable, Node.IterableNodeType, Negatable { @Input private LogicNode condition; private final DeoptimizationReason reason; @@ -79,11 +79,6 @@ } @Override - public void generate(LIRGeneratorTool gen) { - gen.emitGuardCheck(condition, reason, action, negated); - } - - @Override public void simplify(SimplifierTool tool) { if (condition instanceof LogicConstantNode) { LogicConstantNode c = (LogicConstantNode) condition; diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes; +import java.util.*; + import com.oracle.graal.nodes.type.*; public abstract class FixedNode extends ValueNode { @@ -32,6 +34,10 @@ super(stamp); } + public FixedNode(Stamp stamp, List dependencies) { + super(stamp, dependencies); + } + public FixedNode(Stamp stamp, ValueNode... dependencies) { super(stamp, dependencies); } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedWithNextNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedWithNextNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedWithNextNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes; +import java.util.*; + import com.oracle.graal.nodes.type.*; /** @@ -43,6 +45,10 @@ super(stamp); } + public FixedWithNextNode(Stamp stamp, List dependencies) { + super(stamp, dependencies); + } + public FixedWithNextNode(Stamp stamp, ValueNode... dependencies) { super(stamp, dependencies); } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -42,7 +42,7 @@ * control flow would have reached the guarded node (without taking exceptions into account). */ @NodeInfo(nameTemplate = "Guard(!={p#negated}) {p#reason/s}") -public final class GuardNode extends FloatingNode implements Canonicalizable, LIRLowerable, Node.IterableNodeType, Negatable { +public final class GuardNode extends FloatingNode implements Canonicalizable, Node.IterableNodeType, Negatable { @Input private LogicNode condition; private final DeoptimizationReason reason; @@ -91,11 +91,6 @@ } @Override - public void generate(LIRGeneratorTool gen) { - gen.emitGuardCheck(condition(), reason(), action(), negated()); - } - - @Override public ValueNode canonical(CanonicalizerTool tool) { if (condition() instanceof LogicConstantNode) { LogicConstantNode c = (LogicConstantNode) condition(); diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.type.*; -import com.oracle.graal.nodes.type.GenericStamp.*; import com.oracle.graal.nodes.util.*; /** @@ -174,9 +173,6 @@ @Override public boolean verify() { - for (ValueNode v : dependencies().nonNull()) { - assertTrue(!(v.stamp() instanceof GenericStamp) || ((GenericStamp) v.stamp()).type() == GenericStampType.Dependency, "cannot depend on node with stamp %s", v.stamp()); - } assertTrue(kind() != null, "Should have a valid kind"); assertTrue(kind() == kind().getStackKind(), "Should have a stack kind : %s", kind()); return super.verify(); diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AccessNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AccessNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AccessNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes.extended; +import java.util.*; + import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.type.*; @@ -58,6 +60,12 @@ this.location = location; } + public AccessNode(ValueNode object, ValueNode location, Stamp stamp, List dependencies) { + super(stamp, dependencies); + this.object = object; + this.location = location; + } + public AccessNode(ValueNode object, ValueNode location, Stamp stamp, ValueNode... dependencies) { super(stamp, dependencies); this.object = object; diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes.extended; +import java.util.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -37,6 +39,10 @@ super(object, location, stamp); } + public ReadNode(ValueNode object, ValueNode location, Stamp stamp, List dependencies) { + super(object, location, stamp, dependencies); + } + private ReadNode(ValueNode object, int displacement, Object locationIdentity, Kind kind) { super(object, object.graph().add(new LocationNode(locationIdentity, kind, displacement)), StampFactory.forKind(kind)); } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java Fri Mar 15 18:51:58 2013 +0100 @@ -64,7 +64,7 @@ return previousAnchor; } } - for (Node node : dependencies().nonNull().and(isNotA(BeginNode.class))) { + for (Node node : dependencies().nonNull().and(isNotA(FixedNode.class))) { if (node instanceof ConstantNode) { continue; } diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Fri Mar 15 18:51:58 2013 +0100 @@ -97,8 +97,6 @@ public abstract void emitMembar(int barriers); - public abstract void emitDeoptimizeOnOverflow(DeoptimizationAction action, DeoptimizationReason reason); - public abstract void emitDeoptimize(DeoptimizationAction action, DeoptimizationReason reason); public abstract Value emitCall(RuntimeCallTarget callTarget, CallingConvention cc, boolean canTrap, Value... args); @@ -107,8 +105,6 @@ public abstract void emitConditional(ConditionalNode i); - public abstract void emitGuardCheck(LogicNode comp, DeoptimizationReason deoptReason, DeoptimizationAction deoptAction, boolean negated); - public abstract void emitSwitch(SwitchNode i); public abstract void emitInvoke(Invoke i); diff -r 02a3fd8a8308 -r 338b0d2382b3 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Fri Mar 15 18:51:58 2013 +0100 @@ -23,30 +23,47 @@ package com.oracle.graal.phases.common; import java.util.*; +import java.util.Map.Entry; +import com.oracle.graal.api.code.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.cfg.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.schedule.*; public class GuardLoweringPhase extends Phase { + private TargetDescription target; + + public GuardLoweringPhase(TargetDescription target) { + this.target = target; + } + @Override protected void run(StructuredGraph graph) { SchedulePhase schedule = new SchedulePhase(); schedule.apply(graph); for (Block block : schedule.getCFG().getBlocks()) { - processBlock(block, schedule, graph); + processBlock(block, schedule, graph, target); } } - private static void processBlock(Block block, SchedulePhase schedule, StructuredGraph graph) { + private static void processBlock(Block block, SchedulePhase schedule, StructuredGraph graph, TargetDescription target) { List nodes = schedule.nodesFor(block); + if (GraalOptions.OptImplicitNullChecks && target.implicitNullCheckLimit > 0) { + useImplicitNullChecks(block.getBeginNode(), nodes, graph, target); + } FixedWithNextNode lastFixed = block.getBeginNode(); BeginNode lastFastPath = null; for (Node node : nodes) { + if (!node.isAlive()) { + continue; + } if (lastFastPath != null && node instanceof FixedNode) { lastFastPath.setNext((FixedNode) node); lastFastPath = null; @@ -81,4 +98,70 @@ } } } + + private static void useImplicitNullChecks(BeginNode begin, List nodes, StructuredGraph graph, TargetDescription target) { + ListIterator iterator = nodes.listIterator(); + IdentityHashMap nullGuarded = new IdentityHashMap<>(); + FixedWithNextNode lastFixed = begin; + FixedWithNextNode reconnect = null; + while (iterator.hasNext()) { + Node node = iterator.next(); + + if (reconnect != null && node instanceof FixedNode) { + reconnect.setNext((FixedNode) node); + reconnect = null; + } + if (node instanceof FixedWithNextNode) { + lastFixed = (FixedWithNextNode) node; + } + + if (node instanceof GuardNode) { + GuardNode guard = (GuardNode) node; + if (guard.negated() && guard.condition() instanceof IsNullNode) { + ValueNode obj = ((IsNullNode) guard.condition()).object(); + nullGuarded.put(obj, guard); + } + } else if (node instanceof Access) { + Access access = (Access) node; + GuardNode guard = nullGuarded.get(access.object()); + if (guard != null && isImplicitNullCheck(access.location(), target)) { + NodeInputList dependencies = ((ValueNode) access).dependencies(); + dependencies.remove(guard); + if (access instanceof FloatingReadNode) { + ReadNode read = graph.add(new ReadNode(access.object(), access.location(), ((FloatingReadNode) access).stamp(), dependencies)); + node.replaceAndDelete(read); + access = read; + lastFixed.setNext(read); + lastFixed = read; + reconnect = read; + iterator.set(read); + } + assert access instanceof AccessNode; + access.setNullCheck(true); + LogicNode condition = guard.condition(); + guard.replaceAndDelete(access.node()); + if (condition.usages().isEmpty()) { + GraphUtil.killWithUnusedFloatingInputs(condition); + } + nullGuarded.remove(access.object()); + } + } + if (node instanceof StateSplit && ((StateSplit) node).stateAfter() != null) { + nullGuarded.clear(); + } else { + Iterator> it = nullGuarded.entrySet().iterator(); + while (it.hasNext()) { + Entry entry = it.next(); + GuardNode guard = entry.getValue(); + if (guard.usages().contains(node)) { + it.remove(); + } + } + } + } + } + + private static boolean isImplicitNullCheck(LocationNode location, TargetDescription target) { + return !(location instanceof IndexedLocationNode) && location.displacement() < target.implicitNullCheckLimit; + } } diff -r 02a3fd8a8308 -r 338b0d2382b3 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 Fri Mar 15 18:50:39 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Fri Mar 15 18:51:58 2013 +0100 @@ -83,7 +83,7 @@ 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) && ((GuardNode) usage).negated() == negated && ((GuardNode) usage).dependencies().contains(guardAnchor)) { + if (!activeGuards.isNew(usage) && activeGuards.isMarked(usage) && ((GuardNode) usage).negated() == negated) { return (GuardNode) usage; } }