< prev index next >

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Print this page
rev 54086 : imported patch 8219100-cleanup-young-collection-prologue
rev 54087 : imported patch 8218668-reorganize-collection-set


1923 class VerifyNoCSetOops {
1924   G1CollectedHeap* _g1h;
1925   const char* _phase;
1926   int _info;
1927 
1928 public:
1929   VerifyNoCSetOops(const char* phase, int info = -1) :
1930     _g1h(G1CollectedHeap::heap()),
1931     _phase(phase),
1932     _info(info)
1933   { }
1934 
1935   void operator()(G1TaskQueueEntry task_entry) const {
1936     if (task_entry.is_array_slice()) {
1937       guarantee(_g1h->is_in_reserved(task_entry.slice()), "Slice " PTR_FORMAT " must be in heap.", p2i(task_entry.slice()));
1938       return;
1939     }
1940     guarantee(oopDesc::is_oop(task_entry.obj()),
1941               "Non-oop " PTR_FORMAT ", phase: %s, info: %d",
1942               p2i(task_entry.obj()), _phase, _info);
1943     guarantee(!_g1h->is_in_cset(task_entry.obj()),
1944               "obj: " PTR_FORMAT " in CSet, phase: %s, info: %d",
1945               p2i(task_entry.obj()), _phase, _info);

1946   }
1947 };
1948 
1949 void G1ConcurrentMark::verify_no_collection_set_oops_in_stacks() {
1950   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
1951   if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) {
1952     return;
1953   }
1954 
1955   // Verify entries on the global mark stack
1956   _global_mark_stack.iterate(VerifyNoCSetOops("Stack"));
1957 
1958   // Verify entries on the task queues
1959   for (uint i = 0; i < _max_num_tasks; ++i) {
1960     G1CMTaskQueue* queue = _task_queues->queue(i);
1961     queue->iterate(VerifyNoCSetOops("Queue", i));
1962   }
1963 
1964   // Verify the global finger
1965   HeapWord* global_finger = finger();
1966   if (global_finger != NULL && global_finger < _heap.end()) {
1967     // Since we always iterate over all regions, we might get a NULL HeapRegion
1968     // here.
1969     HeapRegion* global_hr = _g1h->heap_region_containing(global_finger);
1970     guarantee(global_hr == NULL || global_finger == global_hr->bottom(),
1971               "global finger: " PTR_FORMAT " region: " HR_FORMAT,
1972               p2i(global_finger), HR_FORMAT_PARAMS(global_hr));
1973   }
1974 
1975   // Verify the task fingers
1976   assert(_num_concurrent_workers <= _max_num_tasks, "sanity");
1977   for (uint i = 0; i < _num_concurrent_workers; ++i) {
1978     G1CMTask* task = _tasks[i];
1979     HeapWord* task_finger = task->finger();
1980     if (task_finger != NULL && task_finger < _heap.end()) {
1981       // See above note on the global finger verification.
1982       HeapRegion* task_hr = _g1h->heap_region_containing(task_finger);
1983       guarantee(task_hr == NULL || task_finger == task_hr->bottom() ||
1984                 !task_hr->in_collection_set(),
1985                 "task finger: " PTR_FORMAT " region: " HR_FORMAT,
1986                 p2i(task_finger), HR_FORMAT_PARAMS(task_hr));
1987     }
1988   }
1989 }
1990 #endif // PRODUCT
1991 
1992 void G1ConcurrentMark::rebuild_rem_set_concurrently() {
1993   _g1h->rem_set()->rebuild_rem_set(this, _concurrent_workers, _worker_id_offset);
1994 }
1995 
1996 void G1ConcurrentMark::print_stats() {
1997   if (!log_is_enabled(Debug, gc, stats)) {
1998     return;
1999   }
2000   log_debug(gc, stats)("---------------------------------------------------------------------");
2001   for (size_t i = 0; i < _num_active_tasks; ++i) {
2002     _tasks[i]->print_stats();
2003     log_debug(gc, stats)("---------------------------------------------------------------------");
2004   }
2005 }
2006 




