Skip to content

Commit

Permalink
8263718: unused-result warning happens at os_linux.cpp
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, stuefe
  • Loading branch information
YaSuenag authored and benty-amzn committed Jun 21, 2022
1 parent d8d68ea commit 048b2bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
9 changes: 0 additions & 9 deletions hotspot/src/os/bsd/vm/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,15 +693,6 @@ static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) {

// Thread start routine for all newly created threads
static void *java_start(Thread *thread) {
// Try to randomize the cache line index of hot stack frames.
// This helps when threads of the same stack traces evict each other's
// cache lines. The threads can be either from the same JVM instance, or
// from different JVM instances. The benefit is especially true for
// processors with hyperthreading technology.
static int counter = 0;
int pid = os::current_process_id();
alloca(((pid ^ counter++) & 7) * 128);

ThreadLocalStorage::set_thread(thread);

OSThread* osthread = thread->osthread();
Expand Down
8 changes: 7 additions & 1 deletion hotspot/src/os/linux/vm/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,14 +812,20 @@ static bool _thread_safety_check(Thread* thread) {

// Thread start routine for all newly created threads
static void *java_start(Thread *thread) {
#ifndef __GLIBC__
// Try to randomize the cache line index of hot stack frames.
// This helps when threads of the same stack traces evict each other's
// cache lines. The threads can be either from the same JVM instance, or
// from different JVM instances. The benefit is especially true for
// processors with hyperthreading technology.
// This code is not needed anymore in glibc because it has MULTI_PAGE_ALIASING
// and we did not see any degradation in performance without `alloca()`.
static int counter = 0;
int pid = os::current_process_id();
alloca(((pid ^ counter++) & 7) * 128);
void *stackmem = alloca(((pid ^ counter++) & 7) * 128);
// Ensure the alloca result is used in a way that prevents the compiler from eliding it.
*(char *)stackmem = 1;
#endif

ThreadLocalStorage::set_thread(thread);

Expand Down
9 changes: 0 additions & 9 deletions hotspot/src/os/windows/vm/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,6 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);

// Thread start routine for all new Java threads
static unsigned __stdcall java_start(Thread* thread) {
// Try to randomize the cache line index of hot stack frames.
// This helps when threads of the same stack traces evict each other's
// cache lines. The threads can be either from the same JVM instance, or
// from different JVM instances. The benefit is especially true for
// processors with hyperthreading technology.
static int counter = 0;
int pid = os::current_process_id();
_alloca(((pid ^ counter++) & 7) * 128);

OSThread* osthr = thread->osthread();
assert(osthr->get_state() == RUNNABLE, "invalid os thread state");

Expand Down

0 comments on commit 048b2bf

Please sign in to comment.