Changeset 4156 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Apr 22, 2003, 5:09:32 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/list.cpp
r3373 r4156 29 29 30 30 // tunable parameters 31 const int poolSize = 3 2; // must be a power of 231 const int poolSize = 384; 32 32 const int inlineValuesSize = 4; 33 33 34 // derived constants35 const int poolSizeMask = poolSize - 1;36 34 37 35 enum ListImpState { unusedInPool = 0, usedInPool, usedOnHeap, immortal }; … … 44 42 ValueImp **overflow; 45 43 44 ListImp *nextInFreeList; 45 46 46 #if DUMP_STATISTICS 47 47 int sizeHighWaterMark; … … 50 50 51 51 static ListImp pool[poolSize]; 52 static int poolCursor; 52 static ListImp *poolFreeList; 53 static int poolUsed; 53 54 54 55 #if DUMP_STATISTICS … … 89 90 { 90 91 // Find a free one in the pool. 91 int c = poolCursor; 92 int i = c; 93 do { 94 ListImp *imp = &pool[i]; 95 ListImpState s = imp->state; 96 i = (i + 1) & poolSizeMask; 97 if (s == unusedInPool) { 98 poolCursor = i; 99 imp->state = usedInPool; 100 return imp; 101 } 102 } while (i != c); 92 if (poolUsed < poolSize) { 93 ListImp *imp = poolFreeList ? poolFreeList : &pool[0]; 94 poolFreeList = imp->nextInFreeList ? imp->nextInFreeList : imp + 1; 95 imp->state = usedInPool; 96 poolUsed++; 97 return imp; 98 } 103 99 104 100 ListImp *imp = new ListImp; … … 109 105 static inline void deallocateListImp(ListImp *imp) 110 106 { 111 if (imp->state == usedInPool) 107 if (imp->state == usedInPool) { 112 108 imp->state = unusedInPool; 113 else 109 imp->nextInFreeList = poolFreeList; 110 poolFreeList = imp; 111 poolUsed--; 112 } else { 114 113 delete imp; 114 } 115 115 } 116 116
Note:
See TracChangeset
for help on using the changeset viewer.