author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 33105 | 294e48b4f704 |
child 34311 | 586e90e84d60 |
permissions | -rw-r--r-- |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
1 |
/* |
29080
a16b0d9a08f5
8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents:
27009
diff
changeset
|
2 |
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
4 |
* |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
8 |
* |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
13 |
* accompanied this code). |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
14 |
* |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
18 |
* |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
21 |
* questions. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
22 |
* |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
23 |
*/ |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
24 |
|
29080
a16b0d9a08f5
8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents:
27009
diff
changeset
|
25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/g1/concurrentMark.inline.hpp" |
27 |
#include "gc/g1/dirtyCardQueue.hpp" |
|
28 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
|
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
30764
diff
changeset
|
29 |
#include "gc/g1/g1CollectorState.hpp" |
30764 | 30 |
#include "gc/g1/g1EvacFailure.hpp" |
31 |
#include "gc/g1/g1OopClosures.inline.hpp" |
|
32 |
#include "gc/g1/g1_globals.hpp" |
|
33 |
#include "gc/g1/heapRegion.hpp" |
|
34 |
#include "gc/g1/heapRegionRemSet.hpp" |
|
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
35 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
36 |
class UpdateRSetDeferred : public OopsInHeapRegionClosure { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
37 |
private: |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
38 |
G1CollectedHeap* _g1; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
39 |
DirtyCardQueue *_dcq; |
20309 | 40 |
G1SATBCardTableModRefBS* _ct_bs; |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
41 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
42 |
public: |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
43 |
UpdateRSetDeferred(DirtyCardQueue* dcq) : |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
44 |
_g1(G1CollectedHeap::heap()), _ct_bs(_g1->g1_barrier_set()), _dcq(dcq) {} |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
45 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
46 |
virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
47 |
virtual void do_oop( oop* p) { do_oop_work(p); } |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
48 |
template <class T> void do_oop_work(T* p) { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
49 |
assert(_from->is_in_reserved(p), "paranoia"); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
50 |
if (!_from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
51 |
!_from->is_survivor()) { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
52 |
size_t card_index = _ct_bs->index_for(p); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
53 |
if (_ct_bs->mark_card_deferred(card_index)) { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
54 |
_dcq->enqueue((jbyte*)_ct_bs->byte_for_index(card_index)); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
55 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
56 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
57 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
58 |
}; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
59 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
60 |
class RemoveSelfForwardPtrObjClosure: public ObjectClosure { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
61 |
private: |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
62 |
G1CollectedHeap* _g1; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
63 |
ConcurrentMark* _cm; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
64 |
HeapRegion* _hr; |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
65 |
size_t _marked_bytes; |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
66 |
OopsInHeapRegionClosure *_update_rset_cl; |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
67 |
bool _during_initial_mark; |
11583
83a7383de44c
6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents:
11455
diff
changeset
|
68 |
uint _worker_id; |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
69 |
HeapWord* _last_forwarded_object_end; |
11583
83a7383de44c
6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents:
11455
diff
changeset
|
70 |
|
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
71 |
public: |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
72 |
RemoveSelfForwardPtrObjClosure(HeapRegion* hr, |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
73 |
OopsInHeapRegionClosure* update_rset_cl, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
74 |
bool during_initial_mark, |
11583
83a7383de44c
6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents:
11455
diff
changeset
|
75 |
uint worker_id) : |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
76 |
_g1(G1CollectedHeap::heap()), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
77 |
_cm(_g1->concurrent_mark()), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
78 |
_hr(hr), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
79 |
_marked_bytes(0), |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
80 |
_update_rset_cl(update_rset_cl), |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
81 |
_during_initial_mark(during_initial_mark), |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
82 |
_worker_id(worker_id), |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
83 |
_last_forwarded_object_end(hr->bottom()) { } |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
84 |
|
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
85 |
size_t marked_bytes() { return _marked_bytes; } |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
86 |
|
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
87 |
// Iterate over the live objects in the region to find self-forwarded objects |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
88 |
// that need to be kept live. We need to update the remembered sets of these |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
89 |
// objects. Further update the BOT and marks. |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
90 |
// We can coalesce and overwrite the remaining heap contents with dummy objects |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
91 |
// as they have either been dead or evacuated (which are unreferenced now, i.e. |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
92 |
// dead too) already. |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
93 |
void do_object(oop obj) { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
94 |
HeapWord* obj_addr = (HeapWord*) obj; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
95 |
assert(_hr->is_in(obj_addr), "sanity"); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
96 |
size_t obj_size = obj->size(); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
97 |
HeapWord* obj_end = obj_addr + obj_size; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
98 |
|
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
99 |
if (obj->is_forwarded() && obj->forwardee() == obj) { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
100 |
// The object failed to move. |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
101 |
|
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
102 |
zap_dead_objects(_last_forwarded_object_end, obj_addr); |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
103 |
// We consider all objects that we find self-forwarded to be |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
104 |
// live. What we'll do is that we'll update the prev marking |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
105 |
// info so that they are all under PTAMS and explicitly marked. |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
106 |
if (!_cm->isPrevMarked(obj)) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
107 |
_cm->markPrev(obj); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
108 |
} |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
109 |
if (_during_initial_mark) { |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
110 |
// For the next marking info we'll only mark the |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
111 |
// self-forwarded objects explicitly if we are during |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
112 |
// initial-mark (since, normally, we only mark objects pointed |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
113 |
// to by roots if we succeed in copying them). By marking all |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
114 |
// self-forwarded objects we ensure that we mark any that are |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
115 |
// still pointed to be roots. During concurrent marking, and |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
116 |
// after initial-mark, we don't need to mark any objects |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
117 |
// explicitly and all objects in the CSet are considered |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
118 |
// (implicitly) live. So, we won't mark them explicitly and |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
119 |
// we'll leave them over NTAMS. |
11584
e1df4d08a1f4
7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents:
11583
diff
changeset
|
120 |
_cm->grayRoot(obj, obj_size, _worker_id, _hr); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
121 |
} |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
122 |
_marked_bytes += (obj_size * HeapWordSize); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
123 |
obj->set_mark(markOopDesc::prototype()); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
124 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
125 |
// While we were processing RSet buffers during the collection, |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
126 |
// we actually didn't scan any cards on the collection set, |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
127 |
// since we didn't want to update remembered sets with entries |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
128 |
// that point into the collection set, given that live objects |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
129 |
// from the collection set are about to move and such entries |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
130 |
// will be stale very soon. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
131 |
// This change also dealt with a reliability issue which |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
132 |
// involved scanning a card in the collection set and coming |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
133 |
// across an array that was being chunked and looking malformed. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
134 |
// The problem is that, if evacuation fails, we might have |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
135 |
// remembered set entries missing given that we skipped cards on |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
136 |
// the collection set. So, we'll recreate such entries now. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
137 |
obj->oop_iterate(_update_rset_cl); |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
138 |
|
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
139 |
_last_forwarded_object_end = obj_end; |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
140 |
_hr->cross_threshold(obj_addr, obj_end); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
141 |
} |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
142 |
} |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
143 |
|
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
144 |
// Fill the memory area from start to end with filler objects, and update the BOT |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
145 |
// and the mark bitmap accordingly. |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
146 |
void zap_dead_objects(HeapWord* start, HeapWord* end) { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
147 |
if (start == end) { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
148 |
return; |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
149 |
} |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
150 |
|
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
151 |
size_t gap_size = pointer_delta(end, start); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
152 |
MemRegion mr(start, gap_size); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
153 |
if (gap_size >= CollectedHeap::min_fill_size()) { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
154 |
CollectedHeap::fill_with_objects(start, gap_size); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
155 |
|
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
156 |
HeapWord* end_first_obj = start + ((oop)start)->size(); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
157 |
_hr->cross_threshold(start, end_first_obj); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
158 |
// Fill_with_objects() may have created multiple (i.e. two) |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
159 |
// objects, as the max_fill_size() is half a region. |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
160 |
// After updating the BOT for the first object, also update the |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
161 |
// BOT for the second object to make the BOT complete. |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
162 |
if (end_first_obj != end) { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
163 |
_hr->cross_threshold(end_first_obj, end); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
164 |
#ifdef ASSERT |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
165 |
size_t size_second_obj = ((oop)end_first_obj)->size(); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
166 |
HeapWord* end_of_second_obj = end_first_obj + size_second_obj; |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
167 |
assert(end == end_of_second_obj, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31631
diff
changeset
|
168 |
"More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31631
diff
changeset
|
169 |
"second objects size " SIZE_FORMAT " ends at " PTR_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31631
diff
changeset
|
170 |
p2i(start), p2i(end), size_second_obj, p2i(end_of_second_obj)); |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
171 |
#endif |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
172 |
} |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
173 |
} |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
174 |
_cm->clearRangePrevBitmap(mr); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
175 |
} |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
176 |
|
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
177 |
void zap_remainder() { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
178 |
zap_dead_objects(_last_forwarded_object_end, _hr->top()); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
179 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
180 |
}; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
181 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
182 |
class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
183 |
G1CollectedHeap* _g1h; |
11583
83a7383de44c
6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents:
11455
diff
changeset
|
184 |
uint _worker_id; |
27009
e7e723732b6b
8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents:
26846
diff
changeset
|
185 |
HeapRegionClaimer* _hrclaimer; |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
186 |
|
26701
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
26422
diff
changeset
|
187 |
DirtyCardQueue _dcq; |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
26422
diff
changeset
|
188 |
UpdateRSetDeferred _update_rset_cl; |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
26422
diff
changeset
|
189 |
|
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
190 |
public: |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
191 |
RemoveSelfForwardPtrHRClosure(uint worker_id, |
27009
e7e723732b6b
8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents:
26846
diff
changeset
|
192 |
HeapRegionClaimer* hrclaimer) : |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
193 |
_g1h(G1CollectedHeap::heap()), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
194 |
_dcq(&_g1h->dirty_card_queue_set()), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
195 |
_update_rset_cl(&_dcq), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
196 |
_worker_id(worker_id), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
197 |
_hrclaimer(hrclaimer) { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
198 |
} |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
199 |
|
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
200 |
size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr, |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
201 |
bool during_initial_mark) { |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
202 |
RemoveSelfForwardPtrObjClosure rspc(hr, |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
203 |
&_update_rset_cl, |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
204 |
during_initial_mark, |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
205 |
_worker_id); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
206 |
_update_rset_cl.set_region(hr); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
207 |
hr->object_iterate(&rspc); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
208 |
// Need to zap the remainder area of the processed region. |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
209 |
rspc.zap_remainder(); |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
210 |
|
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
211 |
return rspc.marked_bytes(); |
27009
e7e723732b6b
8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents:
26846
diff
changeset
|
212 |
} |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
213 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
214 |
bool doHeapRegion(HeapRegion *hr) { |
31331
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
30764
diff
changeset
|
215 |
bool during_initial_mark = _g1h->collector_state()->during_initial_mark_pause(); |
a7c714b6cfb3
7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents:
30764
diff
changeset
|
216 |
bool during_conc_mark = _g1h->collector_state()->mark_in_progress(); |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
217 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31631
diff
changeset
|
218 |
assert(!hr->is_pinned(), "Unexpected pinned region at index %u", hr->hrm_index()); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
219 |
assert(hr->in_collection_set(), "bad CS"); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
220 |
|
27009
e7e723732b6b
8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents:
26846
diff
changeset
|
221 |
if (_hrclaimer->claim_region(hr->hrm_index())) { |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
222 |
if (hr->evacuation_failed()) { |
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
223 |
hr->note_self_forwarding_removal_start(during_initial_mark, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
224 |
during_conc_mark); |
24244
2c7a1e5649bd
7132678: G1: verify that the marking bitmaps have no marks for objects over TAMS
brutisso
parents:
22234
diff
changeset
|
225 |
_g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
226 |
|
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
227 |
// In the common case (i.e. when there is no evacuation |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
228 |
// failure) we make sure that the following is done when |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
229 |
// the region is freed so that it is "ready-to-go" when it's |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
230 |
// re-allocated. However, when evacuation failure happens, a |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
231 |
// region will remain in the heap and might ultimately be added |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
232 |
// to a CSet in the future. So we have to be careful here and |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
233 |
// make sure the region's RSet is ready for parallel iteration |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
234 |
// whenever this might be required in the future. |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
235 |
hr->rem_set()->reset_for_par_iteration(); |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
236 |
hr->reset_bot(); |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
237 |
|
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
238 |
size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
239 |
|
26422 | 240 |
hr->rem_set()->clean_strong_code_roots(hr); |
241 |
||
11455
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
242 |
hr->note_self_forwarding_removal_end(during_initial_mark, |
a6ab3d8b9a4c
6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents:
11451
diff
changeset
|
243 |
during_conc_mark, |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
244 |
live_bytes); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
245 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
246 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
247 |
return false; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
248 |
} |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
249 |
}; |
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
250 |
|
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
251 |
G1ParRemoveSelfForwardPtrsTask::G1ParRemoveSelfForwardPtrsTask() : |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
252 |
AbstractGangTask("G1 Remove Self-forwarding Pointers"), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
253 |
_g1h(G1CollectedHeap::heap()), |
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
254 |
_hrclaimer(_g1h->workers()->active_workers()) { } |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
255 |
|
29080
a16b0d9a08f5
8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents:
27009
diff
changeset
|
256 |
void G1ParRemoveSelfForwardPtrsTask::work(uint worker_id) { |
31631
4536cf7bc89f
8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents:
31346
diff
changeset
|
257 |
RemoveSelfForwardPtrHRClosure rsfp_cl(worker_id, &_hrclaimer); |
11451
9c9aa4d85660
7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff
changeset
|
258 |
|
29080
a16b0d9a08f5
8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents:
27009
diff
changeset
|
259 |
HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id); |
a16b0d9a08f5
8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents:
27009
diff
changeset
|
260 |
_g1h->collection_set_iterate_from(hr, &rsfp_cl); |
a16b0d9a08f5
8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents:
27009
diff
changeset
|
261 |
} |