Skip to content

Commit

Permalink
Atomically free romToRam hash table and mutex
Browse files Browse the repository at this point in the history
Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Sep 19, 2024
1 parent 5d69d48 commit 8936149
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions runtime/shared_common/shrinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4303,6 +4303,14 @@ j9shr_shutdown(J9JavaVM *vm)
if (config->jclCacheMutex) {
omrthread_monitor_destroy(config->jclCacheMutex);
}

if (compareAndSwapUDATA((uintptr_t *)&config->romToRamHashTable, (uintptr_t)romToRamHashTable, (uintptr_t)NULL)) {
config->romToRamHashTableMutex = NULL;
omrthread_rwmutex_enter_write(romToRamHashTableMutex);
hashTableFree(romToRamHashTable);
omrthread_rwmutex_exit_write(romToRamHashTableMutex);
omrthread_rwmutex_destroy(romToRamHashTableMutex);
}
j9mem_free_memory(config->sharedAPIObject);
j9mem_free_memory(config);

Expand All @@ -4329,16 +4337,6 @@ j9shr_shutdown(J9JavaVM *vm)
if (utfHashTable) {
hashTableFree(utfHashTable);
}
if (NULL != romToRamHashTable) {
omrthread_rwmutex_enter_write(romToRamHashTableMutex);
config->romToRamHashTable = NULL;
config->romToRamHashTableMutex = NULL;
if (romToRamHashTable) {
hashTableFree(romToRamHashTable);
}
omrthread_rwmutex_exit_write(romToRamHashTableMutex);
omrthread_rwmutex_destroy(romToRamHashTableMutex);
}

/* Kill the string farm */

Expand Down

0 comments on commit 8936149

Please sign in to comment.