src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp

Mon, 21 Jul 2014 09:59:46 +0200

author
tschatzl
date
Mon, 21 Jul 2014 09:59:46 +0200
changeset 7007
7df07d855c8e
parent 6938
a2328cbebb23
child 7118
227a9e5e4b4a
permissions
-rw-r--r--

8048085: Aborting marking just before remark results in useless additional clearing of the next mark bitmap
Summary: Skip clearing the next bitmap if we just recently aborted since the full GC already clears this bitmap.
Reviewed-by: brutisso

tschatzl@6937 1 /*
tschatzl@6937 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
tschatzl@6937 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tschatzl@6937 4 *
tschatzl@6937 5 * This code is free software; you can redistribute it and/or modify it
tschatzl@6937 6 * under the terms of the GNU General Public License version 2 only, as
tschatzl@6937 7 * published by the Free Software Foundation.
tschatzl@6937 8 *
tschatzl@6937 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tschatzl@6937 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tschatzl@6937 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tschatzl@6937 12 * version 2 for more details (a copy is included in the LICENSE file that
tschatzl@6937 13 * accompanied this code).
tschatzl@6937 14 *
tschatzl@6937 15 * You should have received a copy of the GNU General Public License version
tschatzl@6937 16 * 2 along with this work; if not, write to the Free Software Foundation,
tschatzl@6937 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tschatzl@6937 18 *
tschatzl@6937 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tschatzl@6937 20 * or visit www.oracle.com if you need additional information or have any
tschatzl@6937 21 * questions.
tschatzl@6937 22 *
tschatzl@6937 23 */
tschatzl@6937 24
tschatzl@6937 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP
tschatzl@6937 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP
tschatzl@6937 27
tschatzl@6937 28 #include "gc_implementation/g1/dirtyCardQueue.hpp"
tschatzl@6937 29 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
tschatzl@6937 30 #include "gc_implementation/g1/g1CollectedHeap.hpp"
tschatzl@6937 31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
tschatzl@6937 32 #include "gc_implementation/g1/g1OopClosures.hpp"
tschatzl@6937 33 #include "gc_implementation/g1/g1RemSet.hpp"
tschatzl@6937 34 #include "gc_implementation/shared/ageTable.hpp"
tschatzl@6937 35 #include "memory/allocation.hpp"
tschatzl@6937 36 #include "oops/oop.hpp"
tschatzl@6937 37
tschatzl@6937 38 class HeapRegion;
tschatzl@6937 39 class outputStream;
tschatzl@6937 40
tschatzl@6937 41 class G1ParScanThreadState : public StackObj {
tschatzl@6938 42 private:
tschatzl@6937 43 G1CollectedHeap* _g1h;
tschatzl@6937 44 RefToScanQueue* _refs;
tschatzl@6937 45 DirtyCardQueue _dcq;
tschatzl@6937 46 G1SATBCardTableModRefBS* _ct_bs;
tschatzl@6937 47 G1RemSet* _g1_rem;
tschatzl@6937 48
tschatzl@6937 49 G1ParGCAllocBuffer _surviving_alloc_buffer;
tschatzl@6937 50 G1ParGCAllocBuffer _tenured_alloc_buffer;
tschatzl@6937 51 G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount];
tschatzl@6937 52 ageTable _age_table;
tschatzl@6937 53
tschatzl@6937 54 G1ParScanClosure _scanner;
tschatzl@6937 55
tschatzl@6937 56 size_t _alloc_buffer_waste;
tschatzl@6937 57 size_t _undo_waste;
tschatzl@6937 58
tschatzl@6937 59 OopsInHeapRegionClosure* _evac_failure_cl;
tschatzl@6937 60
tschatzl@6937 61 int _hash_seed;
tschatzl@6937 62 uint _queue_num;
tschatzl@6937 63
tschatzl@6937 64 size_t _term_attempts;
tschatzl@6937 65
tschatzl@6937 66 double _start;
tschatzl@6937 67 double _start_strong_roots;
tschatzl@6937 68 double _strong_roots_time;
tschatzl@6937 69 double _start_term;
tschatzl@6937 70 double _term_time;
tschatzl@6937 71
tschatzl@6937 72 // Map from young-age-index (0 == not young, 1 is youngest) to
tschatzl@6937 73 // surviving words. base is what we get back from the malloc call
tschatzl@6937 74 size_t* _surviving_young_words_base;
tschatzl@6937 75 // this points into the array, as we use the first few entries for padding
tschatzl@6937 76 size_t* _surviving_young_words;
tschatzl@6937 77
tschatzl@6937 78 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
tschatzl@6937 79
tschatzl@6937 80 void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
tschatzl@6937 81
tschatzl@6937 82 void add_to_undo_waste(size_t waste) { _undo_waste += waste; }
tschatzl@6937 83
tschatzl@6937 84 DirtyCardQueue& dirty_card_queue() { return _dcq; }
tschatzl@6937 85 G1SATBCardTableModRefBS* ctbs() { return _ct_bs; }
tschatzl@6937 86
tschatzl@6937 87 template <class T> inline void immediate_rs_update(HeapRegion* from, T* p, int tid);
tschatzl@6937 88
tschatzl@6937 89 template <class T> void deferred_rs_update(HeapRegion* from, T* p, int tid) {
tschatzl@6937 90 // If the new value of the field points to the same region or
tschatzl@6937 91 // is the to-space, we don't need to include it in the Rset updates.
tschatzl@6937 92 if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
tschatzl@6937 93 size_t card_index = ctbs()->index_for(p);
tschatzl@6937 94 // If the card hasn't been added to the buffer, do it.
tschatzl@6937 95 if (ctbs()->mark_card_deferred(card_index)) {
tschatzl@6937 96 dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
tschatzl@6937 97 }
tschatzl@6937 98 }
tschatzl@6937 99 }
tschatzl@6937 100
tschatzl@6938 101 public:
tschatzl@6937 102 G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp);
tschatzl@6938 103 ~G1ParScanThreadState();
tschatzl@6937 104
tschatzl@6937 105 ageTable* age_table() { return &_age_table; }
tschatzl@6937 106
tschatzl@6937 107 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) {
tschatzl@6937 108 return _alloc_buffers[purpose];
tschatzl@6937 109 }
tschatzl@6937 110
tschatzl@6937 111 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; }
tschatzl@6937 112 size_t undo_waste() const { return _undo_waste; }
tschatzl@6937 113
tschatzl@6937 114 #ifdef ASSERT
tschatzl@6938 115 bool queue_is_empty() const { return _refs->is_empty(); }
tschatzl@6938 116
tschatzl@6937 117 bool verify_ref(narrowOop* ref) const;
tschatzl@6937 118 bool verify_ref(oop* ref) const;
tschatzl@6937 119 bool verify_task(StarTask ref) const;
tschatzl@6937 120 #endif // ASSERT
tschatzl@6937 121
tschatzl@6937 122 template <class T> void push_on_queue(T* ref) {
tschatzl@6937 123 assert(verify_ref(ref), "sanity");
tschatzl@6938 124 _refs->push(ref);
tschatzl@6937 125 }
tschatzl@6937 126
tschatzl@6937 127 template <class T> inline void update_rs(HeapRegion* from, T* p, int tid);
tschatzl@6937 128
tschatzl@6938 129 private:
tschatzl@6937 130
tschatzl@6938 131 inline HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz);
tschatzl@6938 132 inline HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz);
tschatzl@6938 133 inline void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz);
tschatzl@6937 134
tschatzl@6938 135 public:
tschatzl@6937 136
tschatzl@6937 137 void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
tschatzl@6937 138 _evac_failure_cl = evac_failure_cl;
tschatzl@6937 139 }
tschatzl@6938 140
tschatzl@6938 141 OopsInHeapRegionClosure* evac_failure_closure() { return _evac_failure_cl; }
tschatzl@6937 142
tschatzl@6937 143 int* hash_seed() { return &_hash_seed; }
tschatzl@6937 144 uint queue_num() { return _queue_num; }
tschatzl@6937 145
tschatzl@6937 146 size_t term_attempts() const { return _term_attempts; }
tschatzl@6937 147 void note_term_attempt() { _term_attempts++; }
tschatzl@6937 148
tschatzl@6937 149 void start_strong_roots() {
tschatzl@6937 150 _start_strong_roots = os::elapsedTime();
tschatzl@6937 151 }
tschatzl@6937 152 void end_strong_roots() {
tschatzl@6937 153 _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
tschatzl@6937 154 }
tschatzl@6937 155 double strong_roots_time() const { return _strong_roots_time; }
tschatzl@6937 156
tschatzl@6937 157 void start_term_time() {
tschatzl@6937 158 note_term_attempt();
tschatzl@6937 159 _start_term = os::elapsedTime();
tschatzl@6937 160 }
tschatzl@6937 161 void end_term_time() {
tschatzl@6937 162 _term_time += (os::elapsedTime() - _start_term);
tschatzl@6937 163 }
tschatzl@6937 164 double term_time() const { return _term_time; }
tschatzl@6937 165
tschatzl@6937 166 double elapsed_time() const {
tschatzl@6937 167 return os::elapsedTime() - _start;
tschatzl@6937 168 }
tschatzl@6937 169
tschatzl@6938 170 static void print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
tschatzl@6938 171 void print_termination_stats(int i, outputStream* const st = gclog_or_tty) const;
tschatzl@6937 172
tschatzl@6937 173 size_t* surviving_young_words() {
tschatzl@6937 174 // We add on to hide entry 0 which accumulates surviving words for
tschatzl@6937 175 // age -1 regions (i.e. non-young ones)
tschatzl@6937 176 return _surviving_young_words;
tschatzl@6937 177 }
tschatzl@6937 178
tschatzl@6937 179 private:
tschatzl@6938 180 void retire_alloc_buffers();
tschatzl@6937 181
tschatzl@6937 182 #define G1_PARTIAL_ARRAY_MASK 0x2
tschatzl@6937 183
tschatzl@6937 184 inline bool has_partial_array_mask(oop* ref) const {
tschatzl@6937 185 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
tschatzl@6937 186 }
tschatzl@6937 187
tschatzl@6937 188 // We never encode partial array oops as narrowOop*, so return false immediately.
tschatzl@6937 189 // This allows the compiler to create optimized code when popping references from
tschatzl@6937 190 // the work queue.
tschatzl@6937 191 inline bool has_partial_array_mask(narrowOop* ref) const {
tschatzl@6937 192 assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*");
tschatzl@6937 193 return false;
tschatzl@6937 194 }
tschatzl@6937 195
tschatzl@6937 196 // Only implement set_partial_array_mask() for regular oops, not for narrowOops.
tschatzl@6937 197 // We always encode partial arrays as regular oop, to allow the
tschatzl@6937 198 // specialization for has_partial_array_mask() for narrowOops above.
tschatzl@6937 199 // This means that unintentional use of this method with narrowOops are caught
tschatzl@6937 200 // by the compiler.
tschatzl@6937 201 inline oop* set_partial_array_mask(oop obj) const {
tschatzl@6937 202 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
tschatzl@6937 203 return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK);
tschatzl@6937 204 }
tschatzl@6937 205
tschatzl@6937 206 inline oop clear_partial_array_mask(oop* ref) const {
tschatzl@6937 207 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
tschatzl@6937 208 }
tschatzl@6937 209
tschatzl@6937 210 inline void do_oop_partial_array(oop* p);
tschatzl@6937 211
tschatzl@6937 212 // This method is applied to the fields of the objects that have just been copied.
tschatzl@6938 213 template <class T> inline void do_oop_evac(T* p, HeapRegion* from);
tschatzl@6937 214
tschatzl@6938 215 template <class T> inline void deal_with_reference(T* ref_to_scan);
tschatzl@6937 216
tschatzl@6938 217 inline void dispatch_reference(StarTask ref);
tschatzl@6938 218 public:
tschatzl@6937 219
tschatzl@6937 220 oop copy_to_survivor_space(oop const obj);
tschatzl@6937 221
tschatzl@6938 222 void trim_queue();
tschatzl@6937 223
tschatzl@6938 224 inline void steal_and_trim_queue(RefToScanQueueSet *task_queues);
tschatzl@6937 225 };
tschatzl@6937 226
tschatzl@6937 227 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_HPP

mercurial