28 #include "gc_implementation/g1/concurrentMark.hpp" |
28 #include "gc_implementation/g1/concurrentMark.hpp" |
29 #include "gc_implementation/g1/g1CollectedHeap.hpp" |
29 #include "gc_implementation/g1/g1CollectedHeap.hpp" |
30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp" |
30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp" |
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp" |
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp" |
32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
|
33 #include "gc_implementation/g1/heapRegionManager.inline.hpp" |
33 #include "gc_implementation/g1/heapRegionSet.inline.hpp" |
34 #include "gc_implementation/g1/heapRegionSet.inline.hpp" |
34 #include "gc_implementation/g1/heapRegionSeq.inline.hpp" |
|
35 #include "runtime/orderAccess.inline.hpp" |
35 #include "runtime/orderAccess.inline.hpp" |
36 #include "utilities/taskqueue.hpp" |
36 #include "utilities/taskqueue.hpp" |
37 |
37 |
38 // Inline functions for G1CollectedHeap |
38 // Inline functions for G1CollectedHeap |
39 |
39 |
40 // Return the region with the given index. It assumes the index is valid. |
40 // Return the region with the given index. It assumes the index is valid. |
41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); } |
41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); } |
42 |
42 |
43 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const { |
43 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const { |
44 assert(is_in_reserved(addr), |
44 assert(is_in_reserved(addr), |
45 err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")", |
45 err_msg("Cannot calculate region index for address "PTR_FORMAT" that is outside of the heap ["PTR_FORMAT", "PTR_FORMAT")", |
46 p2i(addr), p2i(_reserved.start()), p2i(_reserved.end()))); |
46 p2i(addr), p2i(_reserved.start()), p2i(_reserved.end()))); |
47 return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); |
47 return (uint)(pointer_delta(addr, _reserved.start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes); |
48 } |
48 } |
49 |
49 |
50 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const { |
50 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const { |
51 return _hrs.reserved().start() + index * HeapRegion::GrainWords; |
51 return _hrm.reserved().start() + index * HeapRegion::GrainWords; |
52 } |
52 } |
53 |
53 |
54 template <class T> |
54 template <class T> |
55 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const { |
55 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const { |
56 assert(addr != NULL, "invariant"); |
56 assert(addr != NULL, "invariant"); |
57 assert(is_in_g1_reserved((const void*) addr), |
57 assert(is_in_g1_reserved((const void*) addr), |
58 err_msg("Address "PTR_FORMAT" is outside of the heap ranging from ["PTR_FORMAT" to "PTR_FORMAT")", |
58 err_msg("Address "PTR_FORMAT" is outside of the heap ranging from ["PTR_FORMAT" to "PTR_FORMAT")", |
59 p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()))); |
59 p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()))); |
60 return _hrs.addr_to_region((HeapWord*) addr); |
60 return _hrm.addr_to_region((HeapWord*) addr); |
61 } |
61 } |
62 |
62 |
63 template <class T> |
63 template <class T> |
64 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const { |
64 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const { |
65 HeapRegion* hr = heap_region_containing_raw(addr); |
65 HeapRegion* hr = heap_region_containing_raw(addr); |
85 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) { |
85 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) { |
86 _old_set.remove(hr); |
86 _old_set.remove(hr); |
87 } |
87 } |
88 |
88 |
89 inline bool G1CollectedHeap::obj_in_cs(oop obj) { |
89 inline bool G1CollectedHeap::obj_in_cs(oop obj) { |
90 HeapRegion* r = _hrs.addr_to_region((HeapWord*) obj); |
90 HeapRegion* r = _hrm.addr_to_region((HeapWord*) obj); |
91 return r != NULL && r->in_collection_set(); |
91 return r != NULL && r->in_collection_set(); |
92 } |
92 } |
93 |
93 |
94 inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size, |
94 inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size, |
95 unsigned int* gc_count_before_ret, |
95 unsigned int* gc_count_before_ret, |