Search in sources :

Example 31 with CallingConvention

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

the class SubstrateAMD64Backend method newLIRGenerationResult.

@Override
public LIRGenerationResult newLIRGenerationResult(CompilationIdentifier compilationId, LIR lir, FrameMapBuilder frameMapBuilder, StructuredGraph graph, Object stub) {
    SharedMethod method = (SharedMethod) graph.method();
    CallingConvention callingConvention = CodeUtil.getCallingConvention(getCodeCache(), method.isEntryPoint() ? SubstrateCallingConventionType.NativeCallee : SubstrateCallingConventionType.JavaCallee, method, this);
    return new SubstrateLIRGenerationResult(compilationId, lir, frameMapBuilder, callingConvention, method);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) SharedMethod(com.oracle.svm.core.meta.SharedMethod)

Example 32 with CallingConvention

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

the class HotSpotForeignCallLinkageImpl method create.

/**
 * Creates a {@link HotSpotForeignCallLinkage}.
 *
 * @param descriptor the descriptor of the call
 * @param address the address of the code to call
 * @param effect specifies if the call destroys or preserves all registers (apart from
 *            temporaries which are always destroyed)
 * @param outgoingCcType outgoing (caller) calling convention type
 * @param incomingCcType incoming (callee) calling convention type (can be null)
 * @param transition specifies if this is a {@linkplain #needsDebugInfo() leaf} call
 * @param reexecutable specifies if the call can be re-executed without (meaningful) side
 *            effects. Deoptimization will not return to a point before a call that cannot be
 *            re-executed.
 * @param killedLocations the memory locations killed by the call
 */
public static HotSpotForeignCallLinkage create(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, WordTypes wordTypes, HotSpotForeignCallsProvider foreignCalls, ForeignCallDescriptor descriptor, long address, RegisterEffect effect, Type outgoingCcType, Type incomingCcType, Transition transition, boolean reexecutable, LocationIdentity... killedLocations) {
    CallingConvention outgoingCc = createCallingConvention(metaAccess, codeCache, wordTypes, foreignCalls, descriptor, outgoingCcType);
    CallingConvention incomingCc = incomingCcType == null ? null : createCallingConvention(metaAccess, codeCache, wordTypes, foreignCalls, descriptor, incomingCcType);
    HotSpotForeignCallLinkageImpl linkage = new HotSpotForeignCallLinkageImpl(descriptor, address, effect, transition, outgoingCc, incomingCc, reexecutable, killedLocations);
    if (outgoingCcType == HotSpotCallingConventionType.NativeCall) {
        linkage.temporaries = foreignCalls.getNativeABICallerSaveRegisters();
    }
    return linkage;
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention)

Example 33 with CallingConvention

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

the class HotSpotHostBackend method makeCallingConvention.

protected CallingConvention makeCallingConvention(StructuredGraph graph, Stub stub) {
    if (stub != null) {
        return stub.getLinkage().getIncomingCallingConvention();
    }
    CallingConvention cc = getCallingConvention(getCodeCache(), HotSpotCallingConventionType.JavaCallee, graph.method(), this);
    if (graph.getEntryBCI() != JVMCICompiler.INVOCATION_ENTRY_BCI) {
        // for OSR, only a pointer is passed to the method.
        JavaType[] parameterTypes = new JavaType[] { getMetaAccess().lookupJavaType(long.class) };
        CallingConvention tmp = getCodeCache().getRegisterConfig().getCallingConvention(HotSpotCallingConventionType.JavaCallee, getMetaAccess().lookupJavaType(void.class), parameterTypes, this);
        cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0));
    }
    return cc;
}
Also used : CodeUtil.getCallingConvention(jdk.vm.ci.code.CodeUtil.getCallingConvention) CallingConvention(jdk.vm.ci.code.CallingConvention) JavaType(jdk.vm.ci.meta.JavaType)

Example 34 with CallingConvention

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

the class FrameMapBuilderImpl method buildFrameMap.

@Override
@SuppressWarnings("try")
public FrameMap buildFrameMap(LIRGenerationResult res) {
    DebugContext debug = res.getLIR().getDebug();
    if (debug.areScopesEnabled()) {
        verifyStackSlotAllocation(res);
    }
    for (CallingConvention cc : calls) {
        frameMap.callsMethod(cc);
    }
    frameMap.finish();
    return frameMap;
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 35 with CallingConvention

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

the class NodeLIRBuilder method emitPrologue.

protected void emitPrologue(StructuredGraph graph) {
    CallingConvention incomingArguments = gen.getResult().getCallingConvention();
    Value[] params = new Value[incomingArguments.getArgumentCount()];
    for (int i = 0; i < params.length; i++) {
        params[i] = incomingArguments.getArgument(i);
        if (ValueUtil.isStackSlot(params[i])) {
            StackSlot slot = ValueUtil.asStackSlot(params[i]);
            if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
                gen.getResult().getLIR().setHasArgInCallerFrame();
            }
        }
    }
    gen.emitIncomingValues(params);
    for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
        Value paramValue = params[param.index()];
        assert paramValue.getValueKind().equals(getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT))) : paramValue + " " + getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT));
        setResult(param, gen.emitMove(paramValue));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) StackSlot(jdk.vm.ci.code.StackSlot)

Aggregations

CallingConvention (jdk.vm.ci.code.CallingConvention)36 Register (jdk.vm.ci.code.Register)20 TargetDescription (jdk.vm.ci.code.TargetDescription)14 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)14 RegisterConfig (jdk.vm.ci.code.RegisterConfig)13 CompilationResult (org.graalvm.compiler.code.CompilationResult)12 RegisterValue (jdk.vm.ci.code.RegisterValue)11 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)11 Test (org.junit.Test)11 AMD64Assembler (org.graalvm.compiler.asm.amd64.AMD64Assembler)9 ForeignCallLinkage (org.graalvm.compiler.core.common.spi.ForeignCallLinkage)9 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)6 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 Value (jdk.vm.ci.meta.Value)5 Field (java.lang.reflect.Field)4 StackSlot (jdk.vm.ci.code.StackSlot)3 PlatformKind (jdk.vm.ci.meta.PlatformKind)3 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)3 HotSpotForeignCallLinkage (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)3 HotSpotForeignCallLinkageImpl (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkageImpl)3