Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RepeatingNode;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.LoopConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.cast.BooleanCastNode;
@@ -53,6 +54,7 @@ private static abstract class WhileRepeatingBaseNode extends Node implements Rep
@Child protected BooleanCastNode condition;
@Child protected RubyNode body;

protected final LoopConditionProfile conditionProfile = LoopConditionProfile.createCountingProfile();
protected final BranchProfile redoUsed = BranchProfile.create();
protected final BranchProfile nextUsed = BranchProfile.create();

@@ -77,7 +79,7 @@ public WhileRepeatingNode(RubyContext context, RubyNode condition, RubyNode body

@Override
public boolean executeRepeating(VirtualFrame frame) {
if (!condition.executeBoolean(frame)) {
if (!conditionProfile.profile(condition.executeBoolean(frame))) {
return false;
}

@@ -117,7 +119,7 @@ public boolean executeRepeating(VirtualFrame frame) {
return true;
}

return condition.executeBoolean(frame);
return conditionProfile.profile(condition.executeBoolean(frame));
}

}

0 comments on commit 74165c3

Please sign in to comment.