Reviewed by Oliver Hunt.
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2007 08:36:58 +0000 (08:36 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2007 08:36:58 +0000 (08:36 +0000)
        Removed List from ActivationImp, in preparation for making all lists
        stack-allocated.

        Tests pass.

        1.0% speedup on SunSpider, presumably due to reduced List refcount thrash.

        * kjs/ExecState.cpp:
        (KJS::ExecState::ExecState):
        (KJS::ExecState::~ExecState):
        * kjs/function.cpp:
        (KJS::ActivationImp::ActivationImp):
        (KJS::ActivationImp::createArgumentsObject):
        * kjs/function.h:
        (KJS::ActivationImp::ActivationImpPrivate::ActivationImpPrivate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27344 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/ExecState.cpp
JavaScriptCore/kjs/function.cpp
JavaScriptCore/kjs/function.h

index 6b79a957dc0547706b9ae0967d2e25ea5f5d483c..6db773c3c87581a8dcf9678ada4c9c258110ef3a 100644 (file)
@@ -1,3 +1,23 @@
+2007-11-01  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Oliver Hunt.
+        
+        Removed List from ActivationImp, in preparation for making all lists
+        stack-allocated.
+        
+        Tests pass.
+        
+        1.0% speedup on SunSpider, presumably due to reduced List refcount thrash.
+
+        * kjs/ExecState.cpp:
+        (KJS::ExecState::ExecState):
+        (KJS::ExecState::~ExecState):
+        * kjs/function.cpp:
+        (KJS::ActivationImp::ActivationImp):
+        (KJS::ActivationImp::createArgumentsObject):
+        * kjs/function.h:
+        (KJS::ActivationImp::ActivationImpPrivate::ActivationImpPrivate):
+
 2007-11-01  Adam Roben  <aroben@apple.com>
 
         Use jsNumberCell instead of jsNumber when converting double constants to JSValues
index 15e01cca24a5c575e3756e881eef06a8aa94f843..9bfd6ec1dbcceff6411db6d2ae85eec67a392b8b 100644 (file)
@@ -51,7 +51,7 @@ ExecState::ExecState(Interpreter* interpreter, JSGlobalObject* glob, JSObject* t
     
     // create and initialize activation object (ECMA 10.1.6)
     if (type == FunctionCode) {
-        m_activation = new ActivationImp(func, *args);
+        m_activation = new ActivationImp(this);
         m_variable = m_activation;
     } else {
         m_activation = 0;
@@ -87,14 +87,6 @@ ExecState::ExecState(Interpreter* interpreter, JSGlobalObject* glob, JSObject* t
 ExecState::~ExecState()
 {
     m_interpreter->setCurrentExec(m_savedExecState);
-
-    // The arguments list is only needed to potentially create the  arguments object, 
-    // which isn't accessible from nested scopes so we can discard the list as soon 
-    // as the function is done running.
-    // This prevents lists of Lists from building up, waiting to be garbage collected
-    ActivationImp* activation = static_cast<ActivationImp*>(m_activation);
-    if (activation)
-        activation->releaseArguments();
 }
 
 void ExecState::mark()
index e389ab06f01c3335cac5b82978c08af3827ca8ca..b35f63300d5e8c0175351991dad2b14e414e592c 100644 (file)
@@ -392,9 +392,9 @@ bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
 
 const ClassInfo ActivationImp::info = {"Activation", 0, 0, 0};
 
-ActivationImp::ActivationImp(FunctionImp* function, const List& arguments)
-    : d(new ActivationImpPrivate(function, arguments))
-    , m_symbolTable(&function->body->symbolTable())
+ActivationImp::ActivationImp(ExecState* exec)
+    : d(new ActivationImpPrivate(exec))
+    , m_symbolTable(&exec->function()->body->symbolTable())
 {
 }
 
@@ -478,9 +478,6 @@ void ActivationImp::mark()
 {
     JSObject::mark();
 
-    if (!d->function->marked())
-        d->function->mark();
-
     size_t size = d->localStorage.size();
     for (size_t i = 0; i < size; ++i) {
         JSValue* value = d->localStorage[i].value;
@@ -494,11 +491,7 @@ void ActivationImp::mark()
 
 void ActivationImp::createArgumentsObject(ExecState* exec)
 {
-  d->argumentsObject = new Arguments(exec, d->function, d->arguments, this);
-
-  // The arguments list is only needed to create the arguments object, so discard it now.
-  // This prevents lists of Lists from building up, waiting to be garbage collected.
-  d->arguments.reset();
+    d->argumentsObject = new Arguments(exec, d->exec->function(), *d->exec->arguments(), this);
 }
 
 // ------------------------------ GlobalFunc -----------------------------------
index 06fb52080ef30f96f43373cc0b5126d5a8686406..8284f3a751d667128697eb3285f44f71efdf67bb 100644 (file)
@@ -140,23 +140,19 @@ namespace KJS {
   class ActivationImp : public JSObject {
   private:
     struct ActivationImpPrivate {
-        ActivationImpPrivate(FunctionImp* f, const List& a)
-            : function(f)
-            , arguments(a)
+        ActivationImpPrivate(ExecState* e)
+            : exec(e)
             , argumentsObject(0)
         {
-            ASSERT(f);
         }
         
-        FunctionImp* function;
         LocalStorage localStorage;
-
-        List arguments;
+        ExecState* exec;
         Arguments* argumentsObject;
     };
 
   public:
-    ActivationImp(FunctionImp* function, const List& arguments);
+    ActivationImp(ExecState*);
 
     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None);
@@ -169,8 +165,6 @@ namespace KJS {
 
     bool isActivation() { return true; }
 
-    void releaseArguments() { d->arguments.reset(); }
-    
     LocalStorage& localStorage() { return d->localStorage; }
     SymbolTable& symbolTable() { return *m_symbolTable; }