diff graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java @ 16829:e3724f25056a

SL: use the new IntegerConditionProfile in simple language.
author Christian Humer <christian.humer@gmail.com>
date Thu, 14 Aug 2014 13:11:47 +0200
parents abe7128ca473
children 226552569e34
line wrap: on
line diff
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Wed Aug 13 20:44:36 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Thu Aug 14 13:11:47 2014 +0200
@@ -46,12 +46,13 @@
     @Child private SLStatementNode elsePartNode;
 
     /**
-     * Profiling information, collected by the interpreter, capturing whether the then-branch was
-     * used (analogously for the {@link #elseTaken else-branch}). This allows the compiler to
-     * generate better code for conditions that are always true or always false.
+     * Profiling information, collected by the interpreter, capturing the profiling information of
+     * the condition. This allows the compiler to generate better code for conditions that are
+     * always true or always false. Additionally the {@link IntegerConditionProfile} implementation
+     * (as opposed to {@link BooleanConditionProfile} implementation) transmits the probability of
+     * the condition to be true to the compiler.
      */
-    private final BranchProfile thenTaken = new BranchProfile();
-    private final BranchProfile elseTaken = new BranchProfile();
+    private final ConditionProfile condition = new IntegerConditionProfile();
 
     public SLIfNode(SourceSection src, SLExpressionNode conditionNode, SLStatementNode thenPartNode, SLStatementNode elsePartNode) {
         super(src);
@@ -62,14 +63,14 @@
 
     @Override
     public void executeVoid(VirtualFrame frame) {
-        if (evaluateCondition(frame)) {
-            /* In the interpreter, record profiling information that the then-branch was used. */
-            thenTaken.enter();
+        /*
+         * In the interpreter, record profiling information that the condition was executed and with
+         * which outcome.
+         */
+        if (condition.profile(evaluateCondition(frame))) {
             /* Execute the then-branch. */
             thenPartNode.executeVoid(frame);
         } else {
-            /* In the interpreter, record profiling information that the else-branch was used. */
-            elseTaken.enter();
             /* Execute the else-branch (which is optional according to the SL syntax). */
             if (elsePartNode != null) {
                 elsePartNode.executeVoid(frame);