comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 1394:1316cec51b4d

6819061: G1: eliminate serial Other times that are proportional to the collection set length 6871109: G1: remove the concept of the scan only prefix Summary: Removed scan only regions and associated code. The young portion of the collection set is now constructed incrementally - when a young region is retired as the current allocation region it is added to the collection set. Reviewed-by: apetrusenko, iveresov, tonyp
author johnc
date Thu, 22 Apr 2010 10:02:38 -0700
parents 79e419e5ea3b
children c18cbe5936b8
comparison
equal deleted inserted replaced
1393:6ecb6e6de3d6 1394:1316cec51b4d
1 /* 1 /*
2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
79 private: 79 private:
80 G1CollectedHeap* _g1h; 80 G1CollectedHeap* _g1h;
81 81
82 HeapRegion* _head; 82 HeapRegion* _head;
83 83
84 HeapRegion* _scan_only_head; 84 HeapRegion* _survivor_head;
85 HeapRegion* _scan_only_tail; 85 HeapRegion* _survivor_tail;
86
87 HeapRegion* _curr;
88
86 size_t _length; 89 size_t _length;
87 size_t _scan_only_length; 90 size_t _survivor_length;
88 91
89 size_t _last_sampled_rs_lengths; 92 size_t _last_sampled_rs_lengths;
90 size_t _sampled_rs_lengths; 93 size_t _sampled_rs_lengths;
91 HeapRegion* _curr; 94
92 HeapRegion* _curr_scan_only; 95 void empty_list(HeapRegion* list);
93
94 HeapRegion* _survivor_head;
95 HeapRegion* _survivor_tail;
96 size_t _survivor_length;
97
98 void empty_list(HeapRegion* list);
99 96
100 public: 97 public:
101 YoungList(G1CollectedHeap* g1h); 98 YoungList(G1CollectedHeap* g1h);
102 99
103 void push_region(HeapRegion* hr); 100 void push_region(HeapRegion* hr);
104 void add_survivor_region(HeapRegion* hr); 101 void add_survivor_region(HeapRegion* hr);
105 HeapRegion* pop_region(); 102
106 void empty_list(); 103 void empty_list();
107 bool is_empty() { return _length == 0; } 104 bool is_empty() { return _length == 0; }
108 size_t length() { return _length; } 105 size_t length() { return _length; }
109 size_t scan_only_length() { return _scan_only_length; } 106 size_t survivor_length() { return _survivor_length; }
110 size_t survivor_length() { return _survivor_length; }
111 107
112 void rs_length_sampling_init(); 108 void rs_length_sampling_init();
113 bool rs_length_sampling_more(); 109 bool rs_length_sampling_more();
114 void rs_length_sampling_next(); 110 void rs_length_sampling_next();
115 111
118 } 114 }
119 size_t sampled_rs_lengths() { return _last_sampled_rs_lengths; } 115 size_t sampled_rs_lengths() { return _last_sampled_rs_lengths; }
120 116
121 // for development purposes 117 // for development purposes
122 void reset_auxilary_lists(); 118 void reset_auxilary_lists();
119 void clear() { _head = NULL; _length = 0; }
120
121 void clear_survivors() {
122 _survivor_head = NULL;
123 _survivor_tail = NULL;
124 _survivor_length = 0;
125 }
126
123 HeapRegion* first_region() { return _head; } 127 HeapRegion* first_region() { return _head; }
124 HeapRegion* first_scan_only_region() { return _scan_only_head; }
125 HeapRegion* first_survivor_region() { return _survivor_head; } 128 HeapRegion* first_survivor_region() { return _survivor_head; }
126 HeapRegion* last_survivor_region() { return _survivor_tail; } 129 HeapRegion* last_survivor_region() { return _survivor_tail; }
127 HeapRegion* par_get_next_scan_only_region() {
128 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
129 HeapRegion* ret = _curr_scan_only;
130 if (ret != NULL)
131 _curr_scan_only = ret->get_next_young_region();
132 return ret;
133 }
134 130
135 // debugging 131 // debugging
136 bool check_list_well_formed(); 132 bool check_list_well_formed();
137 bool check_list_empty(bool ignore_scan_only_list, 133 bool check_list_empty(bool check_sample = true);
138 bool check_sample = true);
139 void print(); 134 void print();
140 }; 135 };
141 136
142 class RefineCardTableEntryClosure; 137 class RefineCardTableEntryClosure;
143 class G1CollectedHeap : public SharedHeap { 138 class G1CollectedHeap : public SharedHeap {
403 // simply set to true the array slot corresponding to this region. 398 // simply set to true the array slot corresponding to this region.
404 void register_region_with_in_cset_fast_test(HeapRegion* r) { 399 void register_region_with_in_cset_fast_test(HeapRegion* r) {
405 assert(_in_cset_fast_test_base != NULL, "sanity"); 400 assert(_in_cset_fast_test_base != NULL, "sanity");
406 assert(r->in_collection_set(), "invariant"); 401 assert(r->in_collection_set(), "invariant");
407 int index = r->hrs_index(); 402 int index = r->hrs_index();
408 assert(0 <= (size_t) index && (size_t) index < _in_cset_fast_test_length, 403 assert(0 <= index && (size_t) index < _in_cset_fast_test_length, "invariant");
409 "invariant");
410 assert(!_in_cset_fast_test_base[index], "invariant"); 404 assert(!_in_cset_fast_test_base[index], "invariant");
411 _in_cset_fast_test_base[index] = true; 405 _in_cset_fast_test_base[index] = true;
412 } 406 }
413 407
414 // This is a fast test on whether a reference points into the 408 // This is a fast test on whether a reference points into the
429 } else { 423 } else {
430 return false; 424 return false;
431 } 425 }
432 } 426 }
433 427
428 void clear_cset_fast_test() {
429 assert(_in_cset_fast_test_base != NULL, "sanity");
430 memset(_in_cset_fast_test_base, false,
431 _in_cset_fast_test_length * sizeof(bool));
432 }
433
434 protected: 434 protected:
435 435
436 // Shrink the garbage-first heap by at most the given size (in bytes!). 436 // Shrink the garbage-first heap by at most the given size (in bytes!).
437 // (Rounds down to a HeapRegion boundary.) 437 // (Rounds down to a HeapRegion boundary.)
438 virtual void shrink(size_t expand_bytes); 438 virtual void shrink(size_t expand_bytes);
473 void check_ct_logs_at_safepoint(); 473 void check_ct_logs_at_safepoint();
474 474
475 // After a collection pause, make the regions in the CS into free 475 // After a collection pause, make the regions in the CS into free
476 // regions. 476 // regions.
477 void free_collection_set(HeapRegion* cs_head); 477 void free_collection_set(HeapRegion* cs_head);
478
479 // Abandon the current collection set without recording policy
480 // statistics or updating free lists.
481 void abandon_collection_set(HeapRegion* cs_head);
478 482
479 // Applies "scan_non_heap_roots" to roots outside the heap, 483 // Applies "scan_non_heap_roots" to roots outside the heap,
480 // "scan_rs" to roots inside the heap (having done "set_region" to 484 // "scan_rs" to roots inside the heap (having done "set_region" to
481 // indicate the region in which the root resides), and does "scan_perm" 485 // indicate the region in which the root resides), and does "scan_perm"
482 // (setting the generation to the perm generation.) If "scan_rs" is 486 // (setting the generation to the perm generation.) If "scan_rs" is
486 // In the sequential case this param will be ignored. 490 // In the sequential case this param will be ignored.
487 void g1_process_strong_roots(bool collecting_perm_gen, 491 void g1_process_strong_roots(bool collecting_perm_gen,
488 SharedHeap::ScanningOption so, 492 SharedHeap::ScanningOption so,
489 OopClosure* scan_non_heap_roots, 493 OopClosure* scan_non_heap_roots,
490 OopsInHeapRegionClosure* scan_rs, 494 OopsInHeapRegionClosure* scan_rs,
491 OopsInHeapRegionClosure* scan_so,
492 OopsInGenClosure* scan_perm, 495 OopsInGenClosure* scan_perm,
493 int worker_i); 496 int worker_i);
494
495 void scan_scan_only_set(OopsInHeapRegionClosure* oc,
496 int worker_i);
497 void scan_scan_only_region(HeapRegion* hr,
498 OopsInHeapRegionClosure* oc,
499 int worker_i);
500 497
501 // Apply "blk" to all the weak roots of the system. These include 498 // Apply "blk" to all the weak roots of the system. These include
502 // JNI weak roots, the code cache, system dictionary, symbol table, 499 // JNI weak roots, the code cache, system dictionary, symbol table,
503 // string table, and referents of reachable weak refs. 500 // string table, and referents of reachable weak refs.
504 void g1_process_weak_roots(OopClosure* root_closure, 501 void g1_process_weak_roots(OopClosure* root_closure,
1134 bool should_set_young_locked(); 1131 bool should_set_young_locked();
1135 1132
1136 void set_region_short_lived_locked(HeapRegion* hr); 1133 void set_region_short_lived_locked(HeapRegion* hr);
1137 // add appropriate methods for any other surv rate groups 1134 // add appropriate methods for any other surv rate groups
1138 1135
1139 void young_list_rs_length_sampling_init() { 1136 YoungList* young_list() { return _young_list; }
1140 _young_list->rs_length_sampling_init();
1141 }
1142 bool young_list_rs_length_sampling_more() {
1143 return _young_list->rs_length_sampling_more();
1144 }
1145 void young_list_rs_length_sampling_next() {
1146 _young_list->rs_length_sampling_next();
1147 }
1148 size_t young_list_sampled_rs_lengths() {
1149 return _young_list->sampled_rs_lengths();
1150 }
1151
1152 size_t young_list_length() { return _young_list->length(); }
1153 size_t young_list_scan_only_length() {
1154 return _young_list->scan_only_length(); }
1155
1156 HeapRegion* pop_region_from_young_list() {
1157 return _young_list->pop_region();
1158 }
1159
1160 HeapRegion* young_list_first_region() {
1161 return _young_list->first_region();
1162 }
1163 1137
1164 // debugging 1138 // debugging
1165 bool check_young_list_well_formed() { 1139 bool check_young_list_well_formed() {
1166 return _young_list->check_list_well_formed(); 1140 return _young_list->check_list_well_formed();
1167 } 1141 }
1168 bool check_young_list_empty(bool ignore_scan_only_list, 1142
1143 bool check_young_list_empty(bool check_heap,
1169 bool check_sample = true); 1144 bool check_sample = true);
1170 1145
1171 // *** Stuff related to concurrent marking. It's not clear to me that so 1146 // *** Stuff related to concurrent marking. It's not clear to me that so
1172 // many of these need to be public. 1147 // many of these need to be public.
1173 1148