Changeset 10641 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Sep 27, 2005, 7:25:58 PM (20 years ago)
Author:
adele
Message:

JavaScriptCore:

Reviewed by Maciej.

Changed ints to size_t where appropriate.

  • kjs/collector.cpp: (KJS::Collector::allocate): (KJS::Collector::markStackObjectsConservatively): (KJS::Collector::collect): (KJS::Collector::size): (KJS::Collector::numInterpreters): (KJS::Collector::numGCNotAllowedObjects): (KJS::Collector::numReferencedObjects):
  • kjs/collector.h:

WebCore:

Reviewed by Maciej.

Changing ints to size_t where appropriate.

  • kwq/WebCoreJavaScript.h:
  • kwq/WebCoreJavaScript.mm: (+[WebCoreJavaScript objectCount]): (+[WebCoreJavaScript interpreterCount]): (+[WebCoreJavaScript noGCAllowedObjectCount]): (+[WebCoreJavaScript referencedObjectCount]):

WebKit:

Reviewed by Maciej.

Changed ints to size_t where appropriate.

  • Misc.subproj/WebCoreStatistics.h:
  • Misc.subproj/WebCoreStatistics.m: (+[WebCoreStatistics javaScriptObjectsCount]): (+[WebCoreStatistics javaScriptInterpretersCount]): (+[WebCoreStatistics javaScriptNoGCAllowedObjectsCount]): (+[WebCoreStatistics javaScriptReferencedObjectsCount]):
  • WebView.subproj/WebPreferences.m: (-[WebPreferences _pageCacheSize]): (-[WebPreferences _objectCacheSize]):
  • WebView.subproj/WebPreferencesPrivate.h:
Location:
trunk/JavaScriptCore/kjs
Files:
2 edited

