提交 8f0291b1 编写于 作者: T tschatzl

8035329: Move G1ParCopyClosure::copy_to_survivor_space into G1ParScanThreadState

Summary: Move G1ParCopyClosure::copy_to_survivor_space to decrease code size.
Reviewed-by: stefank, jmasa
上级 4273e88f
...@@ -4539,7 +4539,7 @@ HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose, ...@@ -4539,7 +4539,7 @@ HeapWord* G1CollectedHeap::par_allocate_during_gc(GCAllocPurpose purpose,
G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
ParGCAllocBuffer(gclab_word_size), _retired(false) { } ParGCAllocBuffer(gclab_word_size), _retired(false) { }
G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num) G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp)
: _g1h(g1h), : _g1h(g1h),
_refs(g1h->task_queue(queue_num)), _refs(g1h->task_queue(queue_num)),
_dcq(&g1h->dirty_card_queue_set()), _dcq(&g1h->dirty_card_queue_set()),
...@@ -4549,7 +4549,7 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num) ...@@ -4549,7 +4549,7 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num)
_term_attempts(0), _term_attempts(0),
_surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
_tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)), _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
_age_table(false), _age_table(false), _scanner(g1h, this, rp),
_strong_roots_time(0), _term_time(0), _strong_roots_time(0), _term_time(0),
_alloc_buffer_waste(0), _undo_waste(0) { _alloc_buffer_waste(0), _undo_waste(0) {
// we allocate G1YoungSurvRateNumRegions plus one entries, since // we allocate G1YoungSurvRateNumRegions plus one entries, since
...@@ -4694,27 +4694,25 @@ void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) { ...@@ -4694,27 +4694,25 @@ void G1ParCopyHelper::mark_forwarded_object(oop from_obj, oop to_obj) {
_cm->grayRoot(to_obj, (size_t) from_obj->size(), _worker_id); _cm->grayRoot(to_obj, (size_t) from_obj->size(), _worker_id);
} }
template <G1Barrier barrier, bool do_mark_object> oop G1ParScanThreadState::copy_to_survivor_space(oop const old) {
oop G1ParCopyClosure<barrier, do_mark_object>
::copy_to_survivor_space(oop old) {
size_t word_sz = old->size(); size_t word_sz = old->size();
HeapRegion* from_region = _g1->heap_region_containing_raw(old); HeapRegion* from_region = _g1h->heap_region_containing_raw(old);
// +1 to make the -1 indexes valid... // +1 to make the -1 indexes valid...
int young_index = from_region->young_index_in_cset()+1; int young_index = from_region->young_index_in_cset()+1;
assert( (from_region->is_young() && young_index > 0) || assert( (from_region->is_young() && young_index > 0) ||
(!from_region->is_young() && young_index == 0), "invariant" ); (!from_region->is_young() && young_index == 0), "invariant" );
G1CollectorPolicy* g1p = _g1->g1_policy(); G1CollectorPolicy* g1p = _g1h->g1_policy();
markOop m = old->mark(); markOop m = old->mark();
int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age() int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age()
: m->age(); : m->age();
GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age, GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age,
word_sz); word_sz);
HeapWord* obj_ptr = _par_scan_state->allocate(alloc_purpose, word_sz); HeapWord* obj_ptr = allocate(alloc_purpose, word_sz);
#ifndef PRODUCT #ifndef PRODUCT
// Should this evacuation fail? // Should this evacuation fail?
if (_g1->evacuation_should_fail()) { if (_g1h->evacuation_should_fail()) {
if (obj_ptr != NULL) { if (obj_ptr != NULL) {
_par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz); undo_allocation(alloc_purpose, obj_ptr, word_sz);
obj_ptr = NULL; obj_ptr = NULL;
} }
} }
...@@ -4723,7 +4721,7 @@ oop G1ParCopyClosure<barrier, do_mark_object> ...@@ -4723,7 +4721,7 @@ oop G1ParCopyClosure<barrier, do_mark_object>
if (obj_ptr == NULL) { if (obj_ptr == NULL) {
// This will either forward-to-self, or detect that someone else has // This will either forward-to-self, or detect that someone else has
// installed a forwarding pointer. // installed a forwarding pointer.
return _g1->handle_evacuation_failure_par(_par_scan_state, old); return _g1h->handle_evacuation_failure_par(this, old);
} }
oop obj = oop(obj_ptr); oop obj = oop(obj_ptr);
...@@ -4756,12 +4754,12 @@ oop G1ParCopyClosure<barrier, do_mark_object> ...@@ -4756,12 +4754,12 @@ oop G1ParCopyClosure<barrier, do_mark_object>
m = m->incr_age(); m = m->incr_age();
obj->set_mark(m); obj->set_mark(m);
} }
_par_scan_state->age_table()->add(obj, word_sz); age_table()->add(obj, word_sz);
} else { } else {
obj->set_mark(m); obj->set_mark(m);
} }
size_t* surv_young_words = _par_scan_state->surviving_young_words(); size_t* surv_young_words = surviving_young_words();
surv_young_words[young_index] += word_sz; surv_young_words[young_index] += word_sz;
if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) { if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) {
...@@ -4770,15 +4768,15 @@ oop G1ParCopyClosure<barrier, do_mark_object> ...@@ -4770,15 +4768,15 @@ oop G1ParCopyClosure<barrier, do_mark_object>
// length field of the from-space object. // length field of the from-space object.
arrayOop(obj)->set_length(0); arrayOop(obj)->set_length(0);
oop* old_p = set_partial_array_mask(old); oop* old_p = set_partial_array_mask(old);
_par_scan_state->push_on_queue(old_p); push_on_queue(old_p);
} else { } else {
// No point in using the slower heap_region_containing() method, // No point in using the slower heap_region_containing() method,
// given that we know obj is in the heap. // given that we know obj is in the heap.
_scanner.set_region(_g1->heap_region_containing_raw(obj)); _scanner.set_region(_g1h->heap_region_containing_raw(obj));
obj->oop_iterate_backwards(&_scanner); obj->oop_iterate_backwards(&_scanner);
} }
} else { } else {
_par_scan_state->undo_allocation(alloc_purpose, obj_ptr, word_sz); undo_allocation(alloc_purpose, obj_ptr, word_sz);
obj = forward_ptr; obj = forward_ptr;
} }
return obj; return obj;
...@@ -4809,7 +4807,7 @@ void G1ParCopyClosure<barrier, do_mark_object>::do_oop_work(T* p) { ...@@ -4809,7 +4807,7 @@ void G1ParCopyClosure<barrier, do_mark_object>::do_oop_work(T* p) {
if (obj->is_forwarded()) { if (obj->is_forwarded()) {
forwardee = obj->forwardee(); forwardee = obj->forwardee();
} else { } else {
forwardee = copy_to_survivor_space(obj); forwardee = _par_scan_state->copy_to_survivor_space(obj);
} }
assert(forwardee != NULL, "forwardee should not be NULL"); assert(forwardee != NULL, "forwardee should not be NULL");
oopDesc::encode_store_heap_oop(p, forwardee); oopDesc::encode_store_heap_oop(p, forwardee);
...@@ -5028,7 +5026,7 @@ public: ...@@ -5028,7 +5026,7 @@ public:
ReferenceProcessor* rp = _g1h->ref_processor_stw(); ReferenceProcessor* rp = _g1h->ref_processor_stw();
G1ParScanThreadState pss(_g1h, worker_id); G1ParScanThreadState pss(_g1h, worker_id, rp);
G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss, rp); G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss, rp);
G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, rp); G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, rp);
G1ParScanPartialArrayClosure partial_scan_cl(_g1h, &pss, rp); G1ParScanPartialArrayClosure partial_scan_cl(_g1h, &pss, rp);
...@@ -5471,7 +5469,7 @@ public: ...@@ -5471,7 +5469,7 @@ public:
G1STWIsAliveClosure is_alive(_g1h); G1STWIsAliveClosure is_alive(_g1h);
G1ParScanThreadState pss(_g1h, worker_id); G1ParScanThreadState pss(_g1h, worker_id, NULL);
G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss, NULL); G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss, NULL);
G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, NULL); G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, NULL);
...@@ -5583,7 +5581,7 @@ public: ...@@ -5583,7 +5581,7 @@ public:
ResourceMark rm; ResourceMark rm;
HandleMark hm; HandleMark hm;
G1ParScanThreadState pss(_g1h, worker_id); G1ParScanThreadState pss(_g1h, worker_id, NULL);
G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss, NULL); G1ParScanHeapEvacClosure scan_evac_cl(_g1h, &pss, NULL);
G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, NULL); G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, NULL);
G1ParScanPartialArrayClosure partial_scan_cl(_g1h, &pss, NULL); G1ParScanPartialArrayClosure partial_scan_cl(_g1h, &pss, NULL);
...@@ -5709,7 +5707,7 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) { ...@@ -5709,7 +5707,7 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) {
// JNI refs. // JNI refs.
// Use only a single queue for this PSS. // Use only a single queue for this PSS.
G1ParScanThreadState pss(this, 0); G1ParScanThreadState pss(this, 0, NULL);
// We do not embed a reference processor in the copying/scanning // We do not embed a reference processor in the copying/scanning
// closures while we're actually processing the discovered // closures while we're actually processing the discovered
......
...@@ -1887,6 +1887,8 @@ protected: ...@@ -1887,6 +1887,8 @@ protected:
G1ParGCAllocBufferContainer* _alloc_buffers[GCAllocPurposeCount]; G1ParGCAllocBufferContainer* _alloc_buffers[GCAllocPurposeCount];
ageTable _age_table; ageTable _age_table;
G1ParScanClosure _scanner;
size_t _alloc_buffer_waste; size_t _alloc_buffer_waste;
size_t _undo_waste; size_t _undo_waste;
...@@ -1939,7 +1941,7 @@ protected: ...@@ -1939,7 +1941,7 @@ protected:
} }
public: public:
G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num); G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp);
~G1ParScanThreadState() { ~G1ParScanThreadState() {
FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC); FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC);
...@@ -2074,6 +2076,8 @@ public: ...@@ -2074,6 +2076,8 @@ public:
} }
} }
oop copy_to_survivor_space(oop const obj);
template <class T> void deal_with_reference(T* ref_to_scan) { template <class T> void deal_with_reference(T* ref_to_scan) {
if (has_partial_array_mask(ref_to_scan)) { if (has_partial_array_mask(ref_to_scan)) {
_partial_scan_cl->do_oop_nv(ref_to_scan); _partial_scan_cl->do_oop_nv(ref_to_scan);
......
...@@ -151,22 +151,16 @@ protected: ...@@ -151,22 +151,16 @@ protected:
template <G1Barrier barrier, bool do_mark_object> template <G1Barrier barrier, bool do_mark_object>
class G1ParCopyClosure : public G1ParCopyHelper { class G1ParCopyClosure : public G1ParCopyHelper {
G1ParScanClosure _scanner; private:
template <class T> void do_oop_work(T* p); template <class T> void do_oop_work(T* p);
protected:
oop copy_to_survivor_space(oop obj);
public: public:
G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
ReferenceProcessor* rp) : ReferenceProcessor* rp) :
_scanner(g1, par_scan_state, rp),
G1ParCopyHelper(g1, par_scan_state) { G1ParCopyHelper(g1, par_scan_state) {
assert(_ref_processor == NULL, "sanity"); assert(_ref_processor == NULL, "sanity");
} }
G1ParScanClosure* scanner() { return &_scanner; }
template <class T> void do_oop_nv(T* p) { do_oop_work(p); } template <class T> void do_oop_nv(T* p) { do_oop_work(p); }
virtual void do_oop(oop* p) { do_oop_nv(p); } virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); } virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册