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: e454d1c6188c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 71aaac993234
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Mar 18, 2015

  1. [Truffle] Adding ConditionProfile to ReturnEnumeratorIfNoBlock annota…

    …tion and updating to execute.
    bjfish committed Mar 18, 2015
    Copy the full SHA
    178a55e View commit details
  2. Merge pull request #2721 from bjfish/truffle_returns_enum_fix

    [Truffle] Adding ConditionProfile to ReturnEnumeratorIfNoBlock annotation and updating to execute.
    nirvdrum committed Mar 18, 2015
    Copy the full SHA
    71aaac9 View commit details
Showing with 6 additions and 9 deletions.
  1. +6 −9 truffle/src/main/java/org/jruby/truffle/nodes/core/ReturnEnumeratorIfNoBlockNode.java
Original file line number Diff line number Diff line change
@@ -2,20 +2,19 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;

public class ReturnEnumeratorIfNoBlockNode extends RubyNode {

@Child private RubyNode method;
@Child private CallDispatchHeadNode toEnumNode;
private final String methodName;
private final ConditionProfile noBlockProfile = ConditionProfile.createBinaryProfile();

public ReturnEnumeratorIfNoBlockNode(String methodName, RubyNode method) {
super(method.getContext(), method.getEncapsulatingSourceSection());
@@ -27,7 +26,7 @@ public ReturnEnumeratorIfNoBlockNode(String methodName, RubyNode method) {
public Object execute(VirtualFrame frame) {
final RubyProc block = RubyArguments.getBlock(frame.getArguments());

if (block == null) {
if (noBlockProfile.profile(block == null)) {
if (toEnumNode == null) {
CompilerDirectives.transferToInterpreter();
toEnumNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
@@ -36,11 +35,9 @@ public Object execute(VirtualFrame frame) {
return toEnumNode.call(frame, RubyArguments.getSelf(frame.getArguments()), "to_enum", null, getContext().getSymbolTable().getSymbol(methodName));

} else {
try {
return method.executeRubyBasicObject(frame);
} catch (UnexpectedResultException e) {
return e.getResult();
}

return method.execute(frame);

}
}