use of org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister in project graal by oracle.
the class SPARCHotSpotJumpToExceptionHandlerInCallerOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
// Restore SP from L7 if the exception PC is a method handle call site.
SPARCAddress dst = new SPARCAddress(thread, isMethodHandleReturnOffset);
try (ScratchRegister scratch = masm.getScratchRegister()) {
Register scratchReg = scratch.getRegister();
masm.lduw(dst, scratchReg);
masm.cmp(scratchReg, scratchReg);
masm.movcc(ConditionFlag.NotZero, CC.Icc, l7, sp);
}
masm.jmpl(asRegister(handlerInCallerPc), 0, g0);
// Delay slot
leaveFrame(crb);
}
use of org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister in project graal by oracle.
the class SPARCHotSpotSafepointOp method emitThreadLocalPoll.
/**
* Emit a thread-local safepoint poll.
*/
private static void emitThreadLocalPoll(CompilationResultBuilder crb, SPARCMacroAssembler masm, GraalHotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register thread) {
assert !atReturn || state == null : "state is unneeded at return";
assert config.threadPollingPageOffset >= 0;
try (ScratchRegister scratchReg = masm.getScratchRegister()) {
Register scratch = scratchReg.getRegister();
masm.ldx(new SPARCAddress(thread, config.threadPollingPageOffset), scratch);
crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
if (state != null) {
final int pos = masm.position();
crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
}
masm.ldx(new SPARCAddress(scratch, 0), g0);
}
}
use of org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister in project graal by oracle.
the class SPARCHotSpotBackend method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner) {
SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm;
// TODO: (sa) Fold the two traversals into one
stuffDelayedControlTransfers(lir);
int constantSize = calculateConstantSize(lir);
boolean canUseImmediateConstantLoad = constantSize < (1 << 13);
masm.setImmediateConstantLoad(canUseImmediateConstantLoad);
FrameMap frameMap = crb.frameMap;
RegisterConfig regConfig = frameMap.getRegisterConfig();
Label unverifiedStub = installedCodeOwner == null || installedCodeOwner.isStatic() ? null : new Label();
for (int i = 0; i < 2; i++) {
if (i > 0) {
crb.resetForEmittingCode();
lir.resetLabels();
resetDelayedControlTransfers(lir);
}
// Emit the prefix
if (unverifiedStub != null) {
crb.recordMark(config.MARKID_UNVERIFIED_ENTRY);
// We need to use JavaCall here because we haven't entered the frame yet.
CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCall, null, new JavaType[] { getProviders().getMetaAccess().lookupJavaType(Object.class) }, this);
// see MacroAssembler::ic_call
Register inlineCacheKlass = g5;
try (ScratchRegister sc = masm.getScratchRegister()) {
Register scratch = sc.getRegister();
Register receiver = asRegister(cc.getArgument(0));
SPARCAddress src = new SPARCAddress(receiver, config.hubOffset);
masm.ldx(src, scratch);
masm.cmp(scratch, inlineCacheKlass);
}
BPCC.emit(masm, Xcc, NotEqual, NOT_ANNUL, PREDICT_NOT_TAKEN, unverifiedStub);
// delay slot
masm.nop();
}
masm.align(config.codeEntryAlignment);
crb.recordMark(config.MARKID_OSR_ENTRY);
crb.recordMark(config.MARKID_VERIFIED_ENTRY);
// Emit code for the LIR
crb.emit(lir);
}
profileInstructions(lir, crb);
HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls();
if (!frameContext.isStub) {
crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY);
SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, null);
crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, null);
} else {
// No need to emit the stubs for entries back into the method since
// it has no calls that can cause such "return" entries
}
if (unverifiedStub != null) {
masm.bind(unverifiedStub);
try (ScratchRegister sc = masm.getScratchRegister()) {
Register scratch = sc.getRegister();
SPARCCall.indirectJmp(crb, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER));
}
}
masm.peephole();
}
use of org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister in project graal by oracle.
the class SPARCHotSpotCounterOp method emitIncrement.
private void emitIncrement(int counterIndex, SPARCMacroAssembler masm, SPARCAddress counterAddr, Value increment) {
try (ScratchRegister scratch = masm.getScratchRegister()) {
Register counterReg = scratch.getRegister();
// load counter value
masm.ldx(counterAddr, counterReg);
counterPatchOffsets[counterIndex] = masm.position();
// increment counter
if (isJavaConstant(increment)) {
masm.add(counterReg, asInt(asJavaConstant(increment)), counterReg);
} else {
masm.add(counterReg, asRegister(increment), counterReg);
}
// store counter value
masm.stx(counterReg, counterAddr);
}
}
use of org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister in project graal by oracle.
the class SPARCMove method const2reg.
public static void const2reg(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Register constantTableBase, JavaConstant input, SPARCDelayedControlTransfer delaySlotLir) {
try (ScratchRegister sc = masm.getScratchRegister()) {
Register scratch = sc.getRegister();
Set<CPUFeature> cpuFeatures = ((SPARC) masm.target.arch).getFeatures();
boolean hasVIS1 = cpuFeatures.contains(CPUFeature.VIS1);
boolean hasVIS3 = cpuFeatures.contains(CPUFeature.VIS3);
Register resultRegister = asRegister(result);
switch(input.getJavaKind().getStackKind()) {
case Int:
if (input.isDefaultForKind()) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.clr(resultRegister);
} else if (isSimm13(input.asInt())) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.or(g0, input.asInt(), resultRegister);
} else {
if (constantTableBase.equals(g0)) {
throw GraalError.shouldNotReachHere();
} else {
loadFromConstantTable(crb, masm, constantTableBase, input, resultRegister, delaySlotLir);
}
}
break;
case Long:
if (input.isDefaultForKind()) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.clr(resultRegister);
} else if (isSimm13(input.asLong())) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.or(g0, (int) input.asLong(), resultRegister);
} else {
loadFromConstantTable(crb, masm, constantTableBase, input, resultRegister, delaySlotLir);
}
break;
case Float:
{
float constant = input.asFloat();
int constantBits = java.lang.Float.floatToIntBits(constant);
if (hasVIS1 && constantBits == 0) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.fzeros(resultRegister);
} else {
if (hasVIS3 && isSimm13(constantBits)) {
masm.or(g0, constantBits, scratch);
delaySlotLir.emitControlTransfer(crb, masm);
masm.movwtos(scratch, resultRegister);
} else {
// First load the address into the scratch register
loadFromConstantTable(crb, masm, constantTableBase, input, resultRegister, delaySlotLir);
}
}
break;
}
case Double:
{
double constant = input.asDouble();
long constantBits = java.lang.Double.doubleToRawLongBits(constant);
if (hasVIS1 && constantBits == 0) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.fzerod(resultRegister);
} else {
if (hasVIS3 && isSimm13(constantBits)) {
masm.or(g0, (int) constantBits, scratch);
delaySlotLir.emitControlTransfer(crb, masm);
masm.movxtod(scratch, resultRegister);
} else {
loadFromConstantTable(crb, masm, constantTableBase, input, resultRegister, delaySlotLir);
}
}
break;
}
case Object:
if (input.isNull()) {
delaySlotLir.emitControlTransfer(crb, masm);
masm.clr(resultRegister);
} else {
loadFromConstantTable(crb, masm, constantTableBase, input, resultRegister, delaySlotLir);
}
break;
default:
throw GraalError.shouldNotReachHere("missing: " + input.getJavaKind());
}
}
}
Aggregations