Search in sources :

Example 6 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class VMErrorNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    String whereString;
    if (stateBefore() != null) {
        String nl = CodeUtil.NEW_LINE;
        StringBuilder sb = new StringBuilder("in compiled code associated with frame state:");
        FrameState fs = stateBefore();
        while (fs != null) {
            Bytecode.appendLocation(sb.append(nl).append("\t"), fs.getCode(), fs.bci);
            fs = fs.outerFrameState();
        }
        whereString = sb.toString();
    } else {
        ResolvedJavaMethod method = graph().method();
        whereString = "in compiled code for " + (method == null ? graph().toString() : method.format("%H.%n(%p)"));
    }
    LIRKind wordKind = gen.getLIRGeneratorTool().getLIRKind(StampFactory.pointer());
    Value whereArg = gen.getLIRGeneratorTool().emitConstant(wordKind, new CStringConstant(whereString));
    Value formatArg = gen.getLIRGeneratorTool().emitConstant(wordKind, new CStringConstant(format));
    ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(VM_ERROR);
    gen.getLIRGeneratorTool().emitForeignCall(linkage, null, whereArg, formatArg, gen.operand(value));
}
Also used : Value(jdk.vm.ci.meta.Value) LIRKind(org.graalvm.compiler.core.common.LIRKind) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) FrameState(org.graalvm.compiler.nodes.FrameState) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) CStringConstant(org.graalvm.compiler.replacements.nodes.CStringConstant)

Example 7 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class SPARCHotSpotUnwindOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
    // This Frame is left but the called unwind (which is sibling) method needs the exception as
    // input in i0
    masm.mov(o0, i0);
    leaveFrame(crb);
    ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER);
    CallingConvention cc = linkage.getOutgoingCallingConvention();
    assert cc.getArgumentCount() == 2;
    assert exception.equals(cc.getArgument(0));
    // Get return address (is in o7 after leave).
    Register returnAddress = asRegister(cc.getArgument(1));
    masm.add(o7, SPARCAssembler.PC_RETURN_OFFSET, returnAddress);
    Register scratch = g5;
    SPARCCall.indirectJmp(crb, masm, scratch, linkage);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Example 8 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class SPARCArithmeticLIRGenerator method emitRem.

@Override
public Value emitRem(Value a, Value b, LIRFrameState state) {
    Variable result = getLIRGen().newVariable(LIRKind.combine(a, b));
    // Intermediate values
    Variable q1;
    Variable q2;
    switch((SPARCKind) a.getPlatformKind()) {
        case WORD:
            // Sign extend a and b
            Value as = emitSignExtend(a);
            Value bs = emitSignExtend(b);
            q1 = emitBinary(as.getValueKind(), Sdivx, as, bs, state);
            q2 = emitBinary(as.getValueKind(), Mulx, q1, bs);
            result = emitSub(as, q2, false);
            break;
        case XWORD:
            q1 = emitBinary(result.getValueKind(), Sdivx, a, b, state);
            q2 = emitBinary(result.getValueKind(), Mulx, q1, b);
            result = emitSub(a, q2, false);
            break;
        case SINGLE:
            ForeignCallLinkage fremCall = getLIRGen().getForeignCalls().lookupForeignCall(ARITHMETIC_FREM);
            result = getLIRGen().emitForeignCall(fremCall, state, a, b);
            break;
        case DOUBLE:
            ForeignCallLinkage dremCall = getLIRGen().getForeignCalls().lookupForeignCall(ARITHMETIC_DREM);
            result = getLIRGen().emitForeignCall(dremCall, state, a, b);
            break;
        default:
            throw GraalError.shouldNotReachHere("missing: " + a.getPlatformKind());
    }
    return result;
}
Also used : Variable(org.graalvm.compiler.lir.Variable) ConstantValue(org.graalvm.compiler.lir.ConstantValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) SPARCKind(jdk.vm.ci.sparc.SPARCKind)

Example 9 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class SPARCHotSpotLIRGenerator method emitUnwind.

@Override
public void emitUnwind(Value exception) {
    ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(HotSpotBackend.UNWIND_EXCEPTION_TO_CALLER);
    CallingConvention linkageCc = linkage.getOutgoingCallingConvention();
    assert linkageCc.getArgumentCount() == 2;
    RegisterValue exceptionParameter = (RegisterValue) linkageCc.getArgument(0);
    emitMove(exceptionParameter, exception);
    append(new SPARCHotSpotUnwindOp(exceptionParameter));
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Example 10 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class SPARCHotSpotNodeLIRBuilder method emitJumpToExceptionHandlerInCaller.

@Override
public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) {
    Variable handler = gen.load(operand(handlerInCallerPc));
    ForeignCallLinkage linkage = gen.getForeignCalls().lookupForeignCall(EXCEPTION_HANDLER_IN_CALLER);
    CallingConvention linkageCc = linkage.getOutgoingCallingConvention();
    assert linkageCc.getArgumentCount() == 2;
    RegisterValue exceptionFixed = (RegisterValue) linkageCc.getArgument(0);
    RegisterValue exceptionPcFixed = (RegisterValue) linkageCc.getArgument(1);
    gen.emitMove(exceptionFixed, operand(exception));
    gen.emitMove(exceptionPcFixed, operand(exceptionPc));
    Register thread = getGen().getProviders().getRegisters().getThreadRegister();
    SPARCHotSpotJumpToExceptionHandlerInCallerOp op = new SPARCHotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed, getGen().config.threadIsMethodHandleReturnOffset, thread);
    append(op);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Aggregations

ForeignCallLinkage (org.graalvm.compiler.core.common.spi.ForeignCallLinkage)16 CallingConvention (jdk.vm.ci.code.CallingConvention)9 Register (jdk.vm.ci.code.Register)7 RegisterValue (jdk.vm.ci.code.RegisterValue)6 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)4 Value (jdk.vm.ci.meta.Value)4 HotSpotForeignCallLinkage (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)4 Variable (org.graalvm.compiler.lir.Variable)4 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 AArch64HotSpotRegisterConfig.inlineCacheRegister (jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig.inlineCacheRegister)1 AArch64HotSpotRegisterConfig.metaspaceMethodRegister (jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig.metaspaceMethodRegister)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 SPARCKind (jdk.vm.ci.sparc.SPARCKind)1 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)1 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 HotSpotForeignCallsProvider (org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider)1 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)1 ConstantValue (org.graalvm.compiler.lir.ConstantValue)1 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)1