Legend:

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

    r10634 r10641  
    4949
    5050// tunable parameters
    51 const int MINIMUM_CELL_SIZE = 56;
    52 const int BLOCK_SIZE = (8 * 4096);
    53 const int SPARE_EMPTY_BLOCKS = 2;
    54 const int MIN_ARRAY_SIZE = 14;
    55 const int GROWTH_FACTOR = 2;
    56 const int LOW_WATER_FACTOR = 4;
    57 const int ALLOCATIONS_PER_COLLECTION = 1000;
     51const size_t MINIMUM_CELL_SIZE = 56;
     52const size_t BLOCK_SIZE = (8 * 4096);
     53const size_t SPARE_EMPTY_BLOCKS = 2;
     54const size_t MIN_ARRAY_SIZE = 14;
     55const size_t GROWTH_FACTOR = 2;
     56const size_t LOW_WATER_FACTOR = 4;
     57const size_t ALLOCATIONS_PER_COLLECTION = 1000;
    5858
    5959// derived constants
    60 const int CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0);
    61 const int CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double);
    62 const int CELLS_PER_BLOCK = ((BLOCK_SIZE * 8 - sizeof(int32_t) * 8 - sizeof(void *) * 8) / (CELL_SIZE * 8));
     60const size_t CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0);
     61const size_t CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double);
     62const size_t CELLS_PER_BLOCK = ((BLOCK_SIZE * 8 - sizeof(uint32_t) * 8 - sizeof(void *) * 8) / (CELL_SIZE * 8));
    6363
    6464
     
    7777struct CollectorBlock {
    7878  CollectorCell cells[CELLS_PER_BLOCK];
    79   int32_t usedCells;
     79  uint32_t usedCells;
    8080  CollectorCell *freeList;
    8181};
     
    8383struct CollectorHeap {
    8484  CollectorBlock **blocks;
    85   int numBlocks;
    86   int usedBlocks;
    87   int firstBlockWithPossibleSpace;
     85  size_t numBlocks;
     86  size_t usedBlocks;
     87  size_t firstBlockWithPossibleSpace;
    8888 
    8989  CollectorCell **oversizeCells;
    90   int numOversizeCells;
    91   int usedOversizeCells;
    92 
    93   int numLiveObjects;
    94   int numLiveObjectsAtLastCollect;
     90  size_t numOversizeCells;
     91  size_t usedOversizeCells;
     92
     93  size_t numLiveObjects;
     94  size_t numLiveObjectsAtLastCollect;
    9595};
    9696
     
    104104
    105105  // collect if needed
    106   int numLiveObjects = heap.numLiveObjects;
     106  size_t numLiveObjects = heap.numLiveObjects;
    107107  if (numLiveObjects - heap.numLiveObjectsAtLastCollect >= ALLOCATIONS_PER_COLLECTION) {
    108108    collect();
     
    110110  }
    111111 
    112   if (s > static_cast<size_t>(CELL_SIZE)) {
     112  if (s > CELL_SIZE) {
    113113    // oversize allocator
    114114
    115     int usedOversizeCells = heap.usedOversizeCells;
    116     int numOversizeCells = heap.numOversizeCells;
     115    size_t usedOversizeCells = heap.usedOversizeCells;
     116    size_t numOversizeCells = heap.numOversizeCells;
    117117
    118118    if (usedOversizeCells == numOversizeCells) {
     
    132132  // slab allocator
    133133 
    134   int usedBlocks = heap.usedBlocks;
    135 
    136   int i = heap.firstBlockWithPossibleSpace;
     134  size_t usedBlocks = heap.usedBlocks;
     135
     136  size_t i = heap.firstBlockWithPossibleSpace;
    137137  CollectorBlock *targetBlock;
    138   int targetBlockUsedCells;
     138  size_t targetBlockUsedCells;
    139139  if (i != usedBlocks) {
    140140    targetBlock = heap.blocks[i];
     
    153153    // didn't find one, need to allocate a new block
    154154
    155     int numBlocks = heap.numBlocks;
     155    size_t numBlocks = heap.numBlocks;
    156156    if (usedBlocks == numBlocks) {
    157157      numBlocks = max(MIN_ARRAY_SIZE, numBlocks * GROWTH_FACTOR);
     
    234234#endif
    235235
    236 #define IS_POINTER_ALIGNED(p) (((int)(p) & (sizeof(char *) - 1)) == 0)
     236#define IS_POINTER_ALIGNED(p) (((intptr_t)(p) & (sizeof(char *) - 1)) == 0)
    237237
    238238// cells are 8-byte aligned
    239 #define IS_CELL_ALIGNED(p) (((int)(p) & 7) == 0)
     239#define IS_CELL_ALIGNED(p) (((intptr_t)(p) & 7) == 0)
    240240
    241241void Collector::markStackObjectsConservatively(void *start, void *end)
     
    254254  char **e = (char **)end;
    255255 
    256   int usedBlocks = heap.usedBlocks;
     256  size_t usedBlocks = heap.usedBlocks;
    257257  CollectorBlock **blocks = heap.blocks;
    258   int usedOversizeCells = heap.usedOversizeCells;
     258  size_t usedOversizeCells = heap.usedOversizeCells;
    259259  CollectorCell **oversizeCells = heap.oversizeCells;
    260260
     
    264264    char *x = *p++;
    265265    if (IS_CELL_ALIGNED(x) && x) {
    266       for (int block = 0; block < usedBlocks; block++) {
     266      for (size_t block = 0; block < usedBlocks; block++) {
    267267        size_t offset = x - reinterpret_cast<char *>(blocks[block]);
    268268        if (offset <= lastCellOffset && offset % sizeof(CollectorCell) == 0)
    269269          goto gotGoodPointer;
    270270      }
    271       for (int i = 0; i != usedOversizeCells; i++)
     271      for (size_t i = 0; i != usedOversizeCells; i++)
    272272        if (x == reinterpret_cast<char *>(oversizeCells[i]))
    273273          goto gotGoodPointer;
     
    397397  // SWEEP: delete everything with a zero refcount (garbage) and unmark everything else
    398398 
    399   int emptyBlocks = 0;
    400   int numLiveObjects = heap.numLiveObjects;
    401 
    402   for (int block = 0; block < heap.usedBlocks; block++) {
     399  size_t emptyBlocks = 0;
     400  size_t numLiveObjects = heap.numLiveObjects;
     401
     402  for (size_t block = 0; block < heap.usedBlocks; block++) {
    403403    CollectorBlock *curBlock = heap.blocks[block];
    404404
    405     int usedCells = curBlock->usedCells;
     405    size_t usedCells = curBlock->usedCells;
    406406    CollectorCell *freeList = curBlock->freeList;
    407407
    408408    if (usedCells == CELLS_PER_BLOCK) {
    409409      // special case with a block where all cells are used -- testing indicates this happens often
    410       for (int i = 0; i < CELLS_PER_BLOCK; i++) {
     410      for (size_t i = 0; i < CELLS_PER_BLOCK; i++) {
    411411        CollectorCell *cell = curBlock->cells + i;
    412412        AllocatedValueImp *imp = reinterpret_cast<AllocatedValueImp *>(cell);
     
    425425      }
    426426    } else {
    427       int minimumCellsToProcess = usedCells;
    428       for (int i = 0; i < minimumCellsToProcess; i++) {
     427      size_t minimumCellsToProcess = usedCells;
     428      for (size_t i = 0; i < minimumCellsToProcess; i++) {
    429429        CollectorCell *cell = curBlock->cells + i;
    430430        if (cell->u.freeCell.zeroIfFree == 0) {
     
    473473    heap.firstBlockWithPossibleSpace = 0;
    474474 
    475   int cell = 0;
     475  size_t cell = 0;
    476476  while (cell < heap.usedOversizeCells) {
    477477    AllocatedValueImp *imp = (AllocatedValueImp *)heap.oversizeCells[cell];
     
    511511}
    512512
    513 int Collector::size()
     513size_t Collector::size()
    514514{
    515515  return heap.numLiveObjects;
     
    522522#endif
    523523
    524 int Collector::numInterpreters()
    525 {
    526   int count = 0;
     524size_t Collector::numInterpreters()
     525{
     526  size_t count = 0;
    527527  if (InterpreterImp::s_hook) {
    528528    InterpreterImp *scr = InterpreterImp::s_hook;
     
    535535}
    536536
    537 int Collector::numGCNotAllowedObjects()
     537size_t Collector::numGCNotAllowedObjects()
    538538{
    539539  return 0;
    540540}
    541541
    542 int Collector::numReferencedObjects()
    543 {
    544   int count = 0;
    545 
    546   int size = ProtectedValues::_tableSize;
     542size_t Collector::numReferencedObjects()
     543{
     544  size_t count = 0;
     545
     546  size_t size = ProtectedValues::_tableSize;
    547547  ProtectedValues::KeyValue *table = ProtectedValues::_table;
    548   for (int i = 0; i < size; i++) {
     548  for (size_t i = 0; i < size; i++) {
    549549    AllocatedValueImp *val = table[i].key;
    550550    if (val) {
  • trunk/JavaScriptCore/kjs/collector.h

    r9768 r10641  
    5454     */
    5555    static bool collect();
    56     static int size();
     56    static size_t size();
    5757    static bool outOfMemory() { return memoryFull; }
    5858
     
    6464#endif
    6565
    66     static int numInterpreters();
    67     static int numGCNotAllowedObjects();
    68     static int numReferencedObjects();
     66    static size_t numInterpreters();
     67    static size_t numGCNotAllowedObjects();
     68    static size_t numReferencedObjects();
    6969#if APPLE_CHANGES
    7070    static const void *rootObjectClasses(); // actually returns CFSetRef
Note: See TracChangeset for help on using the changeset viewer.