72 assert(is_in_reserved(addr),
73 "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
74 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
75 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
76 }
77
78 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
79 return _hrm.reserved().start() + index * HeapRegion::GrainWords;
80 }
81
82 template <class T>
83 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
84 assert(addr != NULL, "invariant");
85 assert(is_in_g1_reserved((const void*) addr),
86 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
87 p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()));
88 return _hrm.addr_to_region((HeapWord*) addr);
89 }
90
91 inline void G1CollectedHeap::reset_gc_time_stamp() {
92 _gc_time_stamp = 0;
93 OrderAccess::fence();
94 // Clear the cached CSet starting regions and time stamps.
95 // Their validity is dependent on the GC timestamp.
96 clear_cset_start_regions();
97 }
98
99 inline void G1CollectedHeap::increment_gc_time_stamp() {
100 ++_gc_time_stamp;
101 OrderAccess::fence();
102 }
103
104 inline void G1CollectedHeap::old_set_add(HeapRegion* hr) {
105 _old_set.add(hr);
106 }
107
108 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
109 _old_set.remove(hr);
110 }
111
112 // It dirties the cards that cover the block so that the post
113 // write barrier never queues anything when updating objects on this
114 // block. It is assumed (and in fact we assert) that the block
115 // belongs to a young region.
116 inline void
117 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) {
118 assert_heap_not_locked();
119
120 // Assign the containing region to containing_hr so that we don't
121 // have to keep calling heap_region_containing() in the
|
72 assert(is_in_reserved(addr),
73 "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
74 p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
75 return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
76 }
77
78 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
79 return _hrm.reserved().start() + index * HeapRegion::GrainWords;
80 }
81
82 template <class T>
83 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
84 assert(addr != NULL, "invariant");
85 assert(is_in_g1_reserved((const void*) addr),
86 "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
87 p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()));
88 return _hrm.addr_to_region((HeapWord*) addr);
89 }
90
91 inline void G1CollectedHeap::reset_gc_time_stamp() {
92 assert_at_safepoint(true);
93 _gc_time_stamp = 0;
94 }
95
96 inline void G1CollectedHeap::increment_gc_time_stamp() {
97 assert_at_safepoint(true);
98 ++_gc_time_stamp;
99 }
100
101 inline void G1CollectedHeap::old_set_add(HeapRegion* hr) {
102 _old_set.add(hr);
103 }
104
105 inline void G1CollectedHeap::old_set_remove(HeapRegion* hr) {
106 _old_set.remove(hr);
107 }
108
109 // It dirties the cards that cover the block so that the post
110 // write barrier never queues anything when updating objects on this
111 // block. It is assumed (and in fact we assert) that the block
112 // belongs to a young region.
113 inline void
114 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) {
115 assert_heap_not_locked();
116
117 // Assign the containing region to containing_hr so that we don't
118 // have to keep calling heap_region_containing() in the
|