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


Ignore:
Timestamp:
Jan 11, 2008, 6:08:50 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

Reviewed by Maciej.

Optimized ActivationImp allocation, so that activation records are now
first allocated on an explicitly managed stack and only heap allocated
when necessary. Roughly a 5% improvement on SunSpider, and a larger
improvement on benchmarks that use more function calls.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/Activation.h: Added. (KJS::ActivationImp::ActivationData::ActivationData): (KJS::ActivationImp::ActivationImp): (KJS::ActivationImp::classInfo): (KJS::ActivationImp::isActivationObject): (KJS::ActivationImp::isOnStack): (KJS::ActivationImp::d): (KJS::StackActivation::StackActivation):
  • kjs/ExecState.cpp: (KJS::ExecState::ExecState): (KJS::ExecState::~ExecState):
  • kjs/ExecState.h: (KJS::ExecState::replaceScopeChainTop): (KJS::ExecState::setActivationObject): (KJS::ExecState::setLocalStorage):
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::reset): (KJS::JSGlobalObject::pushActivation): (KJS::JSGlobalObject::checkActivationCount): (KJS::JSGlobalObject::popActivationHelper): (KJS::JSGlobalObject::popActivation): (KJS::JSGlobalObject::tearOffActivation):
  • kjs/JSGlobalObject.h:
  • kjs/JSVariableObject.h: (KJS::JSVariableObject::JSVariableObjectData::JSVariableObjectData): (KJS::JSVariableObject::JSVariableObject):
  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): (KJS::ActivationImp::ActivationImp): (KJS::ActivationImp::~ActivationImp): (KJS::ActivationImp::init): (KJS::ActivationImp::getOwnPropertySlot): (KJS::ActivationImp::markHelper): (KJS::ActivationImp::mark): (KJS::ActivationImp::ActivationData::ActivationData): (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function.h:
  • kjs/nodes.cpp: (KJS::PostIncResolveNode::evaluate): (KJS::PostDecResolveNode::evaluate): (KJS::PreIncResolveNode::evaluate): (KJS::PreDecResolveNode::evaluate): (KJS::ReadModifyResolveNode::evaluate): (KJS::AssignResolveNode::evaluate): (KJS::WithNode::execute): (KJS::TryNode::execute): (KJS::FunctionBodyNode::processDeclarations): (KJS::FuncExprNode::evaluate):
  • kjs/object.h:
  • kjs/scope_chain.h: (KJS::ScopeChain::replace):
  • kjs/scope_chain_mark.h: Added. (KJS::ScopeChain::mark):

WebCore:

Reviewed by Maciej.

Added a new forwarding header, because Activation.h has been separated
from function.h

  • ForwardingHeaders/kjs/Activation.h: Added.

LayoutTests:

Reviewed by Maciej.

Added a test case that came up when developing the ActivationImp tear-off.

  • fast/js/resources/vardecl-preserve-arguments.js:
  • fast/js/vardecl-preserve-arguments-expected.txt:
File:
1 edited

Legend:

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

    r28907 r29425  
    3737  class FunctionBodyNode;
    3838  class FunctionPrototype;
     39  class JSGlobalObject;
    3940
    4041  class InternalFunctionImp : public JSObject {
     
    138139  };
    139140
    140   class ActivationImp : public JSVariableObject {
    141   private:
    142     using JSVariableObject::JSVariableObjectData;
    143 
    144     struct ActivationImpData : public JSVariableObjectData {
    145         ActivationImpData(ExecState* e)
    146             : JSVariableObjectData(&e->function()->body->symbolTable())
    147             , exec(e)
    148             , function(e->function()) // Store this pointer for marking, to keep our symbol table / scope alive after exec has gone out of scope.
    149             , argumentsObject(0)
    150         {
    151         }
    152 
    153         ExecState* exec;
    154         FunctionImp* function;
    155         Arguments* argumentsObject;
    156     };
    157 
    158   public:
    159     ActivationImp(ExecState* exec)
    160         : JSVariableObject(new ActivationImpData(exec))
    161     {
    162     }
    163 
    164     virtual ~ActivationImp()
    165     {
    166         delete d();
    167     }
    168 
    169     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    170     virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None);
    171     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    172 
    173     virtual const ClassInfo* classInfo() const { return &info; }
    174     static const ClassInfo info;
    175 
    176     virtual void mark();
    177 
    178     virtual bool isActivationObject() { return true; }
    179 
    180   private:
    181     static PropertySlot::GetValueFunc getArgumentsGetter();
    182     static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
    183     void createArgumentsObject(ExecState*);
    184     ActivationImpData* d() { return static_cast<ActivationImpData*>(JSVariableObject::d); }
    185   };
    186 
    187141  class GlobalFuncImp : public InternalFunctionImp {
    188142  public:
Note: See TracChangeset for help on using the changeset viewer.