Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @ 845:df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
Summary: Modifications to G1 so as to allow the use of compressed oops.
Reviewed-by: apetrusenko, coleenp, jmasa, kvn, never, phh, tonyp
author | ysr |
---|---|
date | Tue, 14 Jul 2009 15:40:39 -0700 |
parents | d44bdab1c03d |
children | 2c79770d1f6e |
comparison
equal
deleted
inserted
replaced
839:bb18957ad21e | 845:df6caf649ff7 |
---|---|
124 #endif | 124 #endif |
125 } | 125 } |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 void add_reference_work(oop* from, bool par) { | 129 void add_reference_work(OopOrNarrowOopStar from, bool par) { |
130 // Must make this robust in case "from" is not in "_hr", because of | 130 // Must make this robust in case "from" is not in "_hr", because of |
131 // concurrency. | 131 // concurrency. |
132 | 132 |
133 #if HRRS_VERBOSE | 133 #if HRRS_VERBOSE |
134 gclog_or_tty->print_cr(" PRT::Add_reference_work(" PTR_FORMAT "->" PTR_FORMAT").", | 134 gclog_or_tty->print_cr(" PRT::Add_reference_work(" PTR_FORMAT "->" PTR_FORMAT").", |
171 _occupied = 0; | 171 _occupied = 0; |
172 #endif | 172 #endif |
173 _bm.clear(); | 173 _bm.clear(); |
174 } | 174 } |
175 | 175 |
176 void add_reference(oop* from) { | 176 void add_reference(OopOrNarrowOopStar from) { |
177 add_reference_work(from, /*parallel*/ true); | 177 add_reference_work(from, /*parallel*/ true); |
178 } | 178 } |
179 | 179 |
180 void seq_add_reference(oop* from) { | 180 void seq_add_reference(OopOrNarrowOopStar from) { |
181 add_reference_work(from, /*parallel*/ false); | 181 add_reference_work(from, /*parallel*/ false); |
182 } | 182 } |
183 | 183 |
184 void scrub(CardTableModRefBS* ctbs, BitMap* card_bm) { | 184 void scrub(CardTableModRefBS* ctbs, BitMap* card_bm) { |
185 HeapWord* hr_bot = hr()->bottom(); | 185 HeapWord* hr_bot = hr()->bottom(); |
218 } | 218 } |
219 return res; | 219 return res; |
220 } | 220 } |
221 | 221 |
222 // Requires "from" to be in "hr()". | 222 // Requires "from" to be in "hr()". |
223 bool contains_reference(oop* from) const { | 223 bool contains_reference(OopOrNarrowOopStar from) const { |
224 assert(hr()->is_in_reserved(from), "Precondition."); | 224 assert(hr()->is_in_reserved(from), "Precondition."); |
225 size_t card_ind = pointer_delta(from, hr()->bottom(), | 225 size_t card_ind = pointer_delta(from, hr()->bottom(), |
226 CardTableModRefBS::card_size); | 226 CardTableModRefBS::card_size); |
227 return _bm.at(card_ind); | 227 return _bm.at(card_ind); |
228 } | 228 } |
392 | 392 |
393 PosParPRT* next() const { return _next; } | 393 PosParPRT* next() const { return _next; } |
394 void set_next(PosParPRT* nxt) { _next = nxt; } | 394 void set_next(PosParPRT* nxt) { _next = nxt; } |
395 PosParPRT** next_addr() { return &_next; } | 395 PosParPRT** next_addr() { return &_next; } |
396 | 396 |
397 void add_reference(oop* from, int tid) { | 397 void add_reference(OopOrNarrowOopStar from, int tid) { |
398 // Expand if necessary. | 398 // Expand if necessary. |
399 PerRegionTable** pt = par_tables(); | 399 PerRegionTable** pt = par_tables(); |
400 if (par_tables() == NULL && tid > 0 && hr()->is_gc_alloc_region()) { | 400 if (par_tables() == NULL && tid > 0 && hr()->is_gc_alloc_region()) { |
401 par_expand(); | 401 par_expand(); |
402 pt = par_tables(); | 402 pt = par_tables(); |
445 cur = cur->next(); | 445 cur = cur->next(); |
446 } | 446 } |
447 return res; | 447 return res; |
448 } | 448 } |
449 | 449 |
450 bool contains_reference(oop* from) const { | 450 bool contains_reference(OopOrNarrowOopStar from) const { |
451 if (PerRegionTable::contains_reference(from)) return true; | 451 if (PerRegionTable::contains_reference(from)) return true; |
452 if (_par_tables != NULL) { | 452 if (_par_tables != NULL) { |
453 for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets()-1; i++) { | 453 for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets()-1; i++) { |
454 if (_par_tables[i]->contains_reference(from)) return true; | 454 if (_par_tables[i]->contains_reference(from)) return true; |
455 } | 455 } |
562 } | 562 } |
563 } | 563 } |
564 } | 564 } |
565 #endif | 565 #endif |
566 | 566 |
567 void OtherRegionsTable::add_reference(oop* from, int tid) { | 567 void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) { |
568 size_t cur_hrs_ind = hr()->hrs_index(); | 568 size_t cur_hrs_ind = hr()->hrs_index(); |
569 | 569 |
570 #if HRRS_VERBOSE | 570 #if HRRS_VERBOSE |
571 gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").", | 571 gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").", |
572 from, *from); | 572 from, |
573 UseCompressedOops | |
574 ? oopDesc::load_decode_heap_oop((narrowOop*)from) | |
575 : oopDesc::load_decode_heap_oop((oop*)from)); | |
573 #endif | 576 #endif |
574 | 577 |
575 int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift); | 578 int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift); |
576 | 579 |
577 #if HRRS_VERBOSE | 580 #if HRRS_VERBOSE |
1019 } else { | 1022 } else { |
1020 return false; | 1023 return false; |
1021 } | 1024 } |
1022 } | 1025 } |
1023 | 1026 |
1024 bool OtherRegionsTable::contains_reference(oop* from) const { | 1027 bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const { |
1025 // Cast away const in this case. | 1028 // Cast away const in this case. |
1026 MutexLockerEx x((Mutex*)&_m, Mutex::_no_safepoint_check_flag); | 1029 MutexLockerEx x((Mutex*)&_m, Mutex::_no_safepoint_check_flag); |
1027 return contains_reference_locked(from); | 1030 return contains_reference_locked(from); |
1028 } | 1031 } |
1029 | 1032 |
1030 bool OtherRegionsTable::contains_reference_locked(oop* from) const { | 1033 bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const { |
1031 HeapRegion* hr = _g1h->heap_region_containing_raw(from); | 1034 HeapRegion* hr = _g1h->heap_region_containing_raw(from); |
1032 if (hr == NULL) return false; | 1035 if (hr == NULL) return false; |
1033 RegionIdx_t hr_ind = (RegionIdx_t) hr->hrs_index(); | 1036 RegionIdx_t hr_ind = (RegionIdx_t) hr->hrs_index(); |
1034 // Is this region in the coarse map? | 1037 // Is this region in the coarse map? |
1035 if (_coarse_map.at(hr_ind)) return true; | 1038 if (_coarse_map.at(hr_ind)) return true; |
1286 return false; | 1289 return false; |
1287 } | 1290 } |
1288 | 1291 |
1289 | 1292 |
1290 | 1293 |
1291 oop** HeapRegionRemSet::_recorded_oops = NULL; | 1294 OopOrNarrowOopStar* HeapRegionRemSet::_recorded_oops = NULL; |
1292 HeapWord** HeapRegionRemSet::_recorded_cards = NULL; | 1295 HeapWord** HeapRegionRemSet::_recorded_cards = NULL; |
1293 HeapRegion** HeapRegionRemSet::_recorded_regions = NULL; | 1296 HeapRegion** HeapRegionRemSet::_recorded_regions = NULL; |
1294 int HeapRegionRemSet::_n_recorded = 0; | 1297 int HeapRegionRemSet::_n_recorded = 0; |
1295 | 1298 |
1296 HeapRegionRemSet::Event* HeapRegionRemSet::_recorded_events = NULL; | 1299 HeapRegionRemSet::Event* HeapRegionRemSet::_recorded_events = NULL; |
1297 int* HeapRegionRemSet::_recorded_event_index = NULL; | 1300 int* HeapRegionRemSet::_recorded_event_index = NULL; |
1298 int HeapRegionRemSet::_n_recorded_events = 0; | 1301 int HeapRegionRemSet::_n_recorded_events = 0; |
1299 | 1302 |
1300 void HeapRegionRemSet::record(HeapRegion* hr, oop* f) { | 1303 void HeapRegionRemSet::record(HeapRegion* hr, OopOrNarrowOopStar f) { |
1301 if (_recorded_oops == NULL) { | 1304 if (_recorded_oops == NULL) { |
1302 assert(_n_recorded == 0 | 1305 assert(_n_recorded == 0 |
1303 && _recorded_cards == NULL | 1306 && _recorded_cards == NULL |
1304 && _recorded_regions == NULL, | 1307 && _recorded_regions == NULL, |
1305 "Inv"); | 1308 "Inv"); |
1306 _recorded_oops = NEW_C_HEAP_ARRAY(oop*, MaxRecorded); | 1309 _recorded_oops = NEW_C_HEAP_ARRAY(OopOrNarrowOopStar, MaxRecorded); |
1307 _recorded_cards = NEW_C_HEAP_ARRAY(HeapWord*, MaxRecorded); | 1310 _recorded_cards = NEW_C_HEAP_ARRAY(HeapWord*, MaxRecorded); |
1308 _recorded_regions = NEW_C_HEAP_ARRAY(HeapRegion*, MaxRecorded); | 1311 _recorded_regions = NEW_C_HEAP_ARRAY(HeapRegion*, MaxRecorded); |
1309 } | 1312 } |
1310 if (_n_recorded == MaxRecorded) { | 1313 if (_n_recorded == MaxRecorded) { |
1311 gclog_or_tty->print_cr("Filled up 'recorded' (%d).", MaxRecorded); | 1314 gclog_or_tty->print_cr("Filled up 'recorded' (%d).", MaxRecorded); |
1312 } else { | 1315 } else { |
1313 _recorded_cards[_n_recorded] = | 1316 _recorded_cards[_n_recorded] = |
1406 HeapWord* hr3_last = hr3->end() - 1; | 1409 HeapWord* hr3_last = hr3->end() - 1; |
1407 | 1410 |
1408 HeapRegionRemSet* hrrs = hr0->rem_set(); | 1411 HeapRegionRemSet* hrrs = hr0->rem_set(); |
1409 | 1412 |
1410 // Make three references from region 0x101... | 1413 // Make three references from region 0x101... |
1411 hrrs->add_reference((oop*)hr1_start); | 1414 hrrs->add_reference((OopOrNarrowOopStar)hr1_start); |
1412 hrrs->add_reference((oop*)hr1_mid); | 1415 hrrs->add_reference((OopOrNarrowOopStar)hr1_mid); |
1413 hrrs->add_reference((oop*)hr1_last); | 1416 hrrs->add_reference((OopOrNarrowOopStar)hr1_last); |
1414 | 1417 |
1415 hrrs->add_reference((oop*)hr2_start); | 1418 hrrs->add_reference((OopOrNarrowOopStar)hr2_start); |
1416 hrrs->add_reference((oop*)hr2_mid); | 1419 hrrs->add_reference((OopOrNarrowOopStar)hr2_mid); |
1417 hrrs->add_reference((oop*)hr2_last); | 1420 hrrs->add_reference((OopOrNarrowOopStar)hr2_last); |
1418 | 1421 |
1419 hrrs->add_reference((oop*)hr3_start); | 1422 hrrs->add_reference((OopOrNarrowOopStar)hr3_start); |
1420 hrrs->add_reference((oop*)hr3_mid); | 1423 hrrs->add_reference((OopOrNarrowOopStar)hr3_mid); |
1421 hrrs->add_reference((oop*)hr3_last); | 1424 hrrs->add_reference((OopOrNarrowOopStar)hr3_last); |
1422 | 1425 |
1423 // Now cause a coarsening. | 1426 // Now cause a coarsening. |
1424 hrrs->add_reference((oop*)hr4->bottom()); | 1427 hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom()); |
1425 hrrs->add_reference((oop*)hr5->bottom()); | 1428 hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom()); |
1426 | 1429 |
1427 // Now, does iteration yield these three? | 1430 // Now, does iteration yield these three? |
1428 HeapRegionRemSetIterator iter; | 1431 HeapRegionRemSetIterator iter; |
1429 hrrs->init_iterator(&iter); | 1432 hrrs->init_iterator(&iter); |
1430 size_t sum = 0; | 1433 size_t sum = 0; |