Ignore:
Timestamp:
Nov 22, 2002, 12:13:09 AM (23 years ago)
Author:
mjs
Message:
  • a simple change for .4% gain on ibench - instead of unmarking all objects at the start of collection, instead unmark as part of the sweep phase
  • kjs/collector.cpp: (Collector::collect): Remove separate unmarking pass and instead unmark the objects that don't get collected during the sweep phase.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/collector.cpp

    r2788 r2822  
    161161{
    162162  bool deleted = false;
    163   // MARK: first unmark everything
    164   for (int block = 0; block < heap.usedBlocks; block++) {
    165     for (int cell = 0; cell < CELLS_PER_BLOCK; cell++) {
    166       ((ValueImp *)(heap.blocks[block]->cells + cell))->_flags &= ~ValueImp::VI_MARKED;
    167     }
    168   }
    169   for (int cell = 0; cell < heap.usedOversizeCells; cell++) {
    170     ((ValueImp *)heap.oversizeCells[cell])->_flags &= ~ValueImp::VI_MARKED;
    171   }
    172  
    173   // mark all referenced objects recursively
     163
     164  // MARK: first mark all referenced objects recursively
    174165  // starting out from the set of root objects
    175166  if (InterpreterImp::s_hook) {
     
    205196    }
    206197  }
    207  
    208   // SWEEP: delete everything with a zero refcount (garbage)
     198
     199  // SWEEP: delete everything with a zero refcount (garbage) and unmark everything else
    209200 
    210201  int emptyBlocks = 0;
     
    214205      uint32_t word = heap.blocks[block]->bitmap[wordInBitmap];
    215206      for (int bitInWord = 0; bitInWord < BITS_PER_WORD; bitInWord++) {
     207       
     208        if (word & (1 << bitInWord)) {
    216209        ValueImp *imp = (ValueImp *)(heap.blocks[block]->cells + BITS_PER_WORD * wordInBitmap + bitInWord);
    217        
    218         if ((word & (1 << bitInWord)) &&
    219             !imp->refcount && imp->_flags == (ValueImp::VI_GCALLOWED | ValueImp::VI_CREATED)) {
    220           // emulate destructing part of 'operator delete()'
    221           //fprintf( stderr, "Collector::deleting ValueImp %p (%s)\n", (void*)imp, typeid(*imp).name());
    222           imp->~ValueImp();
    223           heap.blocks[block]->bitmap[wordInBitmap] &= ~(1 << bitInWord);
    224           heap.blocks[block]->usedCells--;
    225           heap.numLiveObjects--;
    226           deleted = true;
     210          if (!imp->refcount && imp->_flags == (ValueImp::VI_GCALLOWED | ValueImp::VI_CREATED)) {
     211            //fprintf( stderr, "Collector::deleting ValueImp %p (%s)\n", (void*)imp, typeid(*imp).name());
     212            // emulate destructing part of 'operator delete()'
     213            imp->~ValueImp();
     214            heap.blocks[block]->bitmap[wordInBitmap] &= ~(1 << bitInWord);
     215            heap.blocks[block]->usedCells--;
     216            heap.numLiveObjects--;
     217            deleted = true;
     218          } else {
     219            imp->_flags &= ~ValueImp::VI_MARKED;
     220          }
    227221        }
    228222      }
     
    246240    }
    247241  }
    248 
    249242
    250243 
     
    272265
    273266    } else {
     267      imp->_flags &= ~ValueImp::VI_MARKED;
    274268      cell++;
    275269    }
Note: See TracChangeset for help on using the changeset viewer.