src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/StandardOp.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/StandardOp.java	Mon Mar 20 17:39:44 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/StandardOp.java	Mon Mar 20 17:39:44 2017

*** 26,45 **** --- 26,44 ---- import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.HINT; import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.OUTGOING; import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG; import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK; + import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.Set; import org.graalvm.compiler.asm.Label; import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.lir.asm.CompilationResultBuilder; import org.graalvm.compiler.lir.framemap.FrameMap; ! import org.graalvm.compiler.lir.ssa.SSAUtil; ! import org.graalvm.util.EconomicSet; import jdk.vm.ci.code.Register; import jdk.vm.ci.code.RegisterSaveLayout; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.meta.AllocatableValue;
*** 55,81 **** --- 54,63 ---- /** * A block delimiter. Every well formed block must contain exactly one such operation and it * must be the last operation in the block. */ public interface BlockEndOp { void setOutgoingValues(Value[] values); int getOutgoingSize(); Value getOutgoingValue(int idx); int addOutgoingValues(Value[] values); void clearOutgoingValues(); void forEachOutgoingValue(InstructionValueProcedure proc); /** * The number of {@link SSAUtil phi} operands in the {@link #getOutgoingValue outgoing} * array. */ int getPhiSize(); } public interface NullCheck { Value getCheckedValue();
*** 122,134 **** --- 104,113 ---- private void setNumberOfPhis(int numPhis) { assert numbPhis == 0; numbPhis = numPhis; } /** * @see BlockEndOp#getPhiSize */ public int getPhiSize() { return numbPhis; } public void setIncomingValues(Value[] values) {
*** 190,302 **** --- 169,232 ---- incomingValues[i] = proc.doValue(this, incomingValues[i], OperandMode.DEF, incomingFlags); } } } public abstract static class AbstractBlockEndOp extends LIRInstruction implements BlockEndOp { public static final LIRInstructionClass<AbstractBlockEndOp> TYPE = LIRInstructionClass.create(AbstractBlockEndOp.class); + /** + * LIR operation that is an unconditional jump to a {@link #destination()}. + */ + public static class JumpOp extends LIRInstruction implements BlockEndOp { + public static final LIRInstructionClass<JumpOp> TYPE = LIRInstructionClass.create(JumpOp.class); public static final EnumSet<OperandFlag> outgoingFlags = EnumSet.of(REG, STACK, CONST, OUTGOING); @Alive({REG, STACK, CONST, OUTGOING}) private Value[] outgoingValues; private int numberOfPhis; ! protected AbstractBlockEndOp(LIRInstructionClass<? extends AbstractBlockEndOp> c) { ! private final LabelRef destination; + + public JumpOp(LabelRef destination) { + this(TYPE, destination); + } + + protected JumpOp(LIRInstructionClass<? extends JumpOp> c, LabelRef destination) { super(c); + this.destination = destination; this.outgoingValues = Value.NO_VALUES; } public void setPhiValues(Value[] values) { setOutgoingValues(values); setNumberOfPhis(values.length); + @Override + public void emitCode(CompilationResultBuilder crb) { + if (!crb.isSuccessorEdge(destination)) { + crb.asm.jmp(destination.label()); } private void setNumberOfPhis(int numPhis) { assert numberOfPhis == 0; numberOfPhis = numPhis; } @Override public int getPhiSize() { return numberOfPhis; + public LabelRef destination() { + return destination; } @Override public void setOutgoingValues(Value[] values) { + public void setPhiValues(Value[] values) { assert this.outgoingValues.length == 0; assert values != null; this.outgoingValues = values; } @Override public int getOutgoingSize() { + public int getPhiSize() { return outgoingValues.length; } @Override public Value getOutgoingValue(int idx) { assert checkRange(idx); return outgoingValues[idx]; } @Override public void clearOutgoingValues() { outgoingValues = Value.NO_VALUES; } @Override public int addOutgoingValues(Value[] values) { if (outgoingValues.length == 0) { setOutgoingValues(values); return values.length; } int t = outgoingValues.length + values.length; Value[] newArray = new Value[t]; System.arraycopy(outgoingValues, 0, newArray, 0, outgoingValues.length); System.arraycopy(values, 0, newArray, outgoingValues.length, values.length); outgoingValues = newArray; return t; } private boolean checkRange(int idx) { return idx < outgoingValues.length; } @Override public void forEachOutgoingValue(InstructionValueProcedure proc) { for (int i = 0; i < outgoingValues.length; i++) { outgoingValues[i] = proc.doValue(this, outgoingValues[i], OperandMode.ALIVE, outgoingFlags); } } } /** * LIR operation that is an unconditional jump to a {@link #destination()}. */ public static class JumpOp extends AbstractBlockEndOp { public static final LIRInstructionClass<JumpOp> TYPE = LIRInstructionClass.create(JumpOp.class); private final LabelRef destination; public JumpOp(LabelRef destination) { this(TYPE, destination); } protected JumpOp(LIRInstructionClass<? extends JumpOp> c, LabelRef destination) { super(c); this.destination = destination; } @Override public void emitCode(CompilationResultBuilder crb) { if (!crb.isSuccessorEdge(destination)) { crb.asm.jmp(destination.label()); } } public LabelRef destination() { return destination; } } /** * Marker interface for a LIR operation that is a conditional jump. */
*** 327,343 **** --- 257,273 ---- Constant getConstant(); } /** * An operation that saves registers to the stack. The set of saved registers can be ! * {@linkplain #remove(Set) pruned} and a mapping from registers to the frame slots in which ! * they are saved can be {@linkplain #getMap(FrameMap) retrieved}. ! * {@linkplain #remove(EconomicSet) pruned} and a mapping from registers to the frame slots in ! * which they are saved can be {@linkplain #getMap(FrameMap) retrieved}. */ public interface SaveRegistersOp { /** ! * Determines if the {@link #remove(EconomicSet)} operation is supported for this object. */ boolean supportsRemove(); /** * Prunes {@code doNotSave} from the registers saved by this operation.
*** 345,355 **** --- 275,285 ---- * @param doNotSave registers that should not be saved by this operation * @return the number of registers pruned * @throws UnsupportedOperationException if removal is not {@linkplain #supportsRemove() * supported} */ ! int remove(EconomicSet<Register> doNotSave); /** * Gets a map from the saved registers saved by this operation to the frame slots in which * they are saved. *
*** 382,398 **** --- 312,328 ---- this.block = block; this.index = index; } public void replace(LIR lir, LIRInstruction replacement) { ! ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block); assert instructions.get(index).equals(this) : String.format("Replacing the wrong instruction: %s instead of %s", instructions.get(index), this); instructions.set(index, replacement); } public void remove(LIR lir) { ! ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block); assert instructions.get(index).equals(this) : String.format("Removing the wrong instruction: %s instead of %s", instructions.get(index), this); instructions.remove(index); } @Override

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/StandardOp.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File