comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 6197:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents b9442ac22f59
children 24b9c7f4cae6
comparison
equal deleted inserted replaced
6174:74533f63b116 6197:d2a62e0f25eb
1914 1914
1915 int n_rem_sets = HeapRegionRemSet::num_par_rem_sets(); 1915 int n_rem_sets = HeapRegionRemSet::num_par_rem_sets();
1916 assert(n_rem_sets > 0, "Invariant."); 1916 assert(n_rem_sets > 0, "Invariant.");
1917 1917
1918 HeapRegionRemSetIterator** iter_arr = 1918 HeapRegionRemSetIterator** iter_arr =
1919 NEW_C_HEAP_ARRAY(HeapRegionRemSetIterator*, n_queues); 1919 NEW_C_HEAP_ARRAY(HeapRegionRemSetIterator*, n_queues, mtGC);
1920 for (int i = 0; i < n_queues; i++) { 1920 for (int i = 0; i < n_queues; i++) {
1921 iter_arr[i] = new HeapRegionRemSetIterator(); 1921 iter_arr[i] = new HeapRegionRemSetIterator();
1922 } 1922 }
1923 _rem_set_iterator = iter_arr; 1923 _rem_set_iterator = iter_arr;
1924 1924
1925 _worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues); 1925 _worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
1926 _worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(unsigned int, n_queues); 1926 _worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(unsigned int, n_queues, mtGC);
1927 1927
1928 for (int i = 0; i < n_queues; i++) { 1928 for (int i = 0; i < n_queues; i++) {
1929 RefToScanQueue* q = new RefToScanQueue(); 1929 RefToScanQueue* q = new RefToScanQueue();
1930 q->initialize(); 1930 q->initialize();
1931 _task_queues->register_queue(i, q); 1931 _task_queues->register_queue(i, q);
2080 2080
2081 _g1h = this; 2081 _g1h = this;
2082 2082
2083 _in_cset_fast_test_length = max_regions(); 2083 _in_cset_fast_test_length = max_regions();
2084 _in_cset_fast_test_base = 2084 _in_cset_fast_test_base =
2085 NEW_C_HEAP_ARRAY(bool, (size_t) _in_cset_fast_test_length); 2085 NEW_C_HEAP_ARRAY(bool, (size_t) _in_cset_fast_test_length, mtGC);
2086 2086
2087 // We're biasing _in_cset_fast_test to avoid subtracting the 2087 // We're biasing _in_cset_fast_test to avoid subtracting the
2088 // beginning of the heap every time we want to index; basically 2088 // beginning of the heap every time we want to index; basically
2089 // it's the same with what we do with the card table. 2089 // it's the same with what we do with the card table.
2090 _in_cset_fast_test = _in_cset_fast_test_base - 2090 _in_cset_fast_test = _in_cset_fast_test_base -
3503 3503
3504 void 3504 void
3505 G1CollectedHeap::setup_surviving_young_words() { 3505 G1CollectedHeap::setup_surviving_young_words() {
3506 assert(_surviving_young_words == NULL, "pre-condition"); 3506 assert(_surviving_young_words == NULL, "pre-condition");
3507 uint array_length = g1_policy()->young_cset_region_length(); 3507 uint array_length = g1_policy()->young_cset_region_length();
3508 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length); 3508 _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
3509 if (_surviving_young_words == NULL) { 3509 if (_surviving_young_words == NULL) {
3510 vm_exit_out_of_memory(sizeof(size_t) * array_length, 3510 vm_exit_out_of_memory(sizeof(size_t) * array_length,
3511 "Not enough space for young surv words summary."); 3511 "Not enough space for young surv words summary.");
3512 } 3512 }
3513 memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t)); 3513 memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
3528 } 3528 }
3529 3529
3530 void 3530 void
3531 G1CollectedHeap::cleanup_surviving_young_words() { 3531 G1CollectedHeap::cleanup_surviving_young_words() {
3532 guarantee( _surviving_young_words != NULL, "pre-condition" ); 3532 guarantee( _surviving_young_words != NULL, "pre-condition" );
3533 FREE_C_HEAP_ARRAY(size_t, _surviving_young_words); 3533 FREE_C_HEAP_ARRAY(size_t, _surviving_young_words, mtGC);
3534 _surviving_young_words = NULL; 3534 _surviving_young_words = NULL;
3535 } 3535 }
3536 3536
3537 #ifdef ASSERT 3537 #ifdef ASSERT
3538 class VerifyCSetClosure: public HeapRegionClosure { 3538 class VerifyCSetClosure: public HeapRegionClosure {
4071 } 4071 }
4072 4072
4073 void G1CollectedHeap::init_for_evac_failure(OopsInHeapRegionClosure* cl) { 4073 void G1CollectedHeap::init_for_evac_failure(OopsInHeapRegionClosure* cl) {
4074 _drain_in_progress = false; 4074 _drain_in_progress = false;
4075 set_evac_failure_closure(cl); 4075 set_evac_failure_closure(cl);
4076 _evac_failure_scan_stack = new (ResourceObj::C_HEAP) GrowableArray<oop>(40, true); 4076 _evac_failure_scan_stack = new (ResourceObj::C_HEAP, mtGC) GrowableArray<oop>(40, true);
4077 } 4077 }
4078 4078
4079 void G1CollectedHeap::finalize_for_evac_failure() { 4079 void G1CollectedHeap::finalize_for_evac_failure() {
4080 assert(_evac_failure_scan_stack != NULL && 4080 assert(_evac_failure_scan_stack != NULL &&
4081 _evac_failure_scan_stack->length() == 0, 4081 _evac_failure_scan_stack->length() == 0,
4205 // case of a promotion failure. 4205 // case of a promotion failure.
4206 if (m->must_be_preserved_for_promotion_failure(obj)) { 4206 if (m->must_be_preserved_for_promotion_failure(obj)) {
4207 if (_objs_with_preserved_marks == NULL) { 4207 if (_objs_with_preserved_marks == NULL) {
4208 assert(_preserved_marks_of_objs == NULL, "Both or none."); 4208 assert(_preserved_marks_of_objs == NULL, "Both or none.");
4209 _objs_with_preserved_marks = 4209 _objs_with_preserved_marks =
4210 new (ResourceObj::C_HEAP) GrowableArray<oop>(40, true); 4210 new (ResourceObj::C_HEAP, mtGC) GrowableArray<oop>(40, true);
4211 _preserved_marks_of_objs = 4211 _preserved_marks_of_objs =
4212 new (ResourceObj::C_HEAP) GrowableArray<markOop>(40, true); 4212 new (ResourceObj::C_HEAP, mtGC) GrowableArray<markOop>(40, true);
4213 } 4213 }
4214 _objs_with_preserved_marks->push(obj); 4214 _objs_with_preserved_marks->push(obj);
4215 _preserved_marks_of_objs->push(m); 4215 _preserved_marks_of_objs->push(m);
4216 } 4216 }
4217 } 4217 }
4267 // an attempt to eliminate cache contention 4267 // an attempt to eliminate cache contention
4268 uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length(); 4268 uint real_length = 1 + _g1h->g1_policy()->young_cset_region_length();
4269 uint array_length = PADDING_ELEM_NUM + 4269 uint array_length = PADDING_ELEM_NUM +
4270 real_length + 4270 real_length +
4271 PADDING_ELEM_NUM; 4271 PADDING_ELEM_NUM;
4272 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length); 4272 _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
4273 if (_surviving_young_words_base == NULL) 4273 if (_surviving_young_words_base == NULL)
4274 vm_exit_out_of_memory(array_length * sizeof(size_t), 4274 vm_exit_out_of_memory(array_length * sizeof(size_t),
4275 "Not enough space for young surv histo."); 4275 "Not enough space for young surv histo.");
4276 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM; 4276 _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
4277 memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t)); 4277 memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));