Search in sources :

Example 16 with StackSlot

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

the class LinearScanLifetimeAnalysisPhase method handleMethodArguments.

/**
 * Optimizes moves related to incoming stack based arguments. The interval for the destination
 * of such moves is assigned the stack slot (which is in the caller's frame) as its spill slot.
 */
protected void handleMethodArguments(LIRInstruction op) {
    if (ValueMoveOp.isValueMoveOp(op)) {
        ValueMoveOp move = ValueMoveOp.asValueMoveOp(op);
        if (optimizeMethodArgument(move.getInput())) {
            StackSlot slot = asStackSlot(move.getInput());
            if (Assertions.detailedAssertionsEnabled(allocator.getOptions())) {
                assert op.id() > 0 : "invalid id";
                assert allocator.blockForId(op.id()).getPredecessorCount() == 0 : "move from stack must be in first block";
                assert isVariable(move.getResult()) : "result of move must be a variable";
                if (debug.isLogEnabled()) {
                    debug.log("found move from stack slot %s to %s", slot, move.getResult());
                }
            }
            Interval interval = allocator.intervalFor(move.getResult());
            interval.setSpillSlot(slot);
            interval.assignLocation(slot);
        }
    }
}
Also used : ValueUtil.asStackSlot(jdk.vm.ci.code.ValueUtil.asStackSlot) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) ValueMoveOp(org.graalvm.compiler.lir.StandardOp.ValueMoveOp)

Example 17 with StackSlot

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

the class AArch64Move method const2stack.

private static void const2stack(CompilationResultBuilder crb, AArch64MacroAssembler masm, Value result, JavaConstant constant) {
    try (ScratchRegister addrReg = masm.getScratchRegister()) {
        StackSlot slot = (StackSlot) result;
        AArch64Address resultAddress = loadStackSlotAddress(crb, masm, slot, addrReg.getRegister());
        if (constant.isDefaultForKind() || constant.isNull()) {
            emitStore(crb, masm, (AArch64Kind) result.getPlatformKind(), resultAddress, zr.asValue(LIRKind.combine(result)));
        } else {
            try (ScratchRegister sc = masm.getScratchRegister()) {
                Value scratchRegisterValue = sc.getRegister().asValue(LIRKind.combine(result));
                const2reg(crb, masm, scratchRegisterValue, constant);
                emitStore(crb, masm, (AArch64Kind) result.getPlatformKind(), resultAddress, scratchRegisterValue);
            }
        }
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.asStackSlot(jdk.vm.ci.code.ValueUtil.asStackSlot) VirtualStackSlot(org.graalvm.compiler.lir.VirtualStackSlot) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

Example 18 with StackSlot

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

the class AMD64SaveRegistersOp 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 19 with StackSlot

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

the class LIRGenerator method zapArgumentSpace.

@Override
public LIRInstruction zapArgumentSpace() {
    List<StackSlot> slots = null;
    for (AllocatableValue arg : res.getCallingConvention().getArguments()) {
        if (isStackSlot(arg)) {
            if (slots == null) {
                slots = new ArrayList<>();
            }
            slots.add((StackSlot) arg);
        } else {
            assert !isVirtualStackSlot(arg);
        }
    }
    if (slots == null) {
        return null;
    }
    StackSlot[] zappedStack = slots.toArray(new StackSlot[slots.size()]);
    JavaConstant[] zapValues = new JavaConstant[zappedStack.length];
    for (int i = 0; i < zappedStack.length; i++) {
        PlatformKind kind = zappedStack[i].getPlatformKind();
        zapValues[i] = zapValueForKind(kind);
    }
    return createZapArgumentSpace(zappedStack, zapValues);
}
Also used : LIRValueUtil.isVirtualStackSlot(org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot) StackSlot(jdk.vm.ci.code.StackSlot) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) JavaConstant(jdk.vm.ci.meta.JavaConstant) PlatformKind(jdk.vm.ci.meta.PlatformKind) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) ValueUtil.isAllocatableValue(jdk.vm.ci.code.ValueUtil.isAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 20 with StackSlot

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

the class FrameInfoVerifier method makeValueInfo.

private ValueInfo makeValueInfo(FrameData data, JavaKind kind, JavaValue value) {
    ValueInfo result = new ValueInfo();
    result.kind = kind;
    if (ValueUtil.isIllegalJavaValue(value)) {
        result.type = ValueType.Illegal;
        assert result.kind == JavaKind.Illegal;
    } else if (value instanceof StackSlot) {
        StackSlot stackSlot = (StackSlot) value;
        result.type = ValueType.StackSlot;
        result.data = stackSlot.getOffset(data.totalFrameSize);
        result.isCompressedReference = isCompressedReference(stackSlot);
        ImageSingletons.lookup(Counters.class).stackValueCount.inc();
    } else if (value instanceof JavaConstant) {
        JavaConstant constant = (JavaConstant) value;
        result.value = constant;
        if (constant.isDefaultForKind()) {
            result.type = ValueType.DefaultConstant;
        } else {
            result.type = ValueType.Constant;
            if (constant.getJavaKind() == JavaKind.Object) {
                /*
                     * Collect all Object constants, which will be stored in a separate Object[]
                     * array so that the GC can visit them.
                     */
                objectConstants.addObject(constant);
            }
        }
        ImageSingletons.lookup(Counters.class).constantValueCount.inc();
    } else if (ValueUtil.isVirtualObject(value)) {
        VirtualObject virtualObject = (VirtualObject) value;
        result.type = ValueType.VirtualObject;
        result.data = virtualObject.getId();
        makeVirtualObject(data, virtualObject);
    } else {
        throw shouldNotReachHere();
    }
    return result;
}
Also used : VirtualObject(jdk.vm.ci.code.VirtualObject) ValueInfo(com.oracle.svm.core.code.FrameInfoQueryResult.ValueInfo) StackSlot(jdk.vm.ci.code.StackSlot) Counters(com.oracle.svm.core.code.CodeInfoEncoder.Counters) JavaConstant(jdk.vm.ci.meta.JavaConstant)

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