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