8047330: Remove unrolled card loops in G1 SparsePRTEntry
authorbrutisso
Wed, 20 May 2015 10:45:40 +0200
changeset 30772 fe109817cc79
parent 30771 0d139bc2a24a
child 30773 3f15e2dc056b
child 30867 1c87147477bd
8047330: Remove unrolled card loops in G1 SparsePRTEntry Reviewed-by: ehelin, mgerdin, tschatzl Contributed-by: andreas.sjoberg@oracle.com
hotspot/src/share/vm/gc/g1/sparsePRT.cpp
--- a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp	Tue May 19 17:25:49 2015 +0200
+++ b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp	Wed May 20 10:45:40 2015 +0200
@@ -34,106 +34,42 @@
 
 #define SPARSE_PRT_VERBOSE 0
 
-#define UNROLL_CARD_LOOPS  1
-
 void SparsePRTEntry::init(RegionIdx_t region_ind) {
   _region_ind = region_ind;
   _next_index = NullEntry;
 
-#if UNROLL_CARD_LOOPS
-  assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
-  for (int i = 0; i < cards_num(); i += UnrollFactor) {
+  for (int i = 0; i < cards_num(); i++) {
     _cards[i] = NullEntry;
-    _cards[i + 1] = NullEntry;
-    _cards[i + 2] = NullEntry;
-    _cards[i + 3] = NullEntry;
   }
-#else
-  for (int i = 0; i < cards_num(); i++)
-    _cards[i] = NullEntry;
-#endif
 }
 
 bool SparsePRTEntry::contains_card(CardIdx_t card_index) const {
-#if UNROLL_CARD_LOOPS
-  assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
-  for (int i = 0; i < cards_num(); i += UnrollFactor) {
-    if (_cards[i] == card_index ||
-        _cards[i + 1] == card_index ||
-        _cards[i + 2] == card_index ||
-        _cards[i + 3] == card_index) return true;
-  }
-#else
   for (int i = 0; i < cards_num(); i++) {
     if (_cards[i] == card_index) return true;
   }
-#endif
-  // Otherwise, we're full.
   return false;
 }
 
 int SparsePRTEntry::num_valid_cards() const {
   int sum = 0;
-#if UNROLL_CARD_LOOPS
-  assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
-  for (int i = 0; i < cards_num(); i += UnrollFactor) {
-    sum += (_cards[i] != NullEntry);
-    sum += (_cards[i + 1] != NullEntry);
-    sum += (_cards[i + 2] != NullEntry);
-    sum += (_cards[i + 3] != NullEntry);
-  }
-#else
   for (int i = 0; i < cards_num(); i++) {
     sum += (_cards[i] != NullEntry);
   }
-#endif
-  // Otherwise, we're full.
   return sum;
 }
 
 SparsePRTEntry::AddCardResult SparsePRTEntry::add_card(CardIdx_t card_index) {
-#if UNROLL_CARD_LOOPS
-  assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
-  CardIdx_t c;
-  for (int i = 0; i < cards_num(); i += UnrollFactor) {
-    c = _cards[i];
-    if (c == card_index) return found;
-    if (c == NullEntry) { _cards[i] = card_index; return added; }
-    c = _cards[i + 1];
-    if (c == card_index) return found;
-    if (c == NullEntry) { _cards[i + 1] = card_index; return added; }
-    c = _cards[i + 2];
-    if (c == card_index) return found;
-    if (c == NullEntry) { _cards[i + 2] = card_index; return added; }
-    c = _cards[i + 3];
-    if (c == card_index) return found;
-    if (c == NullEntry) { _cards[i + 3] = card_index; return added; }
-  }
-#else
   for (int i = 0; i < cards_num(); i++) {
     CardIdx_t c = _cards[i];
     if (c == card_index) return found;
     if (c == NullEntry) { _cards[i] = card_index; return added; }
   }
-#endif
   // Otherwise, we're full.
   return overflow;
 }
 
 void SparsePRTEntry::copy_cards(CardIdx_t* cards) const {
-#if UNROLL_CARD_LOOPS
-  assert((cards_num() & (UnrollFactor - 1)) == 0, "Invalid number of cards in the entry");
-  for (int i = 0; i < cards_num(); i += UnrollFactor) {
-    cards[i] = _cards[i];
-    cards[i + 1] = _cards[i + 1];
-    cards[i + 2] = _cards[i + 2];
-    cards[i + 3] = _cards[i + 3];
-  }
-#else
-  for (int i = 0; i < cards_num(); i++) {
-    cards[i] = _cards[i];
-  }
-#endif
+  memcpy(cards, _cards, cards_num() * sizeof(CardIdx_t));
 }
 
 void SparsePRTEntry::copy_cards(SparsePRTEntry* e) const {