Skip to content

Commit

Permalink
Merge pull request eclipse-omr#6587 from keithc-ca/wide
Browse files Browse the repository at this point in the history
Use a wider type for local variables holding the cache line size
  • Loading branch information
0xdaryl authored Jun 23, 2022
2 parents 342963c + 13146da commit 1d10df8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion port/unix/omrcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void
omrcpu_flush_icache(struct OMRPortLibrary *portLibrary, void *memoryPointer, uintptr_t byteAmount)
{
#if defined(LINUXPPC) || defined(PPC) || defined(RS6000)
uint32_t cacheLineSize = PPG_mem_ppcCacheLineSize;
uintptr_t cacheLineSize = PPG_mem_ppcCacheLineSize;
unsigned char *addr = NULL;
unsigned char *limit = (unsigned char *)
(((uintptr_t)memoryPointer + byteAmount + (cacheLineSize - 1))
Expand Down
9 changes: 5 additions & 4 deletions util/omrutil/j9memclr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ OMRZeroMemory(void *ptr, uintptr_t length)
}
#endif /* defined(LINUXPPC) */

uintptr_t localCacheLineSize = cacheLineSize;

/* one-time-only calculation of cache line size */
if (0 == cacheLineSize) {
cacheLineSize = getCacheLineSize();
if (0 == localCacheLineSize) {
localCacheLineSize = getCacheLineSize();
cacheLineSize = localCacheLineSize;
}

uint32_t localCacheLineSize = cacheLineSize;

/* Zeroing by dcbz is effective if requested length is at least twice larger then Data Cache Block size */
if (length < (2 * localCacheLineSize)) {
memset(ptr, 0, (size_t)length);
Expand Down

0 comments on commit 1d10df8

Please sign in to comment.