Skip to content

Commit

Permalink
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
@@ -31,6 +33,8 @@ public class CheckArityNode extends RubyNode {
private final String[] keywords;
private final boolean keywordsRest;

private final ConditionProfile optimizedKeywordArgsProfile = ConditionProfile.createBinaryProfile();

public CheckArityNode(RubyContext context, SourceSection sourceSection, Arity arity) {
this(context, sourceSection, arity, new String[]{}, false);
}
@@ -48,10 +52,8 @@ public void executeVoid(VirtualFrame frame) {
final int given;
final DynamicObject keywordArguments;

//TODO (MS): Check merge
if (RubyArguments.isKwOptimized(frame.getArguments())) {
given = RubyArguments.getUserArgumentsCount(frame.getArguments())
- arity.getKeywordsCount() - 2;
if (optimizedKeywordArgsProfile.profile(RubyArguments.isKwOptimized(frame.getArguments()))) {
given = RubyArguments.getUserArgumentsCount(frame.getArguments()) - arity.getKeywordsCount() - 2;
} else {
given = RubyArguments.getUserArgumentsCount(frame.getArguments());
}

0 comments on commit ea0d8c1

Please sign in to comment.