Search in sources :

Example 16 with LIRFrameState

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

the class SPARCHotSpotLIRGenerator method emitForeignCall.

@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
    HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
    Variable result;
    LIRFrameState debugInfo = null;
    if (hotspotLinkage.needsDebugInfo()) {
        debugInfo = state;
        assert debugInfo != null || getStub() != null;
    }
    if (linkage.destroysRegisters() || hotspotLinkage.needsJavaFrameAnchor()) {
        HotSpotRegistersProvider registers = getProviders().getRegisters();
        Register thread = registers.getThreadRegister();
        Value threadTemp = newVariable(LIRKind.value(SPARCKind.XWORD));
        Register stackPointer = registers.getStackPointerRegister();
        Variable spScratch = newVariable(LIRKind.value(target().arch.getWordKind()));
        append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread, stackPointer, threadTemp, spScratch));
        result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
        append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), thread, threadTemp));
    } else {
        result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
    }
    return result;
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCImmediateAddressValue(org.graalvm.compiler.lir.sparc.SPARCImmediateAddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Example 17 with LIRFrameState

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

the class SPARCHotSpotNodeLIRBuilder method visitSafepointNode.

@Override
public void visitSafepointNode(SafepointNode i) {
    LIRFrameState info = state(i);
    Register thread = getGen().getProviders().getRegisters().getThreadRegister();
    append(new SPARCHotSpotSafepointOp(info, getGen().config, thread, gen));
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Register(jdk.vm.ci.code.Register)

Example 18 with LIRFrameState

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

the class AMD64HotSpotLIRGenerator method emitForeignCall.

@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
    HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
    boolean destroysRegisters = hotspotLinkage.destroysRegisters();
    AMD64SaveRegistersOp save = null;
    Stub stub = getStub();
    if (destroysRegisters) {
        if (stub != null && stub.preservesRegisters()) {
            Register[] savedRegisters = getRegisterConfig().getAllocatableRegisters().toArray();
            save = emitSaveAllRegisters(savedRegisters, true);
        }
    }
    Variable result;
    LIRFrameState debugInfo = null;
    if (hotspotLinkage.needsDebugInfo()) {
        debugInfo = state;
        assert debugInfo != null || stub != null;
    }
    if (hotspotLinkage.needsJavaFrameAnchor()) {
        Register thread = getProviders().getRegisters().getThreadRegister();
        append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
        result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
        append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), config.threadLastJavaPcOffset(), thread));
    } else {
        result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
    }
    if (destroysRegisters) {
        if (stub != null) {
            if (stub.preservesRegisters()) {
                HotSpotLIRGenerationResult generationResult = getResult();
                LIRFrameState key = currentRuntimeCallInfo;
                if (key == null) {
                    key = LIRFrameState.NO_STATE;
                }
                assert !generationResult.getCalleeSaveInfo().containsKey(key);
                generationResult.getCalleeSaveInfo().put(key, save);
                emitRestoreRegisters(save);
            }
        }
    }
    return result;
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) HotSpotLIRGenerationResult(org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage) AMD64SaveRegistersOp(org.graalvm.compiler.lir.amd64.AMD64SaveRegistersOp) Stub(org.graalvm.compiler.hotspot.stubs.Stub)

Example 19 with LIRFrameState

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

the class AMD64HotSpotNodeLIRBuilder method visitSafepointNode.

@Override
public void visitSafepointNode(SafepointNode i) {
    LIRFrameState info = state(i);
    Register thread = getGen().getProviders().getRegisters().getThreadRegister();
    append(new AMD64HotSpotSafepointOp(info, getGen().config, this, thread));
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Register(jdk.vm.ci.code.Register)

Example 20 with LIRFrameState

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

the class AArch64HotSpotLIRGenerator method emitForeignCall.

@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
    HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
    Variable result;
    LIRFrameState debugInfo = null;
    if (hotspotLinkage.needsDebugInfo()) {
        debugInfo = state;
        assert debugInfo != null || getStub() != null;
    }
    if (linkage.destroysRegisters() || hotspotLinkage.needsJavaFrameAnchor()) {
        HotSpotRegistersProvider registers = getProviders().getRegisters();
        Register thread = registers.getThreadRegister();
        Variable scratch = newVariable(LIRKind.value(target().arch.getWordKind()));
        // We need a label for the return address.
        label = new Label();
        append(new AArch64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), thread, scratch, label));
        result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
        append(new AArch64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread));
        // Clear it out so it's not being reused later.
        label = null;
    } else {
        result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
    }
    return result;
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) Label(org.graalvm.compiler.asm.Label) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Aggregations

LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)33 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)15 Test (org.junit.Test)15 Register (jdk.vm.ci.code.Register)7 Value (jdk.vm.ci.meta.Value)7 VirtualObject (jdk.vm.ci.code.VirtualObject)5 Variable (org.graalvm.compiler.lir.Variable)5 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)4 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 HotSpotForeignCallLinkage (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)3 HotSpotLIRGenerator (org.graalvm.compiler.hotspot.HotSpotLIRGenerator)3 SaveRegistersOp (org.graalvm.compiler.lir.StandardOp.SaveRegistersOp)3 BytecodeFrame (jdk.vm.ci.code.BytecodeFrame)2 CallingConvention (jdk.vm.ci.code.CallingConvention)2 HotSpotMetaspaceConstant (jdk.vm.ci.hotspot.HotSpotMetaspaceConstant)2 JavaValue (jdk.vm.ci.meta.JavaValue)2 HotSpotLIRGenerationResult (org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult)2 HotSpotRegistersProvider (org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider)2 Stub (org.graalvm.compiler.hotspot.stubs.Stub)2