Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp @ 20450:fa6c442c59ee
8057827: notify an obj when allocation context stats are available
Reviewed-by: mikael, jmasa, tschatzl
author | jcoomes |
---|---|
date | Wed, 10 Sep 2014 16:06:53 -0700 |
parents | 227a9e5e4b4a |
children | 6948da6d7c13 |
rev | line source |
---|---|
20223 | 1 /* |
2 * Copyright (c) 2014, 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 #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 { | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
42 private: |
20223 | 43 G1CollectedHeap* _g1h; |
44 RefToScanQueue* _refs; | |
45 DirtyCardQueue _dcq; | |
46 G1SATBCardTableModRefBS* _ct_bs; | |
47 G1RemSet* _g1_rem; | |
48 | |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20224
diff
changeset
|
49 G1ParGCAllocator* _g1_par_allocator; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20224
diff
changeset
|
50 |
20223 | 51 ageTable _age_table; |
52 | |
53 G1ParScanClosure _scanner; | |
54 | |
55 size_t _alloc_buffer_waste; | |
56 size_t _undo_waste; | |
57 | |
58 OopsInHeapRegionClosure* _evac_failure_cl; | |
59 | |
60 int _hash_seed; | |
61 uint _queue_num; | |
62 | |
63 size_t _term_attempts; | |
64 | |
65 double _start; | |
66 double _start_strong_roots; | |
67 double _strong_roots_time; | |
68 double _start_term; | |
69 double _term_time; | |
70 | |
71 // Map from young-age-index (0 == not young, 1 is youngest) to | |
72 // surviving words. base is what we get back from the malloc call | |
73 size_t* _surviving_young_words_base; | |
74 // this points into the array, as we use the first few entries for padding | |
75 size_t* _surviving_young_words; | |
76 | |
77 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t)) | |
78 | |
79 void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; } | |
80 void add_to_undo_waste(size_t waste) { _undo_waste += waste; } | |
81 | |
82 DirtyCardQueue& dirty_card_queue() { return _dcq; } | |
83 G1SATBCardTableModRefBS* ctbs() { return _ct_bs; } | |
84 | |
85 template <class T> inline void immediate_rs_update(HeapRegion* from, T* p, int tid); | |
86 | |
87 template <class T> void deferred_rs_update(HeapRegion* from, T* p, int tid) { | |
88 // If the new value of the field points to the same region or | |
89 // is the to-space, we don't need to include it in the Rset updates. | |
90 if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) { | |
91 size_t card_index = ctbs()->index_for(p); | |
92 // If the card hasn't been added to the buffer, do it. | |
93 if (ctbs()->mark_card_deferred(card_index)) { | |
94 dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index)); | |
95 } | |
96 } | |
97 } | |
98 | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
99 public: |
20223 | 100 G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp); |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
101 ~G1ParScanThreadState(); |
20223 | 102 |
103 ageTable* age_table() { return &_age_table; } | |
104 | |
105 #ifdef ASSERT | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
106 bool queue_is_empty() const { return _refs->is_empty(); } |
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
107 |
20223 | 108 bool verify_ref(narrowOop* ref) const; |
109 bool verify_ref(oop* ref) const; | |
110 bool verify_task(StarTask ref) const; | |
111 #endif // ASSERT | |
112 | |
113 template <class T> void push_on_queue(T* ref) { | |
114 assert(verify_ref(ref), "sanity"); | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
115 _refs->push(ref); |
20223 | 116 } |
117 | |
118 template <class T> inline void update_rs(HeapRegion* from, T* p, int tid); | |
119 | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
120 public: |
20223 | 121 |
122 void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) { | |
123 _evac_failure_cl = evac_failure_cl; | |
124 } | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
125 |
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
126 OopsInHeapRegionClosure* evac_failure_closure() { return _evac_failure_cl; } |
20223 | 127 |
128 int* hash_seed() { return &_hash_seed; } | |
129 uint queue_num() { return _queue_num; } | |
130 | |
131 size_t term_attempts() const { return _term_attempts; } | |
132 void note_term_attempt() { _term_attempts++; } | |
133 | |
134 void start_strong_roots() { | |
135 _start_strong_roots = os::elapsedTime(); | |
136 } | |
137 void end_strong_roots() { | |
138 _strong_roots_time += (os::elapsedTime() - _start_strong_roots); | |
139 } | |
140 double strong_roots_time() const { return _strong_roots_time; } | |
141 | |
142 void start_term_time() { | |
143 note_term_attempt(); | |
144 _start_term = os::elapsedTime(); | |
145 } | |
146 void end_term_time() { | |
147 _term_time += (os::elapsedTime() - _start_term); | |
148 } | |
149 double term_time() const { return _term_time; } | |
150 | |
151 double elapsed_time() const { | |
152 return os::elapsedTime() - _start; | |
153 } | |
154 | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
155 static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty); |
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
156 void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const; |
20223 | 157 |
158 size_t* surviving_young_words() { | |
159 // We add on to hide entry 0 which accumulates surviving words for | |
160 // age -1 regions (i.e. non-young ones) | |
161 return _surviving_young_words; | |
162 } | |
163 | |
164 private: | |
165 #define G1_PARTIAL_ARRAY_MASK 0x2 | |
166 | |
167 inline bool has_partial_array_mask(oop* ref) const { | |
168 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; | |
169 } | |
170 | |
171 // We never encode partial array oops as narrowOop*, so return false immediately. | |
172 // This allows the compiler to create optimized code when popping references from | |
173 // the work queue. | |
174 inline bool has_partial_array_mask(narrowOop* ref) const { | |
175 assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); | |
176 return false; | |
177 } | |
178 | |
179 // Only implement set_partial_array_mask() for regular oops, not for narrowOops. | |
180 // We always encode partial arrays as regular oop, to allow the | |
181 // specialization for has_partial_array_mask() for narrowOops above. | |
182 // This means that unintentional use of this method with narrowOops are caught | |
183 // by the compiler. | |
184 inline oop* set_partial_array_mask(oop obj) const { | |
185 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); | |
186 return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); | |
187 } | |
188 | |
189 inline oop clear_partial_array_mask(oop* ref) const { | |
190 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); | |
191 } | |
192 | |
193 inline void do_oop_partial_array(oop* p); | |
194 | |
195 // This method is applied to the fields of the objects that have just been copied. | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
196 template <class T> inline void do_oop_evac(T* p, HeapRegion* from); |
20223 | 197 |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
198 template <class T> inline void deal_with_reference(T* ref_to_scan); |
20223 | 199 |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
200 inline void dispatch_reference(StarTask ref); |
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
201 public: |
20223 | 202 |
203 oop copy_to_survivor_space(oop const obj); | |
204 | |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
205 void trim_queue(); |
20223 | 206 |
20224
a2328cbebb23
8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents:
20223
diff
changeset
|
207 inline void steal_and_trim_queue(RefToScanQueueSet *task_queues); |
20223 | 208 }; |
209 | |
210 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP |