< prev index next >

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

Print this page




  64    * next attempt without processing.
  65    *
  66    * Late threads would return immediately if iterator is finished.
  67    */
  68 
  69   if (_finished) {
  70     return;
  71   }
  72 
  73   int stride = 256; // educated guess
  74   int stride_mask = stride - 1;
  75   assert (is_power_of_2(stride), "sanity");
  76 
  77   int count = 0;
  78   bool process_block = true;
  79 
  80   for (CodeBlob *cb = CodeCache::first_blob(_heap); cb != NULL; cb = CodeCache::next_blob(_heap, cb)) {
  81     int current = count++;
  82     if ((current & stride_mask) == 0) {
  83       process_block = (current >= _claimed_idx) &&
  84                       (Atomic::cmpxchg(current + stride, &_claimed_idx, current) == current);
  85     }
  86     if (process_block) {
  87       if (cb->is_alive()) {
  88         f->do_code_blob(cb);
  89 #ifdef ASSERT
  90         if (cb->is_nmethod())
  91           Universe::heap()->verify_nmethod((nmethod*)cb);
  92 #endif
  93       }
  94     }
  95   }
  96 
  97   _finished = true;
  98 }
  99 
 100 class ShenandoahNMethodOopDetector : public OopClosure {
 101 private:
 102   ResourceMark rm; // For growable array allocation below.
 103   GrowableArray<oop*> _oops;
 104 




  64    * next attempt without processing.
  65    *
  66    * Late threads would return immediately if iterator is finished.
  67    */
  68 
  69   if (_finished) {
  70     return;
  71   }
  72 
  73   int stride = 256; // educated guess
  74   int stride_mask = stride - 1;
  75   assert (is_power_of_2(stride), "sanity");
  76 
  77   int count = 0;
  78   bool process_block = true;
  79 
  80   for (CodeBlob *cb = CodeCache::first_blob(_heap); cb != NULL; cb = CodeCache::next_blob(_heap, cb)) {
  81     int current = count++;
  82     if ((current & stride_mask) == 0) {
  83       process_block = (current >= _claimed_idx) &&
  84                       (Atomic::cmpxchg(&_claimed_idx, current, current + stride) == current);
  85     }
  86     if (process_block) {
  87       if (cb->is_alive()) {
  88         f->do_code_blob(cb);
  89 #ifdef ASSERT
  90         if (cb->is_nmethod())
  91           Universe::heap()->verify_nmethod((nmethod*)cb);
  92 #endif
  93       }
  94     }
  95   }
  96 
  97   _finished = true;
  98 }
  99 
 100 class ShenandoahNMethodOopDetector : public OopClosure {
 101 private:
 102   ResourceMark rm; // For growable array allocation below.
 103   GrowableArray<oop*> _oops;
 104 


< prev index next >