Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp @ 1638:b2a00dd3117c
6957084: simplify TaskQueue overflow handling
Reviewed-by: ysr, jmasa
author | jcoomes |
---|---|
date | Thu, 01 Jul 2010 21:40:45 -0700 |
parents | c18cbe5936b8 |
children | a93a9eda13f7 |
comparison
equal
deleted
inserted
replaced
1628:a00567c82f02 | 1638:b2a00dd3117c |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
76 bool _young_gen_is_full; | 76 bool _young_gen_is_full; |
77 bool _old_gen_is_full; | 77 bool _old_gen_is_full; |
78 PrefetchQueue _prefetch_queue; | 78 PrefetchQueue _prefetch_queue; |
79 | 79 |
80 OopStarTaskQueue _claimed_stack_depth; | 80 OopStarTaskQueue _claimed_stack_depth; |
81 GrowableArray<StarTask>* _overflow_stack_depth; | 81 OverflowTaskQueue<oop> _claimed_stack_breadth; |
82 OopTaskQueue _claimed_stack_breadth; | |
83 GrowableArray<oop>* _overflow_stack_breadth; | |
84 | 82 |
85 bool _depth_first; | 83 bool _depth_first; |
86 bool _totally_drain; | 84 bool _totally_drain; |
87 uint _target_stack_size; | 85 uint _target_stack_size; |
88 | 86 |
94 static MutableSpace* young_space() { return _young_space; } | 92 static MutableSpace* young_space() { return _young_space; } |
95 | 93 |
96 inline static PSPromotionManager* manager_array(int index); | 94 inline static PSPromotionManager* manager_array(int index); |
97 template <class T> inline void claim_or_forward_internal_depth(T* p); | 95 template <class T> inline void claim_or_forward_internal_depth(T* p); |
98 template <class T> inline void claim_or_forward_internal_breadth(T* p); | 96 template <class T> inline void claim_or_forward_internal_breadth(T* p); |
99 | |
100 GrowableArray<StarTask>* overflow_stack_depth() { return _overflow_stack_depth; } | |
101 GrowableArray<oop>* overflow_stack_breadth() { return _overflow_stack_breadth; } | |
102 | 97 |
103 // On the task queues we push reference locations as well as | 98 // On the task queues we push reference locations as well as |
104 // partially-scanned arrays (in the latter case, we push an oop to | 99 // partially-scanned arrays (in the latter case, we push an oop to |
105 // the from-space image of the array and the length on the | 100 // the from-space image of the array and the length on the |
106 // from-space image indicates how many entries on the array we still | 101 // from-space image indicates how many entries on the array we still |
149 template <class T> void push_depth(T* p) { | 144 template <class T> void push_depth(T* p) { |
150 assert(depth_first(), "pre-condition"); | 145 assert(depth_first(), "pre-condition"); |
151 | 146 |
152 #if PS_PM_STATS | 147 #if PS_PM_STATS |
153 ++_total_pushes; | 148 ++_total_pushes; |
154 #endif // PS_PM_STATS | 149 int stack_length = claimed_stack_depth()->overflow_stack()->length(); |
155 | 150 #endif // PS_PM_STATS |
156 if (!claimed_stack_depth()->push(p)) { | 151 |
157 overflow_stack_depth()->push(p); | 152 claimed_stack_depth()->push(p); |
158 #if PS_PM_STATS | 153 |
154 #if PS_PM_STATS | |
155 if (claimed_stack_depth()->overflow_stack()->length() != stack_length) { | |
159 ++_overflow_pushes; | 156 ++_overflow_pushes; |
160 uint stack_length = (uint) overflow_stack_depth()->length(); | 157 if ((uint)stack_length + 1 > _max_overflow_length) { |
161 if (stack_length > _max_overflow_length) { | 158 _max_overflow_length = (uint)stack_length + 1; |
162 _max_overflow_length = stack_length; | |
163 } | 159 } |
164 #endif // PS_PM_STATS | 160 } |
165 } | 161 #endif // PS_PM_STATS |
166 } | 162 } |
167 | 163 |
168 void push_breadth(oop o) { | 164 void push_breadth(oop o) { |
169 assert(!depth_first(), "pre-condition"); | 165 assert(!depth_first(), "pre-condition"); |
170 | 166 |
171 #if PS_PM_STATS | 167 #if PS_PM_STATS |
172 ++_total_pushes; | 168 ++_total_pushes; |
173 #endif // PS_PM_STATS | 169 int stack_length = claimed_stack_breadth()->overflow_stack()->length(); |
174 | 170 #endif // PS_PM_STATS |
175 if(!claimed_stack_breadth()->push(o)) { | 171 |
176 overflow_stack_breadth()->push(o); | 172 claimed_stack_breadth()->push(o); |
177 #if PS_PM_STATS | 173 |
174 #if PS_PM_STATS | |
175 if (claimed_stack_breadth()->overflow_stack()->length() != stack_length) { | |
178 ++_overflow_pushes; | 176 ++_overflow_pushes; |
179 uint stack_length = (uint) overflow_stack_breadth()->length(); | 177 if ((uint)stack_length + 1 > _max_overflow_length) { |
180 if (stack_length > _max_overflow_length) { | 178 _max_overflow_length = (uint)stack_length + 1; |
181 _max_overflow_length = stack_length; | |
182 } | 179 } |
183 #endif // PS_PM_STATS | 180 } |
184 } | 181 #endif // PS_PM_STATS |
185 } | 182 } |
186 | 183 |
187 protected: | 184 protected: |
188 static OopStarTaskQueueSet* stack_array_depth() { return _stack_array_depth; } | 185 static OopStarTaskQueueSet* stack_array_depth() { return _stack_array_depth; } |
189 static OopTaskQueueSet* stack_array_breadth() { return _stack_array_breadth; } | 186 static OopTaskQueueSet* stack_array_breadth() { return _stack_array_breadth; } |
197 | 194 |
198 static PSPromotionManager* gc_thread_promotion_manager(int index); | 195 static PSPromotionManager* gc_thread_promotion_manager(int index); |
199 static PSPromotionManager* vm_thread_promotion_manager(); | 196 static PSPromotionManager* vm_thread_promotion_manager(); |
200 | 197 |
201 static bool steal_depth(int queue_num, int* seed, StarTask& t) { | 198 static bool steal_depth(int queue_num, int* seed, StarTask& t) { |
202 assert(stack_array_depth() != NULL, "invariant"); | |
203 return stack_array_depth()->steal(queue_num, seed, t); | 199 return stack_array_depth()->steal(queue_num, seed, t); |
204 } | 200 } |
205 | 201 |
206 static bool steal_breadth(int queue_num, int* seed, Task& t) { | 202 static bool steal_breadth(int queue_num, int* seed, oop& t) { |
207 assert(stack_array_breadth() != NULL, "invariant"); | |
208 return stack_array_breadth()->steal(queue_num, seed, t); | 203 return stack_array_breadth()->steal(queue_num, seed, t); |
209 } | 204 } |
210 | 205 |
211 PSPromotionManager(); | 206 PSPromotionManager(); |
212 | 207 |
213 // Accessors | 208 // Accessors |
214 OopStarTaskQueue* claimed_stack_depth() { | 209 OopStarTaskQueue* claimed_stack_depth() { |
215 return &_claimed_stack_depth; | 210 return &_claimed_stack_depth; |
216 } | 211 } |
217 OopTaskQueue* claimed_stack_breadth() { | 212 OverflowTaskQueue<oop>* claimed_stack_breadth() { |
218 return &_claimed_stack_breadth; | 213 return &_claimed_stack_breadth; |
219 } | 214 } |
220 | 215 |
221 bool young_gen_is_full() { return _young_gen_is_full; } | 216 bool young_gen_is_full() { return _young_gen_is_full; } |
222 | 217 |
244 } | 239 } |
245 } | 240 } |
246 void drain_stacks_depth(bool totally_drain); | 241 void drain_stacks_depth(bool totally_drain); |
247 void drain_stacks_breadth(bool totally_drain); | 242 void drain_stacks_breadth(bool totally_drain); |
248 | 243 |
249 bool claimed_stack_empty() { | 244 bool depth_first() const { |
250 if (depth_first()) { | 245 return _depth_first; |
251 return claimed_stack_depth()->size() <= 0; | |
252 } else { | |
253 return claimed_stack_breadth()->size() <= 0; | |
254 } | |
255 } | |
256 bool overflow_stack_empty() { | |
257 if (depth_first()) { | |
258 return overflow_stack_depth()->length() <= 0; | |
259 } else { | |
260 return overflow_stack_breadth()->length() <= 0; | |
261 } | |
262 } | 246 } |
263 bool stacks_empty() { | 247 bool stacks_empty() { |
264 return claimed_stack_empty() && overflow_stack_empty(); | 248 return depth_first() ? |
265 } | 249 claimed_stack_depth()->is_empty() : |
266 bool depth_first() { | 250 claimed_stack_breadth()->is_empty(); |
267 return _depth_first; | |
268 } | 251 } |
269 | 252 |
270 inline void process_popped_location_depth(StarTask p); | 253 inline void process_popped_location_depth(StarTask p); |
271 | 254 |
272 inline void flush_prefetch_queue(); | 255 inline void flush_prefetch_queue(); |