annotate src/share/vm/runtime/orderAccess.hpp @ 2368:dde920245681

6896099: Integrate CMS heap ergo with default heap sizing ergo 6627787: CMS: JVM refuses to start up with -Xms16m -Xmx16m 7000125: CMS: Anti-monotone young gen sizing with respect to maximum whole heap size specification 7027529: CMS: retire CMSUseOldDefaults flag Summary: Simplify CMS heap sizing code, relying on ergonomic initial sizing consistent with other collectors for the most part, controlling only young gen sizing to rein in pause times. Make CMS young gen sizing default statically cpu-dependant. Remove inconsistencies wrt generation sizing and policy code, allowing for the fixing for 6627787 and 7000125. For 7027529, retire the flag CMSUseOldDefaults which had been introduced as a bridge from JDK 5 to JDK 6 a number of years ago. Reviewed-by: brutisso, poonam
author ysr
date Wed, 16 Mar 2011 10:37:08 -0700
parents f95d63e2154a
children 63a4eb8bcd23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1711
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
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: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
25 #ifndef SHARE_VM_RUNTIME_ORDERACCESS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
26 #define SHARE_VM_RUNTIME_ORDERACCESS_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
28 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Memory Access Ordering Model
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // This interface is based on the JSR-133 Cookbook for Compiler Writers
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // and on the IA64 memory model. It is the dynamic equivalent of the
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // C/C++ volatile specifier. I.e., volatility restricts compile-time
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // memory access reordering in a way similar to what we want to occur
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // at runtime.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // In the following, the terms 'previous', 'subsequent', 'before',
605
98cb887364d3 6810672: Comment typos
twisti
parents: 0
diff changeset
39 // 'after', 'preceding' and 'succeeding' refer to program order. The
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // terms 'down' and 'below' refer to forward load or store motion
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // relative to program order, while 'up' and 'above' refer to backward
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // motion.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 //
a61af66fc99e Initial load
duke
parents:
diff changeset
44 //
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // We define four primitive memory barrier operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
46 //
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // LoadLoad: Load1(s); LoadLoad; Load2
a61af66fc99e Initial load
duke
parents:
diff changeset
48 //
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Ensures that Load1 completes (obtains the value it loads from memory)
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // before Load2 and any subsequent load operations. Loads before Load1
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // may *not* float below Load2 and any subsequent load operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 //
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // StoreStore: Store1(s); StoreStore; Store2
a61af66fc99e Initial load
duke
parents:
diff changeset
54 //
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Ensures that Store1 completes (the effect on memory of Store1 is made
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // visible to other processors) before Store2 and any subsequent store
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // operations. Stores before Store1 may *not* float below Store2 and any
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // subsequent store operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 //
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // LoadStore: Load1(s); LoadStore; Store2
a61af66fc99e Initial load
duke
parents:
diff changeset
61 //
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Ensures that Load1 completes before Store2 and any subsequent store
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // operations. Loads before Load1 may *not* float below Store2 and any
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // subseqeuent store operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 //
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // StoreLoad: Store1(s); StoreLoad; Load2
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Ensures that Store1 completes before Load2 and any subsequent load
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // operations. Stores before Store1 may *not* float below Load2 and any
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // subseqeuent load operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 //
a61af66fc99e Initial load
duke
parents:
diff changeset
72 //
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // We define two further operations, 'release' and 'acquire'. They are
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // mirror images of each other.
a61af66fc99e Initial load
duke
parents:
diff changeset
75 //
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Execution by a processor of release makes the effect of all memory
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // accesses issued by it previous to the release visible to all
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // processors *before* the release completes. The effect of subsequent
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // memory accesses issued by it *may* be made visible *before* the
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // release. I.e., subsequent memory accesses may float above the
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // release, but prior ones may not float below it.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 //
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Execution by a processor of acquire makes the effect of all memory
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // accesses issued by it subsequent to the acquire visible to all
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // processors *after* the acquire completes. The effect of prior memory
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // accesses issued by it *may* be made visible *after* the acquire.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // I.e., prior memory accesses may float below the acquire, but
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // subsequent ones may not float above it.
a61af66fc99e Initial load
duke
parents:
diff changeset
89 //
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Finally, we define a 'fence' operation, which conceptually is a
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // release combined with an acquire. In the real world these operations
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // require one or more machine instructions which can float above and
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // below the release or acquire, so we usually can't just issue the
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // release-acquire back-to-back. All machines we know of implement some
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // sort of memory fence instruction.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 //
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // The standalone implementations of release and acquire need an associated
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // dummy volatile store or load respectively. To avoid redundant operations,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // we can define the composite operators: 'release_store', 'store_fence' and
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // 'load_acquire'. Here's a summary of the machine instructions corresponding
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // to each operation.
a61af66fc99e Initial load
duke
parents:
diff changeset
103 //
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // sparc RMO ia64 x86
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // ---------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // fence membar #LoadStore | mf lock addl 0,(sp)
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // #StoreStore |
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // #LoadLoad |
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // #StoreLoad
a61af66fc99e Initial load
duke
parents:
diff changeset
110 //
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // release membar #LoadStore | st.rel [sp]=r0 movl $0,<dummy>
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // #StoreStore
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // st %g0,[]
a61af66fc99e Initial load
duke
parents:
diff changeset
114 //
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // acquire ld [%sp],%g0 ld.acq <r>=[sp] movl (sp),<r>
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // membar #LoadLoad |
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // #LoadStore
a61af66fc99e Initial load
duke
parents:
diff changeset
118 //
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // release_store membar #LoadStore | st.rel <store>
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // #StoreStore
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // st
a61af66fc99e Initial load
duke
parents:
diff changeset
122 //
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // store_fence st st lock xchg
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // fence mf
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // load_acquire ld ld.acq <load>
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // membar #LoadLoad |
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // #LoadStore
a61af66fc99e Initial load
duke
parents:
diff changeset
129 //
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Using only release_store and load_acquire, we can implement the
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // following ordered sequences.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 //
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // 1. load, load == load_acquire, load
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // or load_acquire, load_acquire
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // 2. load, store == load, release_store
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // or load_acquire, store
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // or load_acquire, release_store
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // 3. store, store == store, release_store
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // or release_store, release_store
a61af66fc99e Initial load
duke
parents:
diff changeset
140 //
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // These require no membar instructions for sparc-TSO and no extra
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // instructions for ia64.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 //
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Ordering a load relative to preceding stores requires a store_fence,
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // which implies a membar #StoreLoad between the store and load under
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // sparc-TSO. A fence is required by ia64. On x86, we use locked xchg.
a61af66fc99e Initial load
duke
parents:
diff changeset
147 //
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // 4. store, load == store_fence, load
a61af66fc99e Initial load
duke
parents:
diff changeset
149 //
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Use store_fence to make sure all stores done in an 'interesting'
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // region are made visible prior to both subsequent loads and stores.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 //
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // Conventional usage is to issue a load_acquire for ordered loads. Use
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // release_store for ordered stores when you care only that prior stores
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // are visible before the release_store, but don't care exactly when the
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // store associated with the release_store becomes visible. Use
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // release_store_fence to update values like the thread state, where we
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // don't want the current thread to continue until all our prior memory
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // accesses (including the new thread state) are visible to other threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 //
a61af66fc99e Initial load
duke
parents:
diff changeset
161 //
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // C++ Volatility
a61af66fc99e Initial load
duke
parents:
diff changeset
163 //
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // C++ guarantees ordering at operations termed 'sequence points' (defined
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // to be volatile accesses and calls to library I/O functions). 'Side
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // effects' (defined as volatile accesses, calls to library I/O functions
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // and object modification) previous to a sequence point must be visible
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // at that sequence point. See the C++ standard, section 1.9, titled
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // "Program Execution". This means that all barrier implementations,
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // including standalone loadload, storestore, loadstore, storeload, acquire
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // and release must include a sequence point, usually via a volatile memory
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // access. Other ways to guarantee a sequence point are, e.g., use of
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // indirect calls and linux's __asm__ volatile.
1711
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
174 // Note: as of 6973570, we have replaced the originally static "dummy" field
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
175 // (see above) by a volatile store to the stack. All of the versions of the
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
176 // compilers that we currently use (SunStudio, gcc and VC++) respect the
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
177 // semantics of volatile here. If you build HotSpot using other
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
178 // compilers, you may need to verify that no compiler reordering occurs
a6bff45449bc 6973570: OrderAccess::storestore() scales poorly on multi-socket x64 and sparc: cache-line ping-ponging
ysr
parents: 1552
diff changeset
179 // across the sequence point respresented by the volatile access.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 //
a61af66fc99e Initial load
duke
parents:
diff changeset
181 //
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // os::is_MP Considered Redundant
a61af66fc99e Initial load
duke
parents:
diff changeset
183 //
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Callers of this interface do not need to test os::is_MP() before
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // issuing an operation. The test is taken care of by the implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // of the interface (depending on the vm version and platform, the test
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // may or may not be actually done by the implementation).
a61af66fc99e Initial load
duke
parents:
diff changeset
188 //
a61af66fc99e Initial load
duke
parents:
diff changeset
189 //
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // A Note on Memory Ordering and Cache Coherency
a61af66fc99e Initial load
duke
parents:
diff changeset
191 //
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // Cache coherency and memory ordering are orthogonal concepts, though they
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // interact. E.g., all existing itanium machines are cache-coherent, but
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // the hardware can freely reorder loads wrt other loads unless it sees a
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // load-acquire instruction. All existing sparc machines are cache-coherent
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // and, unlike itanium, TSO guarantees that the hardware orders loads wrt
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // loads and stores, and stores wrt to each other.
a61af66fc99e Initial load
duke
parents:
diff changeset
198 //
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Consider the implementation of loadload. *If* your platform *isn't*
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // cache-coherent, then loadload must not only prevent hardware load
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // instruction reordering, but it must *also* ensure that subsequent
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // loads from addresses that could be written by other processors (i.e.,
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // that are broadcast by other processors) go all the way to the first
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // level of memory shared by those processors and the one issuing
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // the loadload.
a61af66fc99e Initial load
duke
parents:
diff changeset
206 //
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // So if we have a MP that has, say, a per-processor D$ that doesn't see
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // writes by other processors, and has a shared E$ that does, the loadload
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // barrier would have to make sure that either
a61af66fc99e Initial load
duke
parents:
diff changeset
210 //
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // 1. cache lines in the issuing processor's D$ that contained data from
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // addresses that could be written by other processors are invalidated, so
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // subsequent loads from those addresses go to the E$, (it could do this
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // by tagging such cache lines as 'shared', though how to tell the hardware
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // to do the tagging is an interesting problem), or
a61af66fc99e Initial load
duke
parents:
diff changeset
216 //
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // 2. there never are such cache lines in the issuing processor's D$, which
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // means all references to shared data (however identified: see above)
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // bypass the D$ (i.e., are satisfied from the E$).
a61af66fc99e Initial load
duke
parents:
diff changeset
220 //
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // If your machine doesn't have an E$, substitute 'main memory' for 'E$'.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 //
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // Either of these alternatives is a pain, so no current machine we know of
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // has incoherent caches.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 //
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // If loadload didn't have these properties, the store-release sequence for
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // publishing a shared data structure wouldn't work, because a processor
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // trying to read data newly published by another processor might go to
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // its own incoherent caches to satisfy the read instead of to the newly
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // written shared memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 //
a61af66fc99e Initial load
duke
parents:
diff changeset
232 //
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // NOTE WELL!!
a61af66fc99e Initial load
duke
parents:
diff changeset
234 //
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // A Note on MutexLocker and Friends
a61af66fc99e Initial load
duke
parents:
diff changeset
236 //
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // See mutexLocker.hpp. We assume throughout the VM that MutexLocker's
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // and friends' constructors do a fence, a lock and an acquire *in that
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // order*. And that their destructors do a release and unlock, in *that*
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // order. If their implementations change such that these assumptions
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // are violated, a whole lot of code will break.
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 class OrderAccess : AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
245 static void loadload();
a61af66fc99e Initial load
duke
parents:
diff changeset
246 static void storestore();
a61af66fc99e Initial load
duke
parents:
diff changeset
247 static void loadstore();
a61af66fc99e Initial load
duke
parents:
diff changeset
248 static void storeload();
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 static void acquire();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 static void release();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 static void fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 static jbyte load_acquire(volatile jbyte* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 static jshort load_acquire(volatile jshort* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 static jint load_acquire(volatile jint* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 static jlong load_acquire(volatile jlong* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
258 static jubyte load_acquire(volatile jubyte* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 static jushort load_acquire(volatile jushort* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 static juint load_acquire(volatile juint* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 static julong load_acquire(volatile julong* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 static jfloat load_acquire(volatile jfloat* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 static jdouble load_acquire(volatile jdouble* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 static intptr_t load_ptr_acquire(volatile intptr_t* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 static void* load_ptr_acquire(volatile void* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 static void* load_ptr_acquire(const volatile void* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 static void release_store(volatile jbyte* p, jbyte v);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 static void release_store(volatile jshort* p, jshort v);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 static void release_store(volatile jint* p, jint v);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 static void release_store(volatile jlong* p, jlong v);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 static void release_store(volatile jubyte* p, jubyte v);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 static void release_store(volatile jushort* p, jushort v);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 static void release_store(volatile juint* p, juint v);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 static void release_store(volatile julong* p, julong v);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 static void release_store(volatile jfloat* p, jfloat v);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 static void release_store(volatile jdouble* p, jdouble v);
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 static void release_store_ptr(volatile intptr_t* p, intptr_t v);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 static void release_store_ptr(volatile void* p, void* v);
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 static void store_fence(jbyte* p, jbyte v);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 static void store_fence(jshort* p, jshort v);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 static void store_fence(jint* p, jint v);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 static void store_fence(jlong* p, jlong v);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 static void store_fence(jubyte* p, jubyte v);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 static void store_fence(jushort* p, jushort v);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 static void store_fence(juint* p, juint v);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 static void store_fence(julong* p, julong v);
a61af66fc99e Initial load
duke
parents:
diff changeset
291 static void store_fence(jfloat* p, jfloat v);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 static void store_fence(jdouble* p, jdouble v);
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 static void store_ptr_fence(intptr_t* p, intptr_t v);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 static void store_ptr_fence(void** p, void* v);
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 static void release_store_fence(volatile jbyte* p, jbyte v);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 static void release_store_fence(volatile jshort* p, jshort v);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 static void release_store_fence(volatile jint* p, jint v);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 static void release_store_fence(volatile jlong* p, jlong v);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 static void release_store_fence(volatile jubyte* p, jubyte v);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 static void release_store_fence(volatile jushort* p, jushort v);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 static void release_store_fence(volatile juint* p, juint v);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 static void release_store_fence(volatile julong* p, julong v);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 static void release_store_fence(volatile jfloat* p, jfloat v);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 static void release_store_fence(volatile jdouble* p, jdouble v);
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 static void release_store_ptr_fence(volatile intptr_t* p, intptr_t v);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 static void release_store_ptr_fence(volatile void* p, void* v);
a61af66fc99e Initial load
duke
parents:
diff changeset
310
671
d0994e5bebce 6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents: 605
diff changeset
311 private:
d0994e5bebce 6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents: 605
diff changeset
312 // This is a helper that invokes the StubRoutines::fence_entry()
d0994e5bebce 6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents: 605
diff changeset
313 // routine if it exists, It should only be used by platforms that
d0994e5bebce 6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents: 605
diff changeset
314 // don't another way to do the inline eassembly.
d0994e5bebce 6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents: 605
diff changeset
315 static void StubRoutines_fence();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
316 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
317
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1711
diff changeset
318 #endif // SHARE_VM_RUNTIME_ORDERACCESS_HPP