annotate src/share/vm/gc/parallel/psPromotionManager.hpp @ 8528:01d947f8d411

8081382: Make flags ParallelGCThreads and ConcGCThreads of type uint Reviewed-by: drwhite, stefank
author david
date Fri, 05 Jun 2015 09:50:09 +0200
parents 92457dfb91bd
children f944761a3ce3
rev   line source
duke@0 1 /*
stefank@8046 2 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
pliden@8413 25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_HPP
pliden@8413 26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_HPP
stefank@1879 27
pliden@8413 28 #include "gc/parallel/psPromotionLAB.hpp"
pliden@8413 29 #include "gc/shared/copyFailedInfo.hpp"
pliden@8413 30 #include "gc/shared/gcTrace.hpp"
pliden@8413 31 #include "gc/shared/taskqueue.hpp"
stefank@1879 32 #include "memory/allocation.hpp"
stefank@5080 33 #include "memory/padded.hpp"
stefank@5080 34 #include "utilities/globalDefinitions.hpp"
stefank@1879 35
duke@0 36 //
duke@0 37 // psPromotionManager is used by a single thread to manage object survival
duke@0 38 // during a scavenge. The promotion manager contains thread local data only.
duke@0 39 //
sla@4802 40 // NOTE! Be careful when allocating the stacks on cheap. If you are going
duke@0 41 // to use a promotion manager in more than one thread, the stacks MUST be
duke@0 42 // on cheap. This can lead to memory leaks, though, as they are not auto
duke@0 43 // deallocated.
duke@0 44 //
duke@0 45 // FIX ME FIX ME Add a destructor, and don't rely on the user to drain/flush/deallocate!
duke@0 46 //
duke@0 47
duke@0 48 class MutableSpace;
duke@0 49 class PSOldGen;
duke@0 50 class ParCompactionManager;
duke@0 51
stefank@5080 52 class PSPromotionManager VALUE_OBJ_CLASS_SPEC {
duke@0 53 friend class PSScavenge;
duke@0 54 friend class PSRefProcTaskExecutor;
duke@0 55 private:
stefank@5080 56 static PaddedEnd<PSPromotionManager>* _manager_array;
stefank@5080 57 static OopStarTaskQueueSet* _stack_array_depth;
stefank@5080 58 static PSOldGen* _old_gen;
stefank@5080 59 static MutableSpace* _young_space;
duke@0 60
jcoomes@1585 61 #if TASKQUEUE_STATS
jcoomes@1585 62 size_t _masked_pushes;
jcoomes@1585 63 size_t _masked_steals;
jcoomes@1585 64 size_t _arrays_chunked;
jcoomes@1585 65 size_t _array_chunks_processed;
duke@0 66
jwilhelm@7225 67 void print_local_stats(outputStream* const out, uint i) const;
jwilhelm@7225 68 static void print_taskqueue_stats(outputStream* const out = gclog_or_tty);
duke@0 69
jcoomes@1585 70 void reset_stats();
jcoomes@1585 71 #endif // TASKQUEUE_STATS
duke@0 72
duke@0 73 PSYoungPromotionLAB _young_lab;
duke@0 74 PSOldPromotionLAB _old_lab;
duke@0 75 bool _young_gen_is_full;
duke@0 76 bool _old_gen_is_full;
duke@0 77
duke@0 78 OopStarTaskQueue _claimed_stack_depth;
zgu@3465 79 OverflowTaskQueue<oop, mtGC> _claimed_stack_breadth;
duke@0 80
duke@0 81 bool _totally_drain;
duke@0 82 uint _target_stack_size;
duke@0 83
duke@0 84 uint _array_chunk_size;
duke@0 85 uint _min_array_size_for_chunking;
duke@0 86
sla@4802 87 PromotionFailedInfo _promotion_failed_info;
sla@4802 88
duke@0 89 // Accessors
coleenp@113 90 static PSOldGen* old_gen() { return _old_gen; }
coleenp@113 91 static MutableSpace* young_space() { return _young_space; }
duke@0 92
david@8528 93 inline static PSPromotionManager* manager_array(uint index);
coleenp@113 94 template <class T> inline void claim_or_forward_internal_depth(T* p);
duke@0 95
duke@0 96 // On the task queues we push reference locations as well as
duke@0 97 // partially-scanned arrays (in the latter case, we push an oop to
duke@0 98 // the from-space image of the array and the length on the
duke@0 99 // from-space image indicates how many entries on the array we still
duke@0 100 // need to scan; this is basically how ParNew does partial array
duke@0 101 // scanning too). To be able to distinguish between reference
duke@0 102 // locations and partially-scanned array oops we simply mask the
duke@0 103 // latter oops with 0x01. The next three methods do the masking,
duke@0 104 // unmasking, and checking whether the oop is masked or not. Notice
duke@0 105 // that the signature of the mask and unmask methods looks a bit
duke@0 106 // strange, as they accept and return different types (oop and
duke@0 107 // oop*). This is because of the difference in types between what
duke@0 108 // the task queue holds (oop*) and oops to partially-scanned arrays
duke@0 109 // (oop). We do all the necessary casting in the mask / unmask
duke@0 110 // methods to avoid sprinkling the rest of the code with more casts.
duke@0 111
coleenp@113 112 // These are added to the taskqueue so PS_CHUNKED_ARRAY_OOP_MASK (or any
coleenp@113 113 // future masks) can't conflict with COMPRESSED_OOP_MASK
coleenp@113 114 #define PS_CHUNKED_ARRAY_OOP_MASK 0x2
coleenp@113 115
coleenp@113 116 bool is_oop_masked(StarTask p) {
coleenp@113 117 // If something is marked chunked it's always treated like wide oop*
coleenp@113 118 return (((intptr_t)(oop*)p) & PS_CHUNKED_ARRAY_OOP_MASK) ==
coleenp@113 119 PS_CHUNKED_ARRAY_OOP_MASK;
duke@0 120 }
duke@0 121
duke@0 122 oop* mask_chunked_array_oop(oop obj) {
duke@0 123 assert(!is_oop_masked((oop*) obj), "invariant");
hseigel@5349 124 oop* ret = (oop*) (cast_from_oop<uintptr_t>(obj) | PS_CHUNKED_ARRAY_OOP_MASK);
duke@0 125 assert(is_oop_masked(ret), "invariant");
duke@0 126 return ret;
duke@0 127 }
duke@0 128
coleenp@113 129 oop unmask_chunked_array_oop(StarTask p) {
duke@0 130 assert(is_oop_masked(p), "invariant");
coleenp@113 131 assert(!p.is_narrow(), "chunked array oops cannot be narrow");
coleenp@113 132 oop *chunk = (oop*)p; // cast p to oop (uses conversion operator)
coleenp@113 133 oop ret = oop((oop*)((uintptr_t)chunk & ~PS_CHUNKED_ARRAY_OOP_MASK));
duke@0 134 assert(!is_oop_masked((oop*) ret), "invariant");
duke@0 135 return ret;
duke@0 136 }
duke@0 137
coleenp@113 138 template <class T> void process_array_chunk_work(oop obj,
coleenp@113 139 int start, int end);
duke@0 140 void process_array_chunk(oop old);
duke@0 141
stefank@8321 142 template <class T> void push_depth(T* p);
duke@0 143
sfriberg@7565 144 inline void promotion_trace_event(oop new_obj, oop old_obj, size_t obj_size,
sfriberg@7565 145 uint age, bool tenured,
sfriberg@7565 146 const PSPromotionLAB* lab);
sfriberg@7565 147
duke@0 148 protected:
coleenp@113 149 static OopStarTaskQueueSet* stack_array_depth() { return _stack_array_depth; }
duke@0 150 public:
duke@0 151 // Static
duke@0 152 static void initialize();
duke@0 153
duke@0 154 static void pre_scavenge();
sla@4802 155 static bool post_scavenge(YoungGCTracer& gc_tracer);
duke@0 156
david@8528 157 static PSPromotionManager* gc_thread_promotion_manager(uint index);
duke@0 158 static PSPromotionManager* vm_thread_promotion_manager();
duke@0 159
stefank@8321 160 static bool steal_depth(int queue_num, int* seed, StarTask& t);
duke@0 161
duke@0 162 PSPromotionManager();
duke@0 163
duke@0 164 // Accessors
duke@0 165 OopStarTaskQueue* claimed_stack_depth() {
duke@0 166 return &_claimed_stack_depth;
duke@0 167 }
duke@0 168
duke@0 169 bool young_gen_is_full() { return _young_gen_is_full; }
duke@0 170
duke@0 171 bool old_gen_is_full() { return _old_gen_is_full; }
duke@0 172 void set_old_gen_is_full(bool state) { _old_gen_is_full = state; }
duke@0 173
duke@0 174 // Promotion methods
iveresov@3101 175 template<bool promote_immediately> oop copy_to_survivor_space(oop o);
duke@0 176 oop oop_promotion_failed(oop obj, markOop obj_mark);
duke@0 177
duke@0 178 void reset();
duke@0 179
duke@0 180 void flush_labs();
duke@0 181 void drain_stacks(bool totally_drain) {
tonyp@1626 182 drain_stacks_depth(totally_drain);
duke@0 183 }
coleenp@113 184 public:
duke@0 185 void drain_stacks_cond_depth() {
duke@0 186 if (claimed_stack_depth()->size() > _target_stack_size) {
duke@0 187 drain_stacks_depth(false);
duke@0 188 }
duke@0 189 }
duke@0 190 void drain_stacks_depth(bool totally_drain);
duke@0 191
duke@0 192 bool stacks_empty() {
tonyp@1626 193 return claimed_stack_depth()->is_empty();
duke@0 194 }
duke@0 195
coleenp@113 196 inline void process_popped_location_depth(StarTask p);
duke@0 197
stefank@7905 198 static bool should_scavenge(oop* p, bool check_to_space = false);
stefank@7905 199 static bool should_scavenge(narrowOop* p, bool check_to_space = false);
stefank@7905 200
stefank@7905 201 template <class T, bool promote_immediately>
stefank@7905 202 void copy_and_push_safe_barrier(T* p);
stefank@7905 203
coleenp@113 204 template <class T> inline void claim_or_forward_depth(T* p);
duke@0 205
jcoomes@1585 206 TASKQUEUE_STATS_ONLY(inline void record_steal(StarTask& p);)
stefank@8046 207
stefank@8046 208 void push_contents(oop obj);
duke@0 209 };
stefank@1879 210
pliden@8413 211 #endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_HPP