Search in sources :

Example 6 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class SPARCSaveRegistersOp method getMap.

@Override
public RegisterSaveLayout getMap(FrameMap frameMap) {
    int total = 0;
    for (int i = 0; i < savedRegisters.length; i++) {
        if (savedRegisters[i] != null) {
            total++;
        }
    }
    Register[] keys = new Register[total];
    int[] values = new int[total];
    if (total != 0) {
        int mapIndex = 0;
        for (int i = 0; i < savedRegisters.length; i++) {
            if (savedRegisters[i] != null) {
                keys[mapIndex] = savedRegisters[i];
                assert isStackSlot(slots[i]) : "not a StackSlot: " + slots[i];
                StackSlot slot = asStackSlot(slots[i]);
                values[mapIndex] = indexForStackSlot(frameMap, slot);
                mapIndex++;
            }
        }
        assert mapIndex == total;
    }
    return new RegisterSaveLayout(keys, values);
}
Also used : RegisterSaveLayout(jdk.vm.ci.code.RegisterSaveLayout) Register(jdk.vm.ci.code.Register) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) ValueUtil.asStackSlot(jdk.vm.ci.code.ValueUtil.asStackSlot) StackSlot(jdk.vm.ci.code.StackSlot)

Example 7 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class SubstrateReferenceMapBuilder method addLiveValue.

@Override
public void addLiveValue(Value value) {
    if (ValueUtil.isStackSlot(value)) {
        StackSlot stackSlot = ValueUtil.asStackSlot(value);
        int offset = stackSlot.getOffset(totalFrameSize);
        assert referenceMap.debugMarkStackSlot(offset, stackSlot);
        LIRKind kind = (LIRKind) value.getValueKind();
        if (!kind.isValue()) {
            if (kind.isUnknownReference()) {
                throw JVMCIError.shouldNotReachHere("unknown reference alive across safepoint");
            } else if (kind.isDerivedReference()) {
                throw JVMCIError.shouldNotReachHere("derived references not supported yet on Substrate VM");
            } else {
                int bytes = bytesPerElement(kind);
                int mapSlotSize = SubstrateReferenceMap.getSlotSizeInBytes();
                assert bytes % mapSlotSize == 0;
                assert offset % mapSlotSize == 0;
                for (int i = 0; i < kind.getPlatformKind().getVectorLength(); i++) {
                    if (kind.isReference(i)) {
                        boolean compressed = kind.isCompressedReference(i);
                        referenceMap.markReferenceAtIndex((offset + i * bytes) / mapSlotSize, compressed);
                    }
                }
            }
        }
    } else if (ValueUtil.isRegister(value)) {
        assert referenceMap.debugMarkRegister(ValueUtil.asRegister(value).number, value);
    } else {
        throw VMError.shouldNotReachHere(value.toString());
    }
}
Also used : StackSlot(jdk.vm.ci.code.StackSlot) LIRKind(org.graalvm.compiler.core.common.LIRKind)

Example 8 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class FrameMap method allocateStackSlots.

/**
 * Reserves a number of contiguous slots in the frame of the method being compiled. If the
 * requested number of slots is 0, this method returns {@code null}.
 *
 * @param slots the number of slots to reserve
 * @param objects specifies the indexes of the object pointer slots. The caller is responsible
 *            for guaranteeing that each such object pointer slot is initialized before any
 *            instruction that uses a reference map. Without this guarantee, the garbage
 *            collector could see garbage object values.
 * @return the first reserved stack slot (i.e., at the lowest address)
 */
