< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahNumberSeq.cpp

Print this page
*** 118,10 ***
--- 118,46 ---
      }
    }
    return maximum();
  }
  
+ // Merge this HdrSeq into hdr2: clear optional and on-by-default
+ // Note: this method isn't intrinsically MT-safe; callers must take care
+ // of any mutual exclusion as necessary.
+ void HdrSeq::merge(HdrSeq& hdr2, bool clear_this) {
+   for (int mag = 0; mag < MagBuckets; mag++) {
+     if (_hdr[mag] != NULL) {
+       int* that_bucket = hdr2._hdr[mag];
+       if (that_bucket == NULL) {
+         if (clear_this) {
+           // the target doesn't have any values, swap in ours.
+           // Could this cause native memory fragmentation?
+           hdr2._hdr[mag] = _hdr[mag];
+           _hdr[mag] = NULL;
+         } else {
+           // We can't clear this, so we create the entries & add in below
+           that_bucket = NEW_C_HEAP_ARRAY(int, ValBuckets, mtInternal);
+           for (int val = 0; val < ValBuckets; val++) {
+             that_bucket[val] = _hdr[mag][val];
+           }
+           hdr2._hdr[mag] = that_bucket;
+         }
+       } else {
+         // Add in our values into target
+         for (int val = 0; val < ValBuckets; val++) {
+           that_bucket[val] += _hdr[mag][val];
+           if (clear_this) {
+             _hdr[mag][val] = 0;
+           }
+         }
+       }
+     }
+   }
+   // Merge up the class hierarchy
+   NumberSeq::merge(hdr2, clear_this);
+ }
+ 
  BinaryMagnitudeSeq::BinaryMagnitudeSeq() {
    _mags = NEW_C_HEAP_ARRAY(size_t, BitsPerSize_t, mtInternal);
    clear();
  }
  
< prev index next >