Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ef2caaa7be89
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 03d227b67395
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 17, 2015

  1. Copy the full SHA
    54cefe5 View commit details
  2. Copy the full SHA
    03d227b View commit details
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@
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;
@@ -33,8 +31,6 @@ 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);
}
@@ -52,7 +48,7 @@ public void executeVoid(VirtualFrame frame) {
final int given;
final DynamicObject keywordArguments;

if (optimizedKeywordArgsProfile.profile(RubyArguments.isKwOptimized(frame.getArguments()))) {
if (arity.acceptsKeywords() && RubyArguments.isKwOptimized(frame.getArguments())) {
given = RubyArguments.getUserArgumentsCount(frame.getArguments()) - arity.getKeywordsCount() - 2;
} else {
given = RubyArguments.getUserArgumentsCount(frame.getArguments());
Original file line number Diff line number Diff line change
@@ -81,24 +81,19 @@ public RubyCallNode(RubyContext context, SourceSection section, String methodNam
super(context, section);

this.methodName = methodName;

this.receiver = receiver;

this.arguments = arguments;
if (block == null) {
this.block = null;
} else {
this.block = ProcOrNullNodeGen.create(context, section, block);
}

this.arguments = arguments;
this.isSplatted = isSplatted;
this.isVCall = isVCall;
this.ignoreVisibility = ignoreVisibility;

this.dispatchHead = DispatchHeadNodeFactory.createMethodCall(context, ignoreVisibility);
this.respondToMissing = DispatchHeadNodeFactory.createMethodCall(context, true, MissingBehavior.RETURN_MISSING);
this.respondToMissingCast = BooleanCastNodeGen.create(context, section, null);

this.ignoreVisibility = ignoreVisibility;

/*
* TODO CS 19-Mar-15 we currently can't swap an @Children array out
@@ -364,8 +359,7 @@ public Object isDefined(VirtualFrame frame) {

final RubyContext context = getContext();

Object receiverObject;

final Object receiverObject;
try {
/*
* TODO(CS): Getting a node via an accessor like this doesn't work with Truffle at the
@@ -386,9 +380,8 @@ public Object isDefined(VirtualFrame frame) {
final Object self = RubyArguments.getSelf(frame.getArguments());

if (method == null) {
final Object r = respondToMissing.call(frame, receiverObject, "respond_to_missing?", null, Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), RubyString.encodeBytelist(methodName, UTF8Encoding.INSTANCE), StringSupport.CR_UNKNOWN, null), false);

if (r != DispatchNode.MISSING && !respondToMissingCast.executeBoolean(frame, r)) {
final Object r = respondToMissing(frame, receiverObject);
if (r != DispatchNode.MISSING && !castRespondToMissingToBoolean(frame, r)) {
return nil();
}
} else if (method.isUndefined()) {
@@ -400,6 +393,23 @@ public Object isDefined(VirtualFrame frame) {
return Layouts.STRING.createString(getContext().getCoreLibrary().getStringFactory(), RubyString.encodeBytelist("method", UTF8Encoding.INSTANCE), StringSupport.CR_7BIT, null);
}

private Object respondToMissing(VirtualFrame frame, Object receiverObject) {
if (respondToMissing == null) {
CompilerDirectives.transferToInterpreter();
respondToMissing = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true, MissingBehavior.RETURN_MISSING));
}
final DynamicObject method = getContext().getSymbol(methodName);
return respondToMissing.call(frame, receiverObject, "respond_to_missing?", null, method, false);
}

private boolean castRespondToMissingToBoolean(VirtualFrame frame, final Object r) {
if (respondToMissingCast == null) {
CompilerDirectives.transferToInterpreter();
respondToMissingCast = insert(BooleanCastNodeGen.create(getContext(), getSourceSection(), null));
}
return respondToMissingCast.executeBoolean(frame, r);
}

public String getName() {
return methodName;
}