--- old/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp 2014-10-17 16:15:59.000000000 +0200 +++ new/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp 2014-10-17 16:15:59.000000000 +0200 @@ -69,30 +69,41 @@ ObjToScanQueueSet* work_queue_set_, Stack* overflow_stacks_, size_t desired_plab_sz_, - ParallelTaskTerminator& term_) : - _to_space(to_space_), _old_gen(old_gen_), _young_gen(young_gen_), _thread_num(thread_num_), - _work_queue(work_queue_set_->queue(thread_num_)), _to_space_full(false), - _overflow_stack(overflow_stacks_ ? overflow_stacks_ + thread_num_ : NULL), - _ageTable(false), // false ==> not the global age table, no perf data. - _to_space_alloc_buffer(desired_plab_sz_), - _to_space_closure(young_gen_, this), _old_gen_closure(young_gen_, this), - _to_space_root_closure(young_gen_, this), _old_gen_root_closure(young_gen_, this), - _older_gen_closure(young_gen_, this), - _evacuate_followers(this, &_to_space_closure, &_old_gen_closure, - &_to_space_root_closure, young_gen_, &_old_gen_root_closure, - work_queue_set_, &term_), - _is_alive_closure(young_gen_), _scan_weak_ref_closure(young_gen_, this), - _keep_alive_closure(&_scan_weak_ref_closure), - _strong_roots_time(0.0), _term_time(0.0) -{ + ParallelTaskTerminator& term_) + : _to_space(to_space_), + _old_gen(old_gen_), + _young_gen(young_gen_), + _thread_num(thread_num_), + _work_queue(work_queue_set_->queue(thread_num_)), + _to_space_full(false), + _overflow_stack(overflow_stacks_ ? overflow_stacks_ + thread_num_ : NULL), + _ageTable(false), // false ==> not the global age table, no perf data. + _to_space_alloc_buffer(desired_plab_sz_), + _to_space_closure(young_gen_, this), + _old_gen_closure(young_gen_, this), + _to_space_root_closure(young_gen_, this), + _old_gen_root_closure(young_gen_, this), + _older_gen_closure(young_gen_, this), + _evacuate_followers(this, + &_to_space_closure, + &_old_gen_closure, + &_to_space_root_closure, + young_gen_, + &_old_gen_root_closure, + work_queue_set_, + &term_), + _is_alive_closure(young_gen_), + _scan_weak_ref_closure(young_gen_, this), + _keep_alive_closure(&_scan_weak_ref_closure), + _strong_roots_time(0.0), + _term_time(0.0) { #if TASKQUEUE_STATS _term_attempts = 0; _overflow_refills = 0; _overflow_refill_objs = 0; #endif // TASKQUEUE_STATS - _survivor_chunk_array = - (ChunkArray*) old_gen()->get_data_recorder(thread_num()); + _survivor_chunk_array = (ChunkArray*) old_gen()->get_data_recorder(thread_num()); _hash_seed = 17; // Might want to take time-based random value. _start = os::elapsedTime(); _old_gen_closure.set_generation(old_gen_); @@ -155,7 +166,6 @@ } } - void ParScanThreadState::trim_queues(int max_size) { ObjToScanQueue* queue = work_queue(); do { @@ -223,15 +233,12 @@ } HeapWord* ParScanThreadState::alloc_in_to_space_slow(size_t word_sz) { - - // Otherwise, if the object is small enough, try to reallocate the - // buffer. + // If the object is small enough, try to reallocate the buffer. HeapWord* obj = NULL; if (!_to_space_full) { ParGCAllocBuffer* const plab = to_space_alloc_buffer(); Space* const sp = to_space(); - if (word_sz * 100 < - ParallelGCBufferWastePct * plab->word_sz()) { + if (word_sz * 100 < ParallelGCBufferWastePct * plab->word_sz()) { // Is small enough; abandon this buffer and start a new one. plab->retire(false, false); size_t buf_size = plab->word_sz(); @@ -273,9 +280,7 @@ return obj; } - -void ParScanThreadState::undo_alloc_in_to_space(HeapWord* obj, - size_t word_sz) { +void ParScanThreadState::undo_alloc_in_to_space(HeapWord* obj, size_t word_sz) { // Is the alloc in the current alloc buffer? if (to_space_alloc_buffer()->contains(obj)) { assert(to_space_alloc_buffer()->contains(obj + word_sz - 1), @@ -301,7 +306,7 @@ ParNewGeneration& gen, Generation& old_gen, ObjToScanQueueSet& queue_set, - Stack* overflow_stacks_, + Stack* overflow_stacks, size_t desired_plab_sz, ParallelTaskTerminator& term); @@ -332,15 +337,18 @@ ParallelTaskTerminator* terminator() { return &_term; } }; - -ParScanThreadStateSet::ParScanThreadStateSet( - int num_threads, Space& to_space, ParNewGeneration& gen, - Generation& old_gen, ObjToScanQueueSet& queue_set, - Stack* overflow_stacks, - size_t desired_plab_sz, ParallelTaskTerminator& term) +ParScanThreadStateSet::ParScanThreadStateSet(int num_threads, + Space& to_space, + ParNewGeneration& gen, + Generation& old_gen, + ObjToScanQueueSet& queue_set, + Stack* overflow_stacks, + size_t desired_plab_sz, + ParallelTaskTerminator& term) : ResourceArray(sizeof(ParScanThreadState), num_threads), - _gen(gen), _old_gen(old_gen), _term(term) -{ + _gen(gen), + _old_gen(old_gen), + _term(term) { assert(num_threads > 0, "sanity check!"); assert(ParGCUseLocalOverflow == (overflow_stacks != NULL), "overflow_stack allocation mismatch"); @@ -352,8 +360,7 @@ } } -inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i) -{ +inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i) { assert(i >= 0 && i < length(), "sanity check!"); return ((ParScanThreadState*)_data)[i]; } @@ -367,8 +374,7 @@ } } -void ParScanThreadStateSet::reset(int active_threads, bool promotion_failed) -{ +void ParScanThreadStateSet::reset(int active_threads, bool promotion_failed) { _term.reset_for_reuse(active_threads); if (promotion_failed) { for (int i = 0; i < length(); ++i) { @@ -379,24 +385,20 @@ #if TASKQUEUE_STATS void -ParScanThreadState::reset_stats() -{ +ParScanThreadState::reset_stats() { taskqueue_stats().reset(); _term_attempts = 0; _overflow_refills = 0; _overflow_refill_objs = 0; } -void ParScanThreadStateSet::reset_stats() -{ +void ParScanThreadStateSet::reset_stats() { for (int i = 0; i < length(); ++i) { thread_state(i).reset_stats(); } } -void -ParScanThreadStateSet::print_termination_stats_hdr(outputStream* const st) -{ +void ParScanThreadStateSet::print_termination_stats_hdr(outputStream* const st) { st->print_raw_cr("GC Termination Stats"); st->print_raw_cr(" elapsed --strong roots-- " "-------termination-------"); @@ -406,8 +408,7 @@ "--------- ------ --------"); } -void ParScanThreadStateSet::print_termination_stats(outputStream* const st) -{ +void ParScanThreadStateSet::print_termination_stats(outputStream* const st) { print_termination_stats_hdr(st); for (int i = 0; i < length(); ++i) { @@ -423,15 +424,13 @@ } // Print stats related to work queue activity. -void ParScanThreadStateSet::print_taskqueue_stats_hdr(outputStream* const st) -{ +void ParScanThreadStateSet::print_taskqueue_stats_hdr(outputStream* const st) { st->print_raw_cr("GC Task Stats"); st->print_raw("thr "); TaskQueueStats::print_header(1, st); st->cr(); st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr(); } -void ParScanThreadStateSet::print_taskqueue_stats(outputStream* const st) -{ +void ParScanThreadStateSet::print_taskqueue_stats(outputStream* const st) { print_taskqueue_stats_hdr(st); TaskQueueStats totals; @@ -453,8 +452,7 @@ } #endif // TASKQUEUE_STATS -void ParScanThreadStateSet::flush() -{ +void ParScanThreadStateSet::flush() { // Work in this loop should be kept as lightweight as // possible since this might otherwise become a bottleneck // to scaling. Should we add heavy-weight work into this @@ -490,9 +488,10 @@ } ParScanClosure::ParScanClosure(ParNewGeneration* g, - ParScanThreadState* par_scan_state) : - OopsInKlassOrGenClosure(g), _par_scan_state(par_scan_state), _g(g) -{ + ParScanThreadState* par_scan_state) + : OopsInKlassOrGenClosure(g), + _par_scan_state(par_scan_state), + _g(g) { _boundary = _g->reserved().end(); } @@ -510,8 +509,9 @@ ParScanWeakRefClosure::ParScanWeakRefClosure(ParNewGeneration* g, ParScanThreadState* par_scan_state) - : ScanWeakRefClosure(g), _par_scan_state(par_scan_state) -{} + : ScanWeakRefClosure(g), + _par_scan_state(par_scan_state) { +} void ParScanWeakRefClosure::do_oop(oop* p) { ParScanWeakRefClosure::do_oop_work(p); } void ParScanWeakRefClosure::do_oop(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); } @@ -520,31 +520,28 @@ #pragma warning(disable: 4786) /* identifier was truncated to '255' characters in the browser information */ #endif -ParEvacuateFollowersClosure::ParEvacuateFollowersClosure( - ParScanThreadState* par_scan_state_, - ParScanWithoutBarrierClosure* to_space_closure_, - ParScanWithBarrierClosure* old_gen_closure_, - ParRootScanWithoutBarrierClosure* to_space_root_closure_, - ParNewGeneration* par_gen_, - ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure_, - ObjToScanQueueSet* task_queues_, - ParallelTaskTerminator* terminator_) : - - _par_scan_state(par_scan_state_), - _to_space_closure(to_space_closure_), - _old_gen_closure(old_gen_closure_), - _to_space_root_closure(to_space_root_closure_), - _old_gen_root_closure(old_gen_root_closure_), - _par_gen(par_gen_), - _task_queues(task_queues_), - _terminator(terminator_) -{} +ParEvacuateFollowersClosure::ParEvacuateFollowersClosure(ParScanThreadState* par_scan_state, + ParScanWithoutBarrierClosure* to_space_closure, + ParScanWithBarrierClosure* old_gen_closure, + ParRootScanWithoutBarrierClosure* to_space_root_closure, + ParNewGeneration* par_gen, + ParRootScanWithBarrierTwoGensClosure* old_gen_root_closure, + ObjToScanQueueSet* task_queues, + ParallelTaskTerminator* terminator) + : _par_scan_state(par_scan_state), + _to_space_closure(to_space_closure), + _old_gen_closure(old_gen_closure), + _to_space_root_closure(to_space_root_closure), + _old_gen_root_closure(old_gen_root_closure), + _par_gen(par_gen), + _task_queues(task_queues), + _terminator(terminator) { +} void ParEvacuateFollowersClosure::do_void() { ObjToScanQueue* work_q = par_scan_state()->work_queue(); while (true) { - // Scan to-space and old-gen objs until we run out of both. oop obj_to_scan; par_scan_state()->trim_queues(0); @@ -577,13 +574,15 @@ par_scan_state()->end_term_time(); } -ParNewGenTask::ParNewGenTask(ParNewGeneration* young_gen, Generation* old_gen, - HeapWord* young_old_boundary, ParScanThreadStateSet* state_set) : - AbstractGangTask("ParNewGeneration collection"), +ParNewGenTask::ParNewGenTask(ParNewGeneration* young_gen, + Generation* old_gen, + HeapWord* young_old_boundary, + ParScanThreadStateSet* state_set) + : AbstractGangTask("ParNewGeneration collection"), _young_gen(young_gen), _old_gen(old_gen), _young_old_boundary(young_old_boundary), - _state_set(state_set) - {} + _state_set(state_set) { +} // Reset the terminator for the given number of // active threads. @@ -639,10 +638,9 @@ ParNewGeneration:: ParNewGeneration(ReservedSpace rs, size_t initial_byte_size) : DefNewGeneration(rs, initial_byte_size, "PCopy"), - _overflow_list(NULL), - _is_alive_closure(this), - _plab_stats(YoungPLABSize, PLABWeight) -{ + _overflow_list(NULL), + _is_alive_closure(this), + _plab_stats(YoungPLABSize, PLABWeight) { NOT_PRODUCT(_overflow_counter = ParGCWorkQueueOverflowInterval;) NOT_PRODUCT(_num_par_pushes = 0;) _task_queues = new ObjToScanQueueSet(ParallelGCThreads); @@ -654,12 +652,12 @@ _task_queues->register_queue(i1, q); } - for (uint i2 = 0; i2 < ParallelGCThreads; i2++) + for (uint i2 = 0; i2 < ParallelGCThreads; i2++) { _task_queues->queue(i2)->initialize(); + } _overflow_stacks = NULL; if (ParGCUseLocalOverflow) { - // typedef to workaround NEW_C_HEAP_ARRAY macro, which can not deal // with ',' typedef Stack GCOopStack; @@ -685,8 +683,9 @@ #endif // ParNewGeneration:: -ParKeepAliveClosure::ParKeepAliveClosure(ParScanWeakRefClosure* cl) : - DefNewGeneration::KeepAliveClosure(cl), _par_cl(cl) {} +ParKeepAliveClosure::ParKeepAliveClosure(ParScanWeakRefClosure* cl) + : DefNewGeneration::KeepAliveClosure(cl), _par_cl(cl) { +} template void /*ParNewGeneration::*/ParKeepAliveClosure::do_oop_work(T* p) { @@ -712,8 +711,9 @@ void /*ParNewGeneration::*/ParKeepAliveClosure::do_oop(narrowOop* p) { ParKeepAliveClosure::do_oop_work(p); } // ParNewGeneration:: -KeepAliveClosure::KeepAliveClosure(ScanWeakRefClosure* cl) : - DefNewGeneration::KeepAliveClosure(cl) {} +KeepAliveClosure::KeepAliveClosure(ScanWeakRefClosure* cl) + : DefNewGeneration::KeepAliveClosure(cl) { +} template void /*ParNewGeneration::*/KeepAliveClosure::do_oop_work(T* p) { @@ -782,22 +782,20 @@ ParScanThreadStateSet& _state_set; }; -ParNewRefProcTaskProxy::ParNewRefProcTaskProxy( - ProcessTask& task, ParNewGeneration& young_gen, - Generation& old_gen, - HeapWord* young_old_boundary, - ParScanThreadStateSet& state_set) +ParNewRefProcTaskProxy::ParNewRefProcTaskProxy(ProcessTask& task, + ParNewGeneration& young_gen, + Generation& old_gen, + HeapWord* young_old_boundary, + ParScanThreadStateSet& state_set) : AbstractGangTask("ParNewGeneration parallel reference processing"), _young_gen(young_gen), _task(task), _old_gen(old_gen), _young_old_boundary(young_old_boundary), - _state_set(state_set) -{ + _state_set(state_set) { } -void ParNewRefProcTaskProxy::work(uint worker_id) -{ +void ParNewRefProcTaskProxy::work(uint worker_id) { ResourceMark rm; HandleMark hm; ParScanThreadState& par_scan_state = _state_set.thread_state(worker_id); @@ -814,18 +812,15 @@ public: ParNewRefEnqueueTaskProxy(EnqueueTask& task) : AbstractGangTask("ParNewGeneration parallel reference enqueue"), - _task(task) - { } + _task(task) { + } - virtual void work(uint worker_id) - { + virtual void work(uint worker_id) { _task.work(worker_id); } }; - -void ParNewRefProcTaskExecutor::execute(ProcessTask& task) -{ +void ParNewRefProcTaskExecutor::execute(ProcessTask& task) { GenCollectedHeap* gch = GenCollectedHeap::heap(); assert(gch->kind() == CollectedHeap::GenCollectedHeap, "not a generational heap"); @@ -839,8 +834,7 @@ _generation.promotion_failed()); } -void ParNewRefProcTaskExecutor::execute(EnqueueTask& task) -{ +void ParNewRefProcTaskExecutor::execute(EnqueueTask& task) { GenCollectedHeap* gch = GenCollectedHeap::heap(); FlexibleWorkGang* workers = gch->workers(); assert(workers != NULL, "Need parallel worker threads."); @@ -848,25 +842,26 @@ workers->run_task(&enq_task); } -void ParNewRefProcTaskExecutor::set_single_threaded_mode() -{ +void ParNewRefProcTaskExecutor::set_single_threaded_mode() { _state_set.flush(); GenCollectedHeap* gch = GenCollectedHeap::heap(); gch->set_par_threads(0); // 0 ==> non-parallel. gch->save_marks(); } -ScanClosureWithParBarrier:: -ScanClosureWithParBarrier(ParNewGeneration* g, bool gc_barrier) : - ScanClosure(g, gc_barrier) {} +ScanClosureWithParBarrier::ScanClosureWithParBarrier(ParNewGeneration* g, + bool gc_barrier) + : ScanClosure(g, gc_barrier) { +} EvacuateFollowersClosureGeneral:: EvacuateFollowersClosureGeneral(GenCollectedHeap* gch, OopsInGenClosure* cur, - OopsInGenClosure* older) : - _gch(gch), - _scan_cur_or_nonheap(cur), _scan_older(older) -{} + OopsInGenClosure* older) + : _gch(gch), + _scan_cur_or_nonheap(cur), + _scan_older(older) { +} void EvacuateFollowersClosureGeneral::do_void() { do { @@ -883,7 +878,9 @@ bool ParNewGeneration::_avoid_promotion_undo = false; -void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, ParScanThreadStateSet& thread_state_set, ParNewTracer& gc_tracer) { +void ParNewGeneration::handle_promotion_failed(GenCollectedHeap* gch, + ParScanThreadStateSet& thread_state_set, + ParNewTracer& gc_tracer) { assert(_promo_failure_scan_stack.is_empty(), "post condition"); _promo_failure_scan_stack.clear(true); // Clear cached segments. @@ -1188,11 +1185,10 @@ forward_ptr = old->forward_to_atomic(ClaimedForwardPtr); if (forward_ptr != NULL) { // someone else beat us to it. - return real_forwardee(old); + return real_forwardee(old); } - new_obj = _old_gen->par_promote(par_scan_state->thread_num(), - old, m, sz); + new_obj = _old_gen->par_promote(par_scan_state->thread_num(), old, m, sz); if (new_obj == NULL) { // promotion failed, forward to self @@ -1222,8 +1218,11 @@ // information. if (TraceScavenge) { gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", - is_in_reserved(new_obj) ? "copying" : "tenuring", - new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size()); + is_in_reserved(new_obj) ? "copying" : "tenuring", + new_obj->klass()->internal_name(), + (void *)old, + (void *)new_obj, + new_obj->size()); } #endif @@ -1343,8 +1342,11 @@ // information. if (TraceScavenge) { gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", - is_in_reserved(new_obj) ? "copying" : "tenuring", - new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size()); + is_in_reserved(new_obj) ? "copying" : "tenuring", + new_obj->klass()->internal_name(), + (void*)old, + (void*)new_obj, + new_obj->size()); } #endif @@ -1506,7 +1508,9 @@ assert(!UseCompressedOops, "Error"); assert(par_scan_state->overflow_stack() == NULL, "Error"); - if (_overflow_list == NULL) return false; + if (_overflow_list == NULL) { + return false; + } // Otherwise, there was something there; try claiming the list. oop prefix = cast_to_oop(Atomic::xchg_ptr(BUSY, &_overflow_list));