< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/extended/BranchProbabilityNode.java

Print this page
rev 56282 : [mq]: graal
   1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  56 /**
  57  * Instances of this node class will look for a preceding if node and put the given probability into
  58  * the if node's taken probability. Then the branch probability node will be removed. This node is
  59  * intended primarily for snippets, so that they can define their fast and slow paths.
  60  */
  61 @NodeInfo(cycles = CYCLES_0, cyclesRationale = "Artificial Node", size = SIZE_0)
  62 public final class BranchProbabilityNode extends FloatingNode implements Simplifiable, Lowerable, Canonicalizable {
  63 
  64     public static final NodeClass<BranchProbabilityNode> TYPE = NodeClass.create(BranchProbabilityNode.class);
  65     public static final double LIKELY_PROBABILITY = 0.6;
  66     public static final double NOT_LIKELY_PROBABILITY = 1 - LIKELY_PROBABILITY;
  67 
  68     public static final double FREQUENT_PROBABILITY = 0.9;
  69     public static final double NOT_FREQUENT_PROBABILITY = 1 - FREQUENT_PROBABILITY;
  70 
  71     public static final double FAST_PATH_PROBABILITY = 0.99;
  72     public static final double SLOW_PATH_PROBABILITY = 1 - FAST_PATH_PROBABILITY;
  73 
  74     public static final double VERY_FAST_PATH_PROBABILITY = 0.999;
  75     public static final double VERY_SLOW_PATH_PROBABILITY = 1 - VERY_FAST_PATH_PROBABILITY;


  76 
  77     /*
  78      * This probability may seem excessive, but it makes a difference in long running loops. Lets
  79      * say a loop is executed 100k times and it has a few null checks with probability 0.999. As
  80      * these probabilities multiply for every loop iteration, the overall loop frequency will be
  81      * calculated as approximately 30 while it should be 100k.
  82      */
  83     public static final double LUDICROUSLY_FAST_PATH_PROBABILITY = 0.999999;
  84     public static final double LUDICROUSLY_SLOW_PATH_PROBABILITY = 1 - LUDICROUSLY_FAST_PATH_PROBABILITY;
  85 
  86     @Input ValueNode probability;
  87     @Input ValueNode condition;
  88 
  89     public BranchProbabilityNode(ValueNode probability, ValueNode condition) {
  90         super(TYPE, StampFactory.forKind(JavaKind.Boolean));
  91         this.probability = probability;
  92         this.condition = condition;
  93     }
  94 
  95     public ValueNode getProbability() {


   1 /*
   2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  56 /**
  57  * Instances of this node class will look for a preceding if node and put the given probability into
  58  * the if node's taken probability. Then the branch probability node will be removed. This node is
  59  * intended primarily for snippets, so that they can define their fast and slow paths.
  60  */
  61 @NodeInfo(cycles = CYCLES_0, cyclesRationale = "Artificial Node", size = SIZE_0)
  62 public final class BranchProbabilityNode extends FloatingNode implements Simplifiable, Lowerable, Canonicalizable {
  63 
  64     public static final NodeClass<BranchProbabilityNode> TYPE = NodeClass.create(BranchProbabilityNode.class);
  65     public static final double LIKELY_PROBABILITY = 0.6;
  66     public static final double NOT_LIKELY_PROBABILITY = 1 - LIKELY_PROBABILITY;
  67 
  68     public static final double FREQUENT_PROBABILITY = 0.9;
  69     public static final double NOT_FREQUENT_PROBABILITY = 1 - FREQUENT_PROBABILITY;
  70 
  71     public static final double FAST_PATH_PROBABILITY = 0.99;
  72     public static final double SLOW_PATH_PROBABILITY = 1 - FAST_PATH_PROBABILITY;
  73 
  74     public static final double VERY_FAST_PATH_PROBABILITY = 0.999;
  75     public static final double VERY_SLOW_PATH_PROBABILITY = 1 - VERY_FAST_PATH_PROBABILITY;
  76 
  77     public static final double DEOPT_PROBABILITY = 0.0;
  78 
  79     /*
  80      * This probability may seem excessive, but it makes a difference in long running loops. Lets
  81      * say a loop is executed 100k times and it has a few null checks with probability 0.999. As
  82      * these probabilities multiply for every loop iteration, the overall loop frequency will be
  83      * calculated as approximately 30 while it should be 100k.
  84      */
  85     public static final double LUDICROUSLY_FAST_PATH_PROBABILITY = 0.999999;
  86     public static final double LUDICROUSLY_SLOW_PATH_PROBABILITY = 1 - LUDICROUSLY_FAST_PATH_PROBABILITY;
  87 
  88     @Input ValueNode probability;
  89     @Input ValueNode condition;
  90 
  91     public BranchProbabilityNode(ValueNode probability, ValueNode condition) {
  92         super(TYPE, StampFactory.forKind(JavaKind.Boolean));
  93         this.probability = probability;
  94         this.condition = condition;
  95     }
  96 
  97     public ValueNode getProbability() {


< prev index next >