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
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
27
28 #include "gc_implementation/g1/concurrentMark.hpp"
29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
33 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
34 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36 #include "utilities/taskqueue.hpp"
37
38 // Inline functions for G1CollectedHeap
39
40 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
41 return _allocation_context_stats;
42 }
43
44 // Return the region with the given index. It assumes the index is valid.
45 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
46
47 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
48 assert(is_in_reserved(addr),
49 err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
50 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())));
51 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
52 }
53
54 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
55 return _hrm.reserved().start() + index * HeapRegion::GrainWords;
56 }
57
186 inline bool G1CollectedHeap::isMarkedNext(oop obj) const {
187 return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj);
188 }
189
190 // This is a fast test on whether a reference points into the
191 // collection set or not. Assume that the reference
192 // points into the heap.
193 inline bool G1CollectedHeap::is_in_cset(oop obj) {
194 bool ret = _in_cset_fast_test.is_in_cset((HeapWord*)obj);
195 // let's make sure the result is consistent with what the slower
196 // test returns
197 assert( ret || !obj_in_cs(obj), "sanity");
198 assert(!ret || obj_in_cs(obj), "sanity");
199 return ret;
200 }
201
202 bool G1CollectedHeap::is_in_cset_or_humongous(const oop obj) {
203 return _in_cset_fast_test.is_in_cset_or_humongous((HeapWord*)obj);
204 }
205
206 G1CollectedHeap::in_cset_state_t G1CollectedHeap::in_cset_state(const oop obj) {
207 return _in_cset_fast_test.at((HeapWord*)obj);
208 }
209
210 void G1CollectedHeap::register_humongous_region_with_in_cset_fast_test(uint index) {
211 _in_cset_fast_test.set_humongous(index);
212 }
213
214 #ifndef PRODUCT
215 // Support for G1EvacuationFailureALot
216
217 inline bool
218 G1CollectedHeap::evacuation_failure_alot_for_gc_type(bool gcs_are_young,
219 bool during_initial_mark,
220 bool during_marking) {
221 bool res = false;
222 if (during_marking) {
223 res |= G1EvacuationFailureALotDuringConcMark;
224 }
225 if (during_initial_mark) {
226 res |= G1EvacuationFailureALotDuringInitialMark;
|
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
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
27
28 #include "gc_implementation/g1/concurrentMark.hpp"
29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
33 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
34 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36 #include "utilities/taskqueue.hpp"
37
38 PLABStats* G1CollectedHeap::alloc_buffer_stats(InCSetState dest) {
39 switch (dest.value()) {
40 case InCSetState::Young:
41 return &_survivor_plab_stats;
42 case InCSetState::Old:
43 return &_old_plab_stats;
44 default:
45 ShouldNotReachHere();
46 return NULL; // Keep some compilers happy
47 }
48 }
49
50 size_t G1CollectedHeap::desired_plab_sz(InCSetState dest) {
51 size_t gclab_word_size = alloc_buffer_stats(dest)->desired_plab_sz();
52 // Prevent humongous PLAB sizes for two reasons:
53 // * PLABs are allocated using a similar paths as oops, but should
54 // never be in a humongous region
55 // * Allowing humongous PLABs needlessly churns the region free lists
56 return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
57 }
58
59 HeapWord* G1CollectedHeap::par_allocate_during_gc(InCSetState dest,
60 size_t word_size,
61 AllocationContext_t context) {
62 switch (dest.value()) {
63 case InCSetState::Young:
64 return survivor_attempt_allocation(word_size, context);
65 case InCSetState::Old:
66 return old_attempt_allocation(word_size, context);
67 default:
68 ShouldNotReachHere();
69 return NULL; // Keep some compilers happy
70 }
71 }
72
73 // Inline functions for G1CollectedHeap
74
75 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
76 return _allocation_context_stats;
77 }
78
79 // Return the region with the given index. It assumes the index is valid.
80 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
81
82 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
83 assert(is_in_reserved(addr),
84 err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")",
85 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())));
86 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
87 }
88
89 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
90 return _hrm.reserved().start() + index * HeapRegion::GrainWords;
91 }
92
221 inline bool G1CollectedHeap::isMarkedNext(oop obj) const {
222 return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj);
223 }
224
225 // This is a fast test on whether a reference points into the
226 // collection set or not. Assume that the reference
227 // points into the heap.
228 inline bool G1CollectedHeap::is_in_cset(oop obj) {
229 bool ret = _in_cset_fast_test.is_in_cset((HeapWord*)obj);
230 // let's make sure the result is consistent with what the slower
231 // test returns
232 assert( ret || !obj_in_cs(obj), "sanity");
233 assert(!ret || obj_in_cs(obj), "sanity");
234 return ret;
235 }
236
237 bool G1CollectedHeap::is_in_cset_or_humongous(const oop obj) {
238 return _in_cset_fast_test.is_in_cset_or_humongous((HeapWord*)obj);
239 }
240
241 InCSetState G1CollectedHeap::in_cset_state(const oop obj) {
242 return _in_cset_fast_test.at((HeapWord*)obj);
243 }
244
245 void G1CollectedHeap::register_humongous_region_with_in_cset_fast_test(uint index) {
246 _in_cset_fast_test.set_humongous(index);
247 }
248
249 #ifndef PRODUCT
250 // Support for G1EvacuationFailureALot
251
252 inline bool
253 G1CollectedHeap::evacuation_failure_alot_for_gc_type(bool gcs_are_young,
254 bool during_initial_mark,
255 bool during_marking) {
256 bool res = false;
257 if (during_marking) {
258 res |= G1EvacuationFailureALotDuringConcMark;
259 }
260 if (during_initial_mark) {
261 res |= G1EvacuationFailureALotDuringInitialMark;
|