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 *
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 #include "precompiled.hpp"
26 #include "gc/g1/g1CollectedHeap.hpp"
27 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
28 #include "gc/g1/g1FullCollector.inline.hpp"
29 #include "gc/g1/g1FullGCCompactionPoint.hpp"
30 #include "gc/g1/g1FullGCCompactTask.hpp"
31 #include "gc/g1/heapRegion.inline.hpp"
32 #include "gc/shared/gcTraceTime.inline.hpp"
33 #include "logging/log.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "utilities/ticks.hpp"
36
37 // Do work for all skip-compacting regions.
38 class G1ResetSkipCompactingClosure : public HeapRegionClosure {
39 G1FullCollector* _collector;
40
41 public:
42 G1ResetSkipCompactingClosure(G1FullCollector* collector) : _collector(collector) { }
43
44 bool do_heap_region(HeapRegion* r) {
45 uint region_index = r->hrm_index();
46 // Only for skip-compaction regions; early return otherwise.
47 if (!_collector->is_skip_compacting(region_index)) {
48 return false;
49 }
50 #ifdef ASSERT
51 if (r->is_humongous()) {
52 oop obj = cast_to_oop(r->humongous_start_region()->bottom());
62 "should be quite full");
63 }
64 #endif
65 assert(_collector->compaction_top(r) == nullptr,
66 "region %u compaction_top " PTR_FORMAT " must not be different from bottom " PTR_FORMAT,
67 r->hrm_index(), p2i(_collector->compaction_top(r)), p2i(r->bottom()));
68
69 r->reset_skip_compacting_after_full_gc();
70 return false;
71 }
72 };
73
74 void G1FullGCCompactTask::G1CompactRegionClosure::clear_in_bitmap(oop obj) {
75 assert(_bitmap->is_marked(obj), "Should only compact marked objects");
76 _bitmap->clear(obj);
77 }
78
79 size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
80 size_t size = obj->size();
81 if (obj->is_forwarded()) {
82 HeapWord* destination = cast_from_oop<HeapWord*>(obj->forwardee());
83
84 // copy object and reinit its mark
85 HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
86 assert(obj_addr != destination, "everything in this pass should be moving");
87 Copy::aligned_conjoint_words(obj_addr, destination, size);
88
89 // There is no need to transform stack chunks - marking already did that.
90 cast_to_oop(destination)->init_mark();
91 assert(cast_to_oop(destination)->klass() != NULL, "should have a class");
92 }
93
94 // Clear the mark for the compacted object to allow reuse of the
95 // bitmap without an additional clearing step.
96 clear_in_bitmap(obj);
97 return size;
98 }
99
100 void G1FullGCCompactTask::compact_region(HeapRegion* hr) {
101 assert(!hr->is_pinned(), "Should be no pinned region in compaction queue");
102 assert(!hr->is_humongous(), "Should be no humongous regions in compaction queue");
|
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 *
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 #include "precompiled.hpp"
26 #include "gc/g1/g1CollectedHeap.hpp"
27 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
28 #include "gc/g1/g1FullCollector.inline.hpp"
29 #include "gc/g1/g1FullGCCompactionPoint.hpp"
30 #include "gc/g1/g1FullGCCompactTask.hpp"
31 #include "gc/g1/heapRegion.inline.hpp"
32 #include "gc/shared/gcTraceTime.inline.hpp"
33 #include "gc/shared/slidingForwarding.inline.hpp"
34 #include "logging/log.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "utilities/ticks.hpp"
37
38 // Do work for all skip-compacting regions.
39 class G1ResetSkipCompactingClosure : public HeapRegionClosure {
40 G1FullCollector* _collector;
41
42 public:
43 G1ResetSkipCompactingClosure(G1FullCollector* collector) : _collector(collector) { }
44
45 bool do_heap_region(HeapRegion* r) {
46 uint region_index = r->hrm_index();
47 // Only for skip-compaction regions; early return otherwise.
48 if (!_collector->is_skip_compacting(region_index)) {
49 return false;
50 }
51 #ifdef ASSERT
52 if (r->is_humongous()) {
53 oop obj = cast_to_oop(r->humongous_start_region()->bottom());
63 "should be quite full");
64 }
65 #endif
66 assert(_collector->compaction_top(r) == nullptr,
67 "region %u compaction_top " PTR_FORMAT " must not be different from bottom " PTR_FORMAT,
68 r->hrm_index(), p2i(_collector->compaction_top(r)), p2i(r->bottom()));
69
70 r->reset_skip_compacting_after_full_gc();
71 return false;
72 }
73 };
74
75 void G1FullGCCompactTask::G1CompactRegionClosure::clear_in_bitmap(oop obj) {
76 assert(_bitmap->is_marked(obj), "Should only compact marked objects");
77 _bitmap->clear(obj);
78 }
79
80 size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
81 size_t size = obj->size();
82 if (obj->is_forwarded()) {
83 HeapWord* destination = cast_from_oop<HeapWord*>(_forwarding->forwardee(obj));
84
85 // copy object and reinit its mark
86 HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
87 assert(obj_addr != destination, "everything in this pass should be moving");
88 Copy::aligned_conjoint_words(obj_addr, destination, size);
89
90 // There is no need to transform stack chunks - marking already did that.
91 cast_to_oop(destination)->init_mark();
92 assert(cast_to_oop(destination)->klass() != NULL, "should have a class");
93 }
94
95 // Clear the mark for the compacted object to allow reuse of the
96 // bitmap without an additional clearing step.
97 clear_in_bitmap(obj);
98 return size;
99 }
100
101 void G1FullGCCompactTask::compact_region(HeapRegion* hr) {
102 assert(!hr->is_pinned(), "Should be no pinned region in compaction queue");
103 assert(!hr->is_humongous(), "Should be no humongous regions in compaction queue");
|