src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/LocalLiveness.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/LocalLiveness.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/LocalLiveness.java
Print this page
*** 74,161 ****
import static org.graalvm.compiler.bytecode.Bytecodes.LSTORE_2;
import static org.graalvm.compiler.bytecode.Bytecodes.LSTORE_3;
import static org.graalvm.compiler.bytecode.Bytecodes.RET;
import org.graalvm.compiler.bytecode.BytecodeStream;
! import org.graalvm.compiler.debug.Debug;
import org.graalvm.compiler.java.BciBlockMapping.BciBlock;
/**
* Encapsulates the liveness calculation, so that subclasses for locals ≤ 64 and locals > 64
* can be implemented.
*/
public abstract class LocalLiveness {
protected final BciBlock[] blocks;
! public static LocalLiveness compute(BytecodeStream stream, BciBlock[] blocks, int maxLocals, int loopCount) {
LocalLiveness liveness = maxLocals <= 64 ? new SmallLocalLiveness(blocks, maxLocals, loopCount) : new LargeLocalLiveness(blocks, maxLocals, loopCount);
! liveness.computeLiveness(stream);
return liveness;
}
protected LocalLiveness(BciBlock[] blocks) {
this.blocks = blocks;
}
! void computeLiveness(BytecodeStream stream) {
for (BciBlock block : blocks) {
computeLocalLiveness(stream, block);
}
boolean changed;
int iteration = 0;
do {
! assert traceIteration(iteration);
changed = false;
for (int i = blocks.length - 1; i >= 0; i--) {
BciBlock block = blocks[i];
int blockID = block.getId();
! assert traceStart(block, blockID);
boolean blockChanged = (iteration == 0);
if (block.getSuccessorCount() > 0) {
int oldCardinality = liveOutCardinality(blockID);
for (BciBlock sux : block.getSuccessors()) {
! assert traceSuccessor(sux);
propagateLiveness(blockID, sux.getId());
}
blockChanged |= (oldCardinality != liveOutCardinality(blockID));
}
if (blockChanged) {
updateLiveness(blockID);
! assert traceEnd(block, blockID);
}
changed |= blockChanged;
}
iteration++;
} while (changed);
}
! private static boolean traceIteration(int iteration) {
! Debug.log("Iteration %d", iteration);
return true;
}
! private boolean traceEnd(BciBlock block, int blockID) {
! if (Debug.isLogEnabled()) {
! Debug.logv(" end B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.getId(), block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID), debugLiveGen(blockID),
debugLiveKill(blockID));
}
return true;
}
! private boolean traceSuccessor(BciBlock sux) {
! if (Debug.isLogEnabled()) {
! Debug.log(" Successor B%d: %s", sux.getId(), debugLiveIn(sux.getId()));
}
return true;
}
! private boolean traceStart(BciBlock block, int blockID) {
! if (Debug.isLogEnabled()) {
! Debug.logv(" start B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.getId(), block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID), debugLiveGen(blockID),
debugLiveKill(blockID));
}
return true;
}
--- 74,161 ----
import static org.graalvm.compiler.bytecode.Bytecodes.LSTORE_2;
import static org.graalvm.compiler.bytecode.Bytecodes.LSTORE_3;
import static org.graalvm.compiler.bytecode.Bytecodes.RET;
import org.graalvm.compiler.bytecode.BytecodeStream;
! import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.java.BciBlockMapping.BciBlock;
/**
* Encapsulates the liveness calculation, so that subclasses for locals ≤ 64 and locals > 64
* can be implemented.
*/
public abstract class LocalLiveness {
protected final BciBlock[] blocks;
! public static LocalLiveness compute(DebugContext debug, BytecodeStream stream, BciBlock[] blocks, int maxLocals, int loopCount) {
LocalLiveness liveness = maxLocals <= 64 ? new SmallLocalLiveness(blocks, maxLocals, loopCount) : new LargeLocalLiveness(blocks, maxLocals, loopCount);
! liveness.computeLiveness(debug, stream);
return liveness;
}
protected LocalLiveness(BciBlock[] blocks) {
this.blocks = blocks;
}
! void computeLiveness(DebugContext debug, BytecodeStream stream) {
for (BciBlock block : blocks) {
computeLocalLiveness(stream, block);
}
boolean changed;
int iteration = 0;
do {
! assert traceIteration(debug, iteration);
changed = false;
for (int i = blocks.length - 1; i >= 0; i--) {
BciBlock block = blocks[i];
int blockID = block.getId();
! assert traceStart(debug, block, blockID);
boolean blockChanged = (iteration == 0);
if (block.getSuccessorCount() > 0) {
int oldCardinality = liveOutCardinality(blockID);
for (BciBlock sux : block.getSuccessors()) {
! assert traceSuccessor(debug, sux);
propagateLiveness(blockID, sux.getId());
}
blockChanged |= (oldCardinality != liveOutCardinality(blockID));
}
if (blockChanged) {
updateLiveness(blockID);
! assert traceEnd(debug, block, blockID);
}
changed |= blockChanged;
}
iteration++;
} while (changed);
}
! private static boolean traceIteration(DebugContext debug, int iteration) {
! debug.log("Iteration %d", iteration);
return true;
}
! private boolean traceEnd(DebugContext debug, BciBlock block, int blockID) {
! if (debug.isLogEnabled()) {
! debug.logv(" end B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.getId(), block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID), debugLiveGen(blockID),
debugLiveKill(blockID));
}
return true;
}
! private boolean traceSuccessor(DebugContext debug, BciBlock sux) {
! if (debug.isLogEnabled()) {
! debug.log(" Successor B%d: %s", sux.getId(), debugLiveIn(sux.getId()));
}
return true;
}
! private boolean traceStart(DebugContext debug, BciBlock block, int blockID) {
! if (debug.isLogEnabled()) {
! debug.logv(" start B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.getId(), block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID), debugLiveGen(blockID),
debugLiveKill(blockID));
}
return true;
}
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/LocalLiveness.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File