Mercurial > hg > truffle
annotate src/share/vm/runtime/park.cpp @ 21282:93215cb4a2f9
include duringCall and rethrowException for BytecodeFrames in disassembly comments
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 11 May 2015 12:22:49 +0200 |
parents | 52b4284cb496 |
children |
rev | line source |
---|---|
1878 | 1 /* |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
6842
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
1878 | 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 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "runtime/thread.hpp" | |
1878 | 27 |
28 | |
29 | |
30 // Lifecycle management for TSM ParkEvents. | |
31 // ParkEvents are type-stable (TSM). | |
32 // In our particular implementation they happen to be immortal. | |
33 // | |
34 // We manage concurrency on the FreeList with a CAS-based | |
35 // detach-modify-reattach idiom that avoids the ABA problems | |
36 // that would otherwise be present in a simple CAS-based | |
37 // push-pop implementation. (push-one and pop-all) | |
38 // | |
39 // Caveat: Allocate() and Release() may be called from threads | |
40 // other than the thread associated with the Event! | |
41 // If we need to call Allocate() when running as the thread in | |
42 // question then look for the PD calls to initialize native TLS. | |
43 // Native TLS (Win32/Linux/Solaris) can only be initialized or | |
44 // accessed by the associated thread. | |
45 // See also pd_initialize(). | |
46 // | |
47 // Note that we could defer associating a ParkEvent with a thread | |
48 // until the 1st time the thread calls park(). unpark() calls to | |
49 // an unprovisioned thread would be ignored. The first park() call | |
50 // for a thread would allocate and associate a ParkEvent and return | |
51 // immediately. | |
52 | |
53 volatile int ParkEvent::ListLock = 0 ; | |
54 ParkEvent * volatile ParkEvent::FreeList = NULL ; | |
55 | |
56 ParkEvent * ParkEvent::Allocate (Thread * t) { | |
57 // In rare cases -- JVM_RawMonitor* operations -- we can find t == null. | |
58 ParkEvent * ev ; | |
59 | |
60 // Start by trying to recycle an existing but unassociated | |
61 // ParkEvent from the global free list. | |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
62 // Using a spin lock since we are part of the mutex impl. |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
63 // 8028280: using concurrent free list without memory management can leak |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
64 // pretty badly it turns out. |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
65 Thread::SpinAcquire(&ListLock, "ParkEventFreeListAllocate"); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
66 { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
67 ev = FreeList; |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
68 if (ev != NULL) { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
69 FreeList = ev->FreeNext; |
1878 | 70 } |
71 } | |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
72 Thread::SpinRelease(&ListLock); |
1878 | 73 |
74 if (ev != NULL) { | |
75 guarantee (ev->AssociatedWith == NULL, "invariant") ; | |
76 } else { | |
77 // Do this the hard way -- materialize a new ParkEvent. | |
78 ev = new ParkEvent () ; | |
79 guarantee ((intptr_t(ev) & 0xFF) == 0, "invariant") ; | |
80 } | |
81 ev->reset() ; // courtesy to caller | |
82 ev->AssociatedWith = t ; // Associate ev with t | |
83 ev->FreeNext = NULL ; | |
84 return ev ; | |
85 } | |
86 | |
87 void ParkEvent::Release (ParkEvent * ev) { | |
88 if (ev == NULL) return ; | |
89 guarantee (ev->FreeNext == NULL , "invariant") ; | |
90 ev->AssociatedWith = NULL ; | |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
91 // Note that if we didn't have the TSM/immortal constraint, then |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
92 // when reattaching we could trim the list. |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
93 Thread::SpinAcquire(&ListLock, "ParkEventFreeListRelease"); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
94 { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
95 ev->FreeNext = FreeList; |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
96 FreeList = ev; |
1878 | 97 } |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
98 Thread::SpinRelease(&ListLock); |
1878 | 99 } |
100 | |
101 // Override operator new and delete so we can ensure that the | |
102 // least significant byte of ParkEvent addresses is 0. | |
103 // Beware that excessive address alignment is undesirable | |
104 // as it can result in D$ index usage imbalance as | |
105 // well as bank access imbalance on Niagara-like platforms, | |
106 // although Niagara's hash function should help. | |
107 | |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
6842
diff
changeset
|
108 void * ParkEvent::operator new (size_t sz) throw() { |
6197 | 109 return (void *) ((intptr_t (AllocateHeap(sz + 256, mtInternal, CALLER_PC)) + 256) & -256) ; |
1878 | 110 } |
111 | |
112 void ParkEvent::operator delete (void * a) { | |
113 // ParkEvents are type-stable and immortal ... | |
114 ShouldNotReachHere(); | |
115 } | |
116 | |
117 | |
118 // 6399321 As a temporary measure we copied & modified the ParkEvent:: | |
119 // allocate() and release() code for use by Parkers. The Parker:: forms | |
14909 | 120 // will eventually be removed as we consolide and shift over to ParkEvents |
1878 | 121 // for both builtin synchronization and JSR166 operations. |
122 | |
123 volatile int Parker::ListLock = 0 ; | |
124 Parker * volatile Parker::FreeList = NULL ; | |
125 | |
126 Parker * Parker::Allocate (JavaThread * t) { | |
127 guarantee (t != NULL, "invariant") ; | |
128 Parker * p ; | |
129 | |
130 // Start by trying to recycle an existing but unassociated | |
131 // Parker from the global free list. | |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
132 // 8028280: using concurrent free list without memory management can leak |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
133 // pretty badly it turns out. |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
134 Thread::SpinAcquire(&ListLock, "ParkerFreeListAllocate"); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
135 { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
136 p = FreeList; |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
137 if (p != NULL) { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
138 FreeList = p->FreeNext; |
1878 | 139 } |
140 } | |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
141 Thread::SpinRelease(&ListLock); |
1878 | 142 |
143 if (p != NULL) { | |
144 guarantee (p->AssociatedWith == NULL, "invariant") ; | |
145 } else { | |
146 // Do this the hard way -- materialize a new Parker.. | |
147 p = new Parker() ; | |
148 } | |
149 p->AssociatedWith = t ; // Associate p with t | |
150 p->FreeNext = NULL ; | |
151 return p ; | |
152 } | |
153 | |
154 | |
155 void Parker::Release (Parker * p) { | |
156 if (p == NULL) return ; | |
157 guarantee (p->AssociatedWith != NULL, "invariant") ; | |
158 guarantee (p->FreeNext == NULL , "invariant") ; | |
159 p->AssociatedWith = NULL ; | |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
160 |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
161 Thread::SpinAcquire(&ListLock, "ParkerFreeListRelease"); |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
162 { |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
163 p->FreeNext = FreeList; |
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
164 FreeList = p; |
1878 | 165 } |
18041
52b4284cb496
Merge with jdk8u20-b26
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14909
diff
changeset
|
166 Thread::SpinRelease(&ListLock); |
1878 | 167 } |
168 |