Ignore:
Timestamp:
Apr 22, 2007, 9:16:42 PM (18 years ago)
Author:
mjs
Message:

Reviewed by Darin.


Based an idea by Christopher E. Hyde <[email protected]>. His patch to do
this also had many other List changes and I found this much simpler subset of the changes
was actually a hair faster.


This optimization is valid because the arguments list is only kept around to
lazily make the arguments object. If it's not made by the time the function
exits, it never will be, since any function that captures the continuation will
have its own local arguments variable in scope.


Besides the 1.7% speed improvement, it shrinks List by 4 bytes
(which in turn shrinks ActivationImp by 4 bytes).


  • kjs/Context.cpp: (KJS::Context::~Context): Clear the activation's arguments list.
  • kjs/function.cpp: (KJS::ActivationImp::ActivationImp): Adjusted for list changes. (KJS::ActivationImp::mark): No need to mark, lists are always protected (this doesn't cause a ref-cycle for reasons stated above). (KJS::ActivationImp::createArgumentsObject): Clear arguments list.
  • kjs/function.h:
  • kjs/list.cpp: (KJS::List::List): No more needsMarking boolean (KJS::List::operator=): ditto
  • kjs/list.h: (KJS::List::List): ditto (KJS::List::reset): ditto (KJS::List::deref): ditto
File:
1 edited

Legend:

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

    r20310 r21019  
    510510// ECMA 10.1.6
    511511ActivationImp::ActivationImp(FunctionImp* function, const List& arguments)
    512     : _function(function), _arguments(true), _argumentsObject(0)
    513 {
    514   _arguments.copyFrom(arguments);
     512    : _function(function), _arguments(arguments), _argumentsObject(0)
     513{
    515514  // FIXME: Do we need to support enumerating the arguments property?
    516515}
     
    571570    if (_function && !_function->marked())
    572571        _function->mark();
    573     _arguments.mark();
    574572    if (_argumentsObject && !_argumentsObject->marked())
    575573        _argumentsObject->mark();
     
    577575}
    578576
    579 void ActivationImp::createArgumentsObject(ExecState* exec) const
     577void ActivationImp::createArgumentsObject(ExecState* exec)
    580578{
    581579  _argumentsObject = new Arguments(exec, _function, _arguments, const_cast<ActivationImp*>(this));
     580  // The arguments list is only needed to create the arguments object, so discard it now
     581  _arguments.reset();
    582582}
    583583
Note: See TracChangeset for help on using the changeset viewer.