comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 23030:399885e13e90

8075215: SATB buffer processing found reclaimed humongous object Summary: Don't assume SATB buffer entries are valid objects Reviewed-by: brutisso, ecaspole
author kbarrett
date Fri, 01 May 2015 17:38:12 -0400
parents 0f8f1250fed5
children dd9cc155639c ab892d05b029
comparison
equal deleted inserted replaced
23029:0f8f1250fed5 23030:399885e13e90
2638 CMBitMapRO* temp = _prevMarkBitMap; 2638 CMBitMapRO* temp = _prevMarkBitMap;
2639 _prevMarkBitMap = (CMBitMapRO*)_nextMarkBitMap; 2639 _prevMarkBitMap = (CMBitMapRO*)_nextMarkBitMap;
2640 _nextMarkBitMap = (CMBitMap*) temp; 2640 _nextMarkBitMap = (CMBitMap*) temp;
2641 } 2641 }
2642 2642
2643 class CMObjectClosure; 2643 // Closure for marking entries in SATB buffers.
2644 2644 class CMSATBBufferClosure : public SATBBufferClosure {
2645 // Closure for iterating over objects, currently only used for
2646 // processing SATB buffers.
2647 class CMObjectClosure : public ObjectClosure {
2648 private: 2645 private:
2649 CMTask* _task; 2646 CMTask* _task;
2647 G1CollectedHeap* _g1h;
2648
2649 // This is very similar to CMTask::deal_with_reference, but with
2650 // more relaxed requirements for the argument, so this must be more
2651 // circumspect about treating the argument as an object.
2652 void do_entry(void* entry) const {
2653 _task->increment_refs_reached();
2654 HeapRegion* hr = _g1h->heap_region_containing_raw(entry);
2655 if (entry < hr->next_top_at_mark_start()) {
2656 // Until we get here, we don't know whether entry refers to a valid
2657 // object; it could instead have been a stale reference.
2658 oop obj = static_cast<oop>(entry);
2659 assert(obj->is_oop(true /* ignore mark word */),
2660 err_msg("Invalid oop in SATB buffer: " PTR_FORMAT, p2i(obj)));
2661 _task->make_reference_grey(obj, hr);
2662 }
2663 }
2650 2664
2651 public: 2665 public:
2652 void do_object(oop obj) { 2666 CMSATBBufferClosure(CMTask* task, G1CollectedHeap* g1h)
2653 _task->deal_with_reference(obj); 2667 : _task(task), _g1h(g1h) { }
2654 } 2668
2655 2669 virtual void do_buffer(void** buffer, size_t size) {
2656 CMObjectClosure(CMTask* task) : _task(task) { } 2670 for (size_t i = 0; i < size; ++i) {
2671 do_entry(buffer[i]);
2672 }
2673 }
2657 }; 2674 };
2658 2675
2659 class G1RemarkThreadsClosure : public ThreadClosure { 2676 class G1RemarkThreadsClosure : public ThreadClosure {
2660 CMObjectClosure _cm_obj; 2677 CMSATBBufferClosure _cm_satb_cl;
2661 G1CMOopClosure _cm_cl; 2678 G1CMOopClosure _cm_cl;
2662 MarkingCodeBlobClosure _code_cl; 2679 MarkingCodeBlobClosure _code_cl;
2663 int _thread_parity; 2680 int _thread_parity;
2664 bool _is_par; 2681 bool _is_par;
2665 2682
2666 public: 2683 public:
2667 G1RemarkThreadsClosure(G1CollectedHeap* g1h, CMTask* task, bool is_par) : 2684 G1RemarkThreadsClosure(G1CollectedHeap* g1h, CMTask* task, bool is_par) :
2668 _cm_obj(task), _cm_cl(g1h, g1h->concurrent_mark(), task), _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations), 2685 _cm_satb_cl(task, g1h),
2686 _cm_cl(g1h, g1h->concurrent_mark(), task),
2687 _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
2669 _thread_parity(SharedHeap::heap()->strong_roots_parity()), _is_par(is_par) {} 2688 _thread_parity(SharedHeap::heap()->strong_roots_parity()), _is_par(is_par) {}
2670 2689
2671 void do_thread(Thread* thread) { 2690 void do_thread(Thread* thread) {
2672 if (thread->is_Java_thread()) { 2691 if (thread->is_Java_thread()) {
2673 if (thread->claim_oops_do(_is_par, _thread_parity)) { 2692 if (thread->claim_oops_do(_is_par, _thread_parity)) {
2679 // * Weakly reachable otherwise 2698 // * Weakly reachable otherwise
2680 // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be 2699 // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
2681 // live by the SATB invariant but other oops recorded in nmethods may behave differently. 2700 // live by the SATB invariant but other oops recorded in nmethods may behave differently.
2682 jt->nmethods_do(&_code_cl); 2701 jt->nmethods_do(&_code_cl);
2683 2702
2684 jt->satb_mark_queue().apply_closure_and_empty(&_cm_obj); 2703 jt->satb_mark_queue().apply_closure_and_empty(&_cm_satb_cl);
2685 } 2704 }
2686 } else if (thread->is_VM_thread()) { 2705 } else if (thread->is_VM_thread()) {
2687 if (thread->claim_oops_do(_is_par, _thread_parity)) { 2706 if (thread->claim_oops_do(_is_par, _thread_parity)) {
2688 JavaThread::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_obj); 2707 JavaThread::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_satb_cl);
2689 } 2708 }
2690 } 2709 }
2691 } 2710 }
2692 }; 2711 };
2693 2712
3974 // middle of draining buffers and doesn't set the abort flag when it 3993 // middle of draining buffers and doesn't set the abort flag when it
3975 // notices that SATB buffers are available for draining. It'd be 3994 // notices that SATB buffers are available for draining. It'd be
3976 // very counter productive if it did that. :-) 3995 // very counter productive if it did that. :-)
3977 _draining_satb_buffers = true; 3996 _draining_satb_buffers = true;
3978 3997
3979 CMObjectClosure oc(this); 3998 CMSATBBufferClosure satb_cl(this, _g1h);
3980 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); 3999 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
3981 4000
3982 // This keeps claiming and applying the closure to completed buffers 4001 // This keeps claiming and applying the closure to completed buffers
3983 // until we run out of buffers or we need to abort. 4002 // until we run out of buffers or we need to abort.
3984 while (!has_aborted() && 4003 while (!has_aborted() &&
3985 satb_mq_set.apply_closure_to_completed_buffer(&oc)) { 4004 satb_mq_set.apply_closure_to_completed_buffer(&satb_cl)) {
3986 if (_cm->verbose_medium()) { 4005 if (_cm->verbose_medium()) {
3987 gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id); 4006 gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id);
3988 } 4007 }
3989 statsOnly( ++_satb_buffers_processed ); 4008 statsOnly( ++_satb_buffers_processed );
3990 regular_clock_call(); 4009 regular_clock_call();