use of org.graalvm.compiler.asm.amd64.AMD64Address in project graal by oracle.
the class AMD64HotSpotBackend method emitCodePrefix.
/**
* Emits the code prior to the verified entry point.
*
* @param installedCodeOwner see {@link Backend#emitCode}
*/
public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, Label verifiedEntry) {
HotSpotProviders providers = getProviders();
if (installedCodeOwner != null && !installedCodeOwner.isStatic()) {
crb.recordMark(config.MARKID_UNVERIFIED_ENTRY);
CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCallee, null, new JavaType[] { providers.getMetaAccess().lookupJavaType(Object.class) }, this);
// see definition of IC_Klass in
Register inlineCacheKlass = rax;
// c1_LIRAssembler_x86.cpp
Register receiver = asRegister(cc.getArgument(0));
AMD64Address src = new AMD64Address(receiver, config.hubOffset);
if (config.useCompressedClassPointers) {
Register register = r10;
AMD64HotSpotMove.decodeKlassPointer(crb, asm, register, providers.getRegisters().getHeapBaseRegister(), src, config);
if (GeneratePIC.getValue(crb.getOptions())) {
asm.movq(providers.getRegisters().getHeapBaseRegister(), asm.getPlaceholder(-1));
crb.recordMark(config.MARKID_NARROW_OOP_BASE_ADDRESS);
} else {
if (config.narrowKlassBase != 0) {
// The heap base register was destroyed above, so restore it
asm.movq(providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase);
}
}
asm.cmpq(inlineCacheKlass, register);
} else {
asm.cmpq(inlineCacheKlass, src);
}
AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual);
}
asm.align(config.codeEntryAlignment);
crb.recordMark(config.MARKID_OSR_ENTRY);
asm.bind(verifiedEntry);
crb.recordMark(config.MARKID_VERIFIED_ENTRY);
if (GeneratePIC.getValue(crb.getOptions())) {
// Check for method state
HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
if (!frameContext.isStub) {
crb.recordInlineDataInCodeWithNote(new HotSpotSentinelConstant(LIRKind.value(AMD64Kind.QWORD), JavaKind.Long), HotSpotConstantLoadAction.MAKE_NOT_ENTRANT);
asm.movq(AMD64.rax, asm.getPlaceholder(-1));
asm.testq(AMD64.rax, AMD64.rax);
AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(WRONG_METHOD_HANDLER), ConditionFlag.NotZero);
}
}
}
use of org.graalvm.compiler.asm.amd64.AMD64Address in project graal by oracle.
the class AMD64HotSpotCounterOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb) {
AMD64MacroAssembler masm = (AMD64MacroAssembler) crb.asm;
TargetDescription target = crb.target;
Register scratch;
// want to spill it to the stack.
if (!contains(increments, rax)) {
scratch = rax;
} else if (!contains(increments, rbx)) {
scratch = rbx;
} else {
// emitIncrement().
throw GraalError.unimplemented("RAX and RBX are increment registers at the same time, spilling over the scratch register is not supported right now");
}
// address for counters array
AMD64Address countersArrayAddr = new AMD64Address(thread, config.jvmciCountersThreadOffset);
Register countersArrayReg = scratch;
// backup scratch register
masm.movq((AMD64Address) crb.asAddress(backupSlot), scratch);
// load counters array
masm.movptr(countersArrayReg, countersArrayAddr);
CounterProcedure emitProcedure = (counterIndex, increment, displacement) -> emitIncrement(masm, countersArrayReg, increment, displacement);
forEachCounter(emitProcedure, target);
// restore scratch register
masm.movq(scratch, (AMD64Address) crb.asAddress(backupSlot));
}
use of org.graalvm.compiler.asm.amd64.AMD64Address in project graal by oracle.
the class AMD64HotSpotJumpToExceptionHandlerInCallerOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
leaveFrameAndRestoreRbp(crb, masm);
// Discard the return address, thus completing restoration of caller frame
masm.incrementq(rsp, 8);
if (System.getProperty("java.specification.version").compareTo("1.8") < 0) {
// Restore rsp from rbp if the exception PC is a method handle call site.
AMD64Address dst = new AMD64Address(thread, isMethodHandleReturnOffset);
masm.cmpl(dst, 0);
masm.cmovq(ConditionFlag.NotEqual, rsp, rbp);
}
masm.jmp(asRegister(handlerInCallerPc));
}
use of org.graalvm.compiler.asm.amd64.AMD64Address 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.asm.amd64.AMD64Address in project graal by oracle.
the class AMD64HotSpotLoadConfigValueOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
if (GeneratePIC.getValue(crb.getOptions())) {
AMD64Kind kind = (AMD64Kind) result.getPlatformKind();
Register reg = asRegister(result);
AMD64Address placeholder = masm.getPlaceholder(-1);
switch(kind) {
case BYTE:
masm.movsbl(reg, placeholder);
break;
case WORD:
masm.movswl(reg, placeholder);
break;
case DWORD:
masm.movl(reg, placeholder);
break;
case QWORD:
masm.movq(reg, placeholder);
break;
default:
throw GraalError.unimplemented();
}
} else {
throw GraalError.unimplemented();
}
crb.recordMark(markId);
}
Aggregations