hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp
changeset 33783 6499ca6ce575
parent 33589 7cbd1b2c139b
child 33786 ac8da6513351
equal deleted inserted replaced
33782:e8ee017b6b6a 33783:6499ca6ce575
   460       CardIdx_t card_index = from_card - from_hr_bot_card_index;
   460       CardIdx_t card_index = from_card - from_hr_bot_card_index;
   461       assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
   461       assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
   462              "Must be in range.");
   462              "Must be in range.");
   463       if (G1HRRSUseSparseTable &&
   463       if (G1HRRSUseSparseTable &&
   464           _sparse_table.add_card(from_hrm_ind, card_index)) {
   464           _sparse_table.add_card(from_hrm_ind, card_index)) {
   465         if (G1RecordHRRSOops) {
       
   466           HeapRegionRemSet::record(_hr, from);
       
   467           if (G1TraceHeapRegionRememberedSet) {
       
   468             gclog_or_tty->print("   Added card " PTR_FORMAT " to region "
       
   469                                 "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
       
   470                                 align_size_down(uintptr_t(from),
       
   471                                                 CardTableModRefBS::card_size),
       
   472                                 p2i(_hr->bottom()), p2i(from));
       
   473           }
       
   474         }
       
   475         if (G1TraceHeapRegionRememberedSet) {
   465         if (G1TraceHeapRegionRememberedSet) {
   476           gclog_or_tty->print_cr("   added card to sparse table.");
   466           gclog_or_tty->print_cr("   added card to sparse table.");
   477         }
   467         }
   478         assert(contains_reference_locked(from), "We just added it!");
   468         assert(contains_reference_locked(from), "We just added it!");
   479         return;
   469         return;
   529   // possibility of concurrent reuse.  But see head comment of
   519   // possibility of concurrent reuse.  But see head comment of
   530   // OtherRegionsTable for why this is OK.
   520   // OtherRegionsTable for why this is OK.
   531   assert(prt != NULL, "Inv");
   521   assert(prt != NULL, "Inv");
   532 
   522 
   533   prt->add_reference(from);
   523   prt->add_reference(from);
   534 
       
   535   if (G1RecordHRRSOops) {
       
   536     HeapRegionRemSet::record(_hr, from);
       
   537     if (G1TraceHeapRegionRememberedSet) {
       
   538       gclog_or_tty->print("Added card " PTR_FORMAT " to region "
       
   539                           "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
       
   540                           align_size_down(uintptr_t(from),
       
   541                                           CardTableModRefBS::card_size),
       
   542                           p2i(_hr->bottom()), p2i(from));
       
   543     }
       
   544   }
       
   545   assert(contains_reference(from), "We just added it!");
   524   assert(contains_reference(from), "We just added it!");
   546 }
   525 }
   547 
   526 
   548 PerRegionTable*
   527 PerRegionTable*
   549 OtherRegionsTable::find_region_table(size_t ind, HeapRegion* hr) const {
   528 OtherRegionsTable::find_region_table(size_t ind, HeapRegion* hr) const {
  1069          "Should have yielded all the cards in the rem set "
  1048          "Should have yielded all the cards in the rem set "
  1070          "(in the non-par case).");
  1049          "(in the non-par case).");
  1071   return false;
  1050   return false;
  1072 }
  1051 }
  1073 
  1052 
  1074 
       
  1075 
       
  1076 OopOrNarrowOopStar* HeapRegionRemSet::_recorded_oops = NULL;
       
  1077 HeapWord**          HeapRegionRemSet::_recorded_cards = NULL;
       
  1078 HeapRegion**        HeapRegionRemSet::_recorded_regions = NULL;
       
  1079 int                 HeapRegionRemSet::_n_recorded = 0;
       
  1080 
       
  1081 HeapRegionRemSet::Event* HeapRegionRemSet::_recorded_events = NULL;
       
  1082 int*         HeapRegionRemSet::_recorded_event_index = NULL;
       
  1083 int          HeapRegionRemSet::_n_recorded_events = 0;
       
  1084 
       
  1085 void HeapRegionRemSet::record(HeapRegion* hr, OopOrNarrowOopStar f) {
       
  1086   if (_recorded_oops == NULL) {
       
  1087     assert(_n_recorded == 0
       
  1088            && _recorded_cards == NULL
       
  1089            && _recorded_regions == NULL,
       
  1090            "Inv");
       
  1091     _recorded_oops    = NEW_C_HEAP_ARRAY(OopOrNarrowOopStar, MaxRecorded, mtGC);
       
  1092     _recorded_cards   = NEW_C_HEAP_ARRAY(HeapWord*,          MaxRecorded, mtGC);
       
  1093     _recorded_regions = NEW_C_HEAP_ARRAY(HeapRegion*,        MaxRecorded, mtGC);
       
  1094   }
       
  1095   if (_n_recorded == MaxRecorded) {
       
  1096     gclog_or_tty->print_cr("Filled up 'recorded' (%d).", MaxRecorded);
       
  1097   } else {
       
  1098     _recorded_cards[_n_recorded] =
       
  1099       (HeapWord*)align_size_down(uintptr_t(f),
       
  1100                                  CardTableModRefBS::card_size);
       
  1101     _recorded_oops[_n_recorded] = f;
       
  1102     _recorded_regions[_n_recorded] = hr;
       
  1103     _n_recorded++;
       
  1104   }
       
  1105 }
       
  1106 
       
  1107 void HeapRegionRemSet::record_event(Event evnt) {
       
  1108   if (!G1RecordHRRSEvents) return;
       
  1109 
       
  1110   if (_recorded_events == NULL) {
       
  1111     assert(_n_recorded_events == 0
       
  1112            && _recorded_event_index == NULL,
       
  1113            "Inv");
       
  1114     _recorded_events = NEW_C_HEAP_ARRAY(Event, MaxRecordedEvents, mtGC);
       
  1115     _recorded_event_index = NEW_C_HEAP_ARRAY(int, MaxRecordedEvents, mtGC);
       
  1116   }
       
  1117   if (_n_recorded_events == MaxRecordedEvents) {
       
  1118     gclog_or_tty->print_cr("Filled up 'recorded_events' (%d).", MaxRecordedEvents);
       
  1119   } else {
       
  1120     _recorded_events[_n_recorded_events] = evnt;
       
  1121     _recorded_event_index[_n_recorded_events] = _n_recorded;
       
  1122     _n_recorded_events++;
       
  1123   }
       
  1124 }
       
  1125 
       
  1126 void HeapRegionRemSet::print_event(outputStream* str, Event evnt) {
       
  1127   switch (evnt) {
       
  1128   case Event_EvacStart:
       
  1129     str->print("Evac Start");
       
  1130     break;
       
  1131   case Event_EvacEnd:
       
  1132     str->print("Evac End");
       
  1133     break;
       
  1134   case Event_RSUpdateEnd:
       
  1135     str->print("RS Update End");
       
  1136     break;
       
  1137   }
       
  1138 }
       
  1139 
       
  1140 void HeapRegionRemSet::print_recorded() {
       
  1141   int cur_evnt = 0;
       
  1142   Event cur_evnt_kind = Event_illegal;
       
  1143   int cur_evnt_ind = 0;
       
  1144   if (_n_recorded_events > 0) {
       
  1145     cur_evnt_kind = _recorded_events[cur_evnt];
       
  1146     cur_evnt_ind = _recorded_event_index[cur_evnt];
       
  1147   }
       
  1148 
       
  1149   for (int i = 0; i < _n_recorded; i++) {
       
  1150     while (cur_evnt < _n_recorded_events && i == cur_evnt_ind) {
       
  1151       gclog_or_tty->print("Event: ");
       
  1152       print_event(gclog_or_tty, cur_evnt_kind);
       
  1153       gclog_or_tty->cr();
       
  1154       cur_evnt++;
       
  1155       if (cur_evnt < MaxRecordedEvents) {
       
  1156         cur_evnt_kind = _recorded_events[cur_evnt];
       
  1157         cur_evnt_ind = _recorded_event_index[cur_evnt];
       
  1158       }
       
  1159     }
       
  1160     gclog_or_tty->print("Added card " PTR_FORMAT " to region [" PTR_FORMAT "...]"
       
  1161                         " for ref " PTR_FORMAT ".\n",
       
  1162                         p2i(_recorded_cards[i]), p2i(_recorded_regions[i]->bottom()),
       
  1163                         p2i(_recorded_oops[i]));
       
  1164   }
       
  1165 }
       
  1166 
       
  1167 void HeapRegionRemSet::reset_for_cleanup_tasks() {
  1053 void HeapRegionRemSet::reset_for_cleanup_tasks() {
  1168   SparsePRT::reset_for_cleanup_tasks();
  1054   SparsePRT::reset_for_cleanup_tasks();
  1169 }
  1055 }
  1170 
  1056 
  1171 void HeapRegionRemSet::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) {
  1057 void HeapRegionRemSet::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) {