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

Commits on Dec 13, 2016

  1. Copy the full SHA
    5caf633 View commit details
  2. Copy the full SHA
    69e4715 View commit details
  3. Copy the full SHA
    0972ddc View commit details
  4. Copy the full SHA
    e3fc025 View commit details
6 changes: 6 additions & 0 deletions mx.jruby/eclipse-settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -4,3 +4,9 @@ org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
64 changes: 33 additions & 31 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -107,7 +107,8 @@ public DynamicObject allocate(DynamicObject rubyClass) {
@ImportStatic(ArrayGuards.class)
public abstract static class AddNode extends CoreMethodNode {

@CreateCast("b") public RubyNode coerceOtherToAry(RubyNode other) {
@CreateCast("b")
public RubyNode coerceOtherToAry(RubyNode other) {
return ToAryNodeGen.create(null, null, other);
}

@@ -330,7 +331,7 @@ public Object set(VirtualFrame frame, DynamicObject array, Object indexObject, O
public Object setObject(VirtualFrame frame, DynamicObject array, int start, int length, Object value,
@Cached("forValue(value)") ArrayStrategy strategy,
@Cached("createBinaryProfile()") ConditionProfile negativeIndexProfile,
@Cached("new()") SnippetNode snippetNode) {
@Cached("new()") SnippetNode snippetNode) {
checkLengthPositive(length);

final int size = getSize(array);
@@ -531,14 +532,15 @@ private int toInt(VirtualFrame frame, Object indexObject) {

@CoreMethod(names = "at", required = 1)
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "array"),
@NodeChild(type = RubyNode.class, value = "index")
@NodeChild(type = RubyNode.class, value = "array"),
@NodeChild(type = RubyNode.class, value = "index")
})
public abstract static class AtNode extends CoreMethodNode {

@Child private ArrayReadDenormalizedNode readNode;

@CreateCast("index") public RubyNode coerceOtherToInt(RubyNode index) {
@CreateCast("index")
public RubyNode coerceOtherToInt(RubyNode index) {
return FixnumLowerNodeGen.create(null, null, ToIntNodeGen.create(index));
}

@@ -568,15 +570,15 @@ public DynamicObject clear(DynamicObject array) {
@ImportStatic(ArrayGuards.class)
public abstract static class CompactNode extends ArrayCoreMethodNode {

@Specialization(guards = {"strategy.matches(array)", "!strategy.accepts(nil())"}, limit = "ARRAY_STRATEGIES")
@Specialization(guards = { "strategy.matches(array)", "!strategy.accepts(nil())" }, limit = "ARRAY_STRATEGIES")
public DynamicObject compactPrimitive(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy) {
final int size = strategy.getSize(array);
Object store = strategy.newMirror(array).extractRange(0, size).getArray();
return createArray(store, size);
}

@Specialization(guards = {"strategy.matches(array)", "strategy.accepts(nil())"}, limit = "ARRAY_STRATEGIES")
@Specialization(guards = { "strategy.matches(array)", "strategy.accepts(nil())" }, limit = "ARRAY_STRATEGIES")
public Object compactObjects(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy) {
// TODO CS 9-Feb-15 by removing nil we could make this array suitable for a primitive array storage class
@@ -602,13 +604,13 @@ public Object compactObjects(DynamicObject array,
@CoreMethod(names = "compact!", raiseIfFrozenSelf = true)
public abstract static class CompactBangNode extends ArrayCoreMethodNode {

@Specialization(guards = {"strategy.matches(array)", "!strategy.accepts(nil())"}, limit = "ARRAY_STRATEGIES")
@Specialization(guards = { "strategy.matches(array)", "!strategy.accepts(nil())" }, limit = "ARRAY_STRATEGIES")
public DynamicObject compactNotObjects(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy) {
return nil();
}

@Specialization(guards = {"strategy.matches(array)", "strategy.accepts(nil())"}, limit = "ARRAY_STRATEGIES")
@Specialization(guards = { "strategy.matches(array)", "strategy.accepts(nil())" }, limit = "ARRAY_STRATEGIES")
public Object compactObjects(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy) {
final Object[] store = (Object[]) getStore(array);
@@ -644,7 +646,8 @@ public abstract static class ConcatNode extends CoreMethodNode {

@Child private ArrayAppendManyNode appendManyNode = ArrayAppendManyNodeGen.create(null, null);

@CreateCast("other") public RubyNode coerceOtherToAry(RubyNode other) {
@CreateCast("other")
public RubyNode coerceOtherToAry(RubyNode other) {
return ToAryNodeGen.create(null, null, other);
}

@@ -713,13 +716,14 @@ public void checkFrozen(Object object) {

@CoreMethod(names = "delete_at", required = 1, raiseIfFrozenSelf = true, lowerFixnum = 1)
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "array"),
@NodeChild(type = RubyNode.class, value = "index")
@NodeChild(type = RubyNode.class, value = "array"),
@NodeChild(type = RubyNode.class, value = "index")
})
@ImportStatic(ArrayGuards.class)
public abstract static class DeleteAtNode extends CoreMethodNode {

@CreateCast("index") public RubyNode coerceOtherToInt(RubyNode index) {
@CreateCast("index")
public RubyNode coerceOtherToInt(RubyNode index) {
return ToIntNodeGen.create(index);
}

@@ -838,8 +842,8 @@ public abstract static class HashNode extends ArrayCoreMethodNode {

@Specialization(guards = "strategy.matches(array)", limit = "ARRAY_STRATEGIES")
public long hash(VirtualFrame frame, DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy,
@Cached("createMethodCall()") CallDispatchHeadNode toHashNode) {
@Cached("of(array)") ArrayStrategy strategy,
@Cached("createMethodCall()") CallDispatchHeadNode toHashNode) {
final int size = strategy.getSize(array);
// TODO BJF Jul 4, 2016 Seed could be chosen in advance to avoid branching
long h = Hashing.start(size);
@@ -1048,7 +1052,8 @@ protected ReplaceNode createReplaceNode() {
@ImportStatic(ArrayGuards.class)
public abstract static class InitializeCopyNode extends CoreMethodNode {

@CreateCast("from") public RubyNode coerceOtherToAry(RubyNode other) {
@CreateCast("from")
public RubyNode coerceOtherToAry(RubyNode other) {
return ToAryNodeGen.create(null, null, other);
}

@@ -1236,13 +1241,10 @@ public abstract static class PackNode extends ArrayCoreMethodNode {
private final BranchProfile exceptionProfile = BranchProfile.create();
private final ConditionProfile resizeProfile = ConditionProfile.createBinaryProfile();

@Specialization(
guards = {
"isRubyString(format)",
"ropesEqual(format, cachedFormat)"
},
limit = "getCacheLimit()"
)
@Specialization(guards = {
"isRubyString(format)",
"ropesEqual(format, cachedFormat)"
}, limit = "getCacheLimit()")
public DynamicObject packCached(
VirtualFrame frame,
DynamicObject array,
@@ -1496,7 +1498,6 @@ protected RejectInPlaceNode createRejectInPlaceNode() {

}


@CoreMethod(names = "reject!", needsBlock = true, enumeratorSize = "size", raiseIfFrozenSelf = true)
@ImportStatic(ArrayGuards.class)
public abstract static class RejectInPlaceNode extends YieldingCoreMethodNode {
@@ -1553,7 +1554,8 @@ public abstract static class ReplaceNode extends CoreMethodNode {

public abstract DynamicObject executeReplace(DynamicObject array, DynamicObject other);

@CreateCast("other") public RubyNode coerceOtherToAry(RubyNode index) {
@CreateCast("other")
public RubyNode coerceOtherToAry(RubyNode index) {
return ToAryNodeGen.create(null, null, index);
}

@@ -1696,7 +1698,7 @@ public abstract static class SizeNode extends ArrayCoreMethodNode {

@Specialization(guards = "strategy.matches(array)", limit = "ARRAY_STRATEGIES")
public int size(DynamicObject array,
@Cached("of(array)") ArrayStrategy strategy) {
@Cached("of(array)") ArrayStrategy strategy) {
return strategy.getSize(array);
}

@@ -1722,7 +1724,7 @@ public DynamicObject sortNull(DynamicObject array, Object unusedBlock) {
}

@ExplodeLoop
@Specialization(guards = {"!isEmptyArray(array)", "isSmall(array)", "strategy.matches(array)"}, limit = "ARRAY_STRATEGIES")
@Specialization(guards = { "!isEmptyArray(array)", "isSmall(array)", "strategy.matches(array)" }, limit = "ARRAY_STRATEGIES")
public DynamicObject sortVeryShort(VirtualFrame frame, DynamicObject array, NotProvided block,
@Cached("of(array)") ArrayStrategy strategy) {
final ArrayMirror originalStore = strategy.newMirror(array);
@@ -1757,14 +1759,14 @@ public DynamicObject sortVeryShort(VirtualFrame frame, DynamicObject array, NotP
return createArray(store.getArray(), size);
}

@Specialization(guards = {"!isEmptyArray(array)", "!isSmall(array)"})
@Specialization(guards = { "!isEmptyArray(array)", "!isSmall(array)" })
public Object sortLargeArray(VirtualFrame frame, DynamicObject array, NotProvided block,
@Cached("new()") SnippetNode snippetNode) {
return snippetNode.execute(frame,
"sorted = dup; Truffle.privately { sorted.mergesort! }; sorted");
}

@Specialization(guards = {"!isEmptyArray(array)", "isObjectArray(array)"})
@Specialization(guards = { "!isEmptyArray(array)", "isObjectArray(array)" })
public Object sortObjectWithBlock(DynamicObject array, DynamicObject block) {
final int size = getSize(array);
Object[] copy = ((Object[]) getStore(array)).clone();
@@ -1777,7 +1779,7 @@ private void doSort(Object[] copy, int size, DynamicObject block) {
Arrays.sort(copy, 0, size, (a, b) -> castSortValue(ProcOperations.rootCall(block, a, b)));
}

@Specialization(guards = {"!isEmptyArray(array)", "!isObjectArray(array)"})
@Specialization(guards = { "!isEmptyArray(array)", "!isObjectArray(array)" })
public Object sortWithBlock(VirtualFrame frame, DynamicObject array, DynamicObject block,
@Cached("new()") SnippetNode snippet) {
return snippet.execute(frame,
@@ -1835,7 +1837,7 @@ public DynamicObject zipObjectIntegerFixnum(DynamicObject array, DynamicObject o
return createArray(zipped, zippedLength);
}

@Specialization(guards = {"isRubyArray(other)", "others.length > 0"})
@Specialization(guards = { "isRubyArray(other)", "others.length > 0" })
public Object zipObjectObjectNotSingleObject(VirtualFrame frame, DynamicObject array, DynamicObject other, Object[] others, NotProvided block) {
return zipRuby(frame, array, null);
}
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ public boolean equal(DynamicObject a, DynamicObject b) {
return a == b;
}

@Specialization(guards = {"isNotDynamicObject(a)", "isNotDynamicObject(b)", "notSameClass(a, b)", "isNotIntLong(a) || isNotIntLong(b)"})
@Specialization(guards = { "isNotDynamicObject(a)", "isNotDynamicObject(b)", "notSameClass(a, b)", "isNotIntLong(a) || isNotIntLong(b)" })
public boolean equalIncompatiblePrimitiveTypes(Object a, Object b) {
return false;
}
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ private byte[] formatBytes(int width, int precision, char fchar, boolean sign, i
}
} else if (negative) {
if (base == 10) {
// warning(ID.NEGATIVE_NUMBER_FOR_U, args, "negative number for %u specifier");
// warning(ID.NEGATIVE_NUMBER_FOR_U, args, "negative number for %u specifier");
leadChar = '.';
len += 2;
} else {