Skip to content

Commit

Permalink
Use a wider type for local variables holding the cache line size
Browse files Browse the repository at this point in the history
This allows the compiler to do the widening operation once,
rather than repeatedly in loops, fixing a performance regression
introduced in eclipse#6515.

Signed-off-by: Keith W. Campbell <[email protected]>
  • Loading branch information
keithc-ca committed Jun 23, 2022
1 parent 8b620b8 commit 8ca8d51
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 8ca8d51

Please sign in to comment.