1923 class VerifyNoCSetOops {
1924   G1CollectedHeap* _g1h;
1925   const char* _phase;
1926   int _info;
1927 
1928 public:
1929   VerifyNoCSetOops(const char* phase, int info = -1) :
1930     _g1h(G1CollectedHeap::heap()),
1931     _phase(phase),
1932     _info(info)
1933   { }
1934 
1935   void operator()(G1TaskQueueEntry task_entry) const {
1936     if (task_entry.is_array_slice()) {
1937       guarantee(_g1h->is_in_reserved(task_entry.slice()), "Slice " PTR_FORMAT " must be in heap.", p2i(task_entry.slice()));
1938       return;
1939     }
1940     guarantee(oopDesc::is_oop(task_entry.obj()),
1941               "Non-oop " PTR_FORMAT ", phase: %s, info: %d",
1942               p2i(task_entry.obj()), _phase, _info);
1943     HeapRegion* r = _g1h->heap_region_containing(task_entry.obj());
1944     guarantee(!(r->in_collection_set() || r->has_index_in_opt_cset()),
1945               "obj " PTR_FORMAT " from %s (%d) in region %u in (optional) collection set",
1946               p2i(task_entry.obj()), _phase, _info, r->hrm_index());
1947   }
1948 };
1949 
1950 void G1ConcurrentMark::verify_no_collection_set_oops_in_stacks() {
1951   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
1952   if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) {
1953     return;
1954   }
1955 
1956   // Verify entries on the global mark stack
1957   _global_mark_stack.iterate(VerifyNoCSetOops("Stack"));
1958 
1959   // Verify entries on the task queues
1960   for (uint i = 0; i < _max_num_tasks; ++i) {
1961     G1CMTaskQueue* queue = _task_queues->queue(i);
1962     queue->iterate(VerifyNoCSetOops("Queue", i));
1963   }
1964 
1965   // Verify the global finger
1966   HeapWord* global_finger = finger();
1967   if (global_finger != NULL && global_finger < _heap.end()) {
1968     // Since we always iterate over all regions, we might get a NULL HeapRegion
1969     // here.
1970     HeapRegion* global_hr = _g1h->heap_region_containing(global_finger);
1971     guarantee(global_hr == NULL || global_finger == global_hr->bottom(),
1972               "global finger: " PTR_FORMAT " region: " HR_FORMAT,
1973               p2i(global_finger), HR_FORMAT_PARAMS(global_hr));
1974   }
1975 
1976   // Verify the task fingers
1977   assert(_num_concurrent_workers <= _max_num_tasks, "sanity");
1978   for (uint i = 0; i < _num_concurrent_workers; ++i) {
1979     G1CMTask* task = _tasks[i];
1980     HeapWord* task_finger = task->finger();
1981     if (task_finger != NULL && task_finger < _heap.end()) {
1982       // See above note on the global finger verification.
1983       HeapRegion* r = _g1h->heap_region_containing(task_finger);
1984       guarantee(r == NULL || task_finger == r->bottom() ||
1985                 !r->in_collection_set() || !r->has_index_in_opt_cset(),
1986                 "task finger: " PTR_FORMAT " region: " HR_FORMAT,
1987                 p2i(task_finger), HR_FORMAT_PARAMS(r));
1988     }
1989   }
1990 }
1991 #endif // PRODUCT
1992 
1993 void G1ConcurrentMark::rebuild_rem_set_concurrently() {
1994   _g1h->rem_set()->rebuild_rem_set(this, _concurrent_workers, _worker_id_offset);
1995 }
1996 
1997 void G1ConcurrentMark::print_stats() {
1998   if (!log_is_enabled(Debug, gc, stats)) {
1999     return;
2000   }
2001   log_debug(gc, stats)("---------------------------------------------------------------------");
2002   for (size_t i = 0; i < _num_active_tasks; ++i) {
2003     _tasks[i]->print_stats();
2004     log_debug(gc, stats)("---------------------------------------------------------------------");
2005   }
2006 }
2007 


< prev index next >