@@ -152,6 +152,7 @@ synchronizeWithConcurrentGCScan(J9VMThread *currentThread, j9object_t continuati
152
152
{
153
153
ContinuationState oldContinuationState = 0 ;
154
154
ContinuationState returnContinuationState = 0 ;
155
+
155
156
/* Set pending state and carrier id, GC need to distinguish between fully mounted (don't scan) vs pending to be mounted (do scan) cases. */
156
157
do {
157
158
oldContinuationState = *continuationStatePtr;
@@ -167,10 +168,11 @@ synchronizeWithConcurrentGCScan(J9VMThread *currentThread, j9object_t continuati
167
168
* but only up to small finite number of times.
168
169
*/
169
170
do {
170
- if (VM_ContinuationHelpers::isConcurrentlyScanned (returnContinuationState)) {
171
+ oldContinuationState = *continuationStatePtr;
172
+ if (VM_ContinuationHelpers::isConcurrentlyScanned (oldContinuationState)) {
171
173
omrthread_monitor_enter (currentThread->publicFlagsMutex );
172
174
/* Wait till potentially concurrent GC scans are complete */
173
- do {
175
+ for (;;) {
174
176
oldContinuationState = *continuationStatePtr;
175
177
if (VM_ContinuationHelpers::isConcurrentlyScanned (oldContinuationState)) {
176
178
PUSH_OBJECT_IN_SPECIAL_FRAME (currentThread, continuationObject);
@@ -183,20 +185,21 @@ synchronizeWithConcurrentGCScan(J9VMThread *currentThread, j9object_t continuati
183
185
continuationObject = POP_OBJECT_IN_SPECIAL_FRAME (currentThread);
184
186
/* Object might have moved - update its address and the address of the state slot. */
185
187
continuationStatePtr = VM_ContinuationHelpers::getContinuationStateAddress (currentThread, continuationObject);
186
- continue ;
188
+ } else {
189
+ break ;
187
190
}
188
- } while ( false );
191
+ }
189
192
omrthread_monitor_exit (currentThread->publicFlagsMutex );
190
193
}
191
194
/* Remove pending state */
192
- oldContinuationState = *continuationStatePtr;
193
195
Assert_VM_true (VM_ContinuationHelpers::isMountedWithCarrierThread (oldContinuationState, currentThread));
194
196
Assert_VM_true (VM_ContinuationHelpers::isPendingToBeMounted (oldContinuationState));
195
197
ContinuationState newContinuationState = oldContinuationState;
196
198
VM_ContinuationHelpers::resetPendingState (&newContinuationState);
197
199
returnContinuationState = VM_AtomicSupport::lockCompareExchange (continuationStatePtr, oldContinuationState, newContinuationState);
198
200
} while (oldContinuationState != returnContinuationState);
199
201
Assert_VM_false (VM_ContinuationHelpers::isPendingToBeMounted (*continuationStatePtr));
202
+ Assert_VM_false (VM_ContinuationHelpers::isConcurrentlyScanned (*continuationStatePtr));
200
203
201
204
return continuationObject;
202
205
}
0 commit comments