webengine/osswebengine/JavaScriptCore/kjs/collector.cpp
changeset 1 7c90e6132015
parent 0 dd21522fd290
child 5 10e98eab6f85
equal deleted inserted replaced
0:dd21522fd290 1:7c90e6132015
    81 const size_t LOW_WATER_FACTOR = 4;
    81 const size_t LOW_WATER_FACTOR = 4;
    82 const size_t ALLOCATIONS_PER_COLLECTION = 4000;
    82 const size_t ALLOCATIONS_PER_COLLECTION = 4000;
    83 
    83 
    84 enum OperationInProgress { NoOperation, Allocation, Collection };
    84 enum OperationInProgress { NoOperation, Allocation, Collection };
    85 
    85 
       
    86 //forward declaration
       
    87 static void freeBlock(CollectorBlock* block);
       
    88 
    86 struct CollectorHeap {
    89 struct CollectorHeap {
    87   CollectorBlock** blocks;
    90   CollectorBlock** blocks;
    88   size_t numBlocks;
    91   size_t numBlocks;
    89   size_t usedBlocks;
    92   size_t usedBlocks;
    90   size_t firstBlockWithPossibleSpace;
    93   size_t firstBlockWithPossibleSpace;
    92   size_t numLiveObjects;
    95   size_t numLiveObjects;
    93   size_t numLiveObjectsAtLastCollect;
    96   size_t numLiveObjectsAtLastCollect;
    94   size_t extraCost;
    97   size_t extraCost;
    95 
    98 
    96   OperationInProgress operationInProgress;
    99   OperationInProgress operationInProgress;
       
   100 
       
   101   ~CollectorHeap() {
       
   102       for(int i=0; i<usedBlocks; ++i) {
       
   103           freeBlock(blocks[i]);
       
   104       }
       
   105   }
    97 };
   106 };
    98 
   107 
    99 static CollectorHeap heap = { 0, 0, 0, 0, 0, 0, 0, NoOperation };
   108 static CollectorHeap heap = { 0, 0, 0, 0, 0, 0, 0, NoOperation };
   100 
   109 
   101 // FIXME: I don't think this needs to be a static data member of the Collector class.
   110 // FIXME: I don't think this needs to be a static data member of the Collector class.