use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class SPARCHotSpotBackend method registerSizePredictionValidator.
/**
* Registers a verifier which checks if the LIRInstructions estimate of constants size is
* greater or equal to the actual one.
*/
private static boolean registerSizePredictionValidator(final CompilationResultBuilder crb, DebugContext debug) {
/**
* Used to hold state between beforeOp and afterOp
*/
class ValidationState {
LIRInstruction op;
final DebugContext debug;
int constantSizeBefore;
ValidationState(DebugContext debug) {
this.debug = debug;
}
public void before(LIRInstruction before) {
assert op == null : "LIRInstruction " + op + " no after call received";
op = before;
constantSizeBefore = calculateDataSectionSize(crb.compilationResult.getDataSection());
}
public void after(LIRInstruction after) {
assert after.equals(op) : "Instructions before/after don't match " + op + "/" + after;
int constantSizeAfter = calculateDataSectionSize(crb.compilationResult.getDataSection());
int actual = constantSizeAfter - constantSizeBefore;
if (op instanceof SPARCLIRInstructionMixin) {
org.graalvm.compiler.lir.sparc.SPARCLIRInstructionMixin.SizeEstimate size = ((SPARCLIRInstructionMixin) op).estimateSize();
assert size != null : "No size prediction available for op: " + op;
Class<?> c = op.getClass();
CONSTANT_ESTIMATED_STATS.add(c, size.constantSize, debug);
CONSTANT_ACTUAL_STATS.add(c, actual, debug);
assert size.constantSize >= actual : "Op " + op + " exceeded estimated constant size; predicted: " + size.constantSize + " actual: " + actual;
} else {
assert actual == 0 : "Op " + op + " emitted to DataSection without any estimate.";
}
op = null;
constantSizeBefore = 0;
}
}
final ValidationState state = new ValidationState(debug);
crb.setOpCallback(op -> state.before(op), op -> state.after(op));
return true;
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class AMD64HotSpotLIRGenerator method beforeRegisterAllocation.
@Override
public void beforeRegisterAllocation() {
super.beforeRegisterAllocation();
boolean hasDebugInfo = getResult().getLIR().hasDebugInfo();
AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo);
if (hasDebugInfo) {
getResult().setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot());
}
getResult().setMaxInterpreterFrameSize(debugInfoBuilder.maxInterpreterFrameSize());
for (AMD64HotSpotRestoreRbpOp op : epilogueOps) {
op.setSavedRbp(savedRbp);
}
if (BenchmarkCounters.enabled) {
// ensure that the rescue slot is available
LIRInstruction op = getOrInitRescueSlotOp();
// insert dummy instruction into the start block
LIR lir = getResult().getLIR();
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(lir.getControlFlowGraph().getStartBlock());
instructions.add(1, op);
lir.getDebug().dump(DebugContext.INFO_LEVEL, lir, "created rescue dummy op");
}
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class Instance method run.
public void run(LIRGenerationResult lirGenRes) {
LIR ir = lirGenRes.getLIR();
DebugContext debug = ir.getDebug();
FrameMap frameMap = lirGenRes.getFrameMap();
for (AbstractBlockBase<?> block : ir.linearScanOrder()) {
for (LIRInstruction op : ir.getLIRforBlock(block)) {
op.forEachState((instruction, state) -> doState(debug, frameMap, instruction, state));
}
}
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class MatchRuleTest method test1.
/**
* Verifies, if the match rules in AMD64NodeMatchRules do work on the graphs by compiling and
* checking if the expected LIR instruction show up.
*/
@Test
public void test1() {
compile(getResolvedJavaMethod("test1Snippet"), null);
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
if (ins instanceof MemoryConstOp && ((MemoryConstOp) ins).getOpcode().toString().equals("CMP")) {
assertFalse("MemoryConstOp expected only once in first block", found);
found = true;
}
}
assertTrue("Memory compare must be in the LIR", found);
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class LinearScanAssignLocationsPhase method debugInfoProcedure.
private Value debugInfoProcedure(LIRInstruction op, Value operand) {
if (isVirtualStackSlot(operand)) {
return operand;
}
int tempOpId = op.id();
OperandMode mode = OperandMode.USE;
AbstractBlockBase<?> block = allocator.blockForId(tempOpId);
if (block.getSuccessorCount() == 1 && tempOpId == allocator.getLastLirInstructionId(block)) {
/*
* Generating debug information for the last instruction of a block. If this instruction
* is a branch, spill moves are inserted before this branch and so the wrong operand
* would be returned (spill moves at block boundaries are not considered in the live
* ranges of intervals).
*
* Solution: use the first opId of the branch target block instead.
*/
final LIRInstruction instr = allocator.getLIR().getLIRforBlock(block).get(allocator.getLIR().getLIRforBlock(block).size() - 1);
if (instr instanceof StandardOp.JumpOp) {
if (allocator.getBlockData(block).liveOut.get(allocator.operandNumber(operand))) {
tempOpId = allocator.getFirstLirInstructionId(block.getSuccessors()[0]);
mode = OperandMode.DEF;
}
}
}
/*
* Get current location of operand. The operand must be live because debug information is
* considered when building the intervals if the interval is not live, colorLirOperand will
* cause an assert on failure.
*/
Value result = colorLirOperand(op, (Variable) operand, mode);
assert !allocator.hasCall(tempOpId) || isStackSlotValue(result) || isJavaConstant(result) || !allocator.isCallerSave(result) : "cannot have caller-save register operands at calls";
return result;
}
Aggregations