Skip to content

Commit 022b62c

Browse files
committed
[GR-32949] Add missing TruffleSafepoint.poll()
PullRequest: truffleruby/2868
2 parents 7969535 + d900c6d commit 022b62c

26 files changed

+132
-95
lines changed

mx.truffleruby/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"name": "regex",
99
"subdir": True,
10-
"version": "c7604b7fd48cc8c3509cf215cd5e268748a81d85",
10+
"version": "86651e3bf6af2662ada38eccdf1f5ebe632d30db",
1111
"urls": [
1212
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
1313
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -16,7 +16,7 @@
1616
{
1717
"name": "sulong",
1818
"subdir": True,
19-
"version": "c7604b7fd48cc8c3509cf215cd5e268748a81d85",
19+
"version": "86651e3bf6af2662ada38eccdf1f5ebe632d30db",
2020
"urls": [
2121
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
2222
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},

src/main/java/org/truffleruby/cext/UnwrapNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static org.truffleruby.cext.ValueWrapperManager.UNDEF_HANDLE;
1515

1616
import com.oracle.truffle.api.CompilerDirectives;
17+
import com.oracle.truffle.api.TruffleSafepoint;
1718
import com.oracle.truffle.api.dsl.Bind;
1819
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
1920
import com.oracle.truffle.api.nodes.ExplodeLoop;
@@ -224,6 +225,7 @@ protected Object[] unwrapCArray(Object cArray,
224225
for (; loopProfile.inject(i < size); i++) {
225226
final Object cValue = readArrayElement(cArray, interop, i);
226227
store[i] = unwrapNode.execute(cValue);
228+
TruffleSafepoint.poll(this);
227229
}
228230
} finally {
229231
profileAndReportLoopCount(loopProfile, i);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package org.truffleruby.core.array;
1111

12+
import com.oracle.truffle.api.TruffleSafepoint;
1213
import com.oracle.truffle.api.profiles.LoopConditionProfile;
1314
import org.truffleruby.core.array.library.ArrayStoreLibrary;
1415
import org.truffleruby.language.RubyBaseNode;
@@ -69,6 +70,7 @@ protected void copy(RubyArray dst, RubyArray src, int dstStart, int srcStart, in
6970
for (; loopProfile.inject(i < length); ++i) {
7071
writeBarrierNode.executeWriteBarrier(stores.read(srcStore, i));
7172
}
73+
TruffleSafepoint.poll(this);
7274
} finally {
7375
profileAndReportLoopCount(loopProfile, i);
7476
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package org.truffleruby.core.array;
1111

12+
import com.oracle.truffle.api.TruffleSafepoint;
1213
import org.truffleruby.core.array.library.ArrayStoreLibrary;
1314
import org.truffleruby.core.proc.RubyProc;
1415
import org.truffleruby.language.RubyBaseNode;
@@ -73,6 +74,7 @@ protected RubyArray iterateMany(RubyArray array, RubyProc block, int startAt, Ar
7374
} else {
7475
return getRecurseNode().execute(array, block, i, consumerNode);
7576
}
77+
TruffleSafepoint.poll(this);
7678
}
7779
} finally {
7880
profileAndReportLoopCount(loopProfile, i - startAt);

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.util.Arrays;
1717

18+
import com.oracle.truffle.api.TruffleSafepoint;
1819
import com.oracle.truffle.api.object.Shape;
1920
import com.oracle.truffle.api.profiles.LoopConditionProfile;
2021
import org.graalvm.collections.EconomicSet;
@@ -186,6 +187,7 @@ protected RubyArray mulOther(RubyArray array, int count,
186187
try {
187188
for (; loopProfile.inject(n < count); n++) {
188189
arrays.copyContents(store, 0, newStore, n * size, size);
190+
TruffleSafepoint.poll(this);
189191
}
190192
} finally {
191193
profileAndReportLoopCount(loopProfile, n);
@@ -498,6 +500,7 @@ protected Object compactObjectsNonMutable(RubyArray array,
498500
arrayBuilder.appendValue(state, m, v);
499501
m++;
500502
}
503+
TruffleSafepoint.poll(this);
501504
}
502505
} finally {
503506
profileAndReportLoopCount(loopProfile, n);
@@ -542,6 +545,7 @@ protected Object compactObjectsNonMutable(RubyArray array,
542545
mutableStores.write(newStore, m, v);
543546
m++;
544547
}
548+
TruffleSafepoint.poll(this);
545549
}
546550
} finally {
547551
profileAndReportLoopCount(loopProfile, n);
@@ -628,6 +632,7 @@ protected RubyArray concatManyGeneral(RubyArray array, Object first, Object[] re
628632
} else {
629633
result = appendManyNode.executeAppendMany(array, toAryNode.executeToAry(arg));
630634
}
635+
TruffleSafepoint.poll(this);
631636
}
632637
} finally {
633638
profileAndReportLoopCount(loopProfile, i);
@@ -705,6 +710,7 @@ private Object delete(RubyArray array, Object value, Object maybeBlock,
705710
i++;
706711
n++;
707712
}
713+
TruffleSafepoint.poll(this);
708714
}
709715
} finally {
710716
profileAndReportLoopCount(loopProfile, n);
@@ -875,11 +881,11 @@ protected boolean equalSamePrimitiveType(RubyArray a, RubyArray b,
875881
int i = 0;
876882
try {
877883
for (; loopProfile.inject(i < aSize); i++) {
878-
if (!sameOrEqualNode
879-
.executeSameOrEqual(stores.read(aStore, i), stores.read(bStore, i))) {
884+
if (!sameOrEqualNode.executeSameOrEqual(stores.read(aStore, i), stores.read(bStore, i))) {
880885
falseProfile.enter();
881886
return false;
882887
}
888+
TruffleSafepoint.poll(this);
883889
}
884890
} finally {
885891
profileAndReportLoopCount(loopProfile, i);
@@ -950,6 +956,7 @@ protected boolean eqlSamePrimitiveType(RubyArray a, RubyArray b,
950956
falseProfile.enter();
951957
return false;
952958
}
959+
TruffleSafepoint.poll(this);
953960
}
954961
} finally {
955962
profileAndReportLoopCount(loopProfile, i);
@@ -1003,6 +1010,7 @@ protected RubyArray fill(RubyArray array, Object[] args, Nil block,
10031010
try {
10041011
for (; loopProfile.inject(i < size); i++) {
10051012
stores.write(store, i, value);
1013+
TruffleSafepoint.poll(this);
10061014
}
10071015
} finally {
10081016
profileAndReportLoopCount(loopProfile, i);
@@ -1051,6 +1059,7 @@ protected long hash(VirtualFrame frame, RubyArray array,
10511059
final Object value = stores.read(store, n);
10521060
final long valueHash = toLongNode.execute(toHashNode.call(value, "hash"));
10531061
h = Hashing.update(h, valueHash);
1062+
TruffleSafepoint.poll(this);
10541063
}
10551064
} finally {
10561065
profileAndReportLoopCount(loopProfile, n);
@@ -1081,6 +1090,7 @@ protected boolean include(RubyArray array, Object value,
10811090
if (sameOrEqualNode.executeSameOrEqual(stored, value)) {
10821091
return true;
10831092
}
1093+
TruffleSafepoint.poll(this);
10841094
}
10851095
} finally {
10861096
profileAndReportLoopCount(loopProfile, n);
@@ -1167,6 +1177,7 @@ protected RubyArray initializeWithSizeAndValue(RubyArray array, int size, Object
11671177
try {
11681178
for (; loopProfile.inject(i < size); i++) {
11691179
allocatedStores.write(allocatedStore, i, fillingValue);
1180+
TruffleSafepoint.poll(this);
11701181
}
11711182
} finally {
11721183
profileAndReportLoopCount(loopProfile, i);
@@ -1412,6 +1423,7 @@ public Object injectSymbolHelper(VirtualFrame frame, RubyArray array, String sym
14121423
for (; loopProfile.inject(n < array.size); n++) {
14131424
accumulator = dispatch
14141425
.dispatch(frame, accumulator, symbol, nil, new Object[]{ stores.read(store, n) });
1426+
TruffleSafepoint.poll(this);
14151427
}
14161428
} finally {
14171429
profileAndReportLoopCount(loopProfile, n);
@@ -1700,6 +1712,7 @@ protected RubyArray pushMany(VirtualFrame frame, RubyArray array, Object value,
17001712
try {
17011713
for (; loopProfile.inject(i < rest.length); i++) {
17021714
appendOneNode.executeAppendOne(array, rest[i]);
1715+
TruffleSafepoint.poll(this);
17031716
}
17041717
} finally {
17051718
profileAndReportLoopCount(loopProfile, i);
@@ -1982,6 +1995,7 @@ private void reverse(ArrayStoreLibrary stores,
19821995
stores.write(store, to, tmp);
19831996
from++;
19841997
to--;
1998+
TruffleSafepoint.poll(this);
19851999
}
19862000
} finally {
19872001
profileAndReportLoopCount(loopProfile, loopCount);
@@ -2273,6 +2287,7 @@ protected RubyArray zipToPairs(RubyArray array, RubyArray other,
22732287
} else {
22742288
zipped[n] = createArray(new Object[]{ aStores.read(a, n), nil });
22752289
}
2290+
TruffleSafepoint.poll(this);
22762291
}
22772292
} finally {
22782293
profileAndReportLoopCount(loopProfile, n);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.List;
1515

1616
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
17+
import com.oracle.truffle.api.TruffleSafepoint;
1718
import com.oracle.truffle.api.nodes.Node;
1819
import com.oracle.truffle.api.profiles.LoopConditionProfile;
1920
import org.truffleruby.RubyLanguage;
@@ -241,6 +242,7 @@ public static void fill(Object[] array, int from, int to, Object value, Node nod
241242
try {
242243
for (; loopProfile.inject(i < to); i++) {
243244
array[i] = value;
245+
TruffleSafepoint.poll(node);
244246
}
245247
} finally {
246248
RubyBaseNode.profileAndReportLoopCount(node, loopProfile, i - from);
@@ -264,6 +266,7 @@ public static int memcmp(byte[] first, int firstStart, byte[] second, int second
264266
if (cmp != 0) {
265267
return cmp;
266268
}
269+
TruffleSafepoint.poll(node);
267270
}
268271
} finally {
269272
RubyBaseNode.profileAndReportLoopCount(node, loopProfile, i);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.truffleruby.core.array.ArrayHelpers.setSize;
1313
import static org.truffleruby.core.array.ArrayHelpers.setStoreAndSize;
1414

15+
import com.oracle.truffle.api.TruffleSafepoint;
1516
import com.oracle.truffle.api.profiles.LoopConditionProfile;
1617
import org.truffleruby.core.array.library.ArrayStoreLibrary;
1718
import org.truffleruby.language.RubyBaseNode;
@@ -93,6 +94,7 @@ protected Object writeBeyondPrimitive(RubyArray array, int index, Object value,
9394
try {
9495
for (; loopProfile.inject(n < index); n++) {
9596
newArrays.write(objectStore, n, nil);
97+
TruffleSafepoint.poll(this);
9698
}
9799
} finally {
98100
profileAndReportLoopCount(loopProfile, n - oldSize);
@@ -120,6 +122,7 @@ protected Object writeBeyondObject(RubyArray array, int index, Object value,
120122
try {
121123
for (; loopProfile.inject(n < index); n++) {
122124
newArrays.write(store, n, nil);
125+
TruffleSafepoint.poll(this);
123126
}
124127
} finally {
125128
profileAndReportLoopCount(loopProfile, n - array.size);

src/main/java/org/truffleruby/core/array/library/DelegatedArrayStorage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Set;
1313

1414
import com.oracle.truffle.api.CompilerDirectives;
15+
import com.oracle.truffle.api.TruffleSafepoint;
1516
import com.oracle.truffle.api.dsl.Cached;
1617
import com.oracle.truffle.api.profiles.LoopConditionProfile;
1718
import org.truffleruby.core.array.ArrayGuards;
@@ -92,6 +93,7 @@ protected void copyContents(int srcStart, Object destStore, int destStart, int l
9293
try {
9394
for (; loopProfile.inject(i < length); i++) {
9495
destStores.write(destStore, i + destStart, srcStores.read(storage, srcStart + offset + i));
96+
TruffleSafepoint.poll(destStores);
9597
}
9698
} finally {
9799
RubyBaseNode.profileAndReportLoopCount(node.getNode(), loopProfile, i);

src/main/java/org/truffleruby/core/array/library/DoubleArrayStore.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Iterator;
1515
import java.util.NoSuchElementException;
1616

17+
import com.oracle.truffle.api.TruffleSafepoint;
1718
import com.oracle.truffle.api.dsl.Cached;
1819
import com.oracle.truffle.api.profiles.LoopConditionProfile;
1920
import org.truffleruby.core.array.ArrayGuards;
@@ -125,6 +126,7 @@ protected static void copyContents(double[] srcStore, int srcStart, Object destS
125126
try {
126127
for (; loopProfile.inject(i < length); i++) {
127128
destStores.write(destStore, destStart + i, srcStore[srcStart + i]);
129+
TruffleSafepoint.poll(destStores);
128130
}
129131
} finally {
130132
RubyBaseNode.profileAndReportLoopCount(destStores.getNode(), loopProfile, i);

src/main/java/org/truffleruby/core/array/library/IntegerArrayStore.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Iterator;
1515
import java.util.NoSuchElementException;
1616

17+
import com.oracle.truffle.api.TruffleSafepoint;
1718
import com.oracle.truffle.api.dsl.Cached;
1819
import com.oracle.truffle.api.profiles.LoopConditionProfile;
1920
import org.truffleruby.core.array.ArrayGuards;
@@ -124,6 +125,7 @@ protected static void copyContents(int[] srcStore, int srcStart, Object destStor
124125
try {
125126
for (; loopProfile.inject(i < length); i++) {
126127
destStores.write(destStore, destStart + i, srcStore[srcStart + i]);
128+
TruffleSafepoint.poll(destStores);
127129
}
128130
} finally {
129131
RubyBaseNode.profileAndReportLoopCount(destStores.getNode(), loopProfile, i);

0 commit comments

Comments
 (0)