Changeset 2883 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Nov 26, 2002, 3:52:00 PM (23 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/collector.cpp
r2845 r2883 163 163 bool Collector::collect() 164 164 { 165 puts("COLLECT"); 165 166 bool deleted = false; 166 167 … … 253 254 emptyBlocks++; 254 255 if (emptyBlocks > SPARE_EMPTY_BLOCKS) { 255 delete heap.blocks[block]; 256 256 #if !DEBUG_COLLECTOR 257 free(heap.blocks[block]); 258 #endif 257 259 // swap with the last block so we compact as we go 258 260 heap.blocks[block] = heap.blocks[heap.usedBlocks - 1]; … … 280 282 281 283 imp->~ValueImp(); 284 #if DEBUG_COLLECTOR 285 heap.oversizeCells[cell]->u.freeCell.zeroIfFree = 0; 286 #else 282 287 free((void *)imp); 288 #endif 283 289 284 290 // swap with the last oversize cell so we compact as we go -
trunk/JavaScriptCore/kjs/context.h
r2851 r2883 56 56 InterpreterImp *_interpreter; 57 57 ContextImp *_callingContext; 58 ActivationImp _activationImp;59 58 FunctionImp *_function; 60 59 const List *_arguments; -
trunk/JavaScriptCore/kjs/function.cpp
r2824 r2883 333 333 334 334 // ECMA 10.1.6 335 ActivationImp::ActivationImp(ContextImp *context) 336 : _context(context), _argumentsObject(0) 337 { 335 ActivationImp::ActivationImp(FunctionImp *function, const List &arguments) 336 : _function(function), _arguments(true), _argumentsObject(0) 337 { 338 _arguments = arguments.copy(); 338 339 // FIXME: Do we need to support enumerating the arguments property? 339 340 } … … 374 375 void ActivationImp::mark() 375 376 { 377 if (_function && !_function->marked()) 378 _function->mark(); 379 _arguments.mark(); 376 380 if (_argumentsObject && !_argumentsObject->marked()) 377 381 _argumentsObject->mark(); … … 381 385 void ActivationImp::createArgumentsObject(ExecState *exec) const 382 386 { 383 FunctionImp *function = _context->function(); 384 const List *arguments = _context->arguments(); 385 if (arguments) 386 _argumentsObject = new ArgumentsImp(exec, function, *arguments); 387 else 388 _argumentsObject = new ArgumentsImp(exec, function); 387 _argumentsObject = new ArgumentsImp(exec, _function, _arguments); 389 388 } 390 389 -
trunk/JavaScriptCore/kjs/function.h
r2821 r2883 101 101 class ActivationImp : public ObjectImp { 102 102 public: 103 ActivationImp( ContextImp *);103 ActivationImp(FunctionImp *function, const List &arguments); 104 104 105 105 virtual Value get(ExecState *exec, const Identifier &propertyName) const; … … 116 116 void createArgumentsObject(ExecState *exec) const; 117 117 118 const ContextImp *_context; 118 FunctionImp *_function; 119 List _arguments; 119 120 mutable ArgumentsImp *_argumentsObject; 120 121 }; -
trunk/JavaScriptCore/kjs/internal.cpp
r2851 r2883 360 360 ContextImp::ContextImp(Object &glob, InterpreterImp *interpreter, Object &thisV, CodeType type, 361 361 ContextImp *callingCon, FunctionImp *func, const List *args) 362 : _interpreter(interpreter), _ activationImp(this), _function(func), _arguments(args)362 : _interpreter(interpreter), _function(func), _arguments(args) 363 363 { 364 364 codeType = type; … … 367 367 // create and initialize activation object (ECMA 10.1.6) 368 368 if (type == FunctionCode || type == AnonymousCode ) { 369 activation = Object( &_activationImp);369 activation = Object(new ActivationImp(func, *args)); 370 370 variable = activation; 371 371 } else { … … 415 415 for (ContextImp *context = this; context; context = context->_callingContext) { 416 416 context->scope.mark(); 417 context->_activationImp.mark();418 #if DEBUG_COLLECTOR419 context->_activationImp._flags &= ~ValueImp::VI_MARKED;420 #endif421 417 } 422 418 } -
trunk/JavaScriptCore/kjs/list.cpp
r2843 r2883 29 29 30 30 // tunable parameters 31 const int poolSize = 16; // must be a power of 231 const int poolSize = 32; // must be a power of 2 32 32 const int inlineValuesSize = 4; 33 33 … … 115 115 } 116 116 117 List::List() : _impBase(allocateListImp()) 117 List::List() : _impBase(allocateListImp()), _needsMarking(false) 118 118 { 119 119 ListImp *imp = static_cast<ListImp *>(_impBase); … … 123 123 imp->overflow = 0; 124 124 125 if (!_needsMarking) { 126 imp->valueRefCount = 1; 127 } 125 128 #if DUMP_STATISTICS 126 129 if (++numLists > numListsHighWaterMark) … … 130 133 } 131 134 132 inline void List::derefValues() 135 List::List(bool needsMarking) : _impBase(allocateListImp()), _needsMarking(needsMarking) 136 { 137 ListImp *imp = static_cast<ListImp *>(_impBase); 138 imp->size = 0; 139 imp->refCount = 1; 140 imp->capacity = 0; 141 imp->overflow = 0; 142 143 if (!_needsMarking) { 144 imp->valueRefCount = 1; 145 } 146 147 #if DUMP_STATISTICS 148 if (++numLists > numListsHighWaterMark) 149 numListsHighWaterMark = numLists; 150 imp->sizeHighWaterMark = 0; 151 #endif 152 } 153 154 void List::derefValues() 133 155 { 134 156 ListImp *imp = static_cast<ListImp *>(_impBase); … … 144 166 for (int i = 0; i != overflowSize; ++i) 145 167 overflow[i]->deref(); 168 } 169 170 void List::refValues() 171 { 172 ListImp *imp = static_cast<ListImp *>(_impBase); 173 174 int size = imp->size; 175 176 int inlineSize = MIN(size, inlineValuesSize); 177 for (int i = 0; i != inlineSize; ++i) 178 imp->values[i]->ref(); 179 180 int overflowSize = size - inlineSize; 181 ValueImp **overflow = imp->overflow; 182 for (int i = 0; i != overflowSize; ++i) 183 overflow[i]->ref(); 184 } 185 186 void List::markValues() 187 { 188 ListImp *imp = static_cast<ListImp *>(_impBase); 189 190 int size = imp->size; 191 192 int inlineSize = MIN(size, inlineValuesSize); 193 for (int i = 0; i != inlineSize; ++i) { 194 if (!imp->values[i]->marked()) { 195 imp->values[i]->mark(); 196 } 197 } 198 199 int overflowSize = size - inlineSize; 200 ValueImp **overflow = imp->overflow; 201 for (int i = 0; i != overflowSize; ++i) { 202 if (!overflow[i]->marked()) { 203 overflow[i]->mark(); 204 } 205 } 146 206 } 147 207 … … 158 218 #endif 159 219 160 derefValues();161 220 delete [] imp->overflow; 162 221 deallocateListImp(imp); … … 175 234 void List::clear() 176 235 { 177 derefValues(); 236 if (_impBase->valueRefCount > 0) { 237 derefValues(); 238 } 178 239 _impBase->size = 0; 179 240 } … … 190 251 #endif 191 252 192 v->ref(); 253 if (imp->valueRefCount > 0) { 254 v->ref(); 255 } 193 256 194 257 if (i < inlineValuesSize) { … … 212 275 } 213 276 214 List List::copy Tail() const277 List List::copy() const 215 278 { 216 279 List copy; … … 232 295 } 233 296 297 298 List List::copyTail() const 299 { 300 List copy; 301 302 ListImp *imp = static_cast<ListImp *>(_impBase); 303 304 int size = imp->size; 305 306 int inlineSize = MIN(size, inlineValuesSize); 307 for (int i = 1; i != inlineSize; ++i) 308 copy.append(imp->values[i]); 309 310 ValueImp **overflow = imp->overflow; 311 int overflowSize = size - inlineSize; 312 for (int i = 0; i != overflowSize; ++i) 313 copy.append(overflow[i]); 314 315 return copy; 316 } 317 234 318 const List &List::empty() 235 319 { -
trunk/JavaScriptCore/kjs/list.h
r2843 r2883 31 31 int size; 32 32 int refCount; 33 int valueRefCount; 33 34 }; 34 35 … … 48 49 public: 49 50 List(); 51 List(bool needsMarking); 50 52 ~List() { deref(); } 51 53 52 List(const List &b) : _impBase(b._impBase) { ++_impBase->refCount; } 54 List(const List &b) : _impBase(b._impBase), _needsMarking(false) { 55 ++_impBase->refCount; 56 if (!_impBase->valueRefCount) refValues(); 57 ++_impBase->valueRefCount; 58 } 53 59 List &operator=(const List &); 54 60 … … 64 70 */ 65 71 void clear(); 72 73 /** 74 * Make a copy of the list 75 */ 76 List copy() const; 77 66 78 /** 67 79 * Make a copy of the list, omitting the first element. … … 108 120 static const List &empty(); 109 121 122 void mark() { if (_impBase->valueRefCount == 0) markValues(); } 110 123 private: 111 124 ListImpBase *_impBase; 112 113 void deref() { if (--_impBase->refCount == 0) release(); } 125 bool _needsMarking; 126 127 void deref() { if (!_needsMarking && --_impBase->valueRefCount == 0) derefValues(); if (--_impBase->refCount == 0) release(); } 114 128 115 129 void release(); 130 void refValues(); 116 131 void derefValues(); 132 void markValues(); 117 133 }; 118 134 … … 177 193 deref(); 178 194 _impBase = bImpBase; 195 if (!_needsMarking) { 196 if (!_impBase->valueRefCount) { 197 refValues(); 198 } 199 _impBase->valueRefCount++; 200 } 201 179 202 return *this; 180 203 } -
trunk/JavaScriptCore/kjs/value.cpp
r2845 r2883 204 204 #if DEBUG_COLLECTOR 205 205 assert (!(rep && !SimpleNumber::is(rep) && *((uint32_t *)rep) == 0 )); 206 assert (!(rep && !SimpleNumber::is(rep) && rep->_flags & V I_MARKED));206 assert (!(rep && !SimpleNumber::is(rep) && rep->_flags & ValueImp::VI_MARKED)); 207 207 #endif 208 208 if (v) … … 219 219 #if DEBUG_COLLECTOR 220 220 assert (!(rep && !SimpleNumber::is(rep) && *((uint32_t *)rep) == 0 )); 221 assert (!(rep && !SimpleNumber::is(rep) && rep->_flags & V I_MARKED));221 assert (!(rep && !SimpleNumber::is(rep) && rep->_flags & ValueImp::VI_MARKED)); 222 222 #endif 223 223 if (rep)
Note:
See TracChangeset
for help on using the changeset viewer.