Search in sources :

Example 6 with VirtualStackSlot

use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.

the class SimpleStackSlotAllocator method allocateStackSlots.

public void allocateStackSlots(FrameMapBuilderTool builder, LIRGenerationResult res) {
    DebugContext debug = res.getLIR().getDebug();
    StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()];
    boolean allocatedFramesizeEnabled = allocatedFramesize.isEnabled(debug);
    long currentFrameSize = allocatedFramesizeEnabled ? builder.getFrameMap().currentFrameSize() : 0;
    for (VirtualStackSlot virtualSlot : builder.getStackSlots()) {
        final StackSlot slot;
        if (virtualSlot instanceof SimpleVirtualStackSlot) {
            slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot);
            virtualFramesize.add(debug, builder.getFrameMap().spillSlotSize(virtualSlot.getValueKind()));
        } else if (virtualSlot instanceof VirtualStackSlotRange) {
            VirtualStackSlotRange slotRange = (VirtualStackSlotRange) virtualSlot;
            slot = mapVirtualStackSlotRange(builder, slotRange);
            virtualFramesize.add(debug, builder.getFrameMap().spillSlotRangeSize(slotRange.getSlots()));
        } else {
            throw GraalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot);
        }
        allocatedSlots.increment(debug);
        mapping[virtualSlot.getId()] = slot;
    }
    updateLIR(res, mapping);
    if (allocatedFramesizeEnabled) {
        allocatedFramesize.add(debug, builder.getFrameMap().currentFrameSize() - currentFrameSize);
    }
}
Also used : VirtualStackSlotRange(org.graalvm.compiler.lir.framemap.VirtualStackSlotRange) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 7 with VirtualStackSlot

use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.

the class AMD64MoveFactoryBase method createStackMove.

@Override
public final AMD64LIRInstruction createStackMove(AllocatableValue result, AllocatableValue input) {
    AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
    switch(kind.getSizeInBytes()) {
        case 2:
            return new AMD64PushPopStackMove(WORD, result, input);
        case 8:
            return new AMD64PushPopStackMove(QWORD, result, input);
        default:
            RegisterBackupPair backup = backupSlotProvider.getScratchRegister(input.getPlatformKind());
            Register scratchRegister = backup.register;
            VirtualStackSlot backupSlot = backup.backupSlot;
            return createStackMove(result, input, scratchRegister, backupSlot);
    }
}
Also used : AMD64Kind(jdk.vm.ci.amd64.AMD64Kind) Register(jdk.vm.ci.code.Register) AMD64PushPopStackMove(org.graalvm.compiler.lir.amd64.AMD64Move.AMD64PushPopStackMove) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Example 8 with VirtualStackSlot

use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.

the class SSAMoveResolver method breakCycle.

@Override
protected void breakCycle(int spillCandidate) {
    if (spillCandidate != -1) {
        super.breakCycle(spillCandidate);
        return;
    }
    assert mappingFromSize() > 1;
    // Arbitrarily select the first entry for spilling.
    int stackSpillCandidate = 0;
    Interval fromInterval = getMappingFrom(stackSpillCandidate);
    // allocate new stack slot
    VirtualStackSlot spillSlot = getAllocator().getFrameMapBuilder().allocateSpillSlot(fromInterval.kind());
    spillInterval(stackSpillCandidate, fromInterval, spillSlot);
}
Also used : LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) Interval(org.graalvm.compiler.lir.alloc.lsra.Interval)

Example 9 with VirtualStackSlot

use of org.graalvm.compiler.lir.VirtualStackSlot 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 10 with VirtualStackSlot

use of org.graalvm.compiler.lir.VirtualStackSlot in project graal by oracle.

the class AllocaNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    VirtualStackSlot array = gen.getLIRGeneratorTool().getResult().getFrameMapBuilder().allocateStackSlots(slots, objects, null);
    Value result = gen.getLIRGeneratorTool().emitAddress(array);
    gen.setResult(this, result);
}
Also used : Value(jdk.vm.ci.meta.Value) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot)

Aggregations

VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)14 Value (jdk.vm.ci.meta.Value)7 BitSet (java.util.BitSet)4 LIRValueUtil.asVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot)3 LIRValueUtil.isVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot)3 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 HotSpotLIRGenerator (org.graalvm.compiler.hotspot.HotSpotLIRGenerator)2 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)1 Register (jdk.vm.ci.code.Register)1 StackLockValue (jdk.vm.ci.code.StackLockValue)1 StackSlot (jdk.vm.ci.code.StackSlot)1 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)1 VirtualObject (jdk.vm.ci.code.VirtualObject)1 JavaValue (jdk.vm.ci.meta.JavaValue)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 ConstantValue (org.graalvm.compiler.lir.ConstantValue)1 Interval (org.graalvm.compiler.lir.alloc.lsra.Interval)1 AMD64PushPopStackMove (org.graalvm.compiler.lir.amd64.AMD64Move.AMD64PushPopStackMove)1 SimpleVirtualStackSlot (org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot)1 VirtualStackSlotRange (org.graalvm.compiler.lir.framemap.VirtualStackSlotRange)1