1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
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 *
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/dirtyCardQueue.hpp"
27 #include "gc/g1/g1CollectedHeap.inline.hpp"
28 #include "gc/g1/g1CollectorState.hpp"
29 #include "gc/g1/g1ConcurrentMark.inline.hpp"
30 #include "gc/g1/g1EvacFailure.hpp"
31 #include "gc/g1/g1HeapVerifier.hpp"
32 #include "gc/g1/g1OopClosures.inline.hpp"
33 #include "gc/g1/g1_globals.hpp"
34 #include "gc/g1/heapRegion.hpp"
35 #include "gc/g1/heapRegionRemSet.hpp"
36 #include "gc/shared/preservedMarks.inline.hpp"
37 #include "oops/access.inline.hpp"
38 #include "oops/compressedOops.inline.hpp"
39 #include "oops/oop.inline.hpp"
40
41 class UpdateRSetDeferred : public BasicOopIterateClosure {
42 private:
43 G1CollectedHeap* _g1h;
44 DirtyCardQueue* _dcq;
45 G1CardTable* _ct;
46
47 public:
48 UpdateRSetDeferred(DirtyCardQueue* dcq) :
49 _g1h(G1CollectedHeap::heap()), _dcq(dcq), _ct(_g1h->card_table()) {}
50
51 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
52 virtual void do_oop( oop* p) { do_oop_work(p); }
53 template <class T> void do_oop_work(T* p) {
54 assert(_g1h->heap_region_containing(p)->is_in_reserved(p), "paranoia");
55 assert(!_g1h->heap_region_containing(p)->is_survivor(), "Unexpected evac failure in survivor region");
56
57 T const o = RawAccess<>::oop_load(p);
58 if (CompressedOops::is_null(o)) {
59 return;
60 }
61
62 if (HeapRegion::is_in_same_region(p, CompressedOops::decode(o))) {
63 return;
64 }
65 size_t card_index = _ct->index_for(p);
66 if (_ct->mark_card_deferred(card_index)) {
67 _dcq->enqueue((jbyte*)_ct->byte_for_index(card_index));
68 }
179 assert(end == end_of_second_obj,
180 "More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", "
181 "second objects size " SIZE_FORMAT " ends at " PTR_FORMAT,
182 p2i(start), p2i(end), size_second_obj, p2i(end_of_second_obj));
183 #endif
184 }
185 }
186 _cm->clear_range_in_prev_bitmap(mr);
187 }
188
189 void zap_remainder() {
190 zap_dead_objects(_last_forwarded_object_end, _hr->top());
191 }
192 };
193
194 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
195 G1CollectedHeap* _g1h;
196 uint _worker_id;
197 HeapRegionClaimer* _hrclaimer;
198
199 DirtyCardQueue _dcq;
200 UpdateRSetDeferred _update_rset_cl;
201
202 public:
203 RemoveSelfForwardPtrHRClosure(uint worker_id,
204 HeapRegionClaimer* hrclaimer) :
205 _g1h(G1CollectedHeap::heap()),
206 _worker_id(worker_id),
207 _hrclaimer(hrclaimer),
208 _dcq(&_g1h->dirty_card_queue_set()),
209 _update_rset_cl(&_dcq){
210 }
211
212 size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr,
213 bool during_initial_mark) {
214 RemoveSelfForwardPtrObjClosure rspc(hr,
215 &_update_rset_cl,
216 during_initial_mark,
217 _worker_id);
218 hr->object_iterate(&rspc);
219 // Need to zap the remainder area of the processed region.
|
1 /*
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
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 *
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.inline.hpp"
27 #include "gc/g1/g1CollectorState.hpp"
28 #include "gc/g1/g1ConcurrentMark.inline.hpp"
29 #include "gc/g1/g1DirtyCardQueue.hpp"
30 #include "gc/g1/g1EvacFailure.hpp"
31 #include "gc/g1/g1HeapVerifier.hpp"
32 #include "gc/g1/g1OopClosures.inline.hpp"
33 #include "gc/g1/g1_globals.hpp"
34 #include "gc/g1/heapRegion.hpp"
35 #include "gc/g1/heapRegionRemSet.hpp"
36 #include "gc/shared/preservedMarks.inline.hpp"
37 #include "oops/access.inline.hpp"
38 #include "oops/compressedOops.inline.hpp"
39 #include "oops/oop.inline.hpp"
40
41 class UpdateRSetDeferred : public BasicOopIterateClosure {
42 private:
43 G1CollectedHeap* _g1h;
44 G1DirtyCardQueue* _dcq;
45 G1CardTable* _ct;
46
47 public:
48 UpdateRSetDeferred(G1DirtyCardQueue* dcq) :
49 _g1h(G1CollectedHeap::heap()), _dcq(dcq), _ct(_g1h->card_table()) {}
50
51 virtual void do_oop(narrowOop* p) { do_oop_work(p); }
52 virtual void do_oop( oop* p) { do_oop_work(p); }
53 template <class T> void do_oop_work(T* p) {
54 assert(_g1h->heap_region_containing(p)->is_in_reserved(p), "paranoia");
55 assert(!_g1h->heap_region_containing(p)->is_survivor(), "Unexpected evac failure in survivor region");
56
57 T const o = RawAccess<>::oop_load(p);
58 if (CompressedOops::is_null(o)) {
59 return;
60 }
61
62 if (HeapRegion::is_in_same_region(p, CompressedOops::decode(o))) {
63 return;
64 }
65 size_t card_index = _ct->index_for(p);
66 if (_ct->mark_card_deferred(card_index)) {
67 _dcq->enqueue((jbyte*)_ct->byte_for_index(card_index));
68 }
179 assert(end == end_of_second_obj,
180 "More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", "
181 "second objects size " SIZE_FORMAT " ends at " PTR_FORMAT,
182 p2i(start), p2i(end), size_second_obj, p2i(end_of_second_obj));
183 #endif
184 }
185 }
186 _cm->clear_range_in_prev_bitmap(mr);
187 }
188
189 void zap_remainder() {
190 zap_dead_objects(_last_forwarded_object_end, _hr->top());
191 }
192 };
193
194 class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
195 G1CollectedHeap* _g1h;
196 uint _worker_id;
197 HeapRegionClaimer* _hrclaimer;
198
199 G1DirtyCardQueue _dcq;
200 UpdateRSetDeferred _update_rset_cl;
201
202 public:
203 RemoveSelfForwardPtrHRClosure(uint worker_id,
204 HeapRegionClaimer* hrclaimer) :
205 _g1h(G1CollectedHeap::heap()),
206 _worker_id(worker_id),
207 _hrclaimer(hrclaimer),
208 _dcq(&_g1h->dirty_card_queue_set()),
209 _update_rset_cl(&_dcq){
210 }
211
212 size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr,
213 bool during_initial_mark) {
214 RemoveSelfForwardPtrObjClosure rspc(hr,
215 &_update_rset_cl,
216 during_initial_mark,
217 _worker_id);
218 hr->object_iterate(&rspc);
219 // Need to zap the remainder area of the processed region.
|