Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v0.42) Add an additional param to SH_CompositeCacheImpl::reset() #18549

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions runtime/shared_common/CacheMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ SH_CacheMap::readCache(J9VMThread* currentThread, SH_CompositeCacheImpl* cache,

/* THREADING: MUST be protected by cache write mutex - therefore single-threaded within this JVM */
IDATA
SH_CacheMap::checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex)
SH_CacheMap::checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex, bool canUnlockCache)
{
IDATA rc = 0;
PORT_ACCESS_FROM_PORT(_portlib);
Expand All @@ -1235,7 +1235,7 @@ SH_CacheMap::checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex)
if (resetAllManagers(currentThread) != 0) {
return -1;
}
_cc->reset(currentThread);
_cc->reset(currentThread, canUnlockCache);
rc = refreshHashtables(currentThread, hasClassSegmentMutex);
}
return rc;
Expand Down Expand Up @@ -1567,7 +1567,7 @@ SH_CacheMap::addClasspathToCache(J9VMThread* currentThread, ClasspathItem* obj)
* @return the number of items read, or -1 on error
*/
IDATA
SH_CacheMap::runEntryPointChecks(J9VMThread* currentThread, void* address, const char** p_subcstr)
SH_CacheMap::runEntryPointChecks(J9VMThread* currentThread, void* address, const char** p_subcstr, bool canUnlockCache)
{
bool hasClassSegmentMutex = false;
IDATA itemsAdded;
Expand Down Expand Up @@ -1600,7 +1600,7 @@ SH_CacheMap::runEntryPointChecks(J9VMThread* currentThread, void* address, const
if (!_ccHead->isRunningReadOnly()) {
if (_ccHead->hasWriteMutex(currentThread)) {
/* Can only call this function if we have the write mutex */
rc = checkForCrash(currentThread, hasClassSegmentMutex);
rc = checkForCrash(currentThread, hasClassSegmentMutex, canUnlockCache);
if(rc < 0) {
Trc_SHR_CM_runEntryPointChecks_Exit_Failed4(currentThread);
return rc;
Expand Down Expand Up @@ -2975,7 +2975,7 @@ SH_CacheMap::updateROMClassResource(J9VMThread* currentThread, const void* addre
}
hasWriteMutex = true;

if (runEntryPointChecks(currentThread, (void*)addressInCache, p_subcstr) == -1) {
if (runEntryPointChecks(currentThread, (void*)addressInCache, p_subcstr, false) == -1) {
Trc_SHR_CM_updateROMClassResource_Exit3(currentThread);
result = J9SHR_RESOURCE_STORE_ERROR;
break;
Expand Down Expand Up @@ -4410,7 +4410,7 @@ SH_CacheMap::markStale(J9VMThread* currentThread, ClasspathEntryItem* cpei, bool
currentThread->omrVMThread->vmState = J9VMSTATE_SHAREDCLASS_MARKSTALE;
while (retryCount < MARK_STALE_RETRY_TIMES) {
if (hasWriteMutex || (_ccHead->enterWriteMutex(currentThread, true,fnName)==0)) { /* true = lockCache */
if (runEntryPointChecks(currentThread, NULL, NULL) == -1) {
if (runEntryPointChecks(currentThread, NULL, NULL, false) == -1) {
if (!hasWriteMutex) {
_ccHead->exitWriteMutex(currentThread, fnName); /* Will unlock cache */
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/shared_common/CacheMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class SH_CacheMap : public SH_SharedCache, public SH_CacheMapStats

bool isCacheCorruptReported(void);

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

void protectPartiallyFilledPages(J9VMThread *currentThread);

Expand Down Expand Up @@ -364,7 +364,7 @@ class SH_CacheMap : public SH_SharedCache, public SH_CacheMapStats

UDATA initializeROMSegmentList(J9VMThread* currentThread);

IDATA checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex);
IDATA checkForCrash(J9VMThread* currentThread, bool hasClassSegmentMutex, bool canUnlockCache = true);

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

Expand Down
8 changes: 5 additions & 3 deletions runtime/shared_common/CompositeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ SH_CompositeCacheImpl::crashDetected(UDATA* localCrashCntr)
* @param [in] currentThread Pointer to J9VMThread structure for the current thread
*/
void
SH_CompositeCacheImpl::reset(J9VMThread* currentThread)
SH_CompositeCacheImpl::reset(J9VMThread* currentThread, bool canUnlockCache)
{
if (!_started) {
Trc_SHR_Assert_ShouldNeverHappen();
Expand All @@ -475,8 +475,10 @@ SH_CompositeCacheImpl::reset(J9VMThread* currentThread)
_maxAOTUnstoredBytes = 0;
_maxJITUnstoredBytes = 0;

/* If cache is locked, unlock it */
doUnlockCache(currentThread);
if (canUnlockCache) {
/* If cache is locked, unlock it */
doUnlockCache(currentThread);
}

Trc_SHR_CC_reset_Exit(currentThread);
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/shared_common/CompositeCacheImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class SH_CompositeCacheImpl : public SH_CompositeCache, public AbstractMemoryPer

bool crashDetected(UDATA* localCrashCntr);

void reset(J9VMThread* currentThread);
void reset(J9VMThread* currentThread, bool canUnlockCache = true);

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

Expand Down