use of org.graalvm.compiler.asm.sparc.SPARCMacroAssembler 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();
}
Aggregations