Ejemplo n.º 1
0
 /// Remove all dead subscriptions if the number of dead nodes exceeds the number of live nodes.
 /// @precondition The signal is not currently running.
 /// @todo Make private.
 void maybeSweep() noexcept {
     assert(true == running); // Must be true!
     if (needsSweep()) {
         NodeType **pred = &head, *cur = head;
         while (nullptr != cur) {
             if (cur->isDead()) { // Does the subscription refer to this node?
                 NodeType *node = cur;
                 *pred = cur->next;
                 cur = cur = cur->next;
                 delete node;
                 deadCount--;
             } else {
                 pred = &cur->next;
                 cur = cur->next;
             }
         }
     }
 }
Ejemplo n.º 2
0
nmethod* zone::allocate(int size) {
  // CSect cs(profilerSemaphore); // for profiler
  // must get method ID here! (because reclaim might change firstFree)
  // (compiler may have used peekID to get ID of new nmethod for LRU stuff)
  if (needsSweep()) doSweep();

  nmethod* n = (nmethod*) methodHeap->allocate(size);
  
  if (n == NULL) {
    // allocation failed so flush zombies and retry
    flushZombies();
    n = (nmethod*) methodHeap->allocate(size);
    if (n == NULL) {
      print();
      fatal("cannot allocate enough space for nmethod");
    }
  }

  verify_if_often();
  return n;
}