hotspot/src/share/vm/gc/g1/concurrentMark.cpp
changeset 33105 294e48b4f704
parent 33103 116b558af514
child 33107 77bf0d2069a3
equal deleted inserted replaced
33104:a7c0f60a1294 33105:294e48b4f704
   397   // accidentally add something to the mark stack during GC, it
   397   // accidentally add something to the mark stack during GC, it
   398   // will be a correctness issue so it's better if we crash. we'll
   398   // will be a correctness issue so it's better if we crash. we'll
   399   // only check this once per GC anyway, so it won't be a performance
   399   // only check this once per GC anyway, so it won't be a performance
   400   // issue in any way.
   400   // issue in any way.
   401   guarantee(_saved_index == _index,
   401   guarantee(_saved_index == _index,
   402             err_msg("saved index: %d index: %d", _saved_index, _index));
   402             "saved index: %d index: %d", _saved_index, _index);
   403   _saved_index = -1;
   403   _saved_index = -1;
   404 }
   404 }
   405 
   405 
   406 CMRootRegions::CMRootRegions() :
   406 CMRootRegions::CMRootRegions() :
   407   _young_list(NULL), _cm(NULL), _scan_in_progress(false),
   407   _young_list(NULL), _cm(NULL), _scan_in_progress(false),
   792     // We currently assume that the concurrent flag has been set to
   792     // We currently assume that the concurrent flag has been set to
   793     // false before we start remark. At this point we should also be
   793     // false before we start remark. At this point we should also be
   794     // in a STW phase.
   794     // in a STW phase.
   795     assert(!concurrent_marking_in_progress(), "invariant");
   795     assert(!concurrent_marking_in_progress(), "invariant");
   796     assert(out_of_regions(),
   796     assert(out_of_regions(),
   797            err_msg("only way to get here: _finger: " PTR_FORMAT ", _heap_end: " PTR_FORMAT,
   797            "only way to get here: _finger: " PTR_FORMAT ", _heap_end: " PTR_FORMAT,
   798                    p2i(_finger), p2i(_heap_end)));
   798            p2i(_finger), p2i(_heap_end));
   799   }
   799   }
   800 }
   800 }
   801 
   801 
   802 void ConcurrentMark::set_non_marking_state() {
   802 void ConcurrentMark::set_non_marking_state() {
   803   // We set the global marking state to some default values when we're
   803   // We set the global marking state to some default values when we're
  1414 
  1414 
  1415     HeapWord* ntams = hr->next_top_at_mark_start();
  1415     HeapWord* ntams = hr->next_top_at_mark_start();
  1416     HeapWord* start = hr->bottom();
  1416     HeapWord* start = hr->bottom();
  1417 
  1417 
  1418     assert(start <= hr->end() && start <= ntams && ntams <= hr->end(),
  1418     assert(start <= hr->end() && start <= ntams && ntams <= hr->end(),
  1419            err_msg("Preconditions not met - "
  1419            "Preconditions not met - "
  1420                    "start: " PTR_FORMAT ", ntams: " PTR_FORMAT ", end: " PTR_FORMAT,
  1420            "start: " PTR_FORMAT ", ntams: " PTR_FORMAT ", end: " PTR_FORMAT,
  1421                    p2i(start), p2i(ntams), p2i(hr->end())));
  1421            p2i(start), p2i(ntams), p2i(hr->end()));
  1422 
  1422 
  1423     // Find the first marked object at or after "start".
  1423     // Find the first marked object at or after "start".
  1424     start = _bm->getNextMarkedWordAddress(start, ntams);
  1424     start = _bm->getNextMarkedWordAddress(start, ntams);
  1425 
  1425 
  1426     size_t marked_bytes = 0;
  1426     size_t marked_bytes = 0;
  1716         // all the cards spanned by the object
  1716         // all the cards spanned by the object
  1717         end_idx += 1;
  1717         end_idx += 1;
  1718       }
  1718       }
  1719 
  1719 
  1720       assert(end_idx <= _card_bm->size(),
  1720       assert(end_idx <= _card_bm->size(),
  1721              err_msg("oob: end_idx=  " SIZE_FORMAT ", bitmap size= " SIZE_FORMAT,
  1721              "oob: end_idx=  " SIZE_FORMAT ", bitmap size= " SIZE_FORMAT,
  1722                      end_idx, _card_bm->size()));
  1722              end_idx, _card_bm->size());
  1723       assert(start_idx < _card_bm->size(),
  1723       assert(start_idx < _card_bm->size(),
  1724              err_msg("oob: start_idx=  " SIZE_FORMAT ", bitmap size= " SIZE_FORMAT,
  1724              "oob: start_idx=  " SIZE_FORMAT ", bitmap size= " SIZE_FORMAT,
  1725                      start_idx, _card_bm->size()));
  1725              start_idx, _card_bm->size());
  1726 
  1726 
  1727       _cm->set_card_bitmap_range(_card_bm, start_idx, end_idx, true /* is_par */);
  1727       _cm->set_card_bitmap_range(_card_bm, start_idx, end_idx, true /* is_par */);
  1728     }
  1728     }
  1729 
  1729 
  1730     // Set the bit for the region if it contains live data
  1730     // Set the bit for the region if it contains live data
  2470     if (entry < hr->next_top_at_mark_start()) {
  2470     if (entry < hr->next_top_at_mark_start()) {
  2471       // Until we get here, we don't know whether entry refers to a valid
  2471       // Until we get here, we don't know whether entry refers to a valid
  2472       // object; it could instead have been a stale reference.
  2472       // object; it could instead have been a stale reference.
  2473       oop obj = static_cast<oop>(entry);
  2473       oop obj = static_cast<oop>(entry);
  2474       assert(obj->is_oop(true /* ignore mark word */),
  2474       assert(obj->is_oop(true /* ignore mark word */),
  2475              err_msg("Invalid oop in SATB buffer: " PTR_FORMAT, p2i(obj)));
  2475              "Invalid oop in SATB buffer: " PTR_FORMAT, p2i(obj));
  2476       _task->make_reference_grey(obj, hr);
  2476       _task->make_reference_grey(obj, hr);
  2477     }
  2477     }
  2478   }
  2478   }
  2479 
  2479 
  2480 public:
  2480 public:
  2587   }
  2587   }
  2588 
  2588 
  2589   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
  2589   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
  2590   guarantee(has_overflown() ||
  2590   guarantee(has_overflown() ||
  2591             satb_mq_set.completed_buffers_num() == 0,
  2591             satb_mq_set.completed_buffers_num() == 0,
  2592             err_msg("Invariant: has_overflown = %s, num buffers = %d",
  2592             "Invariant: has_overflown = %s, num buffers = %d",
  2593                     BOOL_TO_STR(has_overflown()),
  2593             BOOL_TO_STR(has_overflown()),
  2594                     satb_mq_set.completed_buffers_num()));
  2594             satb_mq_set.completed_buffers_num());
  2595 
  2595 
  2596   print_stats();
  2596   print_stats();
  2597 }
  2597 }
  2598 
  2598 
  2599 void ConcurrentMark::clearRangePrevBitmap(MemRegion mr) {
  2599 void ConcurrentMark::clearRangePrevBitmap(MemRegion mr) {
  2723     _info(info)
  2723     _info(info)
  2724   { }
  2724   { }
  2725 
  2725 
  2726   void operator()(oop obj) const {
  2726   void operator()(oop obj) const {
  2727     guarantee(obj->is_oop(),
  2727     guarantee(obj->is_oop(),
  2728               err_msg("Non-oop " PTR_FORMAT ", phase: %s, info: %d",
  2728               "Non-oop " PTR_FORMAT ", phase: %s, info: %d",
  2729                       p2i(obj), _phase, _info));
  2729               p2i(obj), _phase, _info);
  2730     guarantee(!_g1h->obj_in_cs(obj),
  2730     guarantee(!_g1h->obj_in_cs(obj),
  2731               err_msg("obj: " PTR_FORMAT " in CSet, phase: %s, info: %d",
  2731               "obj: " PTR_FORMAT " in CSet, phase: %s, info: %d",
  2732                       p2i(obj), _phase, _info));
  2732               p2i(obj), _phase, _info);
  2733   }
  2733   }
  2734 };
  2734 };
  2735 
  2735 
  2736 void ConcurrentMark::verify_no_cset_oops() {
  2736 void ConcurrentMark::verify_no_cset_oops() {
  2737   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
  2737   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
  2760     // not hold any more.
  2760     // not hold any more.
  2761     // Since we always iterate over all regions, we might get a NULL HeapRegion
  2761     // Since we always iterate over all regions, we might get a NULL HeapRegion
  2762     // here.
  2762     // here.
  2763     HeapRegion* global_hr = _g1h->heap_region_containing_raw(global_finger);
  2763     HeapRegion* global_hr = _g1h->heap_region_containing_raw(global_finger);
  2764     guarantee(global_hr == NULL || global_finger == global_hr->bottom(),
  2764     guarantee(global_hr == NULL || global_finger == global_hr->bottom(),
  2765               err_msg("global finger: " PTR_FORMAT " region: " HR_FORMAT,
  2765               "global finger: " PTR_FORMAT " region: " HR_FORMAT,
  2766                       p2i(global_finger), HR_FORMAT_PARAMS(global_hr)));
  2766               p2i(global_finger), HR_FORMAT_PARAMS(global_hr));
  2767   }
  2767   }
  2768 
  2768 
  2769   // Verify the task fingers
  2769   // Verify the task fingers
  2770   assert(parallel_marking_threads() <= _max_worker_id, "sanity");
  2770   assert(parallel_marking_threads() <= _max_worker_id, "sanity");
  2771   for (uint i = 0; i < parallel_marking_threads(); ++i) {
  2771   for (uint i = 0; i < parallel_marking_threads(); ++i) {
  2774     if (task_finger != NULL && task_finger < _heap_end) {
  2774     if (task_finger != NULL && task_finger < _heap_end) {
  2775       // See above note on the global finger verification.
  2775       // See above note on the global finger verification.
  2776       HeapRegion* task_hr = _g1h->heap_region_containing_raw(task_finger);
  2776       HeapRegion* task_hr = _g1h->heap_region_containing_raw(task_finger);
  2777       guarantee(task_hr == NULL || task_finger == task_hr->bottom() ||
  2777       guarantee(task_hr == NULL || task_finger == task_hr->bottom() ||
  2778                 !task_hr->in_collection_set(),
  2778                 !task_hr->in_collection_set(),
  2779                 err_msg("task finger: " PTR_FORMAT " region: " HR_FORMAT,
  2779                 "task finger: " PTR_FORMAT " region: " HR_FORMAT,
  2780                         p2i(task_finger), HR_FORMAT_PARAMS(task_hr)));
  2780                 p2i(task_finger), HR_FORMAT_PARAMS(task_hr));
  2781     }
  2781     }
  2782   }
  2782   }
  2783 }
  2783 }
  2784 #endif // PRODUCT
  2784 #endif // PRODUCT
  2785 
  2785 
  2815     HeapWord* start = hr->bottom();
  2815     HeapWord* start = hr->bottom();
  2816     HeapWord* limit = hr->next_top_at_mark_start();
  2816     HeapWord* limit = hr->next_top_at_mark_start();
  2817     HeapWord* end = hr->end();
  2817     HeapWord* end = hr->end();
  2818 
  2818 
  2819     assert(start <= limit && limit <= hr->top() && hr->top() <= hr->end(),
  2819     assert(start <= limit && limit <= hr->top() && hr->top() <= hr->end(),
  2820            err_msg("Preconditions not met - "
  2820            "Preconditions not met - "
  2821                    "start: " PTR_FORMAT ", limit: " PTR_FORMAT ", "
  2821            "start: " PTR_FORMAT ", limit: " PTR_FORMAT ", "
  2822                    "top: " PTR_FORMAT ", end: " PTR_FORMAT,
  2822            "top: " PTR_FORMAT ", end: " PTR_FORMAT,
  2823                    p2i(start), p2i(limit), p2i(hr->top()), p2i(hr->end())));
  2823            p2i(start), p2i(limit), p2i(hr->top()), p2i(hr->end()));
  2824 
  2824 
  2825     assert(hr->next_marked_bytes() == 0, "Precondition");
  2825     assert(hr->next_marked_bytes() == 0, "Precondition");
  2826 
  2826 
  2827     if (start == limit) {
  2827     if (start == limit) {
  2828       // NTAMS of this region has not been set so nothing to do.
  2828       // NTAMS of this region has not been set so nothing to do.