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: ff319af2a0d6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: acf63de56000
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jun 30, 2015

  1. [Truffle] Use a RespondToNode instead of the complex Kernel one.

    * RespondToNode should ignore visibility in both usages.
    eregon committed Jun 30, 2015
    Copy the full SHA
    ad43523 View commit details
  2. Copy the full SHA
    acf63de View commit details
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public ArrayCastNode(RubyContext context, SourceSection sourceSection) {

public ArrayCastNode(RubyContext context, SourceSection sourceSection, SplatCastNode.NilBehavior nilBehavior) {
super(context, sourceSection);
toArrayNode = DispatchHeadNodeFactory.createMethodCall(context, MissingBehavior.RETURN_MISSING);
toArrayNode = DispatchHeadNodeFactory.createMethodCall(context, true, MissingBehavior.RETURN_MISSING);
this.nilBehavior = nilBehavior;
}

Original file line number Diff line number Diff line change
@@ -14,7 +14,9 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.dispatch.RespondToNode;
import org.jruby.truffle.runtime.ModuleOperations;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyContext;
@@ -129,20 +131,16 @@ private boolean isHidden(RubyBasicObject object) {
@CoreMethod(names = "define_finalizer", isModuleFunction = true, required = 2)
public abstract static class DefineFinalizerNode extends CoreMethodArrayArgumentsNode {

@Child private KernelNodes.RespondToNode respondToNode;
@Child private RespondToNode respondToNode;

public DefineFinalizerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
respondToNode = new RespondToNode(getContext(), getSourceSection(), null, "call");
}

@Specialization
public RubyBasicObject defineFinalizer(VirtualFrame frame, Object object, Object finalizer) {
if (respondToNode == null) {
CompilerDirectives.transferToInterpreter();
respondToNode = insert(KernelNodesFactory.RespondToNodeFactory.create(getContext(), getSourceSection(), null, null, null));
}

if (respondToNode.doesRespondToString(frame, finalizer, StringNodes.createString(getContext().getCoreLibrary().getStringClass(), "call"), true)) {
if (respondToNode.executeBoolean(frame, finalizer)) {
registerFinalizer(object, finalizer);
return ArrayNodes.fromObjects(getContext().getCoreLibrary().getArrayClass(), 0, finalizer);
} else {
Original file line number Diff line number Diff line change
@@ -11,7 +11,9 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;

public class RespondToNode extends RubyNode {
@@ -25,14 +27,18 @@ public RespondToNode(RubyContext context, SourceSection sourceSection, RubyNode
super(context, sourceSection);
this.methodName = methodName;
this.child = child;
dispatch = new DoesRespondDispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null);
dispatch = new DoesRespondDispatchHeadNode(context, true, false, MissingBehavior.RETURN_MISSING, LexicalScope.NONE);
}

public boolean executeBoolean(VirtualFrame frame) {
// TODO(cseaton): check this is actually a static "find if there is such method" and not a dynamic call to respond_to?
return dispatch.doesRespondTo(frame, methodName, child.execute(frame));
}

public boolean executeBoolean(VirtualFrame frame, Object object) {
return dispatch.doesRespondTo(frame, methodName, object);
}

@Override
public Object execute(VirtualFrame frame) {
return executeBoolean(frame);