Search in sources :

Example 6 with ConstantValue

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();
}
Also used : LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) ConstantValue(org.graalvm.compiler.lir.ConstantValue)

Example 7 with ConstantValue

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));
    }
}
Also used : BitSet(java.util.BitSet) ConstantValue(org.graalvm.compiler.lir.ConstantValue) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 8 with ConstantValue

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);
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Variable(org.graalvm.compiler.lir.Variable) GraalError(org.graalvm.compiler.debug.GraalError) VirtualObjectState(org.graalvm.compiler.virtual.nodes.VirtualObjectState) VirtualObject(jdk.vm.ci.code.VirtualObject) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaValue(jdk.vm.ci.meta.JavaValue) ConstantValue(org.graalvm.compiler.lir.ConstantValue) Value(jdk.vm.ci.meta.Value) MaterializedObjectState(org.graalvm.compiler.virtual.nodes.MaterializedObjectState) ConstantValue(org.graalvm.compiler.lir.ConstantValue) EscapeObjectState(org.graalvm.compiler.nodes.virtual.EscapeObjectState)

Aggregations

ConstantValue (org.graalvm.compiler.lir.ConstantValue)8 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)4 Value (jdk.vm.ci.meta.Value)4 LIRKind (org.graalvm.compiler.core.common.LIRKind)4 Variable (org.graalvm.compiler.lir.Variable)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 LIRValueUtil.asJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant)2 LIRValueUtil.isJavaConstant (org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant)2 AArch64AddressValue (org.graalvm.compiler.lir.aarch64.AArch64AddressValue)2 BitSet (java.util.BitSet)1 VirtualObject (jdk.vm.ci.code.VirtualObject)1 JavaValue (jdk.vm.ci.meta.JavaValue)1 GraalError (org.graalvm.compiler.debug.GraalError)1 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)1 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)1 AArch64SignExtendOp (org.graalvm.compiler.lir.aarch64.AArch64SignExtendOp)1 SPARCOP3Op (org.graalvm.compiler.lir.sparc.SPARCOP3Op)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1