use of org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult in project graal by oracle.
the class HotSpotZapRegistersPhase method run.
@Override
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PostAllocationOptimizationContext context) {
Stub stub = ((HotSpotLIRGenerationResult) lirGenRes).getStub();
boolean zapRegisters = stub != null && !stub.preservesRegisters();
boolean zapStack = false;
for (AllocatableValue arg : lirGenRes.getCallingConvention().getArguments()) {
if (isStackSlot(arg)) {
zapStack = true;
break;
}
}
if (zapRegisters || zapStack) {
LIR lir = lirGenRes.getLIR();
processLIR(context.diagnosticLirGenTool, (HotSpotLIRGenerationResult) lirGenRes, lir, zapRegisters, zapStack);
}
}
use of org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult in project graal by oracle.
the class SPARCHotSpotBackend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRes;
LIR lir = gen.getLIR();
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
Stub stub = gen.getStub();
Assembler masm = createAssembler(frameMap);
// On SPARC we always use stack frames.
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
OptionValues options = lir.getOptions();
DebugContext debug = lir.getDebug();
CompilationResultBuilder crb = factory.createBuilder(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, dataBuilder, frameContext, options, debug, compilationResult);
crb.setTotalFrameSize(frameMap.totalFrameSize());
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
if (deoptimizationRescueSlot != null && stub == null) {
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
}
if (stub != null) {
// Even on sparc we need to save floating point registers
EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo = gen.getCalleeSaveInfo();
updateStub(stub, destroyedCallerRegisters, calleeSaveInfo, frameMap);
}
assert registerSizePredictionValidator(crb, debug);
return crb;
}
use of org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult in project graal by oracle.
the class AMD64HotSpotLIRGenerator method emitForeignCall.
@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
boolean destroysRegisters = hotspotLinkage.destroysRegisters();
AMD64SaveRegistersOp save = null;
Stub stub = getStub();
if (destroysRegisters) {
if (stub != null && stub.preservesRegisters()) {
Register[] savedRegisters = getRegisterConfig().getAllocatableRegisters().toArray();
save = emitSaveAllRegisters(savedRegisters, true);
}
}
Variable result;
LIRFrameState debugInfo = null;
if (hotspotLinkage.needsDebugInfo()) {
debugInfo = state;
assert debugInfo != null || stub != null;
}
if (hotspotLinkage.needsJavaFrameAnchor()) {
Register thread = getProviders().getRegisters().getThreadRegister();
append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), config.threadLastJavaPcOffset(), thread));
} else {
result = super.emitForeignCall(hotspotLinkage, debugInfo, args);
}
if (destroysRegisters) {
if (stub != null) {
if (stub.preservesRegisters()) {
HotSpotLIRGenerationResult generationResult = getResult();
LIRFrameState key = currentRuntimeCallInfo;
if (key == null) {
key = LIRFrameState.NO_STATE;
}
assert !generationResult.getCalleeSaveInfo().containsKey(key);
generationResult.getCalleeSaveInfo().put(key, save);
emitRestoreRegisters(save);
}
}
}
return result;
}
use of org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult in project graal by oracle.
the class AMD64HotSpotBackend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRen, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
// Omit the frame if the method:
// - has no spill slots or other slots allocated during register allocation
// - has no callee-saved registers
// - has no incoming arguments passed on the stack
// - has no deoptimization points
// - makes no foreign calls (which require an aligned stack)
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRen;
LIR lir = gen.getLIR();
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
OptionValues options = lir.getOptions();
DebugContext debug = lir.getDebug();
boolean omitFrame = CanOmitFrame.getValue(options) && !frameMap.frameNeedsAllocating() && !lir.hasArgInCallerFrame() && !gen.hasForeignCall();
Stub stub = gen.getStub();
Assembler masm = createAssembler(frameMap);
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame);
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, dataBuilder, frameContext, options, debug, compilationResult);
crb.setTotalFrameSize(frameMap.totalFrameSize());
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
if (deoptimizationRescueSlot != null && stub == null) {
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
}
if (stub != null) {
EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
updateStub(stub, destroyedCallerRegisters, gen.getCalleeSaveInfo(), frameMap);
}
return crb;
}
use of org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult in project graal by oracle.
the class AArch64HotSpotBackend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRen, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRen;
LIR lir = gen.getLIR();
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
Stub stub = gen.getStub();
Assembler masm = createAssembler(frameMap);
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, dataBuilder, frameContext, lir.getOptions(), lir.getDebug(), compilationResult);
crb.setTotalFrameSize(frameMap.totalFrameSize());
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
if (deoptimizationRescueSlot != null && stub == null) {
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
}
if (stub != null) {
EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
updateStub(stub, destroyedCallerRegisters, gen.getCalleeSaveInfo(), frameMap);
}
return crb;
}
Aggregations