Mercurial > hg > truffle
annotate src/share/vm/gc_interface/collectedHeap.inline.hpp @ 4181:319860ae697a
Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Mon, 02 Jan 2012 14:16:08 -0800 |
parents | a92cdbac8b9e |
children | 9a9bb0010c91 |
rev | line source |
---|---|
0 | 1 /* |
2100
b1a2afa37ec4
7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents:
1972
diff
changeset
|
2 * Copyright (c) 2001, 2011, 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:
579
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
579
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:
579
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_INLINE_HPP |
26 #define SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_INLINE_HPP | |
27 | |
28 #include "gc_interface/collectedHeap.hpp" | |
29 #include "memory/threadLocalAllocBuffer.inline.hpp" | |
30 #include "memory/universe.hpp" | |
31 #include "oops/arrayOop.hpp" | |
32 #include "prims/jvmtiExport.hpp" | |
33 #include "runtime/sharedRuntime.hpp" | |
34 #include "runtime/thread.hpp" | |
35 #include "services/lowMemoryDetector.hpp" | |
36 #include "utilities/copy.hpp" | |
37 #ifdef TARGET_OS_FAMILY_linux | |
38 # include "thread_linux.inline.hpp" | |
39 #endif | |
40 #ifdef TARGET_OS_FAMILY_solaris | |
41 # include "thread_solaris.inline.hpp" | |
42 #endif | |
43 #ifdef TARGET_OS_FAMILY_windows | |
44 # include "thread_windows.inline.hpp" | |
45 #endif | |
3960 | 46 #ifdef TARGET_OS_FAMILY_bsd |
47 # include "thread_bsd.inline.hpp" | |
48 #endif | |
1972 | 49 |
0 | 50 // Inline allocation implementations. |
51 | |
52 void CollectedHeap::post_allocation_setup_common(KlassHandle klass, | |
53 HeapWord* obj, | |
54 size_t size) { | |
55 post_allocation_setup_no_klass_install(klass, obj, size); | |
56 post_allocation_install_obj_klass(klass, oop(obj), (int) size); | |
57 } | |
58 | |
59 void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, | |
60 HeapWord* objPtr, | |
61 size_t size) { | |
62 oop obj = (oop)objPtr; | |
63 | |
64 assert(obj != NULL, "NULL object pointer"); | |
65 if (UseBiasedLocking && (klass() != NULL)) { | |
66 obj->set_mark(klass->prototype_header()); | |
67 } else { | |
68 // May be bootstrapping | |
69 obj->set_mark(markOopDesc::prototype()); | |
70 } | |
71 } | |
72 | |
73 void CollectedHeap::post_allocation_install_obj_klass(KlassHandle klass, | |
74 oop obj, | |
75 int size) { | |
76 // These asserts are kind of complicated because of klassKlass | |
77 // and the beginning of the world. | |
78 assert(klass() != NULL || !Universe::is_fully_initialized(), "NULL klass"); | |
79 assert(klass() == NULL || klass()->is_klass(), "not a klass"); | |
80 assert(klass() == NULL || klass()->klass_part() != NULL, "not a klass"); | |
81 assert(obj != NULL, "NULL object pointer"); | |
82 obj->set_klass(klass()); | |
83 assert(!Universe::is_fully_initialized() || obj->blueprint() != NULL, | |
84 "missing blueprint"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
85 } |
0 | 86 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
87 // Support for jvmti and dtrace |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
88 inline void post_allocation_notify(KlassHandle klass, oop obj) { |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
89 // support low memory notifications (no-op if not enabled) |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
90 LowMemoryDetector::detect_low_memory_for_collected_pools(); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
356
diff
changeset
|
91 |
0 | 92 // support for JVMTI VMObjectAlloc event (no-op if not enabled) |
93 JvmtiExport::vm_object_alloc_event_collector(obj); | |
94 | |
95 if (DTraceAllocProbes) { | |
96 // support for Dtrace object alloc event (no-op most of the time) | |
97 if (klass() != NULL && klass()->klass_part()->name() != NULL) { | |
98 SharedRuntime::dtrace_object_alloc(obj); | |
99 } | |
100 } | |
101 } | |
102 | |
103 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, | |
104 HeapWord* obj, | |
105 size_t size) { | |
106 post_allocation_setup_common(klass, obj, size); | |
107 assert(Universe::is_bootstrapping() || | |
108 !((oop)obj)->blueprint()->oop_is_array(), "must not be an array"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
109 // notify jvmti and dtrace |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
110 post_allocation_notify(klass, (oop)obj); |
0 | 111 } |
112 | |
113 void CollectedHeap::post_allocation_setup_array(KlassHandle klass, | |
114 HeapWord* obj, | |
115 size_t size, | |
116 int length) { | |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
117 // Set array length before setting the _klass field |
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
118 // in post_allocation_setup_common() because the klass field |
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
119 // indicates that the object is parsable by concurrent GC. |
0 | 120 assert(length >= 0, "length should be non-negative"); |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
121 ((arrayOop)obj)->set_length(length); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
122 post_allocation_setup_common(klass, obj, size); |
0 | 123 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
124 // notify jvmti and dtrace (must be after length is set for dtrace) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
125 post_allocation_notify(klass, (oop)obj); |
0 | 126 } |
127 | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
2100
diff
changeset
|
128 HeapWord* CollectedHeap::common_mem_allocate_noinit(size_t size, TRAPS) { |
0 | 129 |
130 // Clear unhandled oops for memory allocation. Memory allocation might | |
131 // not take out a lock if from tlab, so clear here. | |
132 CHECK_UNHANDLED_OOPS_ONLY(THREAD->clear_unhandled_oops();) | |
133 | |
134 if (HAS_PENDING_EXCEPTION) { | |
135 NOT_PRODUCT(guarantee(false, "Should not allocate with exception pending")); | |
136 return NULL; // caller does a CHECK_0 too | |
137 } | |
138 | |
139 HeapWord* result = NULL; | |
140 if (UseTLAB) { | |
141 result = CollectedHeap::allocate_from_tlab(THREAD, size); | |
142 if (result != NULL) { | |
143 assert(!HAS_PENDING_EXCEPTION, | |
144 "Unexpected exception, will result in uninitialized storage"); | |
145 return result; | |
146 } | |
147 } | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
148 bool gc_overhead_limit_was_exceeded = false; |
0 | 149 result = Universe::heap()->mem_allocate(size, |
150 &gc_overhead_limit_was_exceeded); | |
151 if (result != NULL) { | |
152 NOT_PRODUCT(Universe::heap()-> | |
153 check_for_non_bad_heap_word_value(result, size)); | |
154 assert(!HAS_PENDING_EXCEPTION, | |
155 "Unexpected exception, will result in uninitialized storage"); | |
2100
b1a2afa37ec4
7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis
phh
parents:
1972
diff
changeset
|
156 THREAD->incr_allocated_bytes(size * HeapWordSize); |
0 | 157 return result; |
158 } | |
159 | |
160 | |
161 if (!gc_overhead_limit_was_exceeded) { | |
162 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support | |
163 report_java_out_of_memory("Java heap space"); | |
164 | |
165 if (JvmtiExport::should_post_resource_exhausted()) { | |
166 JvmtiExport::post_resource_exhausted( | |
167 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP, | |
168 "Java heap space"); | |
169 } | |
170 | |
171 THROW_OOP_0(Universe::out_of_memory_error_java_heap()); | |
172 } else { | |
173 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support | |
174 report_java_out_of_memory("GC overhead limit exceeded"); | |
175 | |
176 if (JvmtiExport::should_post_resource_exhausted()) { | |
177 JvmtiExport::post_resource_exhausted( | |
178 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP, | |
179 "GC overhead limit exceeded"); | |
180 } | |
181 | |
182 THROW_OOP_0(Universe::out_of_memory_error_gc_overhead_limit()); | |
183 } | |
184 } | |
185 | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
2100
diff
changeset
|
186 HeapWord* CollectedHeap::common_mem_allocate_init(size_t size, TRAPS) { |
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
2100
diff
changeset
|
187 HeapWord* obj = common_mem_allocate_noinit(size, CHECK_NULL); |
0 | 188 init_obj(obj, size); |
189 return obj; | |
190 } | |
191 | |
192 // Need to investigate, do we really want to throw OOM exception here? | |
193 HeapWord* CollectedHeap::common_permanent_mem_allocate_noinit(size_t size, TRAPS) { | |
194 if (HAS_PENDING_EXCEPTION) { | |
195 NOT_PRODUCT(guarantee(false, "Should not allocate with exception pending")); | |
196 return NULL; // caller does a CHECK_NULL too | |
197 } | |
198 | |
199 #ifdef ASSERT | |
200 if (CIFireOOMAt > 0 && THREAD->is_Compiler_thread() && | |
201 ++_fire_out_of_memory_count >= CIFireOOMAt) { | |
202 // For testing of OOM handling in the CI throw an OOM and see how | |
203 // it does. Historically improper handling of these has resulted | |
204 // in crashes which we really don't want to have in the CI. | |
205 THROW_OOP_0(Universe::out_of_memory_error_perm_gen()); | |
206 } | |
207 #endif | |
208 | |
209 HeapWord* result = Universe::heap()->permanent_mem_allocate(size); | |
210 if (result != NULL) { | |
211 NOT_PRODUCT(Universe::heap()-> | |
212 check_for_non_bad_heap_word_value(result, size)); | |
213 assert(!HAS_PENDING_EXCEPTION, | |
214 "Unexpected exception, will result in uninitialized storage"); | |
215 return result; | |
216 } | |
217 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support | |
218 report_java_out_of_memory("PermGen space"); | |
219 | |
220 if (JvmtiExport::should_post_resource_exhausted()) { | |
221 JvmtiExport::post_resource_exhausted( | |
222 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, | |
223 "PermGen space"); | |
224 } | |
225 | |
226 THROW_OOP_0(Universe::out_of_memory_error_perm_gen()); | |
227 } | |
228 | |
229 HeapWord* CollectedHeap::common_permanent_mem_allocate_init(size_t size, TRAPS) { | |
230 HeapWord* obj = common_permanent_mem_allocate_noinit(size, CHECK_NULL); | |
231 init_obj(obj, size); | |
232 return obj; | |
233 } | |
234 | |
235 HeapWord* CollectedHeap::allocate_from_tlab(Thread* thread, size_t size) { | |
236 assert(UseTLAB, "should use UseTLAB"); | |
237 | |
238 HeapWord* obj = thread->tlab().allocate(size); | |
239 if (obj != NULL) { | |
240 return obj; | |
241 } | |
242 // Otherwise... | |
243 return allocate_from_tlab_slow(thread, size); | |
244 } | |
245 | |
246 void CollectedHeap::init_obj(HeapWord* obj, size_t size) { | |
247 assert(obj != NULL, "cannot initialize NULL object"); | |
248 const size_t hs = oopDesc::header_size(); | |
249 assert(size >= hs, "unexpected object size"); | |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
250 ((oop)obj)->set_klass_gap(0); |
0 | 251 Copy::fill_to_aligned_words(obj + hs, size - hs); |
252 } | |
253 | |
254 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) { | |
255 debug_only(check_for_valid_allocation_state()); | |
256 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | |
257 assert(size >= 0, "int won't convert to size_t"); | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
2100
diff
changeset
|
258 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); |
0 | 259 post_allocation_setup_obj(klass, obj, size); |
260 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); | |
261 return (oop)obj; | |
262 } | |
263 | |
264 oop CollectedHeap::array_allocate(KlassHandle klass, | |
265 int size, | |
266 int length, | |
267 TRAPS) { | |
268 debug_only(check_for_valid_allocation_state()); | |
269 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | |
270 assert(size >= 0, "int won't convert to size_t"); | |
3774
c9ca3f51cf41
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
2100
diff
changeset
|
271 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); |
0 | 272 post_allocation_setup_array(klass, obj, size, length); |
273 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); | |
274 return (oop)obj; | |
275 } | |
276 | |
3961
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
277 oop CollectedHeap::array_allocate_nozero(KlassHandle klass, |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
278 int size, |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
279 int length, |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
280 TRAPS) { |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
281 debug_only(check_for_valid_allocation_state()); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
282 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
283 assert(size >= 0, "int won't convert to size_t"); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
284 HeapWord* obj = common_mem_allocate_noinit(size, CHECK_NULL); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
285 ((oop)obj)->set_klass_gap(0); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
286 post_allocation_setup_array(klass, obj, size, length); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
287 #ifndef PRODUCT |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
288 const size_t hs = oopDesc::header_size()+1; |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
289 Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs); |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
290 #endif |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
291 return (oop)obj; |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
292 } |
a92cdbac8b9e
7081933: Use zeroing elimination optimization for large array
kvn
parents:
3960
diff
changeset
|
293 |
0 | 294 oop CollectedHeap::permanent_obj_allocate(KlassHandle klass, int size, TRAPS) { |
295 oop obj = permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL); | |
296 post_allocation_install_obj_klass(klass, obj, size); | |
297 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj, | |
298 size)); | |
299 return obj; | |
300 } | |
301 | |
302 oop CollectedHeap::permanent_obj_allocate_no_klass_install(KlassHandle klass, | |
303 int size, | |
304 TRAPS) { | |
305 debug_only(check_for_valid_allocation_state()); | |
306 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | |
307 assert(size >= 0, "int won't convert to size_t"); | |
308 HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL); | |
309 post_allocation_setup_no_klass_install(klass, obj, size); | |
3892 | 310 #ifndef PRODUCT |
311 const size_t hs = oopDesc::header_size(); | |
312 Universe::heap()->check_for_bad_heap_word_value(obj+hs, size-hs); | |
313 #endif | |
0 | 314 return (oop)obj; |
315 } | |
316 | |
317 oop CollectedHeap::permanent_array_allocate(KlassHandle klass, | |
318 int size, | |
319 int length, | |
320 TRAPS) { | |
321 debug_only(check_for_valid_allocation_state()); | |
322 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | |
323 assert(size >= 0, "int won't convert to size_t"); | |
324 HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL); | |
325 post_allocation_setup_array(klass, obj, size, length); | |
326 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); | |
327 return (oop)obj; | |
328 } | |
329 | |
330 // Returns "TRUE" if "p" is a method oop in the | |
331 // current heap with high probability. NOTE: The main | |
332 // current consumers of this interface are Forte:: | |
333 // and ThreadProfiler::. In these cases, the | |
334 // interpreter frame from which "p" came, may be | |
335 // under construction when sampled asynchronously, so | |
336 // the clients want to check that it represents a | |
337 // valid method before using it. Nonetheless since | |
338 // the clients do not typically lock out GC, the | |
339 // predicate is_valid_method() is not stable, so | |
340 // it is possible that by the time "p" is used, it | |
341 // is no longer valid. | |
342 inline bool CollectedHeap::is_valid_method(oop p) const { | |
343 return | |
344 p != NULL && | |
345 | |
346 // Check whether it is aligned at a HeapWord boundary. | |
347 Space::is_aligned(p) && | |
348 | |
349 // Check whether "method" is in the allocated part of the | |
350 // permanent generation -- this needs to be checked before | |
351 // p->klass() below to avoid a SEGV (but see below | |
352 // for a potential window of vulnerability). | |
353 is_permanent((void*)p) && | |
354 | |
355 // See if GC is active; however, there is still an | |
356 // apparently unavoidable window after this call | |
357 // and before the client of this interface uses "p". | |
358 // If the client chooses not to lock out GC, then | |
359 // it's a risk the client must accept. | |
360 !is_gc_active() && | |
361 | |
362 // Check that p is a methodOop. | |
363 p->klass() == Universe::methodKlassObj(); | |
364 } | |
365 | |
366 | |
367 #ifndef PRODUCT | |
368 | |
369 inline bool | |
370 CollectedHeap::promotion_should_fail(volatile size_t* count) { | |
371 // Access to count is not atomic; the value does not have to be exact. | |
372 if (PromotionFailureALot) { | |
373 const size_t gc_num = total_collections(); | |
374 const size_t elapsed_gcs = gc_num - _promotion_failure_alot_gc_number; | |
375 if (elapsed_gcs >= PromotionFailureALotInterval) { | |
376 // Test for unsigned arithmetic wrap-around. | |
377 if (++*count >= PromotionFailureALotCount) { | |
378 *count = 0; | |
379 return true; | |
380 } | |
381 } | |
382 } | |
383 return false; | |
384 } | |
385 | |
386 inline bool CollectedHeap::promotion_should_fail() { | |
387 return promotion_should_fail(&_promotion_failure_alot_count); | |
388 } | |
389 | |
390 inline void CollectedHeap::reset_promotion_should_fail(volatile size_t* count) { | |
391 if (PromotionFailureALot) { | |
392 _promotion_failure_alot_gc_number = total_collections(); | |
393 *count = 0; | |
394 } | |
395 } | |
396 | |
397 inline void CollectedHeap::reset_promotion_should_fail() { | |
398 reset_promotion_should_fail(&_promotion_failure_alot_count); | |
399 } | |
400 #endif // #ifndef PRODUCT | |
1972 | 401 |
402 #endif // SHARE_VM_GC_INTERFACE_COLLECTEDHEAP_INLINE_HPP |