--- old/src/os/windows/vm/os_windows.cpp 2015-11-04 23:03:33.163813527 -0500 +++ new/src/os/windows/vm/os_windows.cpp 2015-11-04 23:03:31.671729440 -0500 @@ -419,6 +419,8 @@ int pid = os::current_process_id(); _alloca(((pid ^ counter++) & 7) * 128); + thread->initialize_thread_current(); + OSThread* osthr = thread->osthread(); assert(osthr->get_state() == RUNNABLE, "invalid os thread state"); @@ -2375,7 +2377,7 @@ address pc = (address) exceptionInfo->ContextRecord->Eip; #endif #endif - Thread* t = ThreadLocalStorage::get_thread_slow(); // slow & steady + Thread* t = Thread::current(); // Handle SafeFetch32 and SafeFetchN exceptions. if (StubRoutines::is_safefetch_fault(pc)) { @@ -4002,27 +4004,6 @@ return result == IDYES; } -int os::allocate_thread_local_storage() { - return TlsAlloc(); -} - - -void os::free_thread_local_storage(int index) { - TlsFree(index); -} - - -void os::thread_local_storage_at_put(int index, void* value) { - TlsSetValue(index, value); - assert(thread_local_storage_at(index) == value, "Just checking"); -} - - -void* os::thread_local_storage_at(int index) { - return TlsGetValue(index); -} - - #ifndef PRODUCT #ifndef _WIN64 // Helpers to check whether NX protection is enabled @@ -4070,6 +4051,9 @@ fatal("DuplicateHandle failed\n"); } main_thread_id = (int) GetCurrentThreadId(); + + // initialize fast thread access - only used for 32-bit + win32::initialize_thread_ptr_offset(); } // To install functions for atexit processing @@ -5282,7 +5266,7 @@ DWORD exception_code = e->ExceptionRecord->ExceptionCode; if (exception_code == EXCEPTION_ACCESS_VIOLATION) { - JavaThread* thread = (JavaThread*)ThreadLocalStorage::get_thread_slow(); + JavaThread* thread = JavaThread::current(); PEXCEPTION_RECORD exceptionRecord = e->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; @@ -5992,3 +5976,16 @@ UseNUMAInterleaving = old_use_numa_interleaving; } #endif // PRODUCT + +// Fast current thread access + +int os::win32::_thread_ptr_offset = 0; + +static void call_wrapper_dummy() {} + +// We need to call the os_exception_wrapper once so that it sets +// up the offset from FS of the thread pointer. +void os::win32::initialize_thread_ptr_offset() { + os::os_exception_wrapper( (java_call_t)call_wrapper_dummy, + NULL, NULL, NULL, NULL); +}