< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java
Print this page
rev 52509 : [mq]: graal2
*** 96,106 ****
SchedulePhase schedule = new SchedulePhase(graph.getOptions());
schedule.apply(graph, false);
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
for (Loop<Block> loop : cfg.getLoops()) {
! double loopProbability = cfg.blockFor(loop.getHeader().getBeginNode()).probability();
if (loopProbability > (1D / Integer.MAX_VALUE)) {
addSectionCounters(loop.getHeader().getBeginNode(), loop.getBlocks(), loop.getChildren(), graph.getLastSchedule(), cfg);
}
}
// don't put the counter increase directly after the start (problems with OSR)
--- 96,106 ----
SchedulePhase schedule = new SchedulePhase(graph.getOptions());
schedule.apply(graph, false);
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
for (Loop<Block> loop : cfg.getLoops()) {
! double loopProbability = cfg.blockFor(loop.getHeader().getBeginNode()).getRelativeFrequency();
if (loopProbability > (1D / Integer.MAX_VALUE)) {
addSectionCounters(loop.getHeader().getBeginNode(), loop.getBlocks(), loop.getChildren(), graph.getLastSchedule(), cfg);
}
}
// don't put the counter increase directly after the start (problems with OSR)
*** 124,137 ****
private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
HashSet<Block> blocks = new HashSet<>(sectionBlocks);
for (Loop<Block> loop : childLoops) {
blocks.removeAll(loop.getBlocks());
}
! double weight = getSectionWeight(schedule, blocks) / cfg.blockFor(start).probability();
! DynamicCounterNode.addCounterBefore(GROUP_NAME, sectionHead(start), (long) weight, true, start.next());
if (WITH_INVOKE_FREE_SECTIONS && !hasInvoke(blocks)) {
! DynamicCounterNode.addCounterBefore(GROUP_NAME_WITHOUT, sectionHead(start), (long) weight, true, start.next());
}
}
private static String sectionHead(Node node) {
if (WITH_SECTION_HEADER) {
--- 124,137 ----
private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
HashSet<Block> blocks = new HashSet<>(sectionBlocks);
for (Loop<Block> loop : childLoops) {
blocks.removeAll(loop.getBlocks());
}
! long increment = DynamicCounterNode.clampIncrement((long) (getSectionWeight(schedule, blocks) / cfg.blockFor(start).getRelativeFrequency()));
! DynamicCounterNode.addCounterBefore(GROUP_NAME, sectionHead(start), increment, true, start.next());
if (WITH_INVOKE_FREE_SECTIONS && !hasInvoke(blocks)) {
! DynamicCounterNode.addCounterBefore(GROUP_NAME_WITHOUT, sectionHead(start), increment, true, start.next());
}
}
private static String sectionHead(Node node) {
if (WITH_SECTION_HEADER) {
*** 142,152 ****
}
private static double getSectionWeight(ScheduleResult schedule, Collection<Block> blocks) {
double count = 0;
for (Block block : blocks) {
! double blockProbability = block.probability();
for (Node node : schedule.getBlockToNodesMap().get(block)) {
count += blockProbability * getNodeWeight(node);
}
}
return count;
--- 142,152 ----
}
private static double getSectionWeight(ScheduleResult schedule, Collection<Block> blocks) {
double count = 0;
for (Block block : blocks) {
! double blockProbability = block.getRelativeFrequency();
for (Node node : schedule.getBlockToNodesMap().get(block)) {
count += blockProbability * getNodeWeight(node);
}
}
return count;
< prev index next >