comparison src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp @ 3798:65dba8692db7

7061197: ThreadLocalStorage sp map table should be optional Reviewed-by: dholmes, never, jwilhelm, kvn
author jcoomes
date Wed, 06 Jul 2011 12:22:29 -0700
parents f95d63e2154a
children f34d701e952e
comparison
equal deleted inserted replaced
3797:eb94b7226b7a 3798:65dba8692db7
50 // is less than 4M bytes. If it becomes an issue, we could use madvise() 50 // is less than 4M bytes. If it becomes an issue, we could use madvise()
51 // with MADV_DONTNEED to reclaim unused (i.e. all-zero) pages in _sp_map. 51 // with MADV_DONTNEED to reclaim unused (i.e. all-zero) pages in _sp_map.
52 // MADV_DONTNEED on Linux keeps the virtual memory mapping, but zaps the 52 // MADV_DONTNEED on Linux keeps the virtual memory mapping, but zaps the
53 // physical memory page (i.e. similar to MADV_FREE on Solaris). 53 // physical memory page (i.e. similar to MADV_FREE on Solaris).
54 54
55 #ifndef AMD64 55 #if !defined(AMD64) && !defined(MINIMIZE_RAM_USAGE)
56 Thread* ThreadLocalStorage::_sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)]; 56 Thread* ThreadLocalStorage::_sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)];
57 #endif // !AMD64
58 57
59 void ThreadLocalStorage::generate_code_for_get_thread() { 58 void ThreadLocalStorage::generate_code_for_get_thread() {
60 // nothing we can do here for user-level thread 59 // nothing we can do here for user-level thread
61 } 60 }
62 61
63 void ThreadLocalStorage::pd_init() { 62 void ThreadLocalStorage::pd_init() {
64 #ifndef AMD64
65 assert(align_size_down(os::vm_page_size(), PAGE_SIZE) == os::vm_page_size(), 63 assert(align_size_down(os::vm_page_size(), PAGE_SIZE) == os::vm_page_size(),
66 "page size must be multiple of PAGE_SIZE"); 64 "page size must be multiple of PAGE_SIZE");
67 #endif // !AMD64
68 } 65 }
69 66
70 void ThreadLocalStorage::pd_set_thread(Thread* thread) { 67 void ThreadLocalStorage::pd_set_thread(Thread* thread) {
71 os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); 68 os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
72
73 #ifndef AMD64
74 address stack_top = os::current_stack_base(); 69 address stack_top = os::current_stack_base();
75 size_t stack_size = os::current_stack_size(); 70 size_t stack_size = os::current_stack_size();
76 71
77 for (address p = stack_top - stack_size; p < stack_top; p += PAGE_SIZE) { 72 for (address p = stack_top - stack_size; p < stack_top; p += PAGE_SIZE) {
78 // pd_set_thread() is called with non-NULL value when a new thread is 73 // pd_set_thread() is called with non-NULL value when a new thread is
86 assert(thread == NULL || _sp_map[(uintptr_t)p >> PAGE_SHIFT] == NULL || 81 assert(thread == NULL || _sp_map[(uintptr_t)p >> PAGE_SHIFT] == NULL ||
87 thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT], 82 thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT],
88 "thread exited without detaching from VM??"); 83 "thread exited without detaching from VM??");
89 _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread; 84 _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread;
90 } 85 }
91 #endif // !AMD64
92 } 86 }
87 #else
88
89 void ThreadLocalStorage::generate_code_for_get_thread() {
90 // nothing we can do here for user-level thread
91 }
92
93 void ThreadLocalStorage::pd_init() {
94 }
95
96 void ThreadLocalStorage::pd_set_thread(Thread* thread) {
97 os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
98 }
99 #endif // !AMD64 && !MINIMIZE_RAM_USAGE