# HG changeset patch # User Thomas Wuerthinger # Date 1303934223 -7200 # Node ID 3e960f8a6c52082c45df29d5dc73008d7bf92bd5 # Parent b6cd17226aad8a08df0d51114c8552b39d38d511# Parent 7a0e1bd2bb64753b794c88cff466a94cf96183f3 Merge. diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java --- a/graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java Wed Apr 27 21:57:03 2011 +0200 @@ -31,33 +31,17 @@ /** * This class contains a number of fields that collect metrics about compilation, particularly * the number of times certain optimizations are performed. - * - * @author Ben L. Titzer */ public class C1XMetrics { public static int CompiledMethods; public static int TargetMethods; public static int LocalValueNumberHits; - public static int GlobalValueNumberHits; public static int ValueMapResizes; public static int InlinedFinalizerChecks; - public static int MethodsFolded; public static int InlineForcedMethods; public static int InlineForbiddenMethods; public static int InlinedJsrs; - public static int NullCheckIterations; - public static int NullCheckEliminations; - public static int NullChecksRedundant; - public static int NullCheckIdsAssigned; - public static int ZeroChecksRedundant; - public static int DivideSpecialChecksRedundant; - public static int BoundsChecksElminations; - public static int ConditionalEliminations; - public static int BlocksMerged; - public static int BlocksSkipped; public static int BlocksDeleted; - public static int DeadCodeEliminated; - public static int ResolveCPEAttempts; public static int BytecodesCompiled; public static int CodeBytesEmitted; public static int SafepointsEmitted; @@ -76,7 +60,6 @@ public static int LoadConstantIterations; public static int CodeBufferCopies; public static int UniqueValueIdsAssigned; - public static int RedundantConditionals; public static int FrameStatesCreated; public static int FrameStateValuesCreated; diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java --- a/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/alloc/LinearScan.java Wed Apr 27 21:57:03 2011 +0200 @@ -2045,13 +2045,6 @@ assert con == null || operand.isVariable() || operand.isConstant() || operand.isIllegal() : "Constant instructions have only constant operands (or illegal if constant is optimized away)"; - if (con != null && !con.isLive() && !operand.isConstant()) { - // Unpinned constants may have a variable operand for a part of the lifetime - // or may be illegal when it was optimized away, - // so always use a constant operand - operand = con.asConstant(); - } - if (operand.isVariable()) { OperandMode mode = OperandMode.Input; BlockBegin block = blockForId(opId); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/debug/BlockPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/BlockPrinter.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/BlockPrinter.java Wed Apr 27 21:57:03 2011 +0200 @@ -29,19 +29,15 @@ /** * Prints a listing for a {@linkplain BlockBegin block}. - * - * @author Doug Simon */ public class BlockPrinter implements BlockClosure { private final InstructionPrinter ip; private final boolean cfgOnly; - private final boolean liveOnly; - public BlockPrinter(IR ir, InstructionPrinter ip, boolean cfgOnly, boolean liveOnly) { + public BlockPrinter(IR ir, InstructionPrinter ip, boolean cfgOnly) { this.ip = ip; this.cfgOnly = cfgOnly; - this.liveOnly = liveOnly; } public void apply(BlockBegin block) { @@ -49,11 +45,11 @@ ip.printInstruction(block); ip.out().println(); } else { - printBlock(block, liveOnly); + printBlock(block); } } - public void printBlock(BlockBegin block, boolean liveOnly) { + public void printBlock(BlockBegin block) { ip.printInstruction(block); LogStream out = ip.out(); out.println(); @@ -65,9 +61,7 @@ ip.printInstructionListingHeader(); for (Instruction i = block.next(); i != null; i = i.next()) { - if (!liveOnly || i.isLive()) { - ip.printInstructionListing(i); - } + ip.printInstructionListing(i); } out.println(); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/debug/InstructionPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/InstructionPrinter.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/InstructionPrinter.java Wed Apr 27 21:57:03 2011 +0200 @@ -129,10 +129,6 @@ * @param instruction the instruction to print */ public void printInstructionListing(Value instruction) { - if (instruction.isLive()) { - out.print('.'); - } - int indentation = out.indentationLevel(); out.fillTo(BCI.position + indentation, ' '). print(instruction instanceof Instruction ? ((Instruction) instruction).bci() : 0). diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed Apr 27 21:57:03 2011 +0200 @@ -205,10 +205,6 @@ this.operands = new OperandPool(compilation.target); new PhiSimplifier(ir); - - // mark the liveness of all instructions if it hasn't already been done by the optimizer - LivenessMarker livenessMarker = new LivenessMarker(ir); - C1XMetrics.LiveHIRInstructions += livenessMarker.liveCount(); } public ArrayList deoptimizationStubs() { @@ -229,7 +225,7 @@ this.currentBlock = block; for (Instruction instr = block; instr != null; instr = instr.next()) { - if (instr.isLive()) { + if (!(instr instanceof BlockBegin)) { walkState(instr, instr.stateBefore()); doRoot(instr); } @@ -277,9 +273,7 @@ Local local = ((Local) instr); CiKind kind = src.kind.stackKind(); assert kind == local.kind.stackKind() : "local type check failed"; - if (local.isLive()) { - setResult(local, dest); - } + setResult(local, dest); javaIndex += kind.jvmSlots; } } @@ -365,21 +359,14 @@ @Override public void visitConstant(Constant x) { - if (canInlineAsConstant(x)) { - //setResult(x, loadConstant(x)); - } else { + if (!canInlineAsConstant(x)) { CiValue res = x.operand(); if (!(res.isLegal())) { res = x.asConstant(); } if (res.isConstant()) { - if (isUsedForValue(x)) { - CiVariable reg = createResultVariable(x); - lir.move(res, reg); - } else { - assert x.checkFlag(Value.Flag.LiveDeopt); - x.setOperand(res); - } + CiVariable reg = createResultVariable(x); + lir.move(res, reg); } else { setResult(x, (CiVariable) res); } @@ -1220,7 +1207,6 @@ void doRoot(Instruction instr) { currentInstruction = instr; - assert instr.isLive() : "use only with roots"; assert !instr.hasSubst() : "shouldn't have missed substitution"; if (C1XOptions.TraceLIRVisit) { @@ -1230,12 +1216,6 @@ if (C1XOptions.TraceLIRVisit) { TTY.println("Operand for " + instr + " = " + instr.operand()); } - - assert (instr.operand().isLegal()) || !isUsedForValue(instr) || instr.isConstant() : "operand was not set for live instruction"; - } - - private boolean isUsedForValue(Instruction instr) { - return instr.checkFlag(Value.Flag.LiveValue); } protected void logicOp(int code, CiValue resultOp, CiValue leftOp, CiValue rightOp) { @@ -1271,8 +1251,7 @@ if (suxVal instanceof Phi) { Phi phi = (Phi) suxVal; // curVal can be null without phi being null in conjunction with inlining - if (phi.isLive() && !phi.isDeadPhi() && curVal != null && curVal != phi) { - assert curVal.isLive() : "value not live: " + curVal + ", suxVal=" + suxVal; + if (!phi.isDeadPhi() && curVal != null && curVal != phi) { assert !phi.isIllegal() : "illegal phi cannot be marked as live"; if (curVal instanceof Phi) { operandForPhi((Phi) curVal); @@ -1365,7 +1344,6 @@ } protected void setNoResult(Instruction x) { - assert !isUsedForValue(x) : "can't have use"; x.clearOperand(); } @@ -1419,7 +1397,7 @@ assert x instanceof ExceptionObject || x instanceof Throw || x instanceof MonitorEnter || - x instanceof MonitorExit; + x instanceof MonitorExit : x + ", " + x.getClass(); } for (int index = 0; index < s.localsSize(); index++) { @@ -1438,7 +1416,6 @@ private void walkStateValue(Value value) { if (value != null) { assert !value.hasSubst() : "missed substitution"; - assert value.isLive() : "value must be marked live in frame state"; if (value instanceof Phi && !value.isIllegal()) { // phi's are special operandForPhi((Phi) value); @@ -1513,7 +1490,6 @@ if (instruction == null) { return CiValue.IllegalValue; } - assert instruction.isLive(); CiValue operand = instruction.operand(); if (operand.isIllegal()) { if (instruction instanceof Phi) { @@ -1605,11 +1581,11 @@ } public boolean requiresReadBarrier() { - return current == null || current.kind == CiKind.Object; + return current == null || true; } public boolean requiresWriteBarrier() { - return current == null || current.kind == CiKind.Object; + return current == null || true; } public boolean requiresArrayStoreCheck() { diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java Wed Apr 27 21:57:03 2011 +0200 @@ -1272,7 +1272,7 @@ if (x instanceof StateSplit) { StateSplit stateSplit = (StateSplit) x; - if (!stateSplit.isStateCleared() && stateSplit.stateBefore() == null) { + if (stateSplit.stateBefore() == null) { stateSplit.setStateBefore(curState.immutableCopy(bci)); } } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/graph/IR.java --- a/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/graph/IR.java Wed Apr 27 21:57:03 2011 +0200 @@ -138,7 +138,7 @@ if (!TTY.isSuppressed()) { TTY.println("IR for " + compilation.method); final InstructionPrinter ip = new InstructionPrinter(TTY.out()); - final BlockPrinter bp = new BlockPrinter(this, ip, cfgOnly, false); + final BlockPrinter bp = new BlockPrinter(this, ip, cfgOnly); startBlock.iteratePreOrder(bp); } } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java Wed Apr 27 21:57:03 2011 +0200 @@ -93,16 +93,6 @@ return isLoaded() && Modifier.isVolatile(field.accessFlags()); } - /** - * Checks whether this field access may cause a trap or an exception, which - * is if it either requires a null check or needs patching. - * @return {@code true} if this field access can cause a trap - */ - @Override - public boolean canTrap() { - return true; - } - @Override public void inputValuesDo(ValueClosure closure) { object = closure.apply(object); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java Wed Apr 27 21:57:03 2011 +0200 @@ -77,15 +77,6 @@ return elementType; } - /** - * Checks whether this instruction can cause a trap. - * @return {@code true} if this instruction can cause a trap - */ - @Override - public boolean canTrap() { - return true; - } - @Override public void inputValuesDo(ValueClosure closure) { super.inputValuesDo(closure); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java Wed Apr 27 21:57:03 2011 +0200 @@ -44,15 +44,6 @@ super(CiKind.Int, array, newFrameState); } - /** - * Checks whether this instruction can cause a trap. - * @return {@code true} if this instruction can cause a trap - */ - @Override - public boolean canTrap() { - return true; - } - @Override public void accept(ValueVisitor v) { v.visitArrayLength(this); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java Wed Apr 27 21:57:03 2011 +0200 @@ -31,8 +31,6 @@ /** * The {@code BlockEnd} instruction is a base class for all instructions that end a basic * block, including branches, switches, throws, and goto's. - * - * @author Ben L. Titzer */ public abstract class BlockEnd extends Instruction { @@ -53,7 +51,6 @@ this.successors = successors == null ? new ArrayList(2) : successors; setStateAfter(stateAfter); this.isSafepoint = isSafepoint; - setFlag(Flag.LiveSideEffect); } public BlockEnd(CiKind kind, FrameState stateAfter, boolean isSafepoint) { diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/CompareOp.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/CompareOp.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/CompareOp.java Wed Apr 27 21:57:03 2011 +0200 @@ -28,8 +28,6 @@ /** * The {@code CompareOp} instruction represents comparisons such as equals, not equal, etc. - * - * @author Ben L. Titzer */ public final class CompareOp extends Op2 { @@ -42,10 +40,6 @@ */ public CompareOp(int opcode, CiKind kind, Value x, Value y) { super(kind, opcode, x, y); - if (kind.isVoid()) { - // A compare that does not produce a value exists soley for it's side effect (i.e. setting condition codes) - setFlag(Flag.LiveSideEffect); - } } @Override diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionObject.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionObject.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionObject.java Wed Apr 27 21:57:03 2011 +0200 @@ -28,8 +28,6 @@ /** * The {@code ExceptionObject} instruction represents the incoming exception object to an exception handler. - * - * @author Ben L. Titzer */ public final class ExceptionObject extends Instruction { @@ -45,7 +43,6 @@ public ExceptionObject(FrameState stateBefore) { super(CiKind.Object); setFlag(Flag.NonNull); - setFlag(Flag.LiveSideEffect); this.stateBefore = stateBefore; } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Wed Apr 27 21:57:03 2011 +0200 @@ -105,15 +105,6 @@ } /** - * Checks whether this instruction can trap. - * @return {@code true}, conservatively assuming the called method may throw an exception - */ - @Override - public boolean canTrap() { - return true; - } - - /** * Checks whether this invocation has a receiver object. * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a * static call diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java Wed Apr 27 21:57:03 2011 +0200 @@ -46,15 +46,6 @@ super(object, lockAddress, stateBefore, lockNumber); } - /** - * Checks whether this instruction can trap. - * @return {@code true} if this instruction may raise a {@link NullPointerException} - */ - @Override - public boolean canTrap() { - return true; - } - @Override public void accept(ValueVisitor v) { v.visitMonitorEnter(this); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java Wed Apr 27 21:57:03 2011 +0200 @@ -45,11 +45,6 @@ } @Override - public boolean canTrap() { - return true; - } - - @Override public void accept(ValueVisitor v) { v.visitMonitorExit(this); } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewArray.java Wed Apr 27 21:57:03 2011 +0200 @@ -54,16 +54,6 @@ } /** - * Checks whether this instruction can trap. - * @return true, conservatively assuming that this instruction can throw such - * exceptions as {@code OutOfMemoryError} - */ - @Override - public boolean canTrap() { - return true; - } - - /** * Applies the specified closure to all input values of this instruction. * @param closure the closure to apply */ diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NewInstance.java Wed Apr 27 21:57:03 2011 +0200 @@ -61,15 +61,6 @@ } /** - * Checks whether this instruction can trap. - * @return {@code true}, assuming that allocation can cause OutOfMemory or other exceptions - */ - @Override - public boolean canTrap() { - return true; - } - - /** * Gets the exact type produced by this instruction. For allocations of instance classes, this is * always the class allocated. * @return the exact type produced by this instruction diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java Wed Apr 27 21:57:03 2011 +0200 @@ -54,15 +54,6 @@ return object; } - /** - * Checks whether this instruction can cause a trap. - * @return {@code true} if this instruction can cause a trap - */ - @Override - public boolean canTrap() { - return true; - } - @Override public void inputValuesDo(ValueClosure closure) { object = closure.apply(object); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/RegisterFinalizer.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/RegisterFinalizer.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/RegisterFinalizer.java Wed Apr 27 21:57:03 2011 +0200 @@ -51,11 +51,6 @@ } @Override - public boolean canTrap() { - return true; - } - - @Override public void print(LogStream out) { out.print("register finalizer ").print(object); } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/ResolveClass.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ResolveClass.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ResolveClass.java Wed Apr 27 21:57:03 2011 +0200 @@ -52,11 +52,6 @@ } @Override - public boolean canTrap() { - return true; - } - - @Override public int valueNumber() { return 0x50000000 | type.hashCode(); } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StateSplit.java Wed Apr 27 21:57:03 2011 +0200 @@ -49,21 +49,9 @@ this.stateBefore = stateBefore; } - /** - * Determines if the state for this instruction has explicitly - * been cleared (as opposed to never initialized). Once explicitly - * cleared, an instruction must not have it state (re)set. - */ - public boolean isStateCleared() { - return stateBefore == CLEARED_STATE; - } - - /** - * Clears the state for this instruction. Once explicitly - * cleared, an instruction must not have it state (re)set. - */ - protected void clearState() { - stateBefore = CLEARED_STATE; + @Override + public boolean canTrap() { + return stateBefore != null; } /** @@ -82,6 +70,6 @@ */ @Override public final FrameState stateBefore() { - return stateBefore == CLEARED_STATE ? null : stateBefore; + return stateBefore; } } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java Wed Apr 27 21:57:03 2011 +0200 @@ -49,7 +49,6 @@ public StoreField(Value object, RiField field, Value value, FrameState stateBefore) { super(CiKind.Void, object, field, stateBefore); this.value = value; - setFlag(Flag.LiveSideEffect); } /** diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java Wed Apr 27 21:57:03 2011 +0200 @@ -50,7 +50,6 @@ public StoreIndexed(Value array, Value index, Value length, CiKind elementType, Value value, FrameState stateBefore) { super(CiKind.Void, array, index, length, elementType, stateBefore); this.value = value; - setFlag(Flag.LiveSideEffect); } /** @@ -61,15 +60,6 @@ return value; } - /** - * Checks whether this instruction can cause a trap. - * @return {@code true} if this instruction can cause a trap - */ - @Override - public boolean canTrap() { - return true; - } - @Override public void inputValuesDo(ValueClosure closure) { super.inputValuesDo(closure); diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/TypeCheck.java Wed Apr 27 21:57:03 2011 +0200 @@ -84,15 +84,6 @@ } /** - * Checks whether this instruction can trap. - * @return {@code true}, conservatively assuming the cast may fail - */ - @Override - public boolean canTrap() { - return true; - } - - /** * Iterates over the input values to this instruction. * @param closure the closure to apply */ diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/ir/Value.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Wed Apr 27 21:57:03 2011 +0200 @@ -37,10 +37,6 @@ public enum Flag { NonNull, // this value is non-null - LiveValue, // live because value is used - LiveDeopt, // live for deoptimization - LiveSideEffect, // live for possible side-effects only - PhiDead, // phi is illegal because local is dead PhiCannotSimplify, // phi cannot be simplified PhiVisited; // phi has been visited during simplification @@ -48,9 +44,6 @@ public final int mask = 1 << ordinal(); } - private static final int LIVE_FLAGS = Flag.LiveValue.mask | - Flag.LiveDeopt.mask | - Flag.LiveSideEffect.mask; /** * The kind of this value. This is {@link CiKind#Void} for instructions that produce no value. * This kind is guaranteed to be a {@linkplain CiKind#stackKind() stack kind}. @@ -86,25 +79,6 @@ } /** - * Checks whether this instruction is live (i.e. code should be generated for it). - * This is computed in a dedicated pass by {@link LivenessMarker}. - * An instruction is live because its value is needed by another live instruction, - * because its value is needed for deoptimization, or the program is control dependent - * upon it. - * @return {@code true} if this instruction should be considered live - */ - public final boolean isLive() { - return C1XOptions.PinAllInstructions || (flags & LIVE_FLAGS) != 0; - } - - /** - * Clears all liveness flags. - */ - public final void clearLive() { - flags = flags & ~LIVE_FLAGS; - } - - /** * Gets the instruction that should be substituted for this one. Note that this * method is recursive; if the substituted instruction has a substitution, then * the final substituted instruction will be returned. If there is no substitution diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/opt/LivenessMarker.java --- a/graal/GraalCompiler/src/com/sun/c1x/opt/LivenessMarker.java Wed Apr 27 21:25:15 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2009, 2011, 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.sun.c1x.opt; - -import static com.sun.c1x.ir.Value.Flag.*; - -import com.sun.c1x.graph.*; -import com.sun.c1x.ir.*; -import com.sun.c1x.value.*; - -/** - * The {@code LivenessMarker} class walks over an IR graph and marks instructions - * whose values are live, either because they are needed to compute the method's result, - * may produce a side-effect, or are needed for deoptimization. - * - * @author Ben L. Titzer - */ -public final class LivenessMarker { - - final IR ir; - - final InstructionMarker deoptMarker = new InstructionMarker(LiveDeopt); - final InstructionMarker valueMarker = new InstructionMarker(LiveValue); - - int count; - - /** - * Creates a new liveness marking instance and marks live instructions. - * @param ir the IR to mark - */ - public LivenessMarker(IR ir) { - this.ir = ir; - markRoots(); - } - - private void markRoots() { - // first pass: mark root instructions and their inputs - ir.startBlock.iteratePreOrder(new BlockClosure() { - public void apply(BlockBegin block) { - block.stateBefore().valuesDo(deoptMarker); - if (block.stateAfter() != null) { - block.stateAfter().valuesDo(deoptMarker); - } - Instruction i = block; - while ((i = i.next()) != null) { - // visit all instructions first, marking control dependent and side-effects - markRootInstr(i); - } - } - }); - - // propagate liveness flags to inputs of instructions - valueMarker.markAll(); - deoptMarker.markAll(); - } - - public int liveCount() { - return count; - } - - private static class Link { - final Value value; - Link next; - - Link(Value v) { - this.value = v; - } - } - - private final class InstructionMarker implements ValueClosure { - final Value.Flag reason; - Link head; - Link tail; - - public InstructionMarker(Value.Flag reason) { - this.reason = reason; - } - - public Value apply(Value i) { - if (!i.checkFlag(reason) && !i.isDeadPhi()) { - // set the flag and add to the queue - setFlag(i, reason); - if (head == null) { - head = tail = new Link(i); - } else { - tail.next = new Link(i); - tail = tail.next; - } - } - return i; - } - - private void markAll() { - Link cursor = head; - while (cursor != null) { - markInputs(cursor.value); - cursor = cursor.next; - } - } - - private void clearAll() { - Link cursor = head; - while (cursor != null) { - cursor.value.clearLive(); - cursor = cursor.next; - } - } - - private void markInputs(Value i) { - if (!i.isDeadPhi()) { - i.inputValuesDo(this); - if (i instanceof Phi) { - // phis are special - Phi phi = (Phi) i; - int max = phi.inputCount(); - for (int j = 0; j < max; j++) { - apply(phi.inputAt(j)); - } - } - } - } - } - - void markRootInstr(Instruction i) { - FrameState stateBefore = i.stateBefore(); - if (stateBefore != null) { - // stateBefore != null implies that this instruction may have side effects - stateBefore.valuesDo(deoptMarker); - i.inputValuesDo(valueMarker); - setFlag(i, LiveSideEffect); - } else if (i.checkFlag(LiveSideEffect)) { - // instruction has a side effect - i.inputValuesDo(valueMarker); - } - FrameState stateAfter = i.stateAfter(); - if (stateAfter != null) { - stateAfter.valuesDo(deoptMarker); - } - } - - void setFlag(Value i, Value.Flag flag) { - if (!i.isLive()) { - count++; - } - i.setFlag(flag); - } -} diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java --- a/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java Wed Apr 27 21:57:03 2011 +0200 @@ -486,7 +486,7 @@ int max = this.valuesSize(); for (int i = 0; i < max; i++) { Value instr = values[i]; - if (instr instanceof Phi && instr.isLive() && !instr.isDeadPhi()) { + if (instr instanceof Phi && !instr.isDeadPhi()) { Phi phi = (Phi) instr; if (block == null || phi.block() == block) { if (!proc.doPhi(phi)) { @@ -563,7 +563,7 @@ final int max = state.valuesSize(); for (int i = 0; i < max; i++) { Value value = state.values[i]; - if (value != null && value.isLive()) { + if (value != null) { proc.doValue(value); } } diff -r 7a0e1bd2bb64 -r 3e960f8a6c52 graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java --- a/graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java Wed Apr 27 21:25:15 2011 +0200 +++ b/graal/GraalRuntime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java Wed Apr 27 21:57:03 2011 +0200 @@ -427,7 +427,7 @@ asm.mark(MARK_IMPLICIT_NULL); } asm.pstore(kind, object, fieldOffset, value, is(NULL_CHECK, flags)); - if (is(WRITE_BARRIER, flags)) { + if (is(WRITE_BARRIER, flags) && kind == CiKind.Object) { XirOperand temp = asm.createTemp("temp", CiKind.Word); asm.mov(temp, object); writeBarrier(asm, temp); @@ -876,7 +876,7 @@ XirLabel store = null; XirLabel slowStoreCheck = null; - if (is(STORE_CHECK, flags)) { + if (is(STORE_CHECK, flags) && kind == CiKind.Object) { valueHub = asm.createRegisterTemp("valueHub", CiKind.Word, AMD64.rdi); compHub = asm.createRegisterTemp("compHub", CiKind.Word, AMD64.rsi); temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.r10); @@ -1056,6 +1056,7 @@ valueHub = asm.createTemp("valueHub", CiKind.Object); compHub = asm.createTemp("compHub", CiKind.Object); if (implicitNullException) { + asm.nop(1); asm.mark(MARK_IMPLICIT_NULL); } asm.pload(CiKind.Object, compHub, array, asm.i(config.hubOffset), implicitNullException); @@ -1069,6 +1070,7 @@ int elemSize = target.sizeInBytes(kind); if (implicitNullException) { + asm.nop(1); asm.mark(MARK_IMPLICIT_NULL); } int disp = config.getArrayOffset(kind); @@ -1076,7 +1078,7 @@ if (kind == CiKind.Object) { verifyPointer(asm, value); } - if (is(WRITE_BARRIER, flags)) { + if (is(WRITE_BARRIER, flags) && kind == CiKind.Object) { asm.lea(temp, array, index, disp, scale); asm.pstore(kind, temp, value, implicitNullException); writeBarrier(asm, temp);