9
9
*/
10
10
package org .truffleruby .core .array ;
11
11
12
- import static org .truffleruby .core .array .ArrayHelpers .setSize ;
13
- import static org .truffleruby .core .array .ArrayHelpers .setStoreAndSize ;
14
12
import static org .truffleruby .language .dispatch .DispatchConfiguration .PUBLIC ;
15
13
16
14
import java .util .Arrays ;
@@ -473,7 +471,7 @@ public abstract static class ClearNode extends ArrayCoreMethodNode {
473
471
@ Specialization
474
472
RubyArray clear (RubyArray array ,
475
473
@ Cached IsSharedNode isSharedNode ) {
476
- setStoreAndSize (array ,
474
+ array . setStoreAndSize (
477
475
ArrayStoreLibrary .initialStorage (isSharedNode .execute (this , array )),
478
476
0 );
479
477
return array ;
@@ -571,7 +569,7 @@ Object compactObjects(RubyArray array,
571
569
572
570
stores .clear (oldStore , m , size - m );
573
571
574
- setStoreAndSize (array , newStore , m );
572
+ array . setStoreAndSize (newStore , m );
575
573
576
574
if (m == size ) {
577
575
return nil ;
@@ -738,7 +736,7 @@ private Object delete(RubyArray array, Object value, Object maybeBlock,
738
736
if (sameStores ) {
739
737
oldStores .clear (oldStore , i , size - i );
740
738
}
741
- setStoreAndSize (array , newStore , i );
739
+ array . setStoreAndSize (newStore , i );
742
740
return found ;
743
741
} else {
744
742
if (maybeBlock == nil ) {
@@ -780,14 +778,14 @@ static Object doDelete(RubyArray array, Object indexObject,
780
778
final Object value = stores .read (store , i );
781
779
stores .copyContents (store , i + 1 , store , i , size - i - 1 );
782
780
stores .clear (store , size - 1 , 1 );
783
- setStoreAndSize (array , store , size - 1 );
781
+ array . setStoreAndSize (store , size - 1 );
784
782
return value ;
785
783
} else {
786
784
final Object mutableStore = stores .allocator (store ).allocate (size - 1 );
787
785
stores .copyContents (store , 0 , mutableStore , 0 , i );
788
786
final Object value = stores .read (store , i );
789
787
stores .copyContents (store , i + 1 , mutableStore , i , size - i - 1 );
790
- setStoreAndSize (array , mutableStore , size - 1 );
788
+ array . setStoreAndSize (mutableStore , size - 1 );
791
789
return value ;
792
790
}
793
791
}
@@ -1121,7 +1119,7 @@ protected abstract RubyArray executeInitialize(RubyArray array, Object size, Obj
1121
1119
@ Specialization
1122
1120
RubyArray initializeNoArgs (RubyArray array , NotProvided size , NotProvided fillingValue , Nil block ,
1123
1121
@ Cached @ Shared IsSharedNode isSharedNode ) {
1124
- setStoreAndSize (array ,
1122
+ array . setStoreAndSize (
1125
1123
ArrayStoreLibrary .initialStorage (isSharedNode .execute (this , array )),
1126
1124
0 );
1127
1125
return array ;
@@ -1136,7 +1134,7 @@ RubyArray initializeOnlyBlock(RubyArray array, NotProvided size, NotProvided fil
1136
1134
warningNode .warningMessage (sourceSection , "given block not used" );
1137
1135
}
1138
1136
1139
- setStoreAndSize (array ,
1137
+ array . setStoreAndSize (
1140
1138
ArrayStoreLibrary .initialStorage (isSharedNode .execute (this , array )),
1141
1139
0 );
1142
1140
return array ;
@@ -1174,7 +1172,7 @@ RubyArray initializeWithSizeNoValue(RubyArray array, int size, NotProvided filli
1174
1172
store = new Object [size ];
1175
1173
}
1176
1174
stores .fill (store , 0 , size , nil );
1177
- setStoreAndSize (array , store , size );
1175
+ array . setStoreAndSize (store , size );
1178
1176
return array ;
1179
1177
}
1180
1178
@@ -1199,7 +1197,7 @@ RubyArray initializeWithSizeAndValue(RubyArray array, int size, Object fillingVa
1199
1197
profileAndReportLoopCount (loopProfile , i );
1200
1198
}
1201
1199
}
1202
- setStoreAndSize (array , allocatedStore , size );
1200
+ array . setStoreAndSize (allocatedStore , size );
1203
1201
return array ;
1204
1202
}
1205
1203
@@ -1236,7 +1234,7 @@ static Object initializeBlock(RubyArray array, int size, Object unusedFillingVal
1236
1234
if (isSharedNode .execute (node , array )) {
1237
1235
store = stores .makeShared (store , n );
1238
1236
}
1239
- setStoreAndSize (array , store , n );
1237
+ array . setStoreAndSize (store , n );
1240
1238
}
1241
1239
1242
1240
return array ;
@@ -1688,7 +1686,7 @@ RubyArray popNotEmptySharedStorage(RubyArray array, int n,
1688
1686
final Object prefix = stores .extractRange (store , 0 , size - numPop ); // copy on write
1689
1687
// NOTE(norswap): if one of these two arrays outlives the other, you get a memory leak
1690
1688
1691
- setStoreAndSize (array , prefix , size - numPop );
1689
+ array . setStoreAndSize (prefix , size - numPop );
1692
1690
return createArray (popped , numPop );
1693
1691
}
1694
1692
@@ -1709,7 +1707,7 @@ RubyArray popNotEmptyUnsharedStorage(RubyArray array, int n,
1709
1707
1710
1708
// Remove the end from the original array.
1711
1709
stores .clear (store , size - numPop , numPop );
1712
- setSize (array , size - numPop );
1710
+ array . setSize (size - numPop );
1713
1711
1714
1712
return createArray (popped , numPop );
1715
1713
}
@@ -1837,7 +1835,7 @@ RubyArray replace(RubyArray array, Object otherObject,
1837
1835
if (isSharedNode .execute (this , array )) {
1838
1836
store = stores .makeShared (store , size );
1839
1837
}
1840
- setStoreAndSize (array , store , size );
1838
+ array . setStoreAndSize (store , size );
1841
1839
return array ;
1842
1840
}
1843
1841
@@ -1922,7 +1920,7 @@ RubyArray rotateStorageNotMutable(RubyArray array, int rotation,
1922
1920
1923
1921
final Object rotated = stores .allocator (store ).allocate (size );
1924
1922
rotateArrayCopy (rotation , size , stores , store , rotated );
1925
- setStoreAndSize (array , rotated , size );
1923
+ array . setStoreAndSize (rotated , size );
1926
1924
return array ;
1927
1925
}
1928
1926
@@ -2042,7 +2040,7 @@ Object shiftOther(RubyArray array, NotProvided n,
2042
2040
final int size = array .size ;
2043
2041
final Object value = stores .read (store , 0 );
2044
2042
stores .clear (store , 0 , 1 );
2045
- setStoreAndSize (array , stores .extractRange (store , 1 , size ), size - 1 );
2043
+ array . setStoreAndSize (stores .extractRange (store , 1 , size ), size - 1 );
2046
2044
return value ;
2047
2045
}
2048
2046
@@ -2074,7 +2072,7 @@ Object shiftMany(RubyArray array, int n,
2074
2072
final int numShift = minProfile .profile (size < n ) ? size : n ;
2075
2073
final Object result = stores .extractRangeAndUnshare (store , 0 , numShift );
2076
2074
final Object newStore = stores .extractRange (store , numShift , size );
2077
- setStoreAndSize (array , newStore , size - numShift );
2075
+ array . setStoreAndSize (newStore , size - numShift );
2078
2076
return createArray (result , numShift );
2079
2077
}
2080
2078
@@ -2238,8 +2236,8 @@ static RubyArray stealStorage(RubyArray array, RubyArray other,
2238
2236
2239
2237
final int size = other .size ;
2240
2238
final Object store = other .getStore ();
2241
- setStoreAndSize (array , store , size );
2242
- setStoreAndSize (other , stores .initialStore (store ), 0 );
2239
+ array . setStoreAndSize (store , size );
2240
+ other . setStoreAndSize (stores .initialStore (store ), 0 );
2243
2241
2244
2242
return array ;
2245
2243
}
0 commit comments