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));
}
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);
}
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;
}
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));
}
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);
}
Aggregations