author | stefank |
Tue, 28 Apr 2015 12:17:56 +0000 | |
changeset 30568 | d0a24d56d8ea |
parent 30564 | a37d98a1eb54 |
parent 30566 | 18eb9aa972d0 |
permissions | -rw-r--r-- |
25482 | 1 |
/* |
30564
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
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 |
||
25 |
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP |
|
26 |
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP |
|
27 |
||
28 |
#include "gc_implementation/g1/dirtyCardQueue.hpp" |
|
29 |
#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" |
|
30 |
#include "gc_implementation/g1/g1CollectedHeap.hpp" |
|
31 |
#include "gc_implementation/g1/g1CollectorPolicy.hpp" |
|
32 |
#include "gc_implementation/g1/g1OopClosures.hpp" |
|
33 |
#include "gc_implementation/g1/g1RemSet.hpp" |
|
34 |
#include "gc_implementation/shared/ageTable.hpp" |
|
35 |
#include "memory/allocation.hpp" |
|
36 |
#include "oops/oop.hpp" |
|
37 |
||
38 |
class HeapRegion; |
|
39 |
class outputStream; |
|
40 |
||
41 |
class G1ParScanThreadState : public StackObj { |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
42 |
private: |
25482 | 43 |
G1CollectedHeap* _g1h; |
44 |
RefToScanQueue* _refs; |
|
45 |
DirtyCardQueue _dcq; |
|
46 |
G1SATBCardTableModRefBS* _ct_bs; |
|
47 |
G1RemSet* _g1_rem; |
|
48 |
||
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
49 |
G1ParGCAllocator* _g1_par_allocator; |
25482 | 50 |
|
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
51 |
ageTable _age_table; |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
52 |
InCSetState _dest[InCSetState::Num]; |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
53 |
// Local tenuring threshold. |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
54 |
uint _tenuring_threshold; |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
55 |
G1ParScanClosure _scanner; |
25482 | 56 |
|
57 |
OopsInHeapRegionClosure* _evac_failure_cl; |
|
58 |
||
59 |
int _hash_seed; |
|
60 |
uint _queue_num; |
|
61 |
||
62 |
size_t _term_attempts; |
|
63 |
||
64 |
double _start; |
|
65 |
double _start_strong_roots; |
|
66 |
double _strong_roots_time; |
|
67 |
double _start_term; |
|
68 |
double _term_time; |
|
69 |
||
70 |
// Map from young-age-index (0 == not young, 1 is youngest) to |
|
71 |
// surviving words. base is what we get back from the malloc call |
|
72 |
size_t* _surviving_young_words_base; |
|
73 |
// this points into the array, as we use the first few entries for padding |
|
74 |
size_t* _surviving_young_words; |
|
75 |
||
76 |
#define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t)) |
|
77 |
||
78 |
DirtyCardQueue& dirty_card_queue() { return _dcq; } |
|
79 |
G1SATBCardTableModRefBS* ctbs() { return _ct_bs; } |
|
80 |
||
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
81 |
InCSetState dest(InCSetState original) const { |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
82 |
assert(original.is_valid(), |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
83 |
err_msg("Original state invalid: " CSETSTATE_FORMAT, original.value())); |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
84 |
assert(_dest[original.value()].is_valid_gen(), |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
85 |
err_msg("Dest state is invalid: " CSETSTATE_FORMAT, _dest[original.value()].value())); |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
86 |
return _dest[original.value()]; |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
87 |
} |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
88 |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
89 |
public: |
25482 | 90 |
G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp); |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
91 |
~G1ParScanThreadState(); |
25482 | 92 |
|
93 |
ageTable* age_table() { return &_age_table; } |
|
94 |
||
95 |
#ifdef ASSERT |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
96 |
bool queue_is_empty() const { return _refs->is_empty(); } |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
97 |
|
25482 | 98 |
bool verify_ref(narrowOop* ref) const; |
99 |
bool verify_ref(oop* ref) const; |
|
100 |
bool verify_task(StarTask ref) const; |
|
101 |
#endif // ASSERT |
|
102 |
||
30566
18eb9aa972d0
8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents:
28213
diff
changeset
|
103 |
template <class T> void push_on_queue(T* ref); |
25482 | 104 |
|
26850
515ff48cf5f0
8036116: Fix thread-id types in G1 remembered set implementations
brutisso
parents:
26837
diff
changeset
|
105 |
template <class T> void update_rs(HeapRegion* from, T* p, uint tid) { |
26701
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
106 |
// If the new value of the field points to the same region or |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
107 |
// is the to-space, we don't need to include it in the Rset updates. |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
108 |
if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) { |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
109 |
size_t card_index = ctbs()->index_for(p); |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
110 |
// If the card hasn't been added to the buffer, do it. |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
111 |
if (ctbs()->mark_card_deferred(card_index)) { |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
112 |
dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index)); |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
113 |
} |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
114 |
} |
f8ff74a6c058
8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents:
25483
diff
changeset
|
115 |
} |
25482 | 116 |
|
117 |
void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) { |
|
118 |
_evac_failure_cl = evac_failure_cl; |
|
119 |
} |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
120 |
|
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
121 |
OopsInHeapRegionClosure* evac_failure_closure() { return _evac_failure_cl; } |
25482 | 122 |
|
123 |
int* hash_seed() { return &_hash_seed; } |
|
124 |
uint queue_num() { return _queue_num; } |
|
125 |
||
126 |
size_t term_attempts() const { return _term_attempts; } |
|
127 |
void note_term_attempt() { _term_attempts++; } |
|
128 |
||
129 |
void start_strong_roots() { |
|
130 |
_start_strong_roots = os::elapsedTime(); |
|
131 |
} |
|
132 |
void end_strong_roots() { |
|
133 |
_strong_roots_time += (os::elapsedTime() - _start_strong_roots); |
|
134 |
} |
|
135 |
double strong_roots_time() const { return _strong_roots_time; } |
|
136 |
||
137 |
void start_term_time() { |
|
138 |
note_term_attempt(); |
|
139 |
_start_term = os::elapsedTime(); |
|
140 |
} |
|
141 |
void end_term_time() { |
|
142 |
_term_time += (os::elapsedTime() - _start_term); |
|
143 |
} |
|
144 |
double term_time() const { return _term_time; } |
|
145 |
||
146 |
double elapsed_time() const { |
|
147 |
return os::elapsedTime() - _start; |
|
148 |
} |
|
149 |
||
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
150 |
static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty); |
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
151 |
void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const; |
25482 | 152 |
|
153 |
size_t* surviving_young_words() { |
|
154 |
// We add on to hide entry 0 which accumulates surviving words for |
|
155 |
// age -1 regions (i.e. non-young ones) |
|
156 |
return _surviving_young_words; |
|
157 |
} |
|
158 |
||
159 |
private: |
|
160 |
#define G1_PARTIAL_ARRAY_MASK 0x2 |
|
161 |
||
162 |
inline bool has_partial_array_mask(oop* ref) const { |
|
163 |
return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; |
|
164 |
} |
|
165 |
||
166 |
// We never encode partial array oops as narrowOop*, so return false immediately. |
|
167 |
// This allows the compiler to create optimized code when popping references from |
|
168 |
// the work queue. |
|
169 |
inline bool has_partial_array_mask(narrowOop* ref) const { |
|
170 |
assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); |
|
171 |
return false; |
|
172 |
} |
|
173 |
||
174 |
// Only implement set_partial_array_mask() for regular oops, not for narrowOops. |
|
175 |
// We always encode partial arrays as regular oop, to allow the |
|
176 |
// specialization for has_partial_array_mask() for narrowOops above. |
|
177 |
// This means that unintentional use of this method with narrowOops are caught |
|
178 |
// by the compiler. |
|
179 |
inline oop* set_partial_array_mask(oop obj) const { |
|
180 |
assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); |
|
181 |
return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); |
|
182 |
} |
|
183 |
||
184 |
inline oop clear_partial_array_mask(oop* ref) const { |
|
185 |
return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); |
|
186 |
} |
|
187 |
||
188 |
inline void do_oop_partial_array(oop* p); |
|
189 |
||
190 |
// This method is applied to the fields of the objects that have just been copied. |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
191 |
template <class T> inline void do_oop_evac(T* p, HeapRegion* from); |
25482 | 192 |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
193 |
template <class T> inline void deal_with_reference(T* ref_to_scan); |
25482 | 194 |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
195 |
inline void dispatch_reference(StarTask ref); |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
196 |
|
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
197 |
// Tries to allocate word_sz in the PLAB of the next "generation" after trying to |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
198 |
// allocate into dest. State is the original (source) cset state for the object |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
199 |
// that is allocated for. |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
200 |
// Returns a non-NULL pointer if successful, and updates dest if required. |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
201 |
HeapWord* allocate_in_next_plab(InCSetState const state, |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
202 |
InCSetState* dest, |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
203 |
size_t word_sz, |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
204 |
AllocationContext_t const context); |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
205 |
|
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
206 |
inline InCSetState next_state(InCSetState const state, markOop const m, uint& age); |
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
207 |
public: |
25482 | 208 |
|
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
27682
diff
changeset
|
209 |
oop copy_to_survivor_space(InCSetState const state, oop const obj, markOop const old_mark); |
25482 | 210 |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
211 |
void trim_queue(); |
25482 | 212 |
|
25483
962ccf95c515
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
25482
diff
changeset
|
213 |
inline void steal_and_trim_queue(RefToScanQueueSet *task_queues); |
25482 | 214 |
}; |
215 |
||
216 |
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP |