use of org.graalvm.compiler.lir.framemap.FrameMap in project graal by oracle.
the class AMD64HotSpotLeaveCurrentStackFrameOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
FrameMap frameMap = crb.frameMap;
RegisterConfig registerConfig = frameMap.getRegisterConfig();
RegisterSaveLayout registerSaveLayout = saveRegisterOp.getMap(frameMap);
Register stackPointer = registerConfig.getFrameRegister();
// Restore integer result register.
final int stackSlotSize = frameMap.getTarget().wordSize;
Register integerResultRegister = registerConfig.getReturnRegister(JavaKind.Long);
masm.movptr(integerResultRegister, new AMD64Address(stackPointer, registerSaveLayout.registerToSlot(integerResultRegister) * stackSlotSize));
masm.movptr(rdx, new AMD64Address(stackPointer, registerSaveLayout.registerToSlot(rdx) * stackSlotSize));
// Restore float result register.
Register floatResultRegister = registerConfig.getReturnRegister(JavaKind.Double);
masm.movdbl(floatResultRegister, new AMD64Address(stackPointer, registerSaveLayout.registerToSlot(floatResultRegister) * stackSlotSize));
/*
* All of the register save area will be popped of the stack. Only the return address
* remains.
*/
leaveFrameAndRestoreRbp(crb, masm);
// Remove return address.
masm.addq(stackPointer, crb.target.arch.getReturnAddressSize());
}
use of org.graalvm.compiler.lir.framemap.FrameMap in project graal by oracle.
the class AArch64HotSpotBackend method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner) {
AArch64MacroAssembler masm = (AArch64MacroAssembler) crb.asm;
FrameMap frameMap = crb.frameMap;
RegisterConfig regConfig = frameMap.getRegisterConfig();
Label verifiedStub = new Label();
emitCodePrefix(crb, installedCodeOwner, masm, regConfig, verifiedStub);
emitCodeBody(crb, lir, masm);
emitCodeSuffix(crb, masm, frameMap);
}
use of org.graalvm.compiler.lir.framemap.FrameMap in project graal by oracle.
the class GraalCompiler method emitCode.
@SuppressWarnings("try")
public static void emitCode(Backend backend, Assumptions assumptions, ResolvedJavaMethod rootMethod, Collection<ResolvedJavaMethod> inlinedMethods, EconomicSet<ResolvedJavaField> accessedFields, int bytecodeSize, LIRGenerationResult lirGenRes, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, CompilationResultBuilderFactory factory) {
DebugContext debug = lirGenRes.getLIR().getDebug();
try (DebugCloseable a = EmitCode.start(debug)) {
FrameMap frameMap = lirGenRes.getFrameMap();
CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGenRes, frameMap, compilationResult, factory);
backend.emitCode(crb, lirGenRes.getLIR(), installedCodeOwner);
if (assumptions != null && !assumptions.isEmpty()) {
compilationResult.setAssumptions(assumptions.toArray());
}
if (rootMethod != null) {
compilationResult.setMethods(rootMethod, inlinedMethods);
compilationResult.setFields(accessedFields);
compilationResult.setBytecodeSize(bytecodeSize);
}
crb.finish();
if (debug.isCountEnabled()) {
List<DataPatch> ldp = compilationResult.getDataPatches();
JavaKind[] kindValues = JavaKind.values();
CounterKey[] dms = new CounterKey[kindValues.length];
for (int i = 0; i < dms.length; i++) {
dms[i] = DebugContext.counter("DataPatches-%s", kindValues[i]);
}
for (DataPatch dp : ldp) {
JavaKind kind = JavaKind.Illegal;
if (dp.reference instanceof ConstantReference) {
VMConstant constant = ((ConstantReference) dp.reference).getConstant();
if (constant instanceof JavaConstant) {
kind = ((JavaConstant) constant).getJavaKind();
}
}
dms[kind.ordinal()].add(debug, 1);
}
DebugContext.counter("CompilationResults").increment(debug);
DebugContext.counter("CodeBytesEmitted").add(debug, compilationResult.getTargetCodeSize());
DebugContext.counter("InfopointsEmitted").add(debug, compilationResult.getInfopoints().size());
DebugContext.counter("DataPatches").add(debug, ldp.size());
DebugContext.counter("ExceptionHandlersEmitted").add(debug, compilationResult.getExceptionHandlers().size());
}
debug.dump(DebugContext.BASIC_LEVEL, compilationResult, "After code generation");
}
}
use of org.graalvm.compiler.lir.framemap.FrameMap 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.lir.framemap.FrameMap in project graal by oracle.
the class AMD64HotSpotBackend method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner) {
AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm;
FrameMap frameMap = crb.frameMap;
RegisterConfig regConfig = frameMap.getRegisterConfig();
Label verifiedEntry = new Label();
// Emit the prefix
emitCodePrefix(installedCodeOwner, crb, asm, regConfig, verifiedEntry);
// Emit code for the LIR
emitCodeBody(installedCodeOwner, crb, lir);
// Emit the suffix
emitCodeSuffix(installedCodeOwner, crb, asm, frameMap);
// Profile assembler instructions
profileInstructions(lir, crb);
}
Aggregations