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

Commits on Jun 24, 2015

  1. [Truffle] Translate undefined.equal?(obj) to IsRubiniusUndefinedNode(…

    …obj).
    
    * Avoids polluting BasicObject#equal?(obj).
    eregon committed Jun 24, 2015
    Copy the full SHA
    2c9f45e View commit details
  2. Copy the full SHA
    c077c19 View commit details
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.arguments;

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.RubyContext;

public class IsRubiniusUndefinedNode extends RubyNode {

@Child private RubyNode child;

public IsRubiniusUndefinedNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection);
this.child = child;
}

@Override
public boolean executeBoolean(VirtualFrame frame) {
return isRubiniusUndefined(child.execute(frame));
}

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

}
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.ThreadLocalObjectNode;
import org.jruby.truffle.nodes.arguments.IsRubiniusUndefinedNode;
import org.jruby.truffle.nodes.arguments.MissingArgumentBehaviour;
import org.jruby.truffle.nodes.arguments.ReadPreArgumentNode;
import org.jruby.truffle.nodes.cast.*;
@@ -389,39 +390,45 @@ public RubyNode visitBreakNode(org.jruby.ast.BreakNode node) {
@Override
public RubyNode visitCallNode(CallNode node) {
final SourceSection sourceSection = translate(node.getPosition());
final Node receiver = node.getReceiverNode();
final String methodName = node.getName();

if (node.getReceiverNode() instanceof org.jruby.ast.ConstNode
&& ((ConstNode) node.getReceiverNode()).getName().equals("Rubinius")) {
if (node.getName().equals("primitive")) {
// Rubinius.<method>
if (receiver instanceof org.jruby.ast.ConstNode
&& ((ConstNode) receiver).getName().equals("Rubinius")) {
if (methodName.equals("primitive")) {
return translateRubiniusPrimitive(sourceSection, node);
} else if (node.getName().equals("invoke_primitive")) {
} else if (methodName.equals("invoke_primitive")) {
return translateRubiniusInvokePrimitive(sourceSection, node);
} else if (node.getName().equals("privately")) {
} else if (methodName.equals("privately")) {
return translateRubiniusPrivately(sourceSection, node);
} else if (node.getName().equals("single_block_arg")) {
} else if (methodName.equals("single_block_arg")) {
return translateRubiniusSingleBlockArg(sourceSection, node);
} else if (node.getName().equals("check_frozen")) {
} else if (methodName.equals("check_frozen")) {
return translateRubiniusCheckFrozen(sourceSection);
}
} else if (node.getReceiverNode() instanceof org.jruby.ast.Colon2ConstNode
&& ((org.jruby.ast.Colon2ConstNode) node.getReceiverNode()).getLeftNode() instanceof org.jruby.ast.ConstNode
&& ((org.jruby.ast.ConstNode) ((org.jruby.ast.Colon2ConstNode) node.getReceiverNode()).getLeftNode()).getName().equals("Truffle")
&& ((org.jruby.ast.Colon2ConstNode) node.getReceiverNode()).getName().equals("Primitive")
&& node.getName().equals("assert_constant")) {
return AssertConstantNodeGen.create(context, sourceSection, node.getArgsNode().childNodes().get(0).accept(this));
} else if (node.getReceiverNode() instanceof org.jruby.ast.Colon2ConstNode
&& ((org.jruby.ast.Colon2ConstNode) node.getReceiverNode()).getLeftNode() instanceof org.jruby.ast.ConstNode
&& ((org.jruby.ast.ConstNode) ((org.jruby.ast.Colon2ConstNode) node.getReceiverNode()).getLeftNode()).getName().equals("Truffle")
&& ((org.jruby.ast.Colon2ConstNode) node.getReceiverNode()).getName().equals("Primitive")
&& node.getName().equals("assert_not_compiled")) {
return AssertNotCompiledNodeGen.create(context, sourceSection);
} else if (node.getReceiverNode() instanceof org.jruby.ast.ConstNode
&& ((ConstNode) node.getReceiverNode()).getName().equals("Truffle")) {
if (node.getName().equals("omit")) {
} else if (receiver instanceof org.jruby.ast.Colon2ConstNode // Truffle::Primitive.<method>
&& ((org.jruby.ast.Colon2ConstNode) receiver).getLeftNode() instanceof org.jruby.ast.ConstNode
&& ((org.jruby.ast.ConstNode) ((org.jruby.ast.Colon2ConstNode) receiver).getLeftNode()).getName().equals("Truffle")
&& ((org.jruby.ast.Colon2ConstNode) receiver).getName().equals("Primitive")) {
if (methodName.equals("assert_constant")) {
return AssertConstantNodeGen.create(context, sourceSection, node.getArgsNode().childNodes().get(0).accept(this));
} else if (methodName.equals("assert_not_compiled")) {
return AssertNotCompiledNodeGen.create(context, sourceSection);
}
} else if (receiver instanceof org.jruby.ast.ConstNode // Truffle.omit
&& ((ConstNode) receiver).getName().equals("Truffle")) {
if (methodName.equals("omit")) {
// We're never going to run the omitted code and it's never used as the RHS for anything, so just
// replace the call with nil.
return new LiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject());
}
} else if (receiver instanceof VCallNode // undefined.equal?(obj)
&& ((VCallNode) receiver).getName().equals("undefined")
&& sourceSection.getSource().getPath().startsWith("core:/core/")
&& methodName.equals("equal?")) {
RubyNode argument = translateArgumentsAndBlock(sourceSection, null, node.getArgsNode(), null, methodName).getArguments()[0];
return new IsRubiniusUndefinedNode(context, sourceSection, argument);
}

return visitCallNodeExtraArgument(node, null, false, false);