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: ee07e39f6701
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7567b0bb8fbc
Choose a head ref

Commits on Dec 29, 2014

  1. Copy the full SHA
    409925e View commit details
  2. Eclipse: update factory path

    eregon committed Dec 29, 2014
    Copy the full SHA
    0cd457e View commit details
  3. 2
    Copy the full SHA
    6199915 View commit details
  4. Copy the full SHA
    13e2779 View commit details
  5. Copy the full SHA
    27067b0 View commit details
  6. [Truffle] Remove useless RubyBignum specializations when RubyBasicObj…

    …ect is enough.
    
    * And fix Kernel#String(String).
    eregon committed Dec 29, 2014
    Copy the full SHA
    85db07c View commit details
  7. [Truffle] Remove incorrect specializations in Kernel#String.

    * Fixnum#to_s should be called.
    eregon committed Dec 29, 2014
    Copy the full SHA
    11b16fe View commit details
  8. [Truffle] Remove old guard.

    eregon committed Dec 29, 2014
    Copy the full SHA
    fdfe94d View commit details
  9. Copy the full SHA
    3792e0f View commit details
  10. [Truffle] Make $_ thread local - at the same time as being frame local.

    We achieve this by wrapping the value in a ThreadLocal when it's
    assigned, giving it the default value nil for other threads.
    chrisseaton committed Dec 29, 2014
    2
    Copy the full SHA
    73aa13c View commit details
  11. [Truffle] Allow filename and line number arguments in Kernel#eval.

    These parameters are currently ignored.  The semantics of eval continue to work fine in most cases with the ignored parameters, so I've committed this work in order to avoid issues in code that calls eval with the extra arguments, such as ERB.
    nirvdrum committed Dec 29, 2014
    Copy the full SHA
    56420a0 View commit details
  12. Copy the full SHA
    d7e2d71 View commit details
  13. Copy the full SHA
    b542641 View commit details
  14. [Truffle] Always call block parameters 'block' so they aren't confuse…

    …d with final parameters that just happen to take a RubyProc.
    chrisseaton committed Dec 29, 2014
    Copy the full SHA
    c1ed261 View commit details
  15. Copy the full SHA
    19985d2 View commit details
  16. Copy the full SHA
    dac366d View commit details
  17. Copy the full SHA
    f48d629 View commit details
  18. Copy the full SHA
    cce55de View commit details
  19. Copy the full SHA
    6be4fe2 View commit details
  20. Copy the full SHA
    e8d294c View commit details
  21. Copy the full SHA
    e822799 View commit details

Commits on Dec 30, 2014

  1. Copy the full SHA
    af77cd9 View commit details
  2. Copy the full SHA
    2e03b8f View commit details
  3. Copy the full SHA
    7567b0b View commit details
Showing with 411 additions and 186 deletions.
  1. +2 −2 core/.factorypath
  2. +0 −5 core/src/main/java/org/jruby/ast/CallNode.java
  3. +1 −2 core/src/main/java/org/jruby/ir/IRBuilder.java
  4. +7 −0 core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  5. +1 −0 core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
  6. +4 −3 core/src/main/java/org/jruby/truffle/nodes/cast/SplatCastNode.java
  7. +9 −0 core/src/main/java/org/jruby/truffle/nodes/control/TryNode.java
  8. +37 −9 core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  9. +3 −3 core/src/main/java/org/jruby/truffle/nodes/core/BignumNodes.java
  10. +16 −1 core/src/main/java/org/jruby/truffle/nodes/core/BindingNodes.java
  11. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java
  12. +11 −6 core/src/main/java/org/jruby/truffle/nodes/core/FixnumOrBignumNode.java
  13. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
  14. +18 −13 core/src/main/java/org/jruby/truffle/nodes/core/GeneralDivModNode.java
  15. +40 −70 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  16. +27 −9 core/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
  17. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  18. +65 −1 core/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
  19. +48 −0 core/src/main/java/org/jruby/truffle/nodes/globals/GetFromThreadLocalNode.java
  20. +51 −0 core/src/main/java/org/jruby/truffle/nodes/globals/WrapInThreadLocalNode.java
  21. +2 −0 core/src/main/java/org/jruby/truffle/nodes/globals/WriteReadOnlyGlobalNode.java
  22. +6 −6 core/src/main/java/org/jruby/truffle/nodes/objects/DefineOrGetClassNode.java
  23. +1 −1 core/src/main/java/org/jruby/truffle/nodes/objects/ReadInstanceVariableNode.java
  24. +2 −0 core/src/main/java/org/jruby/truffle/nodes/objects/SingletonClassNode.java
  25. +4 −0 core/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  26. +1 −9 core/src/main/java/org/jruby/truffle/runtime/core/RubyFile.java
  27. +5 −1 core/src/main/java/org/jruby/truffle/runtime/core/StringFormatter.java
  28. +4 −3 core/src/main/java/org/jruby/truffle/runtime/subsystems/FeatureManager.java
  29. +7 −1 core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  30. +1 −1 core/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java
  31. +1 −1 core/src/main/ruby/jruby/truffle/core/kernel.rb
  32. +11 −0 core/src/main/ruby/jruby/truffle/core/main.rb
  33. +20 −18 core/src/main/ruby/jruby/truffle/core/rubinius/kernel/common/time.rb
  34. +1 −5 spec/truffle/tags/core/kernel/eval_tags.txt
  35. +0 −9 spec/truffle/tags/core/string/concat_tags.txt
  36. +0 −2 spec/truffle/tags/language/predefined_tags.txt