public StackSlot allocateStackSlots(int slots, BitSet objects) {
    assert frameSize == -1 : "frame size must not yet be fixed";
    if (slots == 0) {
        return null;
    }
    spillSize += spillSlotRangeSize(slots);
    if (!objects.isEmpty()) {
        assert objects.length() <= slots;
        StackSlot result = null;
        for (int slotIndex = 0; slotIndex < slots; slotIndex++) {
            StackSlot objectSlot = null;
            if (objects.get(slotIndex)) {
                objectSlot = allocateNewSpillSlot(LIRKind.reference(getTarget().arch.getWordKind()), slotIndex * getTarget().wordSize);
                addObjectStackSlot(objectSlot);
            }
            if (slotIndex == 0) {
                if (objectSlot != null) {
                    result = objectSlot;
                } else {
                    result = allocateNewSpillSlot(LIRKind.value(getTarget().arch.getWordKind()), 0);
                }
            }
        }
        assert result != null;
        return result;
    } else {
        return allocateNewSpillSlot(LIRKind.value(getTarget().arch.getWordKind()), 0);
    }
}
Also used : StackSlot(jdk.vm.ci.code.StackSlot)

Example 9 with StackSlot

use of jdk.vm.ci.code.StackSlot 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 10 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class SimpleStackSlotAllocator method updateLIR.

@SuppressWarnings("try")
protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) {
    DebugContext debug = res.getLIR().getDebug();
    try (DebugContext.Scope scope = debug.scope("StackSlotMappingLIR")) {
        ValueProcedure updateProc = (value, mode, flags) -> {
            if (isVirtualStackSlot(value)) {
                StackSlot stackSlot = mapping[asVirtualStackSlot(value).getId()];
                debug.log("map %s -> %s", value, stackSlot);
                return stackSlot;
            }
            return value;
        };
        for (AbstractBlockBase<?> block : res.getLIR().getControlFlowGraph().getBlocks()) {
            try (Indent indent0 = debug.logAndIndent("block: %s", block)) {
                for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) {
                    try (Indent indent1 = debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) {
                        inst.forEachAlive(updateProc);
                        inst.forEachInput(updateProc);
                        inst.forEachOutput(updateProc);
                        inst.forEachTemp(updateProc);
                        inst.forEachState(updateProc);
                    }
                }
            }
        }
    }
}
Also used : ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) FrameMapBuilderTool(org.graalvm.compiler.lir.framemap.FrameMapBuilderTool) AllocationPhase(org.graalvm.compiler.lir.phases.AllocationPhase) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) StackSlotAllocatorUtil.allocatedSlots(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedSlots) VirtualStackSlotRange(org.graalvm.compiler.lir.framemap.VirtualStackSlotRange) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) TargetDescription(jdk.vm.ci.code.TargetDescription) LIRValueUtil.asVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.asVirtualStackSlot) SimpleVirtualStackSlot(org.graalvm.compiler.lir.framemap.SimpleVirtualStackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) StackSlotAllocatorUtil.virtualFramesize(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.virtualFramesize) Indent(org.graalvm.compiler.debug.Indent) GraalError(org.graalvm.compiler.debug.GraalError) StackSlot(jdk.vm.ci.code.StackSlot) LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) ValueProcedure(org.graalvm.compiler.lir.ValueProcedure) StackSlotAllocatorUtil.allocatedFramesize(org.graalvm.compiler.lir.stackslotalloc.StackSlotAllocatorUtil.allocatedFramesize) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) 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)

Aggregations

StackSlot (jdk.vm.ci.code.StackSlot)21 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)8 Register (jdk.vm.ci.code.Register)6 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)6 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 Value (jdk.vm.ci.meta.Value)4 DebugContext (org.graalvm.compiler.debug.DebugContext)4 CallingConvention (jdk.vm.ci.code.CallingConvention)3 RegisterValue (jdk.vm.ci.code.RegisterValue)3 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 Assembler (org.graalvm.compiler.asm.Assembler)3 LIRValueUtil.isVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot)3 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)3 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)3 RegisterSaveLayout (jdk.vm.ci.code.RegisterSaveLayout)2 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)2 HotSpotDataBuilder (org.graalvm.compiler.hotspot.HotSpotDataBuilder)2