File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
core/src/main/java/org/jruby/truffle/nodes/control Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ public class DoWhileNode extends RubyNode {
3232 @ Child protected BooleanCastNode condition ;
3333 @ Child protected RubyNode body ;
3434
35+ @ CompilerDirectives .CompilationFinal private int thenCount ;
36+ @ CompilerDirectives .CompilationFinal private int elseCount ;
37+
38+ private final BranchProfile thenProfile = new BranchProfile ();
39+ private final BranchProfile elseProfile = new BranchProfile ();
40+
3541 private final BranchProfile breakProfile = new BranchProfile ();
3642 private final BranchProfile nextProfile = new BranchProfile ();
3743 private final BranchProfile redoProfile = new BranchProfile ();
@@ -66,10 +72,17 @@ public Object execute(VirtualFrame frame) {
6672 redoProfile .enter ();
6773 }
6874 }
69-
70- if (condition .executeBoolean (frame )) {
75+ if (CompilerDirectives .injectBranchProbability ((double ) thenCount / (double ) (thenCount + elseCount ), condition .executeBoolean (frame ))) {
76+ if (CompilerDirectives .inInterpreter ()) {
77+ thenCount ++;
78+ }
79+ thenProfile .enter ();
7180 continue outer ;
7281 } else {
82+ if (CompilerDirectives .inInterpreter ()) {
83+ elseCount ++;
84+ }
85+ elseProfile .enter ();
7386 break outer ;
7487 }
7588 }
You can’t perform that action at this time.
0 commit comments