4 changes: 2 additions & 2 deletions core/.factorypath
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle/0.5/truffle-0.5.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle-dsl-processor/0.5/truffle-dsl-processor-0.5.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle/0.6/truffle-0.6.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle-dsl-processor/0.6/truffle-dsl-processor-0.6.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/ast/CallNode.java
Original file line number Diff line number Diff line change
@@ -47,11 +47,6 @@ public class CallNode extends Node implements INameNode, IArgumentNode, BlockAcc
protected Node iterNode;
private String name;

@Deprecated
public CallNode(ISourcePosition position, Node receiverNode, String name, Node argsNode) {
this(position, receiverNode, name, argsNode, null);
}

public CallNode(ISourcePosition position, Node receiverNode, String name, Node argsNode,
Node iterNode) {
super(position);
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -599,8 +599,7 @@ protected Operand buildCallArgs(List<Operand> argsList, Node args, IRScope s) {
break;
}
default: {
argsList.add(build(args, s));
break;
throw new NotCompilableException("Use buildRoot(); Root node at: " + args.getPosition());
}
}

7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
@@ -33,6 +34,7 @@
* @see YieldDispatchNode
*/
@TypeSystemReference(RubyTypes.class)
@GenerateNodeFactory
public abstract class RubyNode extends Node {

private final RubyContext context;
@@ -383,6 +385,11 @@ public boolean isRubyBasicObject(Object value) {
return value instanceof RubyBasicObject;
}

@SuppressWarnings("static-method")
public boolean isThreadLocal(Object value) {
return value instanceof ThreadLocal;
}

@SuppressWarnings("static-method")
public boolean isObjectArray(Object value) {
return value instanceof Object[];
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
RubyTime.class, //
RubyEncodingConverter.class, //
RubyBasicObject.class, //
ThreadLocal.class, //
Object[].class})

public class RubyTypes {
Original file line number Diff line number Diff line change
@@ -103,13 +103,14 @@ public RubyArray splat(VirtualFrame frame, Object object) {
method = "to_a";
}

// TODO(CS): why are we directly calling #respond_to? instead of using a respondsTo on a dispatch head node?
if (respondToCast.executeBoolean(frame, respondToToA.call(frame, object, "respond_to?", null, getContext().makeString(method), true))) {
// MRI tries to call dynamic respond_to? here.
Object respondToResult = respondToToA.call(frame, object, "respond_to?", null, getContext().makeString(method), true);
if (respondToResult != Dispatch.MISSING && respondToCast.executeBoolean(frame, respondToResult)) {
final Object array = toA.call(frame, object, method, null);

if (array instanceof RubyArray) {
return (RubyArray) array;
} else if (array instanceof RubyNilClass) {
} else if (array instanceof RubyNilClass || array == Dispatch.MISSING) {
return RubyArray.fromObject(getContext().getCoreLibrary().getArrayClass(), object);
} else {
throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertTo(
Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@
import com.oracle.truffle.api.nodes.*;
import com.oracle.truffle.api.utilities.*;
import org.jruby.truffle.nodes.*;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.methods.ExceptionTranslatingNode;
import org.jruby.truffle.nodes.objects.WriteInstanceVariableNode;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.*;

@@ -28,6 +30,7 @@ public class TryNode extends RubyNode {
@Child protected ExceptionTranslatingNode tryPart;
@Children final RescueNode[] rescueParts;
@Child protected RubyNode elsePart;
@Child protected WriteInstanceVariableNode clearExceptionVariableNode;

private final BranchProfile elseProfile = BranchProfile.create();
private final BranchProfile controlFlowProfile = BranchProfile.create();
@@ -38,6 +41,10 @@ public TryNode(RubyContext context, SourceSection sourceSection, ExceptionTransl
this.tryPart = tryPart;
this.rescueParts = rescueParts;
this.elsePart = elsePart;
clearExceptionVariableNode = new WriteInstanceVariableNode(context, sourceSection, "$!",
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getGlobalVariablesObject()),
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
true);
}

@Override
@@ -60,6 +67,8 @@ public Object execute(VirtualFrame frame) {
} catch (RetryException e) {
continue;
}
} finally {
clearExceptionVariableNode.execute(frame);
}

elseProfile.enter();
46 changes: 37 additions & 9 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
import org.jruby.truffle.nodes.methods.arguments.MissingArgumentBehaviour;
import org.jruby.truffle.nodes.methods.arguments.ReadPreArgumentNode;
import org.jruby.truffle.nodes.methods.locals.ReadLevelVariableNodeFactory;
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.BreakException;
import org.jruby.truffle.runtime.control.NextException;
@@ -3438,31 +3439,34 @@ public RubyArray sliceLongFixnum(RubyArray array, int start, int length) {

}

@CoreMethod(names = "sort")
@CoreMethod(names = "sort", needsBlock = true)
public abstract static class SortNode extends ArrayCoreMethodNode {

@Child protected DispatchHeadNode compareDispatchNode;
@Child protected YieldDispatchHeadNode yieldNode;

public SortNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
compareDispatchNode = new DispatchHeadNode(context);
yieldNode = new YieldDispatchHeadNode(context);
}

public SortNode(SortNode prev) {
super(prev);
compareDispatchNode = prev.compareDispatchNode;
yieldNode = prev.yieldNode;
}

@Specialization(guards = "isNull")
public RubyArray sortNull(RubyArray array) {
public RubyArray sortNull(RubyArray array, UndefinedPlaceholder block) {
notDesignedForCompilation();

return new RubyArray(getContext().getCoreLibrary().getArrayClass());
}

@ExplodeLoop
@Specialization(guards = {"isIntegerFixnum", "isSmall"})
public RubyArray sortVeryShortIntegerFixnum(VirtualFrame frame, RubyArray array) {
public RubyArray sortVeryShortIntegerFixnum(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
final int[] store = (int[]) array.getStore();

final int size = array.getSize();
@@ -3487,7 +3491,7 @@ public RubyArray sortVeryShortIntegerFixnum(VirtualFrame frame, RubyArray array)
}

@Specialization(guards = "isIntegerFixnum")
public RubyArray sortIntegerFixnum(VirtualFrame frame, RubyArray array) {
public RubyArray sortIntegerFixnum(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
notDesignedForCompilation();

final Object[] boxed = ArrayUtils.box((int[]) array.getStore());
@@ -3498,7 +3502,7 @@ public RubyArray sortIntegerFixnum(VirtualFrame frame, RubyArray array) {

@ExplodeLoop
@Specialization(guards = {"isLongFixnum", "isSmall"})
public RubyArray sortVeryShortLongFixnum(VirtualFrame frame, RubyArray array) {
public RubyArray sortVeryShortLongFixnum(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
final long[] store = (long[]) array.getStore();

final int size = array.getSize();
@@ -3523,7 +3527,7 @@ public RubyArray sortVeryShortLongFixnum(VirtualFrame frame, RubyArray array) {
}

@Specialization(guards = "isLongFixnum")
public RubyArray sortLongFixnum(VirtualFrame frame, RubyArray array) {
public RubyArray sortLongFixnum(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
notDesignedForCompilation();

final Object[] boxed = ArrayUtils.box((long[]) array.getStore());
@@ -3533,7 +3537,7 @@ public RubyArray sortLongFixnum(VirtualFrame frame, RubyArray array) {
}

@Specialization(guards = "isFloat")
public RubyArray sortDouble(VirtualFrame frame, RubyArray array) {
public RubyArray sortDouble(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
notDesignedForCompilation();

final Object[] boxed = ArrayUtils.box((double[]) array.getStore());
@@ -3543,7 +3547,7 @@ public RubyArray sortDouble(VirtualFrame frame, RubyArray array) {
}

@Specialization(guards = {"isObject", "isSmall"})
public RubyArray sortVeryShortObject(VirtualFrame frame, RubyArray array) {
public RubyArray sortVeryShortObject(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
final Object[] store = (Object[]) array.getStore();

// Insertion sort
@@ -3565,14 +3569,23 @@ public RubyArray sortVeryShortObject(VirtualFrame frame, RubyArray array) {
}

@Specialization(guards = "isObject")
public RubyArray sortObject(VirtualFrame frame, RubyArray array) {
public RubyArray sortObject(VirtualFrame frame, RubyArray array, UndefinedPlaceholder block) {
notDesignedForCompilation();

final Object[] store = Arrays.copyOf((Object[]) array.getStore(), array.getSize());
sort(frame, store);
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), store, array.getSize());
}

@Specialization(guards = "isObject")
public RubyArray sortWithCompareBlock(VirtualFrame frame, RubyArray array, RubyProc block) {
notDesignedForCompilation();

final Object[] store = Arrays.copyOf((Object[]) array.getStore(), array.getSize());
sort(frame, store, block);
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), store, array.getSize());
}

private <T> void sort(VirtualFrame frame, T[] objects) {
final VirtualFrame finalFrame = frame;

@@ -3587,6 +3600,21 @@ public int compare(Object a, Object b) {
});
}

private <T> void sort(VirtualFrame frame, T[] objects, RubyProc compare) {
final VirtualFrame finalFrame = frame;
final RubyProc finalCompare = compare;

Arrays.sort(objects, new Comparator<Object>() {

@Override
public int compare(Object a, Object b) {
// TODO(CS): node for this cast
return (int) yieldNode.dispatch(finalFrame, finalCompare, a, b);
}

});
}

protected static boolean isSmall(RubyArray array) {
return array.getSize() <= RubyArray.ARRAYS_SMALL;
}
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ public static abstract class BignumCoreMethodNode extends CoreMethodNode {

public BignumCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
fixnumOrBignum = new FixnumOrBignumNode(context);
fixnumOrBignum = new FixnumOrBignumNode(context, sourceSection);
}

public BignumCoreMethodNode(BignumCoreMethodNode prev) {
@@ -255,12 +255,12 @@ public abstract static class DivModNode extends CoreMethodNode {

public DivModNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
divModNode = new GeneralDivModNode(context);
divModNode = new GeneralDivModNode(context, sourceSection);
}

public DivModNode(DivModNode prev) {
super(prev);
divModNode = new GeneralDivModNode(getContext());
divModNode = prev.divModNode;
}

@Specialization
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*;
import org.jruby.truffle.nodes.globals.GetFromThreadLocalNode;
import org.jruby.truffle.nodes.globals.WrapInThreadLocalNode;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.core.*;

@@ -34,7 +36,15 @@ public Object localVariableGet(RubyBinding binding, RubySymbol symbol) {
notDesignedForCompilation();

final MaterializedFrame frame = binding.getFrame();
return frame.getValue(frame.getFrameDescriptor().findFrameSlot(symbol.toString()));

Object value = frame.getValue(frame.getFrameDescriptor().findFrameSlot(symbol.toString()));

// TODO(CS): temporary hack for $_
if (symbol.equals("$_")) {
value = GetFromThreadLocalNode.get(getContext(), value);
}

return value;
}
}

@@ -53,6 +63,11 @@ public LocalVariableSetNode(LocalVariableSetNode prev) {
public Object localVariableSetNode(RubyBinding binding, RubySymbol symbol, Object value) {
notDesignedForCompilation();

// TODO(CS): temporary hack for $_
if (symbol.toString().equals("$_")) {
value = WrapInThreadLocalNode.wrap(getContext(), value);
}

MaterializedFrame frame = binding.getFrame();

while (true) {
Original file line number Diff line number Diff line change
@@ -552,12 +552,12 @@ public abstract static class DivModNode extends CoreMethodNode {

public DivModNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
divModNode = new GeneralDivModNode(context);
divModNode = new GeneralDivModNode(context, sourceSection);
}

public DivModNode(DivModNode prev) {
super(prev);
divModNode = new GeneralDivModNode(getContext());
divModNode = prev.divModNode;
}

@Specialization
Original file line number Diff line number Diff line change
@@ -10,22 +10,23 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBignum;

import java.math.BigDecimal;
import java.math.BigInteger;

public class FixnumOrBignumNode extends Node {
public class FixnumOrBignumNode extends RubyNode {

public FixnumOrBignumNode(RubyContext context) {
this.context = context;
public FixnumOrBignumNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

private final RubyContext context;

private final BranchProfile lowerProfile = BranchProfile.create();
private final BranchProfile integerFromBignumProfile = BranchProfile.create();
private final BranchProfile longFromBignumProfile = BranchProfile.create();
@@ -69,12 +70,16 @@ public Object fixnumOrBignum(double value) {

bignumProfile.enter();

return new RubyBignum(context.getCoreLibrary().getBignumClass(), doubleToBigInteger(value));
return new RubyBignum(getContext().getCoreLibrary().getBignumClass(), doubleToBigInteger(value));
}

@CompilerDirectives.TruffleBoundary
private static BigInteger doubleToBigInteger(double value) {
return new BigDecimal(value).toBigInteger();
}

public Object execute(VirtualFrame frame) {
throw new UnsupportedOperationException();
}

}
Loading