# HG changeset patch # User Christian Humer # Date 1408014707 -7200 # Node ID e3724f25056a652d49d2d35e318f6a9a4c19403a # Parent 2834af86f398d6383c726bdaf14a0bbd4c51d29c SL: use the new IntegerConditionProfile in simple language. diff -r 2834af86f398 -r e3724f25056a graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java --- 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);