# HG changeset patch # User Thomas Wuerthinger # Date 1303930681 -7200 # Node ID 0f9eeb15e636ced4f6abad440a6e44c558377f10 # Parent 3fc322165071218a248ce5fbee9a4447b0652b92 More Value.Flag clean up. diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java --- a/graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java Wed Apr 27 20:58:01 2011 +0200 @@ -51,7 +51,6 @@ public static int NullCheckIdsAssigned; public static int ZeroChecksRedundant; public static int DivideSpecialChecksRedundant; - public static int StoreCheckEliminations; public static int BoundsChecksElminations; public static int ConditionalEliminations; public static int BlocksMerged; diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java Wed Apr 27 20:58:01 2011 +0200 @@ -247,7 +247,7 @@ public CiValue emitArrayLength(ArrayLength x) { XirArgument array = toXirArgument(x.array()); XirSnippet snippet = xir.genArrayLength(site(x), array); - emitXir(snippet, x, x.needsNullCheck() ? stateFor(x) : null, null, true); + emitXir(snippet, x, stateFor(x), null, true); return x.operand(); } @@ -513,13 +513,7 @@ @Override public void visitLoadField(LoadField x) { RiField field = x.field(); - boolean needsPatching = !x.isLoaded(); - LIRDebugInfo info = null; - if (needsPatching || x.needsNullCheck()) { - info = stateFor(x, x.stateBefore()); - assert info != null; - } - + LIRDebugInfo info = stateFor(x, x.stateBefore()); XirArgument receiver = toXirArgument(x.object()); XirSnippet snippet = x.isStatic() ? xir.genGetStatic(site(x), receiver, field) : xir.genGetField(site(x), receiver, field); emitXir(snippet, x, info, null, true); @@ -804,12 +798,7 @@ @Override public void visitStoreField(StoreField x) { RiField field = x.field(); - boolean needsPatching = !x.isLoaded(); - - LIRDebugInfo info = null; - if (needsPatching || x.needsNullCheck()) { - info = stateFor(x, x.stateBefore()); - } + LIRDebugInfo info = stateFor(x, x.stateBefore()); if (x.isVolatile()) { vma.preVolatileWrite(); @@ -1608,23 +1597,23 @@ } public boolean requiresNullCheck() { - return current == null || current.needsNullCheck(); + return current == null || current.canTrap(); } public boolean requiresBoundsCheck() { - return current == null || !current.checkFlag(Value.Flag.NoBoundsCheck); + return true; } public boolean requiresReadBarrier() { - return current == null || !current.checkFlag(Value.Flag.NoReadBarrier); + return current == null || current.kind == CiKind.Object; } public boolean requiresWriteBarrier() { - return current == null || !current.checkFlag(Value.Flag.NoWriteBarrier); + return current == null || current.kind == CiKind.Object; } public boolean requiresArrayStoreCheck() { - return current == null || !current.checkFlag(Value.Flag.NoStoreCheck); + return true; } public RiType getApproximateType(XirArgument argument) { diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/AccessArray.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessArray.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessArray.java Wed Apr 27 20:58:01 2011 +0200 @@ -43,9 +43,6 @@ public AccessArray(CiKind kind, Value array, FrameState stateBefore) { super(kind, stateBefore); this.array = array; - if (array.isNonNull()) { - eliminateNullCheck(); - } } /** @@ -56,16 +53,6 @@ return array; } - /** - * Clears the state if this instruction can (no longer) trap. - */ - @Override - public void runtimeCheckCleared() { - if (!canTrap()) { - clearState(); - } - } - @Override public void inputValuesDo(ValueClosure closure) { array = closure.apply(array); diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessField.java Wed Apr 27 20:58:01 2011 +0200 @@ -49,9 +49,6 @@ super(kind, stateBefore); this.object = object; this.field = field; - if (field.isResolved() && object.isNonNull()) { - eliminateNullCheck(); - } assert object != null : "every field access must reference some object"; } @@ -96,13 +93,6 @@ return isLoaded() && Modifier.isVolatile(field.accessFlags()); } - @Override - public void runtimeCheckCleared() { - if (isLoaded()) { - clearState(); - } - } - /** * Checks whether this field access may cause a trap or an exception, which * is if it either requires a null check or needs patching. @@ -110,7 +100,7 @@ */ @Override public boolean canTrap() { - return !isLoaded() || needsNullCheck(); + return true; } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/AccessIndexed.java Wed Apr 27 20:58:01 2011 +0200 @@ -22,8 +22,6 @@ */ package com.sun.c1x.ir; -import static com.sun.c1x.ir.Value.Flag.*; - import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -80,24 +78,12 @@ } /** - * Checks whether this instruction needs a bounds check. - * @return {@code true} if a bounds check is needed - */ - public boolean needsBoundsCheck() { - return !checkFlag(NoBoundsCheck); - } - - public void eliminateBoundsCheck() { - clearRuntimeCheck(NoBoundsCheck); - } - - /** * Checks whether this instruction can cause a trap. * @return {@code true} if this instruction can cause a trap */ @Override public boolean canTrap() { - return needsNullCheck() || needsBoundsCheck(); + return true; } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArithmeticOp.java Wed Apr 27 20:58:01 2011 +0200 @@ -22,7 +22,6 @@ */ package com.sun.c1x.ir; -import com.sun.c1x.*; import com.sun.c1x.debug.*; import com.sun.c1x.value.*; import com.sun.cri.bytecode.*; @@ -30,13 +29,11 @@ /** * The {@code ArithmeticOp} class represents arithmetic operations such as addition, subtraction, etc. - * - * @author Ben L. Titzer */ public final class ArithmeticOp extends Op2 { - private FrameState stateBefore; - private boolean isStrictFP; + private final FrameState stateBefore; + private final boolean isStrictFP; /** * Creates a new arithmetic operation. @@ -50,21 +47,7 @@ public ArithmeticOp(int opcode, CiKind kind, Value x, Value y, boolean isStrictFP, FrameState stateBefore) { super(kind, opcode, x, y); this.isStrictFP = isStrictFP; - if (stateBefore != null) { - // state before is only used in the case of a division or remainder, - // and isn't needed if the zero check is redundant - if (y.isConstant()) { - long divisor = y.asConstant().asLong(); - if (divisor != 0) { - C1XMetrics.ZeroChecksRedundant++; - setFlag(Flag.NoZeroCheck); - } else { - this.stateBefore = stateBefore; - } - } else { - this.stateBefore = stateBefore; - } - } + this.stateBefore = stateBefore; } @Override @@ -99,14 +82,6 @@ return Bytecodes.isCommutative(opcode); } - public boolean needsZeroCheck() { - return !checkFlag(Flag.NoZeroCheck); - } - - public void eliminateZeroCheck() { - clearRuntimeCheck(Flag.NoZeroCheck); - } - @Override public void print(LogStream out) { out.print(x()).print(' ').print(Bytecodes.operator(opcode)).print(' ').print(y()); diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ArrayLength.java Wed Apr 27 20:58:01 2011 +0200 @@ -42,19 +42,6 @@ */ public ArrayLength(Value array, FrameState newFrameState) { super(CiKind.Int, array, newFrameState); - if (array.isNonNull()) { - eliminateNullCheck(); - } - } - - /** - * Clears the state associated with a null check. - */ - @Override - public void runtimeCheckCleared() { - if (!needsNullCheck()) { - clearState(); - } } /** @@ -63,7 +50,7 @@ */ @Override public boolean canTrap() { - return needsNullCheck(); + return true; } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/InstanceOf.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/InstanceOf.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/InstanceOf.java Wed Apr 27 20:58:01 2011 +0200 @@ -44,9 +44,6 @@ */ public InstanceOf(RiType targetClass, Value targetClassInstruction, Value object, FrameState stateBefore) { super(targetClass, targetClassInstruction, object, CiKind.Int, stateBefore); - if (object.isNonNull()) { - eliminateNullCheck(); - } } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java Wed Apr 27 20:58:01 2011 +0200 @@ -39,13 +39,9 @@ * * Instruction nodes are chained together in a basic block through the embedded * {@link Instruction#next} field. An Instruction may also have a list of {@link ExceptionHandler}s. - * - * - * @author Ben L. Titzer */ public abstract class Instruction extends Value { - public static final int INVOCATION_ENTRY_BCI = -1; // XXX: not currently used public static final int SYNCHRONIZATION_ENTRY_BCI = -1; /** @@ -220,17 +216,6 @@ } /** - * Tests whether this instruction can trap. This is conservative; it does not take - * into account analysis results that may eliminate the possibility of this - * instruction from trapping. - * - * @return {@code true} if this instruction can cause a trap. - */ - public boolean canTrap() { - return false; - } - - /** * Apply the specified closure to all the values of this instruction, including * input values, state values, and other values. * @param closure the closure to apply diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java Wed Apr 27 20:58:01 2011 +0200 @@ -55,9 +55,6 @@ this.arguments = args; this.target = target; this.returnType = returnType; - if (isStatic() || args[0].isNonNull() || args[0].kind.isWord()) { - eliminateNullCheck(); - } } /** diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorAddress.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorAddress.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorAddress.java Wed Apr 27 20:58:01 2011 +0200 @@ -38,7 +38,6 @@ super(CiKind.Word); this.monitor = monitor; setFlag(Flag.NonNull); - eliminateNullCheck(); } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorEnter.java Wed Apr 27 20:58:01 2011 +0200 @@ -44,9 +44,6 @@ */ public MonitorEnter(Value object, Value lockAddress, int lockNumber, FrameState stateBefore) { super(object, lockAddress, stateBefore, lockNumber); - if (object.isNonNull()) { - eliminateNullCheck(); - } } /** @@ -55,7 +52,7 @@ */ @Override public boolean canTrap() { - return needsNullCheck(); + return true; } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/MonitorExit.java Wed Apr 27 20:58:01 2011 +0200 @@ -42,16 +42,11 @@ */ public MonitorExit(Value object, Value lockAddress, int lockNumber, FrameState stateBefore) { super(object, lockAddress, stateBefore, lockNumber); - if (object.isNonNull()) { - eliminateNullCheck(); - } } @Override public boolean canTrap() { - // C1X assumes that locks are well balanced and so there no need to handle - // IllegalMonitorStateExceptions thrown by monitorexit instructions. - return needsNullCheck(); + return true; } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/NullCheck.java Wed Apr 27 20:58:01 2011 +0200 @@ -30,8 +30,6 @@ /** * The {@code NullCheck} class represents an explicit null check instruction. - * - * @author Ben L. Titzer */ public final class NullCheck extends StateSplit { @@ -46,9 +44,6 @@ super(obj.kind, stateBefore); this.object = obj; setFlag(Flag.NonNull); - if (object.isNonNull()) { - eliminateNullCheck(); - } } /** @@ -65,7 +60,7 @@ */ @Override public boolean canTrap() { - return needsNullCheck(); + return true; } @Override @@ -105,11 +100,6 @@ } @Override - public void runtimeCheckCleared() { - clearState(); - } - - @Override public void print(LogStream out) { out.print("null_check(").print(object()).print(')'); if (!canTrap()) { diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreField.java Wed Apr 27 20:58:01 2011 +0200 @@ -50,9 +50,6 @@ super(CiKind.Void, object, field, stateBefore); this.value = value; setFlag(Flag.LiveSideEffect); - if (value.kind != CiKind.Object) { - setFlag(Flag.NoWriteBarrier); - } } /** @@ -63,14 +60,6 @@ return value; } - /** - * Checks whether this instruction needs a write barrier. - * @return {@code true} if this instruction needs a write barrier - */ - public boolean needsWriteBarrier() { - return !checkFlag(Flag.NoWriteBarrier); - } - @Override public void inputValuesDo(ValueClosure closure) { super.inputValuesDo(closure); diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java Wed Apr 27 20:58:01 2011 +0200 @@ -22,8 +22,6 @@ */ package com.sun.c1x.ir; -import static com.sun.c1x.ir.Value.Flag.*; - import com.sun.c1x.debug.*; import com.sun.c1x.value.*; import com.sun.cri.ci.*; @@ -53,9 +51,6 @@ super(CiKind.Void, array, index, length, elementType, stateBefore); this.value = value; setFlag(Flag.LiveSideEffect); - if (elementType != CiKind.Object) { - setFlag(Flag.NoWriteBarrier); - } } /** @@ -67,32 +62,12 @@ } /** - * Checks if this instruction needs a write barrier. - * @return {@code true} if this instruction needs a write barrier - */ - public boolean needsWriteBarrier() { - return !checkFlag(Flag.NoWriteBarrier); - } - - /** - * Checks if this instruction needs a store check. - * @return {@code true} if this instruction needs a store check - */ - public boolean needsStoreCheck() { - return !checkFlag(Flag.NoStoreCheck); - } - - public void eliminateStoreCheck() { - clearRuntimeCheck(NoStoreCheck); - } - - /** * Checks whether this instruction can cause a trap. * @return {@code true} if this instruction can cause a trap */ @Override public boolean canTrap() { - return super.canTrap() || needsStoreCheck(); + return true; } @Override diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/ir/Value.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Value.java Wed Apr 27 20:58:01 2011 +0200 @@ -22,8 +22,6 @@ */ package com.sun.c1x.ir; -import static com.sun.c1x.ir.Value.Flag.*; - import com.sun.c1x.*; import com.sun.c1x.debug.*; import com.sun.c1x.opt.*; @@ -39,16 +37,10 @@ public enum Flag { NonNull, // this value is non-null - NoNullCheck, // does not require null check - NoStoreCheck, // does not require store check - NoBoundsCheck, // does not require bounds check - NoZeroCheck, // divide or modulus cannot cause exception - - NoReadBarrier, // does not require read barrier - NoWriteBarrier, // does not require write barrier 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 @@ -135,44 +127,6 @@ } /** - * Eliminates a given runtime check for this instruction. - * - * @param flag the flag representing the (elimination of the) runtime check - */ - public final void clearRuntimeCheck(Flag flag) { - if (!checkFlag(flag)) { - setFlag(flag); - runtimeCheckCleared(); - if (flag == NoNullCheck) { - C1XMetrics.NullCheckEliminations++; - } else if (flag == NoBoundsCheck) { - C1XMetrics.BoundsChecksElminations++; - } else if (flag == NoStoreCheck) { - C1XMetrics.StoreCheckEliminations++; - } else if (flag != NoZeroCheck) { - throw new InternalError("Unknown runtime check: " + flag); - } - } - } - - - /** - * Clear any internal state related to null checks, because a null check - * for this instruction is redundant. The state cleared may depend - * on the type of this instruction - */ - public final void eliminateNullCheck() { - clearRuntimeCheck(NoNullCheck); - } - - /** - * Notifies this instruction that a runtime check has been - * eliminated or made redundant. - */ - protected void runtimeCheckCleared() { - } - - /** * Check whether this instruction has the specified flag set. * @param flag the flag to test * @return {@code true} if this instruction has the flag @@ -231,14 +185,6 @@ } /** - * Checks whether this instruction needs a null check. - * @return {@code true} if this instruction needs a null check - */ - public final boolean needsNullCheck() { - return !checkFlag(Flag.NoNullCheck); - } - - /** * Checks whether this value is a constant (i.e. it is of type {@link Constant}. * @return {@code true} if this value is a constant */ @@ -247,6 +193,17 @@ } /** + * Tests whether this instruction can trap. This is conservative; it does not take + * into account analysis results that may eliminate the possibility of this + * instruction from trapping. + * + * @return {@code true} if this instruction can cause a trap. + */ + public boolean canTrap() { + return false; + } + + /** * Checks whether this value represents the null constant. * @return {@code true} if this value represents the null constant */ diff -r 3fc322165071 -r 0f9eeb15e636 graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java --- a/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Wed Apr 27 20:27:43 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/target/amd64/AMD64LIRGenerator.java Wed Apr 27 20:58:01 2011 +0200 @@ -197,7 +197,7 @@ int opcode = x.opcode; if (opcode == Bytecodes.LDIV || opcode == Bytecodes.LREM) { // emit inline 64-bit code - LIRDebugInfo info = x.needsZeroCheck() ? stateFor(x) : null; + LIRDebugInfo info = stateFor(x); CiValue dividend = force(x.x(), RAX_L); // dividend must be in RAX CiValue divisor = load(x.y()); // divisor can be in any (other) register @@ -245,7 +245,7 @@ // force the evaluation of other instructions that are needed for // correct debug info. Otherwise the live range of the fixed // register might be too long. - LIRDebugInfo info = x.needsZeroCheck() ? stateFor(x) : null; + LIRDebugInfo info = stateFor(x); CiValue dividend = force(x.x(), RAX_I); // dividend must be in RAX CiValue divisor = load(x.y()); // divisor can be in any (other) register @@ -319,7 +319,7 @@ if (opcode == Bytecodes.WDIV || opcode == Bytecodes.WREM || opcode == Bytecodes.WDIVI || opcode == Bytecodes.WREMI) { // emit code for long division or modulus // emit inline 64-bit code - LIRDebugInfo info = x.needsZeroCheck() ? stateFor(x) : null; + LIRDebugInfo info = stateFor(x); CiValue dividend = force(x.x(), RAX_L); // dividend must be in RAX CiValue divisor = load(x.y()); // divisor can be in any (other) register