Search in sources :

Example 1 with HotSpotForeignCallLinkage

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

the class StubAVXTest method test.

@Test
public void test() {
    HotSpotProviders providers = (HotSpotProviders) getProviders();
    HotSpotForeignCallsProviderImpl foreignCalls = (HotSpotForeignCallsProviderImpl) providers.getForeignCalls();
    HotSpotForeignCallLinkage linkage = foreignCalls.registerStubCall(TEST_STUB, true, HotSpotForeignCallLinkage.Transition.LEAF_NOFP);
    linkage.setCompiledStub(new TestStub(getInitialOptions(), providers, linkage));
    runTest("testStub");
}
Also used : HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage) HotSpotForeignCallsProviderImpl(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProviderImpl) LIRTest(org.graalvm.compiler.lir.jtt.LIRTest) Test(org.junit.Test)

Example 2 with HotSpotForeignCallLinkage

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

the class HotSpotForeignCallsProviderImpl method lookupForeignCall.

@Override
public HotSpotForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
    assert foreignCalls != null : descriptor;
    HotSpotForeignCallLinkage callTarget = foreignCalls.get(descriptor);
    callTarget.finalizeAddress(runtime.getHostBackend());
    return callTarget;
}
Also used : HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Example 3 with HotSpotForeignCallLinkage

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

the class HotSpotForeignCallsProviderImpl method getStubs.

@Override
public List<Stub> getStubs() {
    List<Stub> stubs = new ArrayList<>();
    for (HotSpotForeignCallLinkage linkage : foreignCalls.getValues()) {
        if (linkage.isCompiledStub()) {
            Stub stub = linkage.getStub();
            assert stub != null;
            stubs.add(stub);
        }
    }
    return stubs;
}
Also used : ArrayList(java.util.ArrayList) ForeignCallStub(org.graalvm.compiler.hotspot.stubs.ForeignCallStub) Stub(org.graalvm.compiler.hotspot.stubs.Stub) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Example 4 with HotSpotForeignCallLinkage

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

the class Stub method checkStubInvariants.

/**
 * Checks the conditions a compilation must satisfy to be installed as a RuntimeStub.
 */
private boolean checkStubInvariants(CompilationResult compResult) {
    assert compResult.getExceptionHandlers().isEmpty() : this;
    // assumptions and there is no point in recording evol_method dependencies
    assert compResult.getAssumptions() == null : "stubs should not use assumptions: " + this;
    for (DataPatch data : compResult.getDataPatches()) {
        if (data.reference instanceof ConstantReference) {
            ConstantReference ref = (ConstantReference) data.reference;
            if (ref.getConstant() instanceof HotSpotMetaspaceConstant) {
                HotSpotMetaspaceConstant c = (HotSpotMetaspaceConstant) ref.getConstant();
                if (c.asResolvedJavaType() != null && c.asResolvedJavaType().getName().equals("[I")) {
                    // embedding the type '[I' is safe, since it is never unloaded
                    continue;
                }
            }
        }
        assert !(data.reference instanceof ConstantReference) : this + " cannot have embedded object or metadata constant: " + data.reference;
    }
    for (Infopoint infopoint : compResult.getInfopoints()) {
        assert infopoint instanceof Call : this + " cannot have non-call infopoint: " + infopoint;
        Call call = (Call) infopoint;
        assert call.target instanceof HotSpotForeignCallLinkage : this + " cannot have non runtime call: " + call.target;
        HotSpotForeignCallLinkage callLinkage = (HotSpotForeignCallLinkage) call.target;
        assert !callLinkage.isCompiledStub() || callLinkage.getDescriptor().equals(UNCOMMON_TRAP_HANDLER) : this + " cannot call compiled stub " + callLinkage;
    }
    return true;
}
Also used : Call(jdk.vm.ci.code.site.Call) ConstantReference(jdk.vm.ci.code.site.ConstantReference) DataPatch(jdk.vm.ci.code.site.DataPatch) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage) Infopoint(jdk.vm.ci.code.site.Infopoint) HotSpotMetaspaceConstant(jdk.vm.ci.hotspot.HotSpotMetaspaceConstant)

Example 5 with HotSpotForeignCallLinkage

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

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