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