Search in sources :

Example 6 with HotSpotForeignCallLinkage

use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage in project graal by oracle.

the class AMD64HotSpotLIRGenerator method emitForeignCallOp.

@Override
protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
    currentRuntimeCallInfo = info;
    HotSpotForeignCallLinkage hsLinkage = (HotSpotForeignCallLinkage) linkage;
    AMD64 arch = (AMD64) target().arch;
    if (arch.getFeatures().contains(AMD64.CPUFeature.AVX) && hsLinkage.mayContainFP() && !hsLinkage.isCompiledStub()) {
        /*
             * If the target may contain FP ops, and it is not compiled by us, we may have an
             * AVX-SSE transition.
             *
             * We exclude the argument registers from the zeroing LIR instruction since it violates
             * the LIR semantics of @Temp that values must not be live. Note that the emitted
             * machine instruction actually zeros _all_ XMM registers which is fine since we know
             * that their upper half is not used.
             */
        append(new AMD64VZeroUpper(arguments));
    }
    super.emitForeignCallOp(linkage, result, arguments, temps, info);
}
Also used : AMD64VZeroUpper(org.graalvm.compiler.lir.amd64.AMD64VZeroUpper) AMD64(jdk.vm.ci.amd64.AMD64) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Example 7 with HotSpotForeignCallLinkage

use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage 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 8 with HotSpotForeignCallLinkage

use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage 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)

Example 9 with HotSpotForeignCallLinkage

use of org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage in project graal by oracle.

the class HotSpotForeignCallsProviderImpl method linkForeignCall.

/**
 * Creates a {@linkplain ForeignCallStub stub} for a foreign call.
 *
 * @param descriptor the signature of the call to the stub
 * @param address the address of the foreign code to call
 * @param prependThread true if the JavaThread value for the current thread is to be prepended
 *            to the arguments for the call to {@code address}
 * @param transition specifies if this is a {@linkplain Transition#LEAF leaf} call
 * @param reexecutable specifies if the foreign call can be re-executed without (meaningful)
 *            side effects. Deoptimization will not return to a point before a foreign call that
 *            cannot be re-executed.
 * @param killedLocations the memory locations killed by the foreign call
 */
public void linkForeignCall(OptionValues options, HotSpotProviders providers, ForeignCallDescriptor descriptor, long address, boolean prependThread, Transition transition, boolean reexecutable, LocationIdentity... killedLocations) {
    ForeignCallStub stub = new ForeignCallStub(options, jvmciRuntime, providers, address, descriptor, prependThread, transition, reexecutable, killedLocations);
    HotSpotForeignCallLinkage linkage = stub.getLinkage();
    HotSpotForeignCallLinkage targetLinkage = stub.getTargetLinkage();
    linkage.setCompiledStub(stub);
    register(linkage);
    register(targetLinkage);
}
Also used : HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage) ForeignCallStub(org.graalvm.compiler.hotspot.stubs.ForeignCallStub)

Aggregations

HotSpotForeignCallLinkage (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)9 Register (jdk.vm.ci.code.Register)3 LIRFrameState (org.graalvm.compiler.lir.LIRFrameState)3 Variable (org.graalvm.compiler.lir.Variable)3 HotSpotRegistersProvider (org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider)2 ForeignCallStub (org.graalvm.compiler.hotspot.stubs.ForeignCallStub)2 Stub (org.graalvm.compiler.hotspot.stubs.Stub)2 ArrayList (java.util.ArrayList)1 AMD64 (jdk.vm.ci.amd64.AMD64)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 Call (jdk.vm.ci.code.site.Call)1 ConstantReference (jdk.vm.ci.code.site.ConstantReference)1 DataPatch (jdk.vm.ci.code.site.DataPatch)1 Infopoint (jdk.vm.ci.code.site.Infopoint)1 HotSpotMetaspaceConstant (jdk.vm.ci.hotspot.HotSpotMetaspaceConstant)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 Value (jdk.vm.ci.meta.Value)1 Label (org.graalvm.compiler.asm.Label)1 HotSpotLIRGenerationResult (org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult)1 HotSpotForeignCallsProviderImpl (org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProviderImpl)1