Changeset 27126 in webkit for trunk/JavaScriptCore/kjs/function.h


Ignore:
Timestamp:
Oct 26, 2007, 3:43:03 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Maciej Stachowiak.


Switched ActivationImp to using a symbol table. For now, though, all
clients take the slow path.


Net .6% speedup on SunSpider.


Slowdowns:

  • ActivationImp now mallocs in its constructor
  • Local variable hits use an extra level of indirection to retrieve data
  • Local variable misses do two lookups

Speedups:

  • Fast initialization of local variables upon function entry


  • kjs/function.cpp: (KJS::ActivationImp::ActivationImp): Malloc a private structure to hold data that won't fit in a JSCell. (KJS::ActivationImp::argumentsGetter): Use slow symbol table path for lookup. (KJS::ActivationImp::getOwnPropertySlot): ditto (KJS::ActivationImp::deleteProperty): ditto (KJS::ActivationImp::put): ditto (KJS::ActivationImp::createArgumentsObject): ditto

(KJS::ActivationImp::mark): Call JSObject::mark first so that one of
our properties doesn't try to recursively mark us. (This caused a crash
in earlier testing. Not sure why we haven't run into it before.)

  • kjs/nodes.cpp: Functions now build a symbol table the first time they're called. (KJS::VarDeclNode::evaluate): (KJS::FunctionBodyNode::FunctionBodyNode): (KJS::FunctionBodyNode::initializeSymbolTable): (KJS::FunctionBodyNode::processDeclarations): (KJS::FunctionBodyNode::processDeclarationsForFunctionCode): (KJS::FunctionBodyNode::processDeclarationsForProgramCode):
  • kjs/nodes.h: (KJS::FunctionBodyNode::symbolTable):
  • wtf/Forward.h: Added Vector.
File:
1 edited

Legend:

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

    r27097 r27126  
    2525#define KJS_FUNCTION_H
    2626
     27#include "SymbolTable.h"
    2728#include "object.h"
    2829#include <wtf/OwnPtr.h>
     
    138139  class ActivationImp : public JSObject {
    139140  public:
    140     ActivationImp(FunctionImp* function, const List& arguments);
     141    struct LocalStorageEntry {
     142        LocalStorageEntry()
     143        {
     144        }
     145
     146        LocalStorageEntry(JSValue* v, int a)
     147            : value(v)
     148            , attributes(a)
     149        {
     150        }
     151
     152        JSValue* value;
     153        int attributes;
     154    };
     155
     156    typedef Vector<LocalStorageEntry, 32> LocalStorage;
     157
     158  private:
     159    struct ActivationImpPrivate {
     160        ActivationImpPrivate(FunctionImp* f, const List& a)
     161            : function(f)
     162            , arguments(a)
     163            , argumentsObject(0)
     164        {
     165            ASSERT(f);
     166        }
     167       
     168        FunctionImp* function;
     169        LocalStorage localStorage;
     170
     171        List arguments;
     172        Arguments* argumentsObject;
     173    };
     174
     175  public:
     176    ActivationImp::ActivationImp(FunctionImp* function, const List& arguments);
    141177
    142178    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     
    151187    bool isActivation() { return true; }
    152188
    153     void releaseArguments() { _arguments.reset(); }
     189    void releaseArguments() { d->arguments.reset(); }
     190   
     191    LocalStorage& localStorage() { return d->localStorage; };
    154192
    155193  private:
     
    157195    static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
    158196    void createArgumentsObject(ExecState*);
    159 
    160     FunctionImp* _function;
    161     List _arguments;
    162     mutable Arguments* _argumentsObject;
     197   
     198    OwnPtr<ActivationImpPrivate> d;
     199    SymbolTable* symbolTable;
    163200  };
    164201
Note: See TracChangeset for help on using the changeset viewer.