author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 33786 | ac8da6513351 |
child 34616 | 421a6405ca30 |
permissions | -rw-r--r-- |
25482 | 1 |
/* |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
28213
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25482 | 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 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP |
26 |
#define SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP |
|
25482 | 27 |
|
30764 | 28 |
#include "gc/g1/g1ParScanThreadState.hpp" |
29 |
#include "gc/g1/g1RemSet.inline.hpp" |
|
25482 | 30 |
#include "oops/oop.inline.hpp" |
31 |
||
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
32 |
template <class T> void G1ParScanThreadState::do_oop_evac(T* p, HeapRegion* from) { |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
33 |
assert(!oopDesc::is_null(oopDesc::load_decode_heap_oop(p)), |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
34 |
"Reference should not be NULL here as such are never pushed to the task queue."); |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
35 |
oop obj = oopDesc::load_decode_heap_oop_not_null(p); |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
36 |
|
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
37 |
// Although we never intentionally push references outside of the collection |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
38 |
// set, due to (benign) races in the claim mechanism during RSet scanning more |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
39 |
// than one thread might claim the same card. So the same card may be |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
40 |
// processed multiple times. So redo this check. |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
41 |
const InCSetState in_cset_state = _g1h->in_cset_state(obj); |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
42 |
if (in_cset_state.is_in_cset()) { |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
43 |
oop forwardee; |
27682
dbd1c3f92130
8064473: Improved handling of age during object copy in G1
sfriberg
parents:
26701
diff
changeset
|
44 |
markOop m = obj->mark(); |
dbd1c3f92130
8064473: Improved handling of age during object copy in G1
sfriberg
parents:
26701
diff
changeset
|
45 |
if (m->is_marked()) { |
dbd1c3f92130
8064473: Improved handling of age during object copy in G1
sfriberg
parents:
26701
diff
changeset
|
46 |
forwardee = (oop) m->decode_pointer(); |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
47 |
} else { |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
48 |
forwardee = copy_to_survivor_space(in_cset_state, obj, m); |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
49 |
} |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
50 |
oopDesc::encode_store_heap_oop(p, forwardee); |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
51 |
} else if (in_cset_state.is_humongous()) { |
25889
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25483
diff
changeset
|
52 |
_g1h->set_humongous_is_live(obj); |
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25483
diff
changeset
|
53 |
} else { |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
54 |
assert(!in_cset_state.is_in_cset_or_humongous(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32187
diff
changeset
|
55 |
"In_cset_state must be NotInCSet here, but is " CSETSTATE_FORMAT, in_cset_state.value()); |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
56 |
} |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
57 |
|
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
58 |
assert(obj != NULL, "Must be"); |
33224
bc5da96c1f0e
8139200: Eliminate G1ParClosureSuper::_worker_id
kbarrett
parents:
33105
diff
changeset
|
59 |
update_rs(from, p); |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
60 |
} |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
61 |
|
30566
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
62 |
template <class T> inline void G1ParScanThreadState::push_on_queue(T* ref) { |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
63 |
assert(verify_ref(ref), "sanity"); |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
64 |
_refs->push(ref); |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
65 |
} |
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
30173
diff
changeset
|
66 |
|
25482 | 67 |
inline void G1ParScanThreadState::do_oop_partial_array(oop* p) { |
68 |
assert(has_partial_array_mask(p), "invariant"); |
|
69 |
oop from_obj = clear_partial_array_mask(p); |
|
70 |
||
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
28213
diff
changeset
|
71 |
assert(_g1h->is_in_reserved(from_obj), "must be in heap."); |
25482 | 72 |
assert(from_obj->is_objArray(), "must be obj array"); |
73 |
objArrayOop from_obj_array = objArrayOop(from_obj); |
|
74 |
// The from-space object contains the real length. |
|
75 |
int length = from_obj_array->length(); |
|
76 |
||
77 |
assert(from_obj->is_forwarded(), "must be forwarded"); |
|
78 |
oop to_obj = from_obj->forwardee(); |
|
79 |
assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); |
|
80 |
objArrayOop to_obj_array = objArrayOop(to_obj); |
|
81 |
// We keep track of the next start index in the length field of the |
|
82 |
// to-space object. |
|
83 |
int next_index = to_obj_array->length(); |
|
84 |
assert(0 <= next_index && next_index < length, |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32187
diff
changeset
|
85 |
"invariant, next index: %d, length: %d", next_index, length); |
25482 | 86 |
|
87 |
int start = next_index; |
|
88 |
int end = length; |
|
89 |
int remainder = end - start; |
|
90 |
// We'll try not to push a range that's smaller than ParGCArrayScanChunk. |
|
91 |
if (remainder > 2 * ParGCArrayScanChunk) { |
|
92 |
end = start + ParGCArrayScanChunk; |
|
93 |
to_obj_array->set_length(end); |
|
94 |
// Push the remainder before we process the range in case another |
|
95 |
// worker has run out of things to do and can steal it. |
|
96 |
oop* from_obj_p = set_partial_array_mask(from_obj); |
|
97 |
push_on_queue(from_obj_p); |
|
98 |
} else { |
|
99 |
assert(length == end, "sanity"); |
|
100 |
// We'll process the final range for this object. Restore the length |
|
101 |
// so that the heap remains parsable in case of evacuation failure. |
|
102 |
to_obj_array->set_length(end); |
|
103 |
} |
|
33786
ac8da6513351
8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents:
33224
diff
changeset
|
104 |
_scanner.set_region(_g1h->heap_region_containing(to_obj)); |
25482 | 105 |
// Process indexes [start,end). It will also process the header |
106 |
// along with the first chunk (i.e., the chunk with start == 0). |
|
107 |
// Note that at this point the length field of to_obj_array is not |
|
108 |
// correct given that we are using it to keep track of the next |
|
109 |
// start index. oop_iterate_range() (thankfully!) ignores the length |
|
110 |
// field and only relies on the start / end parameters. It does |
|
111 |
// however return the size of the object which will be incorrect. So |
|
112 |
// we have to ignore it even if we wanted to use it. |
|
113 |
to_obj_array->oop_iterate_range(&_scanner, start, end); |
|
114 |
} |
|
115 |
||
116 |
template <class T> inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) { |
|
117 |
if (!has_partial_array_mask(ref_to_scan)) { |
|
33786
ac8da6513351
8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents:
33224
diff
changeset
|
118 |
HeapRegion* r = _g1h->heap_region_containing(ref_to_scan); |
25482 | 119 |
do_oop_evac(ref_to_scan, r); |
120 |
} else { |
|
121 |
do_oop_partial_array((oop*)ref_to_scan); |
|
122 |
} |
|
123 |
} |
|
124 |
||
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
125 |
inline void G1ParScanThreadState::dispatch_reference(StarTask ref) { |
25482 | 126 |
assert(verify_task(ref), "sanity"); |
127 |
if (ref.is_narrow()) { |
|
128 |
deal_with_reference((narrowOop*)ref); |
|
129 |
} else { |
|
130 |
deal_with_reference((oop*)ref); |
|
131 |
} |
|
132 |
} |
|
133 |
||
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
134 |
void G1ParScanThreadState::steal_and_trim_queue(RefToScanQueueSet *task_queues) { |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
135 |
StarTask stolen_task; |
32187
0891f3fa84fc
8133047: Rename G1ParScanThreadState::_queue_num to _worker_id
tschatzl
parents:
30764
diff
changeset
|
136 |
while (task_queues->steal(_worker_id, &_hash_seed, stolen_task)) { |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
137 |
assert(verify_task(stolen_task), "sanity"); |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
138 |
dispatch_reference(stolen_task); |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
139 |
|
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
140 |
// We've just processed a reference and we might have made |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
141 |
// available new entries on the queues. So we have to make sure |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
142 |
// we drain the queues as necessary. |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
143 |
trim_queue(); |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
144 |
} |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
145 |
} |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
146 |
|
30764 | 147 |
#endif /* SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP */ |
25482 | 148 |