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

Commits on Mar 28, 2016

  1. Copy the full SHA
    56736f2 View commit details
  2. Copy the full SHA
    e9ed318 View commit details
  3. Copy the full SHA
    e729b93 View commit details
  4. Copy the full SHA
    3a8e29e View commit details
  5. Copy the full SHA
    ed32c9d View commit details
  6. Copy the full SHA
    9fa250c View commit details
  7. Copy the full SHA
    bb231d1 View commit details
  8. Copy the full SHA
    aabf1fc View commit details
  9. Copy the full SHA
    af60d2d View commit details
  10. Copy the full SHA
    c4304ef View commit details
  11. Copy the full SHA
    9b23c30 View commit details
  12. Copy the full SHA
    72dcd4b View commit details
  13. Copy the full SHA
    fa87feb View commit details
  14. Copy the full SHA
    76cddce View commit details
  15. Copy the full SHA
    1aafbc1 View commit details
  16. Copy the full SHA
    e16aba4 View commit details
  17. Copy the full SHA
    133574e View commit details
  18. Copy the full SHA
    e896b50 View commit details
  19. [Truffle] Separate the format read nodes which read from an array and…

    … those that read from bytes.
    chrisseaton committed Mar 28, 2016
    Copy the full SHA
    c614f0a View commit details
  20. Copy the full SHA
    946c0c3 View commit details
  21. [Truffle] Separate the format write nodes which write to an array and…

    … those that write to bytes.
    chrisseaton committed Mar 28, 2016
    Copy the full SHA
    dd1552e View commit details
