src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File open Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java

Print this page




 104         // don't put the counter increase directly after the start (problems with OSR)
 105         FixedWithNextNode current = graph.start();
 106         while (current.next() instanceof FixedWithNextNode) {
 107             current = (FixedWithNextNode) current.next();
 108         }
 109         addSectionCounters(current, Arrays.asList(cfg.getBlocks()), cfg.getLoops(), graph.getLastSchedule(), cfg);
 110 
 111         if (WITH_INVOKES) {
 112             for (Node node : graph.getNodes()) {
 113                 if (node instanceof Invoke) {
 114                     Invoke invoke = (Invoke) node;
 115                     DynamicCounterNode.addCounterBefore(GROUP_NAME_INVOKES, invoke.callTarget().targetName(), 1, true, invoke.asNode());
 116 
 117                 }
 118             }
 119         }
 120     }
 121 
 122     private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
 123         HashSet<Block> blocks = new HashSet<>(sectionBlocks);
 124         for (Loop<?> loop : childLoops) {
 125             blocks.removeAll(loop.getBlocks());
 126         }
 127         double weight = getSectionWeight(schedule, blocks) / cfg.blockFor(start).probability();
 128         DynamicCounterNode.addCounterBefore(GROUP_NAME, sectionHead(start), (long) weight, true, start.next());
 129         if (WITH_INVOKE_FREE_SECTIONS && !hasInvoke(blocks)) {
 130             DynamicCounterNode.addCounterBefore(GROUP_NAME_WITHOUT, sectionHead(start), (long) weight, true, start.next());
 131         }
 132     }
 133 
 134     private static String sectionHead(Node node) {
 135         if (WITH_SECTION_HEADER) {
 136             return node.toString();
 137         } else {
 138             return "";
 139         }
 140     }
 141 
 142     private static double getSectionWeight(ScheduleResult schedule, Collection<Block> blocks) {
 143         double count = 0;
 144         for (Block block : blocks) {




 104         // don't put the counter increase directly after the start (problems with OSR)
 105         FixedWithNextNode current = graph.start();
 106         while (current.next() instanceof FixedWithNextNode) {
 107             current = (FixedWithNextNode) current.next();
 108         }
 109         addSectionCounters(current, Arrays.asList(cfg.getBlocks()), cfg.getLoops(), graph.getLastSchedule(), cfg);
 110 
 111         if (WITH_INVOKES) {
 112             for (Node node : graph.getNodes()) {
 113                 if (node instanceof Invoke) {
 114                     Invoke invoke = (Invoke) node;
 115                     DynamicCounterNode.addCounterBefore(GROUP_NAME_INVOKES, invoke.callTarget().targetName(), 1, true, invoke.asNode());
 116 
 117                 }
 118             }
 119         }
 120     }
 121 
 122     private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
 123         HashSet<Block> blocks = new HashSet<>(sectionBlocks);
 124         for (Loop<Block> loop : childLoops) {
 125             blocks.removeAll(loop.getBlocks());
 126         }
 127         double weight = getSectionWeight(schedule, blocks) / cfg.blockFor(start).probability();
 128         DynamicCounterNode.addCounterBefore(GROUP_NAME, sectionHead(start), (long) weight, true, start.next());
 129         if (WITH_INVOKE_FREE_SECTIONS && !hasInvoke(blocks)) {
 130             DynamicCounterNode.addCounterBefore(GROUP_NAME_WITHOUT, sectionHead(start), (long) weight, true, start.next());
 131         }
 132     }
 133 
 134     private static String sectionHead(Node node) {
 135         if (WITH_SECTION_HEADER) {
 136             return node.toString();
 137         } else {
 138             return "";
 139         }
 140     }
 141 
 142     private static double getSectionWeight(ScheduleResult schedule, Collection<Block> blocks) {
 143         double count = 0;
 144         for (Block block : blocks) {


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File