Skip to content

Commit 78e9e03

Browse files
committed
Fix a couple more sharing errors found in CI.
1 parent 8439596 commit 78e9e03

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/org/truffleruby/core/array/ArrayNodes.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,12 @@ protected int normalize(int arraySize, int index,
477477
public abstract static class ClearNode extends ArrayCoreMethodNode {
478478

479479
@Specialization
480-
protected RubyArray clear(RubyArray array) {
481-
setStoreAndSize(array, ArrayStoreLibrary.initialStorage(false), 0);
480+
protected RubyArray clear(RubyArray array,
481+
@Cached IsSharedNode isSharedNode,
482+
@Cached ConditionProfile sharedProfile) {
483+
setStoreAndSize(array,
484+
ArrayStoreLibrary.initialStorage(sharedProfile.profile(isSharedNode.executeIsShared(array))),
485+
0);
482486
return array;
483487
}
484488

@@ -1723,7 +1727,7 @@ protected RubyArray popNotEmptyUnsharedStorage(RubyArray array, int n,
17231727
final int numPop = minProfile.profile(size < n) ? size : n;
17241728

17251729
// Extract values in a new array
1726-
final Object popped = stores.allocator(store).allocate(numPop);
1730+
final Object popped = stores.unsharedAllocator(store).allocate(numPop);
17271731
stores.copyContents(store, size - numPop, popped, 0, numPop);
17281732

17291733
// Remove the end from the original array.

0 commit comments

Comments
 (0)