Showing with 1,283 additions and 1,276 deletions.
  1. 0 truffle/src/main/antlr4/org/jruby/truffle/core/format/{parser → pack}/Pack.g4
  2. 0 truffle/src/main/antlr4/org/jruby/truffle/core/format/{parser → printf}/PrintfLexer.g4
  3. 0 truffle/src/main/antlr4/org/jruby/truffle/core/format/{parser → printf}/PrintfParser.g4
  4. +2 −2 truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendManyNode.java
  5. +3 −3 truffle/src/main/java/org/jruby/truffle/core/array/ArrayAppendOneNode.java
  6. +1 −1 truffle/src/main/java/org/jruby/truffle/core/array/ArrayBuilderNode.java
  7. +4 −4 truffle/src/main/java/org/jruby/truffle/core/array/ArrayEnsureCapacityNode.java
  8. +3 −3 truffle/src/main/java/org/jruby/truffle/core/array/ArrayGeneralizeNode.java
  9. +23 −25 truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
  10. +7 −8 truffle/src/main/java/org/jruby/truffle/core/array/ArrayUtils.java
  11. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{runtime/PackResult.java → BytesResult.java}
  12. +3 −3 ...fle/src/main/java/org/jruby/truffle/core/format/{runtime/PackEncoding.java → FormatEncoding.java}
  13. +3 −3 ...ain/java/org/jruby/truffle/core/format/{parser/PackErrorListener.java → FormatErrorListener.java}
  14. +2 −2 ...ava/org/jruby/truffle/core/format/{runtime/PackFrameDescriptor.java → FormatFrameDescriptor.java}
  15. +6 −2 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/PackGuards.java → FormatGuards.java}
  16. +18 −19 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/PackNode.java → FormatNode.java}
  17. +21 −24 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/PackRootNode.java → FormatRootNode.java}
  18. +3 −3 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → }/LiteralBytesNode.java
  19. +3 −3 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → }/LiteralIntegerNode.java
  20. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{runtime → }/MissingValue.java
  21. +87 −0 truffle/src/main/java/org/jruby/truffle/core/format/SharedTreeBuilder.java
  22. +3 −3 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/AtNode.java
  23. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/AtUnpackNode.java
  24. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/BackNode.java
  25. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/BackUnpackNode.java
  26. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/ForwardUnpackNode.java
  27. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/NNode.java
  28. +6 −6 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/SequenceNode.java
  29. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/control/StarNode.java
  30. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeByteNode.java
  31. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeFloat32Node.java
  32. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeFloat64Node.java
  33. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeInteger16BigNode.java
  34. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeInteger16LittleNode.java
  35. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeInteger32BigNode.java
  36. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeInteger32LittleNode.java
  37. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeInteger64BigNode.java
  38. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/decode/DecodeInteger64LittleNode.java
  39. +1 −1 ...ain/java/org/jruby/truffle/core/format/{runtime → }/exceptions/CantCompressNegativeException.java
  40. +1 −1 ...fle/src/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/CantConvertException.java
  41. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/FormatException.java
  42. +1 −1 ...ain/java/org/jruby/truffle/core/format/{runtime → }/exceptions/NoImplicitConversionException.java
  43. +1 −1 ...src/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/OutsideOfStringException.java
  44. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/PackException.java
  45. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/RangeException.java
  46. +1 −1 ...src/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/TooFewArgumentsException.java
  47. +1 −1 ...c/main/java/org/jruby/truffle/core/format/{runtime → }/exceptions/WrongArgumentTypeException.java
  48. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/format/FormatFloatNode.java
  49. +7 −7 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/format/FormatIntegerNode.java
  50. +2 −63 ...e/src/main/java/org/jruby/truffle/core/format/{parser/PackCompiler.java → pack/LoopRecovery.java}
  51. +69 −0 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackCompiler.java
  52. +81 −119 truffle/src/main/java/org/jruby/truffle/core/format/{parser → pack}/PackTreeBuilder.java
  53. +0 −533 truffle/src/main/java/org/jruby/truffle/core/format/parser/UnpackTreeBuilder.java
  54. +10 −5 truffle/src/main/java/org/jruby/truffle/core/format/{parser → printf}/PrintfCompiler.java
  55. +32 −32 truffle/src/main/java/org/jruby/truffle/core/format/{parser → printf}/PrintfTreeBuilder.java
  56. +3 −3 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → read}/SourceNode.java
  57. +3 −3 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → read/array}/PNode.java
  58. +6 −6 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/array}/ReadDoubleNode.java
  59. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/array}/ReadHashValueNode.java
  60. +6 −6 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/array}/ReadIntegerNode.java
  61. +8 −8 ...c/main/java/org/jruby/truffle/core/format/{nodes/read → read/array}/ReadLongOrBigIntegerNode.java
  62. +7 −7 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/array}/ReadStringNode.java
  63. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/array}/ReadValueNode.java
  64. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadBERNode.java
  65. +5 −5 ...e/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadBase64StringNode.java
  66. +4 −4 ...e/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadBinaryStringNode.java
  67. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadBitStringNode.java
  68. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadByteNode.java
  69. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadBytesNode.java
  70. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadHexStringNode.java
  71. +4 −4 ...fle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadMIMEStringNode.java
  72. +6 −6 .../src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadUTF8CharacterNode.java
  73. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/read → read/bytes}/ReadUUStringNode.java
  74. +0 −15 truffle/src/main/java/org/jruby/truffle/core/format/runtime/Signedness.java
  75. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/AsSinglePrecisionNode.java
  76. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/AsUnsignedNode.java
  77. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/ReinterpretLongNode.java
  78. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/ToDoubleNode.java
  79. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/ToDoubleWithCoercionNode.java
  80. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/ToIntegerNode.java
  81. +9 −9 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/ToLongNode.java
  82. +5 −5 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → }/type/ToStringNode.java
  83. +36 −0 truffle/src/main/java/org/jruby/truffle/core/format/unpack/ArrayResult.java
  84. +9 −5 truffle/src/main/java/org/jruby/truffle/core/format/{parser → unpack}/UnpackCompiler.java
  85. +26 −22 truffle/src/main/java/org/jruby/truffle/core/format/{nodes → unpack}/UnpackRootNode.java
  86. +472 −0 truffle/src/main/java/org/jruby/truffle/core/format/unpack/UnpackTreeBuilder.java
  87. +16 −19 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/array}/WriteValueNode.java
  88. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write16BigNode.java
  89. +4 −4 ...le/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write16LittleNode.java
  90. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write32BigNode.java
  91. +4 −4 ...le/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write32LittleNode.java
  92. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write64BigNode.java
  93. +4 −4 ...le/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write64LittleNode.java
  94. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/Write8Node.java
  95. +7 −7 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteBERNode.java
  96. +5 −5 ...rc/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteBase64StringNode.java
  97. +4 −4 ...rc/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteBinaryStringNode.java
  98. +4 −4 ...e/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteBitStringNode.java
  99. +3 −3 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteByteNode.java
  100. +4 −4 truffle/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteBytesNode.java
  101. +4 −4 ...e/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteHexStringNode.java
  102. +4 −4 .../src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteMIMEStringNode.java
  103. +4 −4 ...src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WritePaddedBytesNode.java
  104. +5 −5 ...c/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteUTF8CharacterNode.java
  105. +5 −5 ...le/src/main/java/org/jruby/truffle/core/format/{nodes/write → write/bytes}/WriteUUStringNode.java
  106. +15 −15 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  107. +18 −35 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
  108. +1 −1 truffle/src/main/java/org/jruby/truffle/language/loader/FeatureLoader.java
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ public void appendManySameTypeGeneric(DynamicObject array, ArrayMirror storeMirr
final int newSize = oldSize + otherSize;

if (extendProfile.profile(newSize > storeMirror.getLength())) {
final ArrayMirror newStoreMirror = storeMirror.copyArrayAndMirror(ArrayUtils.capacity(storeMirror.getLength(), newSize));
final ArrayMirror newStoreMirror = storeMirror.copyArrayAndMirror(ArrayUtils.capacity(getContext(), storeMirror.getLength(), newSize));
otherStoreMirror.copyTo(newStoreMirror, 0, oldSize, otherSize);
Layouts.ARRAY.setStore(array, newStoreMirror.getArray());
Layouts.ARRAY.setSize(array, newSize);
@@ -151,7 +151,7 @@ public void appendManyBoxIntoObjectGeneric(DynamicObject array, int otherSize, A
final Object[] oldStore = (Object[]) Layouts.ARRAY.getStore(array);

if (extendProfile.profile(newSize > oldStore.length)) {
final Object[] newStore = ArrayUtils.grow(oldStore, ArrayUtils.capacity(oldStore.length, newSize));
final Object[] newStore = ArrayUtils.grow(oldStore, ArrayUtils.capacity(getContext(), oldStore.length, newSize));
otherStoreMirror.copyTo(newStore, 0, oldSize, otherSize);
Layouts.ARRAY.setStore(array, newStore);
Layouts.ARRAY.setSize(array, newSize);
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ public void appendOneSameTypeGeneric(DynamicObject array, ArrayMirror storeMirro
final int newSize = oldSize + 1;

if (extendProfile.profile(newSize > storeMirror.getLength())) {
final ArrayMirror newStoreMirror = storeMirror.copyArrayAndMirror(ArrayUtils.capacityForOneMore(storeMirror.getLength()));
final ArrayMirror newStoreMirror = storeMirror.copyArrayAndMirror(ArrayUtils.capacityForOneMore(getContext(), storeMirror.getLength()));
newStoreMirror.set(oldSize, value);
Layouts.ARRAY.setStore(array, newStoreMirror.getArray());
Layouts.ARRAY.setSize(array, newSize);
@@ -117,7 +117,7 @@ public DynamicObject appendOneLongIntoInteger(DynamicObject array, long value) {
final int newSize = oldSize + 1;

final int[] oldStore = (int[]) Layouts.ARRAY.getStore(array);
long[] newStore = ArrayUtils.longCopyOf(oldStore, ArrayUtils.capacity(oldStore.length, newSize));
long[] newStore = ArrayUtils.longCopyOf(oldStore, ArrayUtils.capacity(getContext(), oldStore.length, newSize));

newStore[oldSize] = value;
Layouts.ARRAY.setStore(array, newStore);
@@ -149,7 +149,7 @@ public void appendOneGeneralizeGeneric(DynamicObject array, ArrayMirror storeMir
final int oldSize = Layouts.ARRAY.getSize(array);
final int newSize = oldSize + 1;
final int oldCapacity = storeMirror.getLength();
final int newCapacity = newSize > oldCapacity ? ArrayUtils.capacityForOneMore(storeMirror.getLength()) : oldCapacity;
final int newCapacity = newSize > oldCapacity ? ArrayUtils.capacityForOneMore(getContext(), storeMirror.getLength()) : oldCapacity;
Object[] newStore = storeMirror.getBoxedCopy(newCapacity);
newStore[oldSize] = value;
Layouts.ARRAY.setStore(array, newStore);
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ public Object appendValue(Object store, int index, Object value) {
Object[] storeArray = (Object[]) store;

if (index >= storeArray.length) {
storeArray = ArrayUtils.grow(storeArray, ArrayUtils.capacity(storeArray.length, index + 1));
storeArray = ArrayUtils.grow(storeArray, ArrayUtils.capacity(getContext(), storeArray.length, index + 1));
}

storeArray[index] = value;
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ public boolean ensureCapacityInt(DynamicObject array, int requiredCapacity) {
final int[] store = (int[]) Layouts.ARRAY.getStore(array);

if (allocateProfile.profile(store.length < requiredCapacity)) {
Layouts.ARRAY.setStore(array, Arrays.copyOf(store, ArrayUtils.capacity(store.length, requiredCapacity)));
Layouts.ARRAY.setStore(array, Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity)));
Layouts.ARRAY.setSize(array, Layouts.ARRAY.getSize(array));
return true;
} else {
@@ -55,7 +55,7 @@ public boolean ensureCapacityLong(DynamicObject array, int requiredCapacity) {
final long[] store = (long[]) Layouts.ARRAY.getStore(array);

if (allocateProfile.profile(store.length < requiredCapacity)) {
Layouts.ARRAY.setStore(array, Arrays.copyOf(store, ArrayUtils.capacity(store.length, requiredCapacity)));
Layouts.ARRAY.setStore(array, Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity)));
Layouts.ARRAY.setSize(array, Layouts.ARRAY.getSize(array));
return true;
} else {
@@ -68,7 +68,7 @@ public boolean ensureCapacityDouble(DynamicObject array, int requiredCapacity) {
final double[] store = (double[]) Layouts.ARRAY.getStore(array);

if (allocateProfile.profile(store.length < requiredCapacity)) {
Layouts.ARRAY.setStore(array, Arrays.copyOf(store, ArrayUtils.capacity(store.length, requiredCapacity)));
Layouts.ARRAY.setStore(array, Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity)));
Layouts.ARRAY.setSize(array, Layouts.ARRAY.getSize(array));
return true;
} else {
@@ -81,7 +81,7 @@ public boolean ensureCapacityObject(DynamicObject array, int requiredCapacity) {
final Object[] store = (Object[]) Layouts.ARRAY.getStore(array);

if (allocateProfile.profile(store.length < requiredCapacity)) {
Layouts.ARRAY.setStore(array, ArrayUtils.grow(store, ArrayUtils.capacity(store.length, requiredCapacity)));
Layouts.ARRAY.setStore(array, ArrayUtils.grow(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity)));
Layouts.ARRAY.setSize(array, Layouts.ARRAY.getSize(array));
return true;
} else {
Original file line number Diff line number Diff line change
@@ -42,21 +42,21 @@ public DynamicObject generalizeNull(DynamicObject array, int requiredCapacity) {
@Specialization(guards = "isIntArray(array)")
public DynamicObject generalizeInt(DynamicObject array, int requiredCapacity) {
final int[] store = (int[]) Layouts.ARRAY.getStore(array);
Layouts.ARRAY.setStore(array, ArrayUtils.boxExtra(store, ArrayUtils.capacity(store.length, requiredCapacity) - store.length));
Layouts.ARRAY.setStore(array, ArrayUtils.boxExtra(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity) - store.length));
return array;
}

@Specialization(guards = "isLongArray(array)")
public DynamicObject generalizeLong(DynamicObject array, int requiredCapacity) {
final long[] store = (long[]) Layouts.ARRAY.getStore(array);
Layouts.ARRAY.setStore(array, ArrayUtils.boxExtra(store, ArrayUtils.capacity(store.length, requiredCapacity) - store.length));
Layouts.ARRAY.setStore(array, ArrayUtils.boxExtra(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity) - store.length));
return array;
}

@Specialization(guards = "isDoubleArray(array)")
public DynamicObject generalizeDouble(DynamicObject array, int requiredCapacity) {
final double[] store = (double[]) Layouts.ARRAY.getStore(array);
Layouts.ARRAY.setStore(array, ArrayUtils.boxExtra(store, ArrayUtils.capacity(store.length, requiredCapacity) - store.length));
Layouts.ARRAY.setStore(array, ArrayUtils.boxExtra(store, ArrayUtils.capacity(getContext(), store.length, requiredCapacity) - store.length));
return array;
}

48 changes: 23 additions & 25 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -45,24 +45,22 @@
import org.jruby.truffle.core.coerce.ToAryNodeGen;
import org.jruby.truffle.core.coerce.ToIntNode;
import org.jruby.truffle.core.coerce.ToIntNodeGen;
import org.jruby.truffle.core.format.parser.PackCompiler;
import org.jruby.truffle.core.format.runtime.PackResult;
import org.jruby.truffle.core.format.runtime.exceptions.CantCompressNegativeException;
import org.jruby.truffle.core.format.runtime.exceptions.CantConvertException;
import org.jruby.truffle.core.format.runtime.exceptions.NoImplicitConversionException;
import org.jruby.truffle.core.format.runtime.exceptions.OutsideOfStringException;
import org.jruby.truffle.core.format.runtime.exceptions.PackException;
import org.jruby.truffle.core.format.runtime.exceptions.RangeException;
import org.jruby.truffle.core.format.runtime.exceptions.TooFewArgumentsException;
import org.jruby.truffle.core.format.pack.PackCompiler;
import org.jruby.truffle.core.format.BytesResult;
import org.jruby.truffle.core.format.exceptions.CantCompressNegativeException;
import org.jruby.truffle.core.format.exceptions.CantConvertException;
import org.jruby.truffle.core.format.exceptions.NoImplicitConversionException;
import org.jruby.truffle.core.format.exceptions.OutsideOfStringException;
import org.jruby.truffle.core.format.exceptions.PackException;
import org.jruby.truffle.core.format.exceptions.RangeException;
import org.jruby.truffle.core.format.exceptions.TooFewArgumentsException;
import org.jruby.truffle.core.kernel.KernelNodes;
import org.jruby.truffle.core.kernel.KernelNodesFactory;
import org.jruby.truffle.core.numeric.FixnumLowerNodeGen;
import org.jruby.truffle.core.proc.ProcNodes;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeNodes;
import org.jruby.truffle.core.rope.RopeNodesFactory;
import org.jruby.truffle.core.rope.ValidLeafRope;
import org.jruby.truffle.core.string.StringCachingGuards;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.NotProvided;
@@ -2404,10 +2402,10 @@ public DynamicObject packCached(
@Cached("privatizeRope(format)") Rope cachedFormat,
@Cached("ropeLength(cachedFormat)") int cachedFormatLength,
@Cached("create(compileFormat(format))") DirectCallNode callPackNode) {
final PackResult result;
final BytesResult result;

try {
result = (PackResult) callPackNode.call(frame, new Object[] { getStore(array), getSize(array) });
result = (BytesResult) callPackNode.call(frame, new Object[] { getStore(array), getSize(array) });
} catch (PackException e) {
CompilerDirectives.transferToInterpreter();
throw handleException(e);
@@ -2422,10 +2420,10 @@ public DynamicObject packUncached(
DynamicObject array,
DynamicObject format,
@Cached("create()") IndirectCallNode callPackNode) {
final PackResult result;
final BytesResult result;

try {
result = (PackResult) callPackNode.call(frame, compileFormat(format), new Object[] { getStore(array), getSize(array) });
result = (BytesResult) callPackNode.call(frame, compileFormat(format), new Object[] { getStore(array), getSize(array) });
} catch (PackException e) {
CompilerDirectives.transferToInterpreter();
throw handleException(e);
@@ -2452,7 +2450,7 @@ private RuntimeException handleException(PackException exception) {
}
}

private DynamicObject finishPack(int formatLength, PackResult result) {
private DynamicObject finishPack(int formatLength, BytesResult result) {
byte[] bytes = (byte[]) result.getOutput();
if (bytes.length != result.getOutputLength()) {
bytes = Arrays.copyOf(bytes, result.getOutputLength());
@@ -2930,7 +2928,7 @@ public DynamicObject pushIntegerFixnumSingleIntegerFixnum(DynamicObject array, i

if (store.length < newSize) {
extendBranch.enter();
store = Arrays.copyOf(store, ArrayUtils.capacity(store.length, newSize));
store = Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, newSize));
}

store[oldSize] = value;
@@ -2948,7 +2946,7 @@ public DynamicObject pushIntegerFixnumSingleOther(DynamicObject array, Object va

if (oldStore.length < newSize) {
extendBranch.enter();
store = ArrayUtils.boxExtra(oldStore, ArrayUtils.capacity(oldStore.length, newSize) - oldStore.length);
store = ArrayUtils.boxExtra(oldStore, ArrayUtils.capacity(getContext(), oldStore.length, newSize) - oldStore.length);
} else {
store = ArrayUtils.box(oldStore);
}
@@ -2970,7 +2968,7 @@ public DynamicObject pushIntegerFixnum(VirtualFrame frame, DynamicObject array,

if (oldStore.length < newSize) {
extendBranch.enter();
store = ArrayUtils.boxExtra(oldStore, ArrayUtils.capacity(oldStore.length, newSize) - oldStore.length);
store = ArrayUtils.boxExtra(oldStore, ArrayUtils.capacity(getContext(), oldStore.length, newSize) - oldStore.length);
} else {
store = ArrayUtils.box(oldStore);
}
@@ -2992,7 +2990,7 @@ public DynamicObject pushLongFixnumSingleIntegerFixnum(DynamicObject array, int

if (store.length < newSize) {
extendBranch.enter();
store = Arrays.copyOf(store, ArrayUtils.capacity(store.length, newSize));
store = Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, newSize));
}

store[oldSize] = (long) value;
@@ -3009,7 +3007,7 @@ public DynamicObject pushLongFixnumSingleLongFixnum(DynamicObject array, long va

if (store.length < newSize) {
extendBranch.enter();
store = Arrays.copyOf(store, ArrayUtils.capacity(store.length, newSize));
store = Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, newSize));
}

store[oldSize] = value;
@@ -3040,7 +3038,7 @@ public DynamicObject pushObject(VirtualFrame frame, DynamicObject array, Object

if (store.length < newSize) {
extendBranch.enter();
store = ArrayUtils.grow(store, ArrayUtils.capacity(store.length, newSize));
store = ArrayUtils.grow(store, ArrayUtils.capacity(getContext(), store.length, newSize));
}
;
for (int n = 0; n < values.length; n++) {
@@ -3078,7 +3076,7 @@ public DynamicObject pushIntegerFixnumIntegerFixnum(DynamicObject array, int val

if (store.length < newSize) {
extendBranch.enter();
Object store1 = store = Arrays.copyOf(store, ArrayUtils.capacity(store.length, newSize));
Object store1 = store = Arrays.copyOf(store, ArrayUtils.capacity(getContext(), store.length, newSize));
setStoreAndSize(array, store1, getSize(array));
}

@@ -3097,7 +3095,7 @@ public DynamicObject pushIntegerFixnumObject(DynamicObject array, Object value)

if (oldStore.length < newSize) {
extendBranch.enter();
newStore = ArrayUtils.boxExtra(oldStore, ArrayUtils.capacity(oldStore.length, newSize) - oldStore.length);
newStore = ArrayUtils.boxExtra(oldStore, ArrayUtils.capacity(getContext(), oldStore.length, newSize) - oldStore.length);
} else {
newStore = ArrayUtils.box(oldStore);
}
@@ -3116,7 +3114,7 @@ public DynamicObject pushObjectObject(DynamicObject array, Object value) {

if (store.length < newSize) {
extendBranch.enter();
Object store1 = store = ArrayUtils.grow(store, ArrayUtils.capacity(store.length, newSize));
Object store1 = store = ArrayUtils.grow(store, ArrayUtils.capacity(getContext(), store.length, newSize));
setStoreAndSize(array, store1, getSize(array));
}

Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.core.array;

import com.oracle.truffle.api.CompilerAsserts;
import org.jruby.truffle.RubyContext;

import java.lang.reflect.Array;
import java.util.Arrays;
@@ -356,17 +357,15 @@ public static long[] longCopyOf(int[] ints, int newLength) {
return longs;
}

private static final int INITIAL_CAPACITY = 16;

public static int capacity(int current, int needed) {
public static int capacity(RubyContext context, int current, int needed) {
if (needed == 0) {
return 0;
}

assert current < needed;

if (needed < INITIAL_CAPACITY) {
return INITIAL_CAPACITY;
if (needed < context.getOptions().ARRAY_UNINITIALIZED_SIZE) {
return context.getOptions().ARRAY_UNINITIALIZED_SIZE;
} else {
final int newCapacity = current << 1;
if (newCapacity >= needed) {
@@ -377,9 +376,9 @@ public static int capacity(int current, int needed) {
}
}

public static int capacityForOneMore(int current) {
if (current < INITIAL_CAPACITY) {
return INITIAL_CAPACITY;
public static int capacityForOneMore(RubyContext context, int current) {
if (current < context.getOptions().ARRAY_UNINITIALIZED_SIZE) {
return context.getOptions().ARRAY_UNINITIALIZED_SIZE;
} else {
return current << 1;
}
Original file line number Diff line number Diff line change
@@ -7,20 +7,20 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.runtime;
package org.jruby.truffle.core.format;

import org.jruby.truffle.core.rope.CodeRange;

public class PackResult {
public class BytesResult {

private final Object output;
private final int outputLength;
private final int stringLength;
private final CodeRange stringCodeRange;
private final boolean tainted;
private final PackEncoding encoding;
private final FormatEncoding encoding;

public PackResult(Object output, int outputLength, int stringLength, CodeRange stringCodeRange, boolean tainted, PackEncoding encoding) {
public BytesResult(Object output, int outputLength, int stringLength, CodeRange stringCodeRange, boolean tainted, FormatEncoding encoding) {
this.output = output;
this.outputLength = outputLength;
this.stringLength = stringLength;
@@ -49,7 +49,7 @@ public boolean isTainted() {
return tainted;
}

public PackEncoding getEncoding() {
public FormatEncoding getEncoding() {
return encoding;
}
}
Original file line number Diff line number Diff line change
@@ -7,15 +7,15 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.runtime;
package org.jruby.truffle.core.format;

/**
* The encoding to be used for the string resulting from pack.
* <p>
* We use this enum as the range of encodings possible are very limited and
* we want to abstracted between JRuby's pack and Truffle's pack.
*/
public enum PackEncoding {
public enum FormatEncoding {
DEFAULT,
ASCII_8BIT,
US_ASCII,
@@ -26,7 +26,7 @@ public enum PackEncoding {
* another encoding, give us the encoding that we should use for the result
* of pack.
*/
public PackEncoding unifyWith(PackEncoding other) {
public FormatEncoding unifyWith(FormatEncoding other) {
if (this == DEFAULT) {
return other;
}
Loading