Skip to content

Commit 244201c

Browse files
authored
Merge pull request #18548 from hangshao0/FixSCC
Add an additional param to SH_CompositeCacheImpl::reset()
2 parents 7f0fc97 + b4ba140 commit 244201c

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

runtime/shared_common/CacheMap.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ SH_CacheMap::readCache(J9VMThread* currentThread, SH_CompositeCacheImpl* cache,
12211221

12221222
/* THREADING: MUST be protected by cache write mutex - therefore single-threaded within this JVM */
12231223
IDATA
1224-
SH_CacheMap::checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex)
1224+
SH_CacheMap::checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex, bool canUnlockCache)
12251225
{
12261226
IDATA rc = 0;
12271227
PORT_ACCESS_FROM_PORT(_portlib);
@@ -1235,7 +1235,7 @@ SH_CacheMap::checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex)
12351235
if (resetAllManagers(currentThread) != 0) {
12361236
return -1;
12371237
}
1238-
_cc->reset(currentThread);
1238+
_cc->reset(currentThread, canUnlockCache);
12391239
rc = refreshHashtables(currentThread, hasClassSegmentMutex);
12401240
}
12411241
return rc;
@@ -1567,7 +1567,7 @@ SH_CacheMap::addClasspathToCache(J9VMThread* currentThread, ClasspathItem* obj)
15671567
* @return the number of items read, or -1 on error
15681568
*/
15691569
IDATA
1570-
SH_CacheMap::runEntryPointChecks(J9VMThread* currentThread, void* address, const char** p_subcstr)
1570+
SH_CacheMap::runEntryPointChecks(J9VMThread* currentThread, void* address, const char** p_subcstr, bool canUnlockCache)
15711571
{
15721572
bool hasClassSegmentMutex = false;
15731573
IDATA itemsAdded;
@@ -1600,7 +1600,7 @@ SH_CacheMap::runEntryPointChecks(J9VMThread* currentThread, void* address, const
16001600
if (!_ccHead->isRunningReadOnly()) {
16011601
if (_ccHead->hasWriteMutex(currentThread)) {
16021602
/* Can only call this function if we have the write mutex */
1603-
rc = checkForCrash(currentThread, hasClassSegmentMutex);
1603+
rc = checkForCrash(currentThread, hasClassSegmentMutex, canUnlockCache);
16041604
if(rc < 0) {
16051605
Trc_SHR_CM_runEntryPointChecks_Exit_Failed4(currentThread);
16061606
return rc;
@@ -2975,7 +2975,7 @@ SH_CacheMap::updateROMClassResource(J9VMThread* currentThread, const void* addre
29752975
}
29762976
hasWriteMutex = true;
29772977

2978-
if (runEntryPointChecks(currentThread, (void*)addressInCache, p_subcstr) == -1) {
2978+
if (runEntryPointChecks(currentThread, (void*)addressInCache, p_subcstr, false) == -1) {
29792979
Trc_SHR_CM_updateROMClassResource_Exit3(currentThread);
29802980
result = J9SHR_RESOURCE_STORE_ERROR;
29812981
break;
@@ -4410,7 +4410,7 @@ SH_CacheMap::markStale(J9VMThread* currentThread, ClasspathEntryItem* cpei, bool
44104410
currentThread->omrVMThread->vmState = J9VMSTATE_SHAREDCLASS_MARKSTALE;
44114411
while (retryCount < MARK_STALE_RETRY_TIMES) {
44124412
if (hasWriteMutex || (_ccHead->enterWriteMutex(currentThread, true,fnName)==0)) { /* true = lockCache */
4413-
if (runEntryPointChecks(currentThread, NULL, NULL) == -1) {
4413+
if (runEntryPointChecks(currentThread, NULL, NULL, false) == -1) {
44144414
if (!hasWriteMutex) {
44154415
_ccHead->exitWriteMutex(currentThread, fnName); /* Will unlock cache */
44164416
}

runtime/shared_common/CacheMap.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class SH_CacheMap : public SH_SharedCache, public SH_CacheMapStats
265265

266266
bool isCacheCorruptReported(void);
267267

268-
IDATA runEntryPointChecks(J9VMThread* currentThread, void* isAddressInCache, const char** subcstr);
268+
IDATA runEntryPointChecks(J9VMThread* currentThread, void* isAddressInCache, const char** subcstr, bool canUnlockCache = true);
269269

270270
void protectPartiallyFilledPages(J9VMThread *currentThread);
271271

@@ -364,7 +364,7 @@ class SH_CacheMap : public SH_SharedCache, public SH_CacheMapStats
364364

365365
UDATA initializeROMSegmentList(J9VMThread* currentThread);
366366

367-
IDATA checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex);
367+
IDATA checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex, bool canUnlockCache = true);
368368

369369
void reportCorruptCache(J9VMThread* currentThread, SH_CompositeCacheImpl* _ccToUse);
370370

runtime/shared_common/CompositeCache.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ SH_CompositeCacheImpl::crashDetected(UDATA* localCrashCntr)
456456
* @param [in] currentThread Pointer to J9VMThread structure for the current thread
457457
*/
458458
void
459-
SH_CompositeCacheImpl::reset(J9VMThread* currentThread)
459+
SH_CompositeCacheImpl::reset(J9VMThread* currentThread, bool canUnlockCache)
460460
{
461461
if (!_started) {
462462
Trc_SHR_Assert_ShouldNeverHappen();
@@ -475,8 +475,10 @@ SH_CompositeCacheImpl::reset(J9VMThread* currentThread)
475475
_maxAOTUnstoredBytes = 0;
476476
_maxJITUnstoredBytes = 0;
477477

478-
/* If cache is locked, unlock it */
479-
doUnlockCache(currentThread);
478+
if (canUnlockCache) {
479+
/* If cache is locked, unlock it */
480+
doUnlockCache(currentThread);
481+
}
480482

481483
Trc_SHR_CC_reset_Exit(currentThread);
482484
}

runtime/shared_common/CompositeCacheImpl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class SH_CompositeCacheImpl : public SH_CompositeCache, public AbstractMemoryPer
140140

141141
bool crashDetected(UDATA* localCrashCntr);
142142

143-
void reset(J9VMThread* currentThread);
143+
void reset(J9VMThread* currentThread, bool canUnlockCache = true);
144144

145145
BlockPtr nextEntry(J9VMThread* currentThread, UDATA* staleItems);
146146

0 commit comments

Comments
 (0)