Skip to content

Commit f1cbc2b

Browse files
[GR-65192] Recurring callback fixes.
PullRequest: graal/21231
2 parents 1ec6caa + dbf5d9c commit f1cbc2b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/RecurringCallbackSupport.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ private void maybeExecuteCallback() {
353353
/*
354354
* Before executing the callback, reset the safepoint requested counter as we
355355
* don't want to trigger another callback execution in the near future.
356+
*
357+
* Recurring callbacks typically execute VM-internal code that performs hardly
358+
* any safepoint checks. We explicitly don't update the recurring callback
359+
* statistics anywhere in this method as this could skew the numbers.
356360
*/
357361
setCounter(SafepointCheckCounter.MAX_VALUE);
358362
try {
@@ -364,7 +368,6 @@ private void maybeExecuteCallback() {
364368
*/
365369
} finally {
366370
lastCallbackExecution = System.nanoTime();
367-
updateStatistics();
368371
}
369372
}
370373
} finally {

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/SafepointCheckCounter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@
6262
*/
6363
public class SafepointCheckCounter {
6464
private static final FastThreadLocalInt valueTL = FastThreadLocalFactory.createInt("SafepointCheckCounter.value").setMaxOffset(FastThreadLocal.FIRST_CACHE_LINE);
65-
/** Can be used to reset the thread-local value after a safepoint. */
66-
static final int MAX_VALUE = Integer.MAX_VALUE;
65+
/**
66+
* Can be used to reset the thread-local value after a safepoint. We explicitly keep some
67+
* distance to {@link Integer#MAX_VALUE} to avoid corner cases.
68+
*/
69+
static final int MAX_VALUE = Integer.MAX_VALUE >>> 1;
6770

6871
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
6972
static boolean compareAndSet(IsolateThread thread, int oldValue, int newValue) {

0 commit comments

Comments
 (0)