Changeset 27126 in webkit for trunk/JavaScriptCore/kjs/function.cpp
- Timestamp:
- Oct 26, 2007, 3:43:03 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r27100 r27126 391 391 const ClassInfo ActivationImp::info = {"Activation", 0, 0, 0}; 392 392 393 // ECMA 10.1.6394 393 ActivationImp::ActivationImp(FunctionImp* function, const List& arguments) 395 : _function(function), _arguments(arguments), _argumentsObject(0)396 { 397 // FIXME: Do we need to support enumerating the arguments property? 394 : d(new ActivationImpPrivate(function, arguments)) 395 , symbolTable(&function->body->symbolTable()) 396 { 398 397 } 399 398 … … 401 400 { 402 401 ActivationImp* thisObj = static_cast<ActivationImp*>(slot.slotBase()); 403 404 // default: return builtin arguments array405 if (! thisObj->_argumentsObject)402 ActivationImpPrivate* d = thisObj->d.get(); 403 404 if (!d->argumentsObject) 406 405 thisObj->createArgumentsObject(exec); 407 406 408 return thisObj->_argumentsObject;407 return d->argumentsObject; 409 408 } 410 409 … … 416 415 bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 417 416 { 418 // do this first so property map arguments property wins over the below 419 // we don't call JSObject because we won't have getter/setter properties 420 // and we don't want to support __proto__ 417 // We don't call through to JSObject because there's no way to give an 418 // acitvation object getter/setter properties, and exposing __proto__ in 419 // the scope chain would be bizarre. 420 ASSERT(!_prop.hasGetterSetterProperties()); 421 422 size_t index; 423 if (symbolTable->get(propertyName, index)) { 424 slot.setValueSlot(this, &d->localStorage[index].value); 425 return true; 426 } 421 427 422 428 if (JSValue** location = getDirectLocation(propertyName)) { … … 425 431 } 426 432 433 // Only return the built-in arguments object if it wasn't overridden above. 427 434 if (propertyName == exec->propertyNames().arguments) { 428 435 slot.setCustom(this, getArgumentsGetter()); … … 437 444 if (propertyName == exec->propertyNames().arguments) 438 445 return false; 446 447 size_t index; 448 if (symbolTable->get(propertyName, index)) 449 return false; 450 439 451 return JSObject::deleteProperty(exec, propertyName); 440 452 } … … 442 454 void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr) 443 455 { 444 // There's no way that an activation object can have a prototype or getter/setter properties 456 // There's no way that an activation object can have a prototype or getter/setter properties. 445 457 ASSERT(!_prop.hasGetterSetterProperties()); 446 458 ASSERT(prototype() == jsNull()); 447 459 460 size_t index; 461 if (symbolTable->get(propertyName, index)) { 462 LocalStorageEntry& entry = d->localStorage[index]; 463 entry.value = value; 464 entry.attributes = attr; 465 return; 466 } 467 448 468 _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete)); 449 469 } … … 451 471 void ActivationImp::mark() 452 472 { 453 if (_function && !_function->marked())454 _function->mark();455 if (_argumentsObject && !_argumentsObject->marked())456 _argumentsObject->mark();457 473 JSObject::mark(); 474 475 if (!d->function->marked()) 476 d->function->mark(); 477 478 size_t size = d->localStorage.size(); 479 for (size_t i = 0; i < size; ++i) { 480 JSValue* value = d->localStorage[i].value; 481 if (!value->marked()) 482 value->mark(); 483 } 484 485 if (d->argumentsObject && !d->argumentsObject->marked()) 486 d->argumentsObject->mark(); 458 487 } 459 488 460 489 void ActivationImp::createArgumentsObject(ExecState* exec) 461 490 { 462 _argumentsObject = new Arguments(exec, _function, _arguments, const_cast<ActivationImp*>(this)); 463 // The arguments list is only needed to create the arguments object, so discard it now 464 _arguments.reset(); 491 d->argumentsObject = new Arguments(exec, d->function, d->arguments, this); 492 493 // The arguments list is only needed to create the arguments object, so discard it now. 494 // This prevents lists of Lists from building up, waiting to be garbage collected. 495 d->arguments.reset(); 465 496 } 466 497
Note:
See TracChangeset
for help on using the changeset viewer.