src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/MoveResolver.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/MoveResolver.java Fri Jul 7 09:30:43 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/MoveResolver.java Fri Jul 7 09:30:43 2017
*** 27,56 ****
--- 27,55 ----
import static jdk.vm.ci.code.ValueUtil.isRegister;
import java.util.ArrayList;
import org.graalvm.compiler.core.common.LIRKind;
! import org.graalvm.compiler.debug.Debug;
! import org.graalvm.compiler.debug.DebugCounter;
! import org.graalvm.compiler.debug.CounterKey;
! import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.debug.Indent;
import org.graalvm.compiler.lir.LIRInsertionBuffer;
import org.graalvm.compiler.lir.LIRInstruction;
import org.graalvm.compiler.lir.LIRValueUtil;
import org.graalvm.compiler.lir.gen.LIRGenerationResult;
import org.graalvm.util.Equivalence;
import org.graalvm.util.EconomicSet;
import jdk.vm.ci.meta.AllocatableValue;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.Value;
/**
*/
public class MoveResolver {
! private static final DebugCounter cycleBreakingSlotsAllocated = Debug.counter("LSRA[cycleBreakingSlotsAllocated]");
! private static final CounterKey cycleBreakingSlotsAllocated = DebugContext.counter("LSRA[cycleBreakingSlotsAllocated]");
private final LinearScan allocator;
private int insertIdx;
private LIRInsertionBuffer insertionBuffer; // buffer where moves are inserted
*** 205,225 ****
--- 204,224 ----
Value location = interval.location();
if (mightBeBlocked(location)) {
assert areMultipleReadsAllowed() || valueBlocked(location) == 0 : "location already marked as used: " + location;
int direction = 1;
setValueBlocked(location, direction);
! allocator.getDebug().log("block %s", location);
}
}
// mark assignedReg and assignedRegHi of the interval as unblocked
private void unblockRegisters(Interval interval) {
Value location = interval.location();
if (mightBeBlocked(location)) {
assert valueBlocked(location) > 0 : "location already marked as unused: " + location;
setValueBlocked(location, -1);
! allocator.getDebug().log("unblock %s", location);
}
}
/**
* Checks if the {@linkplain Interval#location() location} of {@code to} is not blocked or is
*** 274,285 ****
--- 273,285 ----
assert insertIdx != -1 : "must setup insert position first";
LIRInstruction move = createMove(fromInterval.operand, toInterval.operand, fromInterval.location(), toInterval.location());
insertionBuffer.append(insertIdx, move);
if (Debug.isLogEnabled()) {
Debug.log("insert move from %s to %s at %d", fromInterval, toInterval, insertIdx);
+ DebugContext debug = allocator.getDebug();
+ if (debug.isLogEnabled()) {
+ debug.log("insert move from %s to %s at %d", fromInterval, toInterval, insertIdx);
}
return move;
}
/**
*** 297,317 ****
--- 297,319 ----
AllocatableValue toOpr = toInterval.operand;
LIRInstruction move = getAllocator().getSpillMoveFactory().createLoad(toOpr, fromOpr);
insertionBuffer.append(insertIdx, move);
if (Debug.isLogEnabled()) {
Debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx);
+ DebugContext debug = allocator.getDebug();
+ if (debug.isLogEnabled()) {
+ debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx);
}
return move;
}
@SuppressWarnings("try")
private void resolveMappings() {
try (Indent indent = Debug.logAndIndent("resolveMapping")) {
+ DebugContext debug = allocator.getDebug();
+ try (Indent indent = debug.logAndIndent("resolveMapping")) {
assert verifyBeforeResolve();
! if (Debug.isLogEnabled()) {
! if (debug.isLogEnabled()) {
printMapping();
}
// Block all registers that are used as input operands of a move.
// When a register is blocked, no move to this register is emitted.
*** 387,397 ****
--- 389,399 ----
// one stack slot to another can happen (not allowed by LIRAssembler
AllocatableValue spillSlot = fromInterval.spillSlot();
if (spillSlot == null) {
spillSlot = getAllocator().getFrameMapBuilder().allocateSpillSlot(fromInterval.kind());
fromInterval.setSpillSlot(spillSlot);
! cycleBreakingSlotsAllocated.increment(allocator.getDebug());
}
spillInterval(spillCandidate, fromInterval, spillSlot);
}
protected void spillInterval(int spillCandidate, Interval fromInterval, AllocatableValue spillSlot) {
*** 404,415 ****
--- 406,418 ----
// checked
spillInterval.addRange(1, 2);
spillInterval.assignLocation(spillSlot);
if (Debug.isLogEnabled()) {
Debug.log("created new Interval for spilling: %s", spillInterval);
+ DebugContext debug = allocator.getDebug();
+ if (debug.isLogEnabled()) {
+ debug.log("created new Interval for spilling: %s", spillInterval);
}
blockRegisters(spillInterval);
// insert a move from register to stack and update the mapping
LIRInstruction move = insertMove(fromInterval, spillInterval);
*** 418,439 ****
--- 421,443 ----
move.setComment(res, "MoveResolver break cycle");
}
@SuppressWarnings("try")
private void printMapping() {
try (Indent indent = Debug.logAndIndent("Mapping")) {
+ DebugContext debug = allocator.getDebug();
+ try (Indent indent = debug.logAndIndent("Mapping")) {
for (int i = mappingFrom.size() - 1; i >= 0; i--) {
Interval fromInterval = mappingFrom.get(i);
Interval toInterval = mappingTo.get(i);
String from;
Value to = toInterval.location();
if (fromInterval == null) {
from = mappingFromOpr.get(i).toString();
} else {
from = fromInterval.location().toString();
}
! Debug.log("move %s <- %s", from, to);
! debug.log("move %s <- %s", from, to);
}
}
}
void setInsertPosition(ArrayList<LIRInstruction> insertList, int insertIdx) {
*** 458,482 ****
--- 462,486 ----
this.insertIdx = newInsertIdx;
}
public void addMapping(Interval fromInterval, Interval toInterval) {
+ DebugContext debug = allocator.getDebug();
if (isIllegal(toInterval.location()) && toInterval.canMaterialize()) {
! if (Debug.isLogEnabled()) {
! Debug.log("no store to rematerializable interval %s needed", toInterval);
! if (debug.isLogEnabled()) {
! debug.log("no store to rematerializable interval %s needed", toInterval);
}
return;
}
if (isIllegal(fromInterval.location()) && fromInterval.canMaterialize()) {
// Instead of a reload, re-materialize the value
Constant rematValue = fromInterval.getMaterializedValue();
addMapping(rematValue, toInterval);
return;
}
! if (Debug.isLogEnabled()) {
! Debug.log("add move mapping from %s to %s", fromInterval, toInterval);
! if (debug.isLogEnabled()) {
! debug.log("add move mapping from %s to %s", fromInterval, toInterval);
}
assert !fromInterval.operand.equals(toInterval.operand) : "from and to interval equal: " + fromInterval;
assert LIRKind.verifyMoveKinds(toInterval.kind(), fromInterval.kind(), allocator.getRegisterAllocationConfig()) : String.format("Kind mismatch: %s vs. %s, from=%s, to=%s", fromInterval.kind(),
toInterval.kind(), fromInterval, toInterval);
*** 484,495 ****
--- 488,500 ----
mappingFromOpr.add(null);
mappingTo.add(toInterval);
}
public void addMapping(Constant fromOpr, Interval toInterval) {
if (Debug.isLogEnabled()) {
Debug.log("add move mapping from %s to %s", fromOpr, toInterval);
+ DebugContext debug = allocator.getDebug();
+ if (debug.isLogEnabled()) {
+ debug.log("add move mapping from %s to %s", fromOpr, toInterval);
}
mappingFrom.add(null);
mappingFromOpr.add(fromOpr);
mappingTo.add(toInterval);
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/lsra/MoveResolver.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File