215 void end_strong_roots() {
216 _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
217 }
218 double strong_roots_time() const { return _strong_roots_time; }
219 void start_term_time() {
220 TASKQUEUE_STATS_ONLY(note_term_attempt());
221 _start_term = os::elapsedTime();
222 }
223 void end_term_time() {
224 _term_time += (os::elapsedTime() - _start_term);
225 }
226 double term_time() const { return _term_time; }
227
228 double elapsed_time() const {
229 return os::elapsedTime() - _start;
230 }
231 };
232
233 class ParNewGenTask: public AbstractGangTask {
234 private:
235 ParNewGeneration* _gen;
236 Generation* _old_gen;
237 HeapWord* _young_old_boundary;
238 class ParScanThreadStateSet* _state_set;
239
240 public:
241 ParNewGenTask(ParNewGeneration* gen,
242 Generation* old_gen,
243 HeapWord* young_old_boundary,
244 ParScanThreadStateSet* state_set);
245
246 HeapWord* young_old_boundary() { return _young_old_boundary; }
247
248 void work(uint worker_id);
249
250 // Reset the terminator in ParScanThreadStateSet for
251 // "active_workers" threads.
252 virtual void set_for_termination(int active_workers);
253 };
254
255 class KeepAliveClosure: public DefNewGeneration::KeepAliveClosure {
256 protected:
257 template <class T> void do_oop_work(T* p);
258 public:
259 KeepAliveClosure(ScanWeakRefClosure* cl);
260 virtual void do_oop(oop* p);
261 virtual void do_oop(narrowOop* p);
262 };
263
264 class EvacuateFollowersClosureGeneral: public VoidClosure {
265 private:
266 GenCollectedHeap* _gch;
267 int _level;
268 OopsInGenClosure* _scan_cur_or_nonheap;
269 OopsInGenClosure* _scan_older;
270 public:
271 EvacuateFollowersClosureGeneral(GenCollectedHeap* gch, int level,
272 OopsInGenClosure* cur,
273 OopsInGenClosure* older);
274 virtual void do_void();
275 };
276
277 // Closure for scanning ParNewGeneration.
278 // Same as ScanClosure, except does parallel GC barrier.
279 class ScanClosureWithParBarrier: public ScanClosure {
280 protected:
281 template <class T> void do_oop_work(T* p);
282 public:
283 ScanClosureWithParBarrier(ParNewGeneration* g, bool gc_barrier);
284 virtual void do_oop(oop* p);
285 virtual void do_oop(narrowOop* p);
286 };
287
288 // Implements AbstractRefProcTaskExecutor for ParNew.
289 class ParNewRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
290 private:
291 ParNewGeneration& _generation;
339 static oop real_forwardee_slow(oop obj);
340 static void waste_some_time();
341
342 // Preserve the mark of "obj", if necessary, in preparation for its mark
343 // word being overwritten with a self-forwarding-pointer.
344 void preserve_mark_if_necessary(oop obj, markOop m);
345
346 void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer);
347
348 protected:
349
350 bool _survivor_overflow;
351
352 bool avoid_promotion_undo() { return _avoid_promotion_undo; }
353 void set_avoid_promotion_undo(bool v) { _avoid_promotion_undo = v; }
354
355 bool survivor_overflow() { return _survivor_overflow; }
356 void set_survivor_overflow(bool v) { _survivor_overflow = v; }
357
358 public:
359 ParNewGeneration(ReservedSpace rs, size_t initial_byte_size, int level);
360
361 ~ParNewGeneration() {
362 for (uint i = 0; i < ParallelGCThreads; i++)
363 delete _task_queues->queue(i);
364
365 delete _task_queues;
366 }
367
368 virtual void ref_processor_init();
369 virtual Generation::Name kind() { return Generation::ParNew; }
370 virtual const char* name() const;
371 virtual const char* short_name() const { return "ParNew"; }
372
373 // override
374 virtual bool refs_discovery_is_mt() const {
375 assert(UseParNewGC, "ParNewGeneration only when UseParNewGC");
376 return ParallelGCThreads > 1;
377 }
378
379 // Make the collection virtual.
|
215 void end_strong_roots() {
216 _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
217 }
218 double strong_roots_time() const { return _strong_roots_time; }
219 void start_term_time() {
220 TASKQUEUE_STATS_ONLY(note_term_attempt());
221 _start_term = os::elapsedTime();
222 }
223 void end_term_time() {
224 _term_time += (os::elapsedTime() - _start_term);
225 }
226 double term_time() const { return _term_time; }
227
228 double elapsed_time() const {
229 return os::elapsedTime() - _start;
230 }
231 };
232
233 class ParNewGenTask: public AbstractGangTask {
234 private:
235 ParNewGeneration* _young_gen;
236 Generation* _old_gen;
237 HeapWord* _young_old_boundary;
238 class ParScanThreadStateSet* _state_set;
239
240 public:
241 ParNewGenTask(ParNewGeneration* young_gen,
242 Generation* old_gen,
243 HeapWord* young_old_boundary,
244 ParScanThreadStateSet* state_set);
245
246 HeapWord* young_old_boundary() { return _young_old_boundary; }
247
248 void work(uint worker_id);
249
250 // Reset the terminator in ParScanThreadStateSet for
251 // "active_workers" threads.
252 virtual void set_for_termination(int active_workers);
253 };
254
255 class KeepAliveClosure: public DefNewGeneration::KeepAliveClosure {
256 protected:
257 template <class T> void do_oop_work(T* p);
258 public:
259 KeepAliveClosure(ScanWeakRefClosure* cl);
260 virtual void do_oop(oop* p);
261 virtual void do_oop(narrowOop* p);
262 };
263
264 class EvacuateFollowersClosureGeneral: public VoidClosure {
265 private:
266 GenCollectedHeap* _gch;
267 OopsInGenClosure* _scan_cur_or_nonheap;
268 OopsInGenClosure* _scan_older;
269 public:
270 EvacuateFollowersClosureGeneral(GenCollectedHeap* gch,
271 OopsInGenClosure* cur,
272 OopsInGenClosure* older);
273 virtual void do_void();
274 };
275
276 // Closure for scanning ParNewGeneration.
277 // Same as ScanClosure, except does parallel GC barrier.
278 class ScanClosureWithParBarrier: public ScanClosure {
279 protected:
280 template <class T> void do_oop_work(T* p);
281 public:
282 ScanClosureWithParBarrier(ParNewGeneration* g, bool gc_barrier);
283 virtual void do_oop(oop* p);
284 virtual void do_oop(narrowOop* p);
285 };
286
287 // Implements AbstractRefProcTaskExecutor for ParNew.
288 class ParNewRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
289 private:
290 ParNewGeneration& _generation;
338 static oop real_forwardee_slow(oop obj);
339 static void waste_some_time();
340
341 // Preserve the mark of "obj", if necessary, in preparation for its mark
342 // word being overwritten with a self-forwarding-pointer.
343 void preserve_mark_if_necessary(oop obj, markOop m);
344
345 void handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer);
346
347 protected:
348
349 bool _survivor_overflow;
350
351 bool avoid_promotion_undo() { return _avoid_promotion_undo; }
352 void set_avoid_promotion_undo(bool v) { _avoid_promotion_undo = v; }
353
354 bool survivor_overflow() { return _survivor_overflow; }
355 void set_survivor_overflow(bool v) { _survivor_overflow = v; }
356
357 public:
358 ParNewGeneration(ReservedSpace rs, size_t initial_byte_size);
359
360 ~ParNewGeneration() {
361 for (uint i = 0; i < ParallelGCThreads; i++)
362 delete _task_queues->queue(i);
363
364 delete _task_queues;
365 }
366
367 virtual void ref_processor_init();
368 virtual Generation::Name kind() { return Generation::ParNew; }
369 virtual const char* name() const;
370 virtual const char* short_name() const { return "ParNew"; }
371
372 // override
373 virtual bool refs_discovery_is_mt() const {
374 assert(UseParNewGC, "ParNewGeneration only when UseParNewGC");
375 return ParallelGCThreads > 1;
376 }
377
378 // Make the collection virtual.
|