hotspot/src/share/vm/memory/cardTableModRefBS.cpp
changeset 1374 4c24294029a9
parent 360 21d113ecbf6a
child 1378 e94c42fe8a0f
equal deleted inserted replaced
615:570062d730b2 1374:4c24294029a9
   296 
   296 
   297 void CardTableModRefBS::write_ref_field_work(void* field, oop newVal) {
   297 void CardTableModRefBS::write_ref_field_work(void* field, oop newVal) {
   298   inline_write_ref_field(field, newVal);
   298   inline_write_ref_field(field, newVal);
   299 }
   299 }
   300 
   300 
       
   301 
       
   302 bool CardTableModRefBS::claim_card(size_t card_index) {
       
   303   jbyte val = _byte_map[card_index];
       
   304   if (val != claimed_card_val()) {
       
   305     jbyte res = Atomic::cmpxchg((jbyte) claimed_card_val(), &_byte_map[card_index], val);
       
   306     if (res == val)
       
   307       return true;
       
   308     else return false;
       
   309   }
       
   310   return false;
       
   311 }
   301 
   312 
   302 void CardTableModRefBS::non_clean_card_iterate(Space* sp,
   313 void CardTableModRefBS::non_clean_card_iterate(Space* sp,
   303                                                MemRegion mr,
   314                                                MemRegion mr,
   304                                                DirtyCardToOopClosure* dcto_cl,
   315                                                DirtyCardToOopClosure* dcto_cl,
   305                                                MemRegionClosure* cl,
   316                                                MemRegionClosure* cl,
   396     *cur = dirty_card;
   407     *cur = dirty_card;
   397     cur++;
   408     cur++;
   398   }
   409   }
   399 }
   410 }
   400 
   411 
   401 void CardTableModRefBS::invalidate(MemRegion mr) {
   412 void CardTableModRefBS::invalidate(MemRegion mr, bool whole_heap) {
   402   for (int i = 0; i < _cur_covered_regions; i++) {
   413   for (int i = 0; i < _cur_covered_regions; i++) {
   403     MemRegion mri = mr.intersection(_covered[i]);
   414     MemRegion mri = mr.intersection(_covered[i]);
   404     if (!mri.is_empty()) dirty_MemRegion(mri);
   415     if (!mri.is_empty()) dirty_MemRegion(mri);
   405   }
   416   }
   406 }
   417 }
   424     MemRegion mri = mr.intersection(_covered[i]);
   435     MemRegion mri = mr.intersection(_covered[i]);
   425     if (!mri.is_empty()) clear_MemRegion(mri);
   436     if (!mri.is_empty()) clear_MemRegion(mri);
   426   }
   437   }
   427 }
   438 }
   428 
   439 
       
   440 void CardTableModRefBS::dirty(MemRegion mr) {
       
   441   jbyte* first = byte_for(mr.start());
       
   442   jbyte* last  = byte_after(mr.last());
       
   443   memset(first, dirty_card, last-first);
       
   444 }
       
   445 
   429 // NOTES:
   446 // NOTES:
   430 // (1) Unlike mod_oop_in_space_iterate() above, dirty_card_iterate()
   447 // (1) Unlike mod_oop_in_space_iterate() above, dirty_card_iterate()
   431 //     iterates over dirty cards ranges in increasing address order.
   448 //     iterates over dirty cards ranges in increasing address order.
   432 // (2) Unlike, e.g., dirty_card_range_after_preclean() below,
       
   433 //     this method does not make the dirty cards prelceaned.
       
   434 void CardTableModRefBS::dirty_card_iterate(MemRegion mr,
   449 void CardTableModRefBS::dirty_card_iterate(MemRegion mr,
   435                                            MemRegionClosure* cl) {
   450                                            MemRegionClosure* cl) {
   436   for (int i = 0; i < _cur_covered_regions; i++) {
   451   for (int i = 0; i < _cur_covered_regions; i++) {
   437     MemRegion mri = mr.intersection(_covered[i]);
   452     MemRegion mri = mr.intersection(_covered[i]);
   438     if (!mri.is_empty()) {
   453     if (!mri.is_empty()) {
   454       }
   469       }
   455     }
   470     }
   456   }
   471   }
   457 }
   472 }
   458 
   473 
   459 MemRegion CardTableModRefBS::dirty_card_range_after_preclean(MemRegion mr) {
   474 MemRegion CardTableModRefBS::dirty_card_range_after_reset(MemRegion mr,
       
   475                                                           bool reset,
       
   476                                                           int reset_val) {
   460   for (int i = 0; i < _cur_covered_regions; i++) {
   477   for (int i = 0; i < _cur_covered_regions; i++) {
   461     MemRegion mri = mr.intersection(_covered[i]);
   478     MemRegion mri = mr.intersection(_covered[i]);
   462     if (!mri.is_empty()) {
   479     if (!mri.is_empty()) {
   463       jbyte* cur_entry, *next_entry, *limit;
   480       jbyte* cur_entry, *next_entry, *limit;
   464       for (cur_entry = byte_for(mri.start()), limit = byte_for(mri.last());
   481       for (cur_entry = byte_for(mri.start()), limit = byte_for(mri.last());
   471           for (dirty_cards = 1;
   488           for (dirty_cards = 1;
   472                next_entry <= limit && *next_entry == dirty_card;
   489                next_entry <= limit && *next_entry == dirty_card;
   473                dirty_cards++, next_entry++);
   490                dirty_cards++, next_entry++);
   474           MemRegion cur_cards(addr_for(cur_entry),
   491           MemRegion cur_cards(addr_for(cur_entry),
   475                               dirty_cards*card_size_in_words);
   492                               dirty_cards*card_size_in_words);
   476           for (size_t i = 0; i < dirty_cards; i++) {
   493           if (reset) {
   477              cur_entry[i] = precleaned_card;
   494             for (size_t i = 0; i < dirty_cards; i++) {
       
   495               cur_entry[i] = reset_val;
       
   496             }
   478           }
   497           }
   479           return cur_cards;
   498           return cur_cards;
   480         }
   499         }
   481       }
   500       }
   482     }
   501     }