use of org.graalvm.compiler.lir.ConstantValue in project graal by oracle.
the class LinearScanAssignLocationsPhase method colorLirOperand.
/**
* Assigns the allocated location for an LIR instruction operand back into the instruction.
*
* @param op current {@link LIRInstruction}
* @param operand an LIR instruction operand
* @param mode the usage mode for {@code operand} by the instruction
* @return the location assigned for the operand
*/
protected Value colorLirOperand(LIRInstruction op, Variable operand, OperandMode mode) {
int opId = op.id();
Interval interval = allocator.intervalFor(operand);
assert interval != null : "interval must exist";
if (opId != -1) {
if (allocator.detailedAsserts) {
AbstractBlockBase<?> block = allocator.blockForId(opId);
if (block.getSuccessorCount() <= 1 && opId == allocator.getLastLirInstructionId(block)) {
/*
* Check if spill moves could have been appended at the end of this block, but
* before the branch instruction. So the split child information for this branch
* would be incorrect.
*/
LIRInstruction instr = allocator.getLIR().getLIRforBlock(block).get(allocator.getLIR().getLIRforBlock(block).size() - 1);
if (instr instanceof StandardOp.JumpOp) {
if (allocator.getBlockData(block).liveOut.get(allocator.operandNumber(operand))) {
assert false : String.format("can't get split child for the last branch of a block because the information would be incorrect (moves are inserted before the branch in resolveDataFlow) block=%s, instruction=%s, operand=%s", block, instr, operand);
}
}
}
}
/*
* Operands are not changed when an interval is split during allocation, so search the
* right interval here.
*/
interval = allocator.splitChildAtOpId(interval, opId, mode);
}
if (isIllegal(interval.location()) && interval.canMaterialize()) {
assert mode != OperandMode.DEF;
return new ConstantValue(interval.kind(), interval.getMaterializedValue());
}
return interval.location();
}
use of org.graalvm.compiler.lir.ConstantValue in project graal by oracle.
the class StackValueNode method generate.
@Override
public void generate(NodeLIRBuilderTool gen) {
assert stackSlotHolder != null : "node not processed by StackValuePhase";
assert stackSlotHolder.gen == null || stackSlotHolder.gen == gen : "Same stack slot holder used during multiple compilations, therefore caching a wrong value";
stackSlotHolder.gen = gen;
if (size == 0) {
gen.setResult(this, new ConstantValue(gen.getLIRGeneratorTool().getLIRKind(FrameAccess.getWordStamp()), JavaConstant.forIntegerKind(FrameAccess.getWordKind(), 0)));
} else {
VirtualStackSlot slot = stackSlotHolder.slot;
if (slot == null) {
int wordSize = gen.getLIRGeneratorTool().target().wordSize;
int slots = roundUp(size, wordSize) / wordSize;
slot = gen.getLIRGeneratorTool().getResult().getFrameMapBuilder().allocateStackSlots(slots, new BitSet(0), null);
stackSlotHolder.slot = slot;
}
gen.setResult(this, gen.getLIRGeneratorTool().emitAddress(slot));
}
}
use of org.graalvm.compiler.lir.ConstantValue in project graal by oracle.
the class DebugInfoBuilder method toJavaValue.
protected JavaValue toJavaValue(ValueNode value) {
try {
if (value instanceof VirtualObjectNode) {
VirtualObjectNode obj = (VirtualObjectNode) value;
EscapeObjectState state = objectStates.get(obj);
if (state == null && obj.entryCount() > 0) {
// null states occur for objects with 0 fields
throw new GraalError("no mapping found for virtual object %s", obj);
}
if (state instanceof MaterializedObjectState) {
return toJavaValue(((MaterializedObjectState) state).materializedValue());
} else {
assert obj.entryCount() == 0 || state instanceof VirtualObjectState;
VirtualObject vobject = virtualObjects.get(obj);
if (vobject == null) {
vobject = VirtualObject.get(obj.type(), virtualObjects.size());
virtualObjects.put(obj, vobject);
pendingVirtualObjects.add(obj);
}
STATE_VIRTUAL_OBJECTS.increment(debug);
return vobject;
}
} else {
// Remove proxies from constants so the constant can be directly embedded.
ValueNode unproxied = GraphUtil.unproxify(value);
if (unproxied instanceof ConstantNode) {
STATE_CONSTANTS.increment(debug);
return unproxied.asJavaConstant();
} else if (value != null) {
STATE_VARIABLES.increment(debug);
Value operand = nodeValueMap.operand(value);
if (operand instanceof ConstantValue && ((ConstantValue) operand).isJavaConstant()) {
return ((ConstantValue) operand).getJavaConstant();
} else {
assert operand instanceof Variable : operand + " for " + value;
return (JavaValue) operand;
}
} else {
// return a dummy value because real value not needed
STATE_ILLEGALS.increment(debug);
return Value.ILLEGAL;
}
}
} catch (GraalError e) {
throw e.addContext("toValue: ", value);
}
}
Aggregations