annotate src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp @ 20223:b0c374311c4e

8035400: Move G1ParScanThreadState into its own files Summary: Extract the G1ParScanThreadState class from G1CollectedHeap.?pp into its own files. Reviewed-by: brutisso, mgerdin
author tschatzl
date Mon, 21 Jul 2014 09:41:04 +0200
parents
children a2328cbebb23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20223
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
1 /*
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
4 *
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
7 * published by the Free Software Foundation.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
8 *
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
13 * accompanied this code).
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
14 *
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
18 *
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
21 * questions.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
22 *
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
23 */
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
24
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
27
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
28 #include "gc_implementation/g1/dirtyCardQueue.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
29 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
30 #include "gc_implementation/g1/g1CollectedHeap.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
32 #include "gc_implementation/g1/g1OopClosures.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
33 #include "gc_implementation/g1/g1RemSet.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
34 #include "gc_implementation/shared/ageTable.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
35 #include "memory/allocation.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
36 #include "oops/oop.hpp"
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
37
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
38 class HeapRegion;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
39 class outputStream;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
40
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
41 class G1ParScanThreadState : public StackObj {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
42 protected:
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
43 G1CollectedHeap* _g1h;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
44 RefToScanQueue* _refs;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
45 DirtyCardQueue _dcq;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
46 G1SATBCardTableModRefBS* _ct_bs;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
47 G1RemSet* _g1_rem;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
48
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
49 G1ParGCAllocBuffer _surviving_alloc_buffer;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
50 G1ParGCAllocBuffer _tenured_alloc_buffer;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
51 G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount];
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
52 ageTable _age_table;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
53
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
54 G1ParScanClosure _scanner;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
55
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
56 size_t _alloc_buffer_waste;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
57 size_t _undo_waste;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
58
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
59 OopsInHeapRegionClosure* _evac_failure_cl;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
60
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
61 int _hash_seed;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
62 uint _queue_num;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
63
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
64 size_t _term_attempts;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
65
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
66 double _start;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
67 double _start_strong_roots;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
68 double _strong_roots_time;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
69 double _start_term;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
70 double _term_time;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
71
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
72 // Map from young-age-index (0 == not young, 1 is youngest) to
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
73 // surviving words. base is what we get back from the malloc call
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
74 size_t* _surviving_young_words_base;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
75 // this points into the array, as we use the first few entries for padding
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
76 size_t* _surviving_young_words;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
77
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
78 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
79
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
80 void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
81
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
82 void add_to_undo_waste(size_t waste) { _undo_waste += waste; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
83
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
84 DirtyCardQueue& dirty_card_queue() { return _dcq; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
85 G1SATBCardTableModRefBS* ctbs() { return _ct_bs; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
86
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
87 template <class T> inline void immediate_rs_update(HeapRegion* from, T* p, int tid);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
88
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
89 template <class T> void deferred_rs_update(HeapRegion* from, T* p, int tid) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
90 // If the new value of the field points to the same region or
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
91 // is the to-space, we don't need to include it in the Rset updates.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
92 if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
93 size_t card_index = ctbs()->index_for(p);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
94 // If the card hasn't been added to the buffer, do it.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
95 if (ctbs()->mark_card_deferred(card_index)) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
96 dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
97 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
98 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
99 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
100
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
101 public:
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
102 G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
103 ~G1ParScanThreadState() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
104 retire_alloc_buffers();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
105 FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
106 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
107
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
108 RefToScanQueue* refs() { return _refs; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
109 ageTable* age_table() { return &_age_table; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
110
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
111 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
112 return _alloc_buffers[purpose];
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
113 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
114
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
115 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
116 size_t undo_waste() const { return _undo_waste; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
117
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
118 #ifdef ASSERT
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
119 bool verify_ref(narrowOop* ref) const;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
120 bool verify_ref(oop* ref) const;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
121 bool verify_task(StarTask ref) const;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
122 #endif // ASSERT
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
123
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
124 template <class T> void push_on_queue(T* ref) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
125 assert(verify_ref(ref), "sanity");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
126 refs()->push(ref);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
127 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
128
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
129 template <class T> inline void update_rs(HeapRegion* from, T* p, int tid);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
130
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
131 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
132 HeapWord* obj = NULL;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
133 size_t gclab_word_size = _g1h->desired_plab_sz(purpose);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
134 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
135 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
136 add_to_alloc_buffer_waste(alloc_buf->words_remaining());
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
137 alloc_buf->retire(false /* end_of_gc */, false /* retain */);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
138
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
139 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
140 if (buf == NULL) return NULL; // Let caller handle allocation failure.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
141 // Otherwise.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
142 alloc_buf->set_word_size(gclab_word_size);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
143 alloc_buf->set_buf(buf);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
144
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
145 obj = alloc_buf->allocate(word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
146 assert(obj != NULL, "buffer was definitely big enough...");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
147 } else {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
148 obj = _g1h->par_allocate_during_gc(purpose, word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
149 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
150 return obj;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
151 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
152
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
153 HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
154 HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
155 if (obj != NULL) return obj;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
156 return allocate_slow(purpose, word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
157 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
158
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
159 void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
160 if (alloc_buffer(purpose)->contains(obj)) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
161 assert(alloc_buffer(purpose)->contains(obj + word_sz - 1),
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
162 "should contain whole object");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
163 alloc_buffer(purpose)->undo_allocation(obj, word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
164 } else {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
165 CollectedHeap::fill_with_object(obj, word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
166 add_to_undo_waste(word_sz);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
167 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
168 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
169
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
170 void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
171 _evac_failure_cl = evac_failure_cl;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
172 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
173 OopsInHeapRegionClosure* evac_failure_closure() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
174 return _evac_failure_cl;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
175 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
176
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
177 int* hash_seed() { return &_hash_seed; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
178 uint queue_num() { return _queue_num; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
179
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
180 size_t term_attempts() const { return _term_attempts; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
181 void note_term_attempt() { _term_attempts++; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
182
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
183 void start_strong_roots() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
184 _start_strong_roots = os::elapsedTime();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
185 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
186 void end_strong_roots() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
187 _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
188 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
189 double strong_roots_time() const { return _strong_roots_time; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
190
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
191 void start_term_time() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
192 note_term_attempt();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
193 _start_term = os::elapsedTime();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
194 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
195 void end_term_time() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
196 _term_time += (os::elapsedTime() - _start_term);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
197 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
198 double term_time() const { return _term_time; }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
199
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
200 double elapsed_time() const {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
201 return os::elapsedTime() - _start;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
202 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
203
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
204 static void
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
205 print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
206 void
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
207 print_termination_stats(int i, outputStream* const st = gclog_or_tty) const;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
208
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
209 size_t* surviving_young_words() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
210 // We add on to hide entry 0 which accumulates surviving words for
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
211 // age -1 regions (i.e. non-young ones)
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
212 return _surviving_young_words;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
213 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
214
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
215 private:
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
216 void retire_alloc_buffers() {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
217 for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
218 size_t waste = _alloc_buffers[ap]->words_remaining();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
219 add_to_alloc_buffer_waste(waste);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
220 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap),
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
221 true /* end_of_gc */,
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
222 false /* retain */);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
223 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
224 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
225
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
226 #define G1_PARTIAL_ARRAY_MASK 0x2
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
227
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
228 inline bool has_partial_array_mask(oop* ref) const {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
229 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
230 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
231
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
232 // We never encode partial array oops as narrowOop*, so return false immediately.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
233 // This allows the compiler to create optimized code when popping references from
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
234 // the work queue.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
235 inline bool has_partial_array_mask(narrowOop* ref) const {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
236 assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
237 return false;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
238 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
239
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
240 // Only implement set_partial_array_mask() for regular oops, not for narrowOops.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
241 // We always encode partial arrays as regular oop, to allow the
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
242 // specialization for has_partial_array_mask() for narrowOops above.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
243 // This means that unintentional use of this method with narrowOops are caught
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
244 // by the compiler.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
245 inline oop* set_partial_array_mask(oop obj) const {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
246 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
247 return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
248 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
249
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
250 inline oop clear_partial_array_mask(oop* ref) const {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
251 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
252 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
253
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
254 inline void do_oop_partial_array(oop* p);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
255
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
256 // This method is applied to the fields of the objects that have just been copied.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
257 template <class T> void do_oop_evac(T* p, HeapRegion* from) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
258 assert(!oopDesc::is_null(oopDesc::load_decode_heap_oop(p)),
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
259 "Reference should not be NULL here as such are never pushed to the task queue.");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
260 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
261
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
262 // Although we never intentionally push references outside of the collection
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
263 // set, due to (benign) races in the claim mechanism during RSet scanning more
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
264 // than one thread might claim the same card. So the same card may be
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
265 // processed multiple times. So redo this check.
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
266 if (_g1h->in_cset_fast_test(obj)) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
267 oop forwardee;
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
268 if (obj->is_forwarded()) {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
269 forwardee = obj->forwardee();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
270 } else {
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
271 forwardee = copy_to_survivor_space(obj);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
272 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
273 assert(forwardee != NULL, "forwardee should not be NULL");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
274 oopDesc::encode_store_heap_oop(p, forwardee);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
275 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
276
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
277 assert(obj != NULL, "Must be");
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
278 update_rs(from, p, queue_num());
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
279 }
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
280 public:
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
281
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
282 oop copy_to_survivor_space(oop const obj);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
283
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
284 template <class T> inline void deal_with_reference(T* ref_to_scan);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
285
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
286 inline void deal_with_reference(StarTask ref);
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
287
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
288 public:
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
289 void trim_queue();
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
290 };
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
291
b0c374311c4e 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
292 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP