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

Commits on Aug 22, 2015

  1. Copy the full SHA
    1759aee View commit details
  2. Copy the full SHA
    17b4ed2 View commit details
Showing with 148 additions and 187 deletions.
  1. +0 −8 truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  2. +12 −6 truffle/src/main/java/org/jruby/truffle/nodes/arguments/ReadRestArgumentNode.java
  3. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/cast/ArrayCastNode.java
  4. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/cast/SingleValueCastNode.java
  5. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/cast/SplatCastNode.java
  6. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/BindingNodes.java
  7. +1 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/ExceptionNodes.java
  8. +8 −13 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  9. +2 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/MatchDataNodes.java
  10. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/MethodNodes.java
  11. +9 −17 truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  12. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ObjectSpaceNodes.java
  13. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
  14. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/RangeNodes.java
  15. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  16. +2 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/SymbolNodes.java
  17. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/UnboundMethodNodes.java
  18. +0 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayBuilderNode.java
  19. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayConcatNode.java
  20. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayDropTailNode.java
  21. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayGetTailNode.java
  22. +7 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayLiteralNode.java
  23. +24 −26 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayNodes.java
  24. +14 −9 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayReadSliceNormalizedNode.java
  25. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArraySliceNode.java
  26. +6 −10 truffle/src/main/java/org/jruby/truffle/nodes/core/hash/HashNodes.java
  27. +12 −12 truffle/src/main/java/org/jruby/truffle/nodes/ext/BigDecimalNodes.java
  28. +2 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/FloatPrimitiveNodes.java
  29. +10 −14 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/IOPrimitiveNodes.java
  30. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StringPrimitiveNodes.java
  31. +3 −6 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  32. +1 −2 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
8 changes: 0 additions & 8 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -191,14 +191,6 @@ protected DynamicObject createString(ByteList bytes) {
return StringNodes.createString(getContext().getCoreLibrary().getStringFactory(), bytes);
}

protected DynamicObject createEmptyArray() {
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);
}

protected DynamicObject createArrayWith(Object... store) {
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), store, store.length);
}

protected DynamicObject createArray(Object store, int size) {
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), store, size);
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.array.ArrayUtils;
import org.jruby.truffle.runtime.layouts.Layouts;

/**
* Read the rest of arguments after a certain point into an array.
@@ -41,8 +42,6 @@ public ReadRestArgumentNode(RubyContext context, SourceSection sourceSection, in

@Override
public Object execute(VirtualFrame frame) {
final DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();

int count = RubyArguments.getUserArgumentsCount(frame.getArguments());

int endIndex = count + negativeEndIndex;
@@ -57,19 +56,26 @@ public Object execute(VirtualFrame frame) {

final int length = endIndex - startIndex;

final Object resultStore;
final int resultLength;

if (startIndex == 0) {
final Object[] arguments = RubyArguments.extractUserArguments(frame.getArguments());
return ArrayNodes.createGeneralArray(arrayClass, arguments, length);
resultStore = arguments;
resultLength = length;
} else {
if (startIndex >= endIndex) {
noArgumentsLeftProfile.enter();
return ArrayNodes.createGeneralArray(arrayClass, null, 0);
resultStore = null;
resultLength = 0;
} else {
subsetOfArgumentsProfile.enter();
final Object[] arguments = RubyArguments.extractUserArguments(frame.getArguments());
// TODO(CS): risk here of widening types too much - always going to be Object[] - does seem to be something that does happen
return ArrayNodes.createGeneralArray(arrayClass, ArrayUtils.extractRange(arguments, startIndex, endIndex), length);
resultStore = ArrayUtils.extractRange(arguments, startIndex, endIndex);
resultLength = length;
}
}

return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), resultStore, resultLength);
}
}
Original file line number Diff line number Diff line change
@@ -17,13 +17,13 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.layouts.Layouts;

/*
* TODO(CS): could probably unify this with SplatCastNode with some final configuration options.
@@ -81,10 +81,10 @@ public DynamicObject castArray(DynamicObject array) {
public Object cast(Object nil) {
switch (nilBehavior) {
case EMPTY_ARRAY:
return createEmptyArray();
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

case ARRAY_WITH_NIL:
return ArrayNodes.createGeneralArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{nil()}, 1);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{nil()}, 1);

case NIL:
return nil;
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

@NodeChild(value = "child", type = RubyNode.class)
public abstract class SingleValueCastNode extends RubyNode {
@@ -41,8 +42,7 @@ protected Object castSingle(Object[] args) {
@TruffleBoundary
@Specialization(guards = { "!noArguments(args)", "!singleArgument(args)" })
protected DynamicObject castMany(Object[] args) {
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
return ArrayNodes.createGeneralArray(arrayClass, args, args.length);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), args, args.length);
}

protected boolean noArguments(Object[] args) {
Original file line number Diff line number Diff line change
@@ -19,13 +19,13 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.array.ArrayDupNode;
import org.jruby.truffle.nodes.core.array.ArrayDupNodeGen;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.dispatch.DispatchNode;
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.layouts.Layouts;

/**
* Splat as used to cast a value to an array if it isn't already, as in {@code *value}.
@@ -64,10 +64,10 @@ public SplatCastNode(RubyContext context, SourceSection sourceSection, NilBehavi
public DynamicObject splat(Object nil) {
switch (nilBehavior) {
case EMPTY_ARRAY:
return createEmptyArray();
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

case ARRAY_WITH_NIL:
return ArrayNodes.createGeneralArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{nil()}, 1);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{nil()}, 1);

default: {
throw new UnsupportedOperationException();
@@ -101,15 +101,15 @@ public DynamicObject splat(VirtualFrame frame, Object object) {
return (DynamicObject) array;
} else if (array == nil() || array == DispatchNode.MISSING) {
CompilerDirectives.transferToInterpreter();
return ArrayNodes.createGeneralArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{object}, 1);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{object}, 1);
} else {
throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertTo(
object, getContext().getCoreLibrary().getArrayClass(), method, array, this)
);
}
}

return ArrayNodes.createGeneralArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{object}, 1);
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{object}, 1);
}

}
Original file line number Diff line number Diff line change
@@ -260,7 +260,7 @@ public LocalVariablesNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public DynamicObject localVariables(DynamicObject binding) {
final DynamicObject array = createEmptyArray();
final DynamicObject array = Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

MaterializedFrame frame = Layouts.BINDING.getFrame(binding);

Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyCallStack;
@@ -45,8 +44,7 @@ public static DynamicObject asRubyStringArray(DynamicObject exception) {
array[n] = StringNodes.createString(Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(exception)).getContext().getCoreLibrary().getStringClass(), lines.get(n));
}

DynamicObject arrayClass = Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(exception)).getContext().getCoreLibrary().getArrayClass();
return ArrayNodes.createGeneralArray(arrayClass, array, array.length);
return Layouts.ARRAY.createArray(Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(exception)).getContext().getCoreLibrary().getArrayFactory(), array, array.length);
}

public static void setMessage(DynamicObject exception, Object message) {
Original file line number Diff line number Diff line change
@@ -1053,7 +1053,7 @@ public DynamicObject instanceVariables(DynamicObject self) {

Arrays.sort(instanceVariableNames);

final DynamicObject array = createEmptyArray();
final DynamicObject array = Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

for (Object name : instanceVariableNames) {
if (name instanceof String) {
@@ -1204,7 +1204,7 @@ public LocalVariablesNode(RubyContext context, SourceSection sourceSection) {
public DynamicObject localVariables() {
CompilerDirectives.transferToInterpreter();

final DynamicObject array = createEmptyArray();
final DynamicObject array = Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

for (Object name : RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, false).getFrameDescriptor().getIdentifiers()) {
if (name instanceof String) {
@@ -1289,9 +1289,8 @@ public DynamicObject methodsRegular(VirtualFrame frame, Object self, boolean reg
final DynamicObject metaClass = metaClassNode.executeMetaClass(frame, self);

CompilerDirectives.transferToInterpreter();
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = Layouts.MODULE.getFields(metaClass).filterMethodsOnObject(regular, MethodFilter.PUBLIC_PROTECTED).toArray();
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}

@Specialization(guards = "!regular")
@@ -1347,9 +1346,8 @@ public DynamicObject privateMethods(VirtualFrame frame, Object self, boolean inc
DynamicObject metaClass = metaClassNode.executeMetaClass(frame, self);

CompilerDirectives.transferToInterpreter();
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = Layouts.MODULE.getFields(metaClass).filterMethodsOnObject(includeAncestors, MethodFilter.PRIVATE).toArray();
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}

}
@@ -1395,9 +1393,8 @@ public DynamicObject protectedMethods(VirtualFrame frame, Object self, boolean i
final DynamicObject metaClass = metaClassNode.executeMetaClass(frame, self);

CompilerDirectives.transferToInterpreter();
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = Layouts.MODULE.getFields(metaClass).filterMethodsOnObject(includeAncestors, MethodFilter.PROTECTED).toArray();
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}

}
@@ -1426,9 +1423,8 @@ public DynamicObject publicMethods(VirtualFrame frame, Object self, boolean incl
final DynamicObject metaClass = metaClassNode.executeMetaClass(frame, self);

CompilerDirectives.transferToInterpreter();
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = Layouts.MODULE.getFields(metaClass).filterMethodsOnObject(includeAncestors, MethodFilter.PUBLIC).toArray();
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}

}
@@ -1764,13 +1760,12 @@ public DynamicObject singletonMethods(VirtualFrame frame, Object self, boolean i
final DynamicObject metaClass = metaClassNode.executeMetaClass(frame, self);

if (!Layouts.CLASS.getIsSingleton(metaClass)) {
return createEmptyArray();
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);
}

CompilerDirectives.transferToInterpreter();
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = Layouts.MODULE.getFields(metaClass).filterSingletonMethods(includeAncestors, MethodFilter.PUBLIC_PROTECTED).toArray();
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}

}
Original file line number Diff line number Diff line change
@@ -326,9 +326,8 @@ public CapturesNode(RubyContext context, SourceSection sourceSection) {
public DynamicObject toA(DynamicObject matchData) {
CompilerDirectives.transferToInterpreter();

DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = getCaptures(matchData);
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}
}

@@ -448,9 +447,8 @@ public ToANode(RubyContext context, SourceSection sourceSection) {
public DynamicObject toA(DynamicObject matchData) {
CompilerDirectives.transferToInterpreter();

DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = Arrays.copyOf(Layouts.MATCH_DATA.getValues(matchData), Layouts.MATCH_DATA.getValues(matchData).length);
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}
}

Original file line number Diff line number Diff line change
@@ -202,9 +202,8 @@ public Object sourceLocation(DynamicObject method) {
return nil();
} else {
DynamicObject file = createString(sourceSection.getSource().getName());
DynamicObject arrayClass = getContext().getCoreLibrary().getArrayClass();
Object[] objects = new Object[]{file, sourceSection.getStartLine()};
return ArrayNodes.createGeneralArray(arrayClass, objects, objects.length);
return createArray(objects, objects.length);
}
}

Loading