Mercurial > hg > truffle
annotate src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp @ 20222:0abcece2ee27
8026847: [TESTBUG] gc/g1/TestSummarizeRSetStats* tests launch 32bit jvm with UseCompressedOops
Summary: The test launched a 32 bit VM with UseCompressedOops enabled. This is not supported on 32 bit VMs, causing a test failure. Investigation showed that the use of this flag is not required at all, so simply remove it.
Reviewed-by: tschatzl, jwilhelm
Contributed-by: Andrey Zakharov <andrey.x.zakharov@oracle.com>
author | tschatzl |
---|---|
date | Mon, 21 Jul 2014 09:40:19 +0200 |
parents | f34d701e952e |
children |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
7180
f34d701e952e
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
3798
diff
changeset
|
26 #include "runtime/thread.inline.hpp" |
1972 | 27 #include "runtime/threadLocalStorage.hpp" |
0 | 28 |
29 // Map stack pointer (%esp) to thread pointer for faster TLS access | |
30 // | |
31 // Here we use a flat table for better performance. Getting current thread | |
32 // is down to one memory access (read _sp_map[%esp>>12]) in generated code | |
33 // and two in runtime code (-fPIC code needs an extra load for _sp_map). | |
34 // | |
35 // This code assumes stack page is not shared by different threads. It works | |
36 // in 32-bit VM when page size is 4K (or a multiple of 4K, if that matters). | |
37 // | |
38 // Notice that _sp_map is allocated in the bss segment, which is ZFOD | |
39 // (zero-fill-on-demand). While it reserves 4M address space upfront, | |
40 // actual memory pages are committed on demand. | |
41 // | |
42 // If an application creates and destroys a lot of threads, usually the | |
43 // stack space freed by a thread will soon get reused by new thread | |
44 // (this is especially true in NPTL or LinuxThreads in fixed-stack mode). | |
45 // No memory page in _sp_map is wasted. | |
46 // | |
47 // However, it's still possible that we might end up populating & | |
48 // committing a large fraction of the 4M table over time, but the actual | |
49 // amount of live data in the table could be quite small. The max wastage | |
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. | |
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). | |
54 | |
3798
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
55 #if !defined(AMD64) && !defined(MINIMIZE_RAM_USAGE) |
0 | 56 Thread* ThreadLocalStorage::_sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)]; |
57 | |
58 void ThreadLocalStorage::generate_code_for_get_thread() { | |
59 // nothing we can do here for user-level thread | |
60 } | |
61 | |
62 void ThreadLocalStorage::pd_init() { | |
63 assert(align_size_down(os::vm_page_size(), PAGE_SIZE) == os::vm_page_size(), | |
64 "page size must be multiple of PAGE_SIZE"); | |
65 } | |
66 | |
67 void ThreadLocalStorage::pd_set_thread(Thread* thread) { | |
68 os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); | |
69 address stack_top = os::current_stack_base(); | |
70 size_t stack_size = os::current_stack_size(); | |
71 | |
72 for (address p = stack_top - stack_size; p < stack_top; p += PAGE_SIZE) { | |
73 // pd_set_thread() is called with non-NULL value when a new thread is | |
74 // created/attached, or with NULL value when a thread is about to exit. | |
75 // If both "thread" and the corresponding _sp_map[] entry are non-NULL, | |
76 // they should have the same value. Otherwise it might indicate that the | |
77 // stack page is shared by multiple threads. However, a more likely cause | |
78 // for this assertion to fail is that an attached thread exited without | |
79 // detaching itself from VM, which is a program error and could cause VM | |
80 // to crash. | |
81 assert(thread == NULL || _sp_map[(uintptr_t)p >> PAGE_SHIFT] == NULL || | |
82 thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT], | |
83 "thread exited without detaching from VM??"); | |
84 _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread; | |
85 } | |
3798
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
86 } |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
87 #else |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
88 |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
89 void ThreadLocalStorage::generate_code_for_get_thread() { |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
90 // nothing we can do here for user-level thread |
0 | 91 } |
3798
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
92 |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
93 void ThreadLocalStorage::pd_init() { |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
94 } |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
95 |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
96 void ThreadLocalStorage::pd_set_thread(Thread* thread) { |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
97 os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
98 } |
65dba8692db7
7061197: ThreadLocalStorage sp map table should be optional
jcoomes
parents:
1972
diff
changeset
|
99 #endif // !AMD64 && !MINIMIZE_RAM_USAGE |