8263718: unused-result warning happens at os_linux.cpp

Reviewed-by: dholmes, stuefe
This commit is contained in:
Yasumasa Suenaga 2021-04-20 05:06:55 +00:00
parent 787908c778
commit f1d4ae6cc9
3 changed files with 7 additions and 21 deletions

View File

@ -546,16 +546,6 @@ objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NU
static void *thread_native_entry(Thread *thread) {
thread->record_stack_base_and_size();
// 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);
thread->initialize_thread_current();
OSThread* osthread = thread->osthread();

View File

@ -663,14 +663,20 @@ static void *thread_native_entry(Thread *thread) {
thread->record_stack_base_and_size();
#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
thread->initialize_thread_current();

View File

@ -519,16 +519,6 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
static unsigned __stdcall thread_native_entry(Thread* thread) {
thread->record_stack_base_and_size();
// 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);
thread->initialize_thread_current();
OSThread* osthr = thread->osthread();