401 guarantee(_saved_index == _index, |
401 guarantee(_saved_index == _index, |
402 err_msg("saved index: %d index: %d", _saved_index, _index)); |
402 err_msg("saved index: %d index: %d", _saved_index, _index)); |
403 _saved_index = -1; |
403 _saved_index = -1; |
404 } |
404 } |
405 |
405 |
406 void CMMarkStack::oops_do(OopClosure* f) { |
|
407 assert(_saved_index == _index, |
|
408 err_msg("saved index: %d index: %d", _saved_index, _index)); |
|
409 for (int i = 0; i < _index; i += 1) { |
|
410 f->do_oop(&_base[i]); |
|
411 } |
|
412 } |
|
413 |
|
414 CMRootRegions::CMRootRegions() : |
406 CMRootRegions::CMRootRegions() : |
415 _young_list(NULL), _cm(NULL), _scan_in_progress(false), |
407 _young_list(NULL), _cm(NULL), _scan_in_progress(false), |
416 _should_abort(false), _next_survivor(NULL) { } |
408 _should_abort(false), _next_survivor(NULL) { } |
417 |
409 |
418 void CMRootRegions::init(G1CollectedHeap* g1h, ConcurrentMark* cm) { |
410 void CMRootRegions::init(G1CollectedHeap* g1h, ConcurrentMark* cm) { |
2715 |
2707 |
2716 return NULL; |
2708 return NULL; |
2717 } |
2709 } |
2718 |
2710 |
2719 #ifndef PRODUCT |
2711 #ifndef PRODUCT |
2720 enum VerifyNoCSetOopsPhase { |
2712 class VerifyNoCSetOops VALUE_OBJ_CLASS_SPEC { |
2721 VerifyNoCSetOopsStack, |
|
2722 VerifyNoCSetOopsQueues |
|
2723 }; |
|
2724 |
|
2725 class VerifyNoCSetOopsClosure : public OopClosure, public ObjectClosure { |
|
2726 private: |
2713 private: |
2727 G1CollectedHeap* _g1h; |
2714 G1CollectedHeap* _g1h; |
2728 VerifyNoCSetOopsPhase _phase; |
2715 const char* _phase; |
2729 int _info; |
2716 int _info; |
2730 |
2717 |
2731 const char* phase_str() { |
2718 public: |
2732 switch (_phase) { |
2719 VerifyNoCSetOops(const char* phase, int info = -1) : |
2733 case VerifyNoCSetOopsStack: return "Stack"; |
2720 _g1h(G1CollectedHeap::heap()), |
2734 case VerifyNoCSetOopsQueues: return "Queue"; |
2721 _phase(phase), |
2735 default: ShouldNotReachHere(); |
2722 _info(info) |
2736 } |
2723 { } |
2737 return NULL; |
2724 |
2738 } |
2725 void operator()(oop obj) const { |
2739 |
2726 guarantee(obj->is_oop(), |
2740 void do_object_work(oop obj) { |
2727 err_msg("Non-oop " PTR_FORMAT ", phase: %s, info: %d", |
|
2728 p2i(obj), _phase, _info)); |
2741 guarantee(!_g1h->obj_in_cs(obj), |
2729 guarantee(!_g1h->obj_in_cs(obj), |
2742 err_msg("obj: " PTR_FORMAT " in CSet, phase: %s, info: %d", |
2730 err_msg("obj: " PTR_FORMAT " in CSet, phase: %s, info: %d", |
2743 p2i((void*) obj), phase_str(), _info)); |
2731 p2i(obj), _phase, _info)); |
2744 } |
|
2745 |
|
2746 public: |
|
2747 VerifyNoCSetOopsClosure() : _g1h(G1CollectedHeap::heap()) { } |
|
2748 |
|
2749 void set_phase(VerifyNoCSetOopsPhase phase, int info = -1) { |
|
2750 _phase = phase; |
|
2751 _info = info; |
|
2752 } |
|
2753 |
|
2754 virtual void do_oop(oop* p) { |
|
2755 oop obj = oopDesc::load_decode_heap_oop(p); |
|
2756 do_object_work(obj); |
|
2757 } |
|
2758 |
|
2759 virtual void do_oop(narrowOop* p) { |
|
2760 // We should not come across narrow oops while scanning marking |
|
2761 // stacks |
|
2762 ShouldNotReachHere(); |
|
2763 } |
|
2764 |
|
2765 virtual void do_object(oop obj) { |
|
2766 do_object_work(obj); |
|
2767 } |
2732 } |
2768 }; |
2733 }; |
2769 |
2734 |
2770 void ConcurrentMark::verify_no_cset_oops() { |
2735 void ConcurrentMark::verify_no_cset_oops() { |
2771 assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint"); |
2736 assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint"); |
2772 if (!G1CollectedHeap::heap()->collector_state()->mark_in_progress()) { |
2737 if (!G1CollectedHeap::heap()->collector_state()->mark_in_progress()) { |
2773 return; |
2738 return; |
2774 } |
2739 } |
2775 |
2740 |
2776 VerifyNoCSetOopsClosure cl; |
|
2777 |
|
2778 // Verify entries on the global mark stack |
2741 // Verify entries on the global mark stack |
2779 cl.set_phase(VerifyNoCSetOopsStack); |
2742 _markStack.iterate(VerifyNoCSetOops("Stack")); |
2780 _markStack.oops_do(&cl); |
|
2781 |
2743 |
2782 // Verify entries on the task queues |
2744 // Verify entries on the task queues |
2783 for (uint i = 0; i < _max_worker_id; i += 1) { |
2745 for (uint i = 0; i < _max_worker_id; ++i) { |
2784 cl.set_phase(VerifyNoCSetOopsQueues, i); |
|
2785 CMTaskQueue* queue = _task_queues->queue(i); |
2746 CMTaskQueue* queue = _task_queues->queue(i); |
2786 queue->oops_do(&cl); |
2747 queue->iterate(VerifyNoCSetOops("Queue", i)); |
2787 } |
2748 } |
2788 |
2749 |
2789 // Verify the global finger |
2750 // Verify the global finger |
2790 HeapWord* global_finger = finger(); |
2751 HeapWord* global_finger = finger(); |
2791 if (global_finger != NULL && global_finger < _heap_end) { |
2752 if (global_finger != NULL && global_finger < _heap_end) { |
2804 p2i(global_finger), HR_FORMAT_PARAMS(global_hr))); |
2765 p2i(global_finger), HR_FORMAT_PARAMS(global_hr))); |
2805 } |
2766 } |
2806 |
2767 |
2807 // Verify the task fingers |
2768 // Verify the task fingers |
2808 assert(parallel_marking_threads() <= _max_worker_id, "sanity"); |
2769 assert(parallel_marking_threads() <= _max_worker_id, "sanity"); |
2809 for (int i = 0; i < (int) parallel_marking_threads(); i += 1) { |
2770 for (uint i = 0; i < parallel_marking_threads(); ++i) { |
2810 CMTask* task = _tasks[i]; |
2771 CMTask* task = _tasks[i]; |
2811 HeapWord* task_finger = task->finger(); |
2772 HeapWord* task_finger = task->finger(); |
2812 if (task_finger != NULL && task_finger < _heap_end) { |
2773 if (task_finger != NULL && task_finger < _heap_end) { |
2813 // See above note on the global finger verification. |
2774 // See above note on the global finger verification. |
2814 HeapRegion* task_hr = _g1h->heap_region_containing_raw(task_finger); |
2775 HeapRegion* task_hr = _g1h->heap_region_containing_raw(task_finger); |