< prev index next >

src/hotspot/share/gc/z/zNMethodTableIteration.cpp

Print this page




  41 void ZNMethodTableIteration::nmethods_do_begin(ZNMethodTableEntry* table, size_t size) {
  42   assert(!in_progress(), "precondition");
  43 
  44   _table = table;
  45   _size = size;
  46   _claimed = 0;
  47 }
  48 
  49 void ZNMethodTableIteration::nmethods_do_end() {
  50   assert(_claimed >= _size, "Failed to claim all table entries");
  51 
  52   // Finish iteration
  53   _table = NULL;
  54 }
  55 
  56 void ZNMethodTableIteration::nmethods_do(NMethodClosure* cl) {
  57   for (;;) {
  58     // Claim table partition. Each partition is currently sized to span
  59     // two cache lines. This number is just a guess, but seems to work well.
  60     const size_t partition_size = (ZCacheLineSize * 2) / sizeof(ZNMethodTableEntry);
  61     const size_t partition_start = MIN2(Atomic::add(partition_size, &_claimed) - partition_size, _size);
  62     const size_t partition_end = MIN2(partition_start + partition_size, _size);
  63     if (partition_start == partition_end) {
  64       // End of table
  65       break;
  66     }
  67 
  68     // Process table partition
  69     for (size_t i = partition_start; i < partition_end; i++) {
  70       const ZNMethodTableEntry entry = _table[i];
  71       if (entry.registered()) {
  72         cl->do_nmethod(entry.method());
  73       }
  74     }
  75   }
  76 }


  41 void ZNMethodTableIteration::nmethods_do_begin(ZNMethodTableEntry* table, size_t size) {
  42   assert(!in_progress(), "precondition");
  43 
  44   _table = table;
  45   _size = size;
  46   _claimed = 0;
  47 }
  48 
  49 void ZNMethodTableIteration::nmethods_do_end() {
  50   assert(_claimed >= _size, "Failed to claim all table entries");
  51 
  52   // Finish iteration
  53   _table = NULL;
  54 }
  55 
  56 void ZNMethodTableIteration::nmethods_do(NMethodClosure* cl) {
  57   for (;;) {
  58     // Claim table partition. Each partition is currently sized to span
  59     // two cache lines. This number is just a guess, but seems to work well.
  60     const size_t partition_size = (ZCacheLineSize * 2) / sizeof(ZNMethodTableEntry);
  61     const size_t partition_start = MIN2(Atomic::add(&_claimed, partition_size) - partition_size, _size);
  62     const size_t partition_end = MIN2(partition_start + partition_size, _size);
  63     if (partition_start == partition_end) {
  64       // End of table
  65       break;
  66     }
  67 
  68     // Process table partition
  69     for (size_t i = partition_start; i < partition_end; i++) {
  70       const ZNMethodTableEntry entry = _table[i];
  71       if (entry.registered()) {
  72         cl->do_nmethod(entry.method());
  73       }
  74     }
  75   }
  76 }
< prev index next >