<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[27072] trunk/JavaScriptCore</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/27072">27072</a></dd>
<dt>Author</dt> <dd>ggaren</dd>
<dt>Date</dt> <dd>2007-10-25 15:29:55 -0700 (Thu, 25 Oct 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Oliver Hunt.
        
        Rolled out my last patch. It turns out that I needed 2 words, not 1,
        so it didn't help.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkJavaScriptCorekjsContextcpp">trunk/JavaScriptCore/kjs/Context.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsfunctioncpp">trunk/JavaScriptCore/kjs/function.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsfunctionh">trunk/JavaScriptCore/kjs/function.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (27071 => 27072)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2007-10-25 22:23:54 UTC (rev 27071)
+++ trunk/JavaScriptCore/ChangeLog        2007-10-25 22:29:55 UTC (rev 27072)
</span><span class="lines">@@ -2,6 +2,13 @@
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Oliver Hunt.
</span><span class="cx">         
</span><ins>+        Rolled out my last patch. It turns out that I needed 2 words, not 1,
+        so it didn't help.
+
+2007-10-25  Geoffrey Garen  &lt;ggaren@apple.com&gt;
+
+        Reviewed by Oliver Hunt.
+        
</ins><span class="cx">         Fixed http://bugs.webkit.org/show_bug.cgi?id=15694
</span><span class="cx">         Shrink the size of an activation object by 1 word
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (27071 => 27072)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2007-10-25 22:23:54 UTC (rev 27071)
+++ trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2007-10-25 22:29:55 UTC (rev 27072)
</span><span class="lines">@@ -1379,7 +1379,6 @@
</span><span class="cx">                 0867D690FE84028FC02AAC07 /* Project object */ = {
</span><span class="cx">                         isa = PBXProject;
</span><span class="cx">                         buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject &quot;JavaScriptCore&quot; */;
</span><del>-                        compatibilityVersion = &quot;Xcode 2.4&quot;;
</del><span class="cx">                         hasScannedForEncodings = 1;
</span><span class="cx">                         mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
</span><span class="cx">                         productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/Context.cpp (27071 => 27072)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/Context.cpp        2007-10-25 22:23:54 UTC (rev 27071)
+++ trunk/JavaScriptCore/kjs/Context.cpp        2007-10-25 22:29:55 UTC (rev 27072)
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">     // This prevents lists of Lists from building up, waiting to be garbage collected
</span><span class="cx">     ActivationImp* activation = static_cast&lt;ActivationImp*&gt;(m_activation);
</span><span class="cx">     if (activation)
</span><del>-        activation-&gt;resetArguments();
</del><ins>+        activation-&gt;releaseArguments();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Context::mark()
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsfunctioncpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/function.cpp (27071 => 27072)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/function.cpp        2007-10-25 22:23:54 UTC (rev 27071)
+++ trunk/JavaScriptCore/kjs/function.cpp        2007-10-25 22:29:55 UTC (rev 27072)
</span><span class="lines">@@ -390,34 +390,24 @@
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ ActivationImp --------------------------------
</span><span class="cx"> 
</span><del>-void ActivationImp::LazyArgumentsObject::createArgumentsObject(ExecState* exec, ActivationImp* activationImp)
-{
-    setArgumentsObject(new Arguments(exec, function(), arguments, activationImp));
</del><ins>+const ClassInfo ActivationImp::info = {&quot;Activation&quot;, 0, 0, 0};
</ins><span class="cx"> 
</span><del>-    // 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.
-    arguments.reset();
-}
-
-void ActivationImp::LazyArgumentsObject::mark()
</del><ins>+// ECMA 10.1.6
+ActivationImp::ActivationImp(FunctionImp* function, const List&amp; arguments)
+    : _function(function), _arguments(arguments), _argumentsObject(0)
</ins><span class="cx"> {
</span><del>-    JSObject* o;
-    if (createdArgumentsObject())
-        o = argumentsObject();
-    else
-        o = function();
-
-    if (!o-&gt;marked())
-        o-&gt;mark();
</del><ins>+  // FIXME: Do we need to support enumerating the arguments property?
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const ClassInfo ActivationImp::info = {&quot;Activation&quot;, 0, 0, 0};
-
</del><span class="cx"> JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&amp;, const PropertySlot&amp; slot)
</span><span class="cx"> {
</span><span class="cx">   ActivationImp* thisObj = static_cast&lt;ActivationImp*&gt;(slot.slotBase());
</span><del>-  return thisObj-&gt;m_lazyArgumentsObject.getOrCreate(exec, thisObj);
</del><ins>+
+  // default: return builtin arguments array
+  if (!thisObj-&gt;_argumentsObject)
+    thisObj-&gt;createArgumentsObject(exec);
+  
+  return thisObj-&gt;_argumentsObject;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PropertySlot::GetValueFunc ActivationImp::getArgumentsGetter()
</span><span class="lines">@@ -462,10 +452,20 @@
</span><span class="cx"> 
</span><span class="cx"> void ActivationImp::mark()
</span><span class="cx"> {
</span><del>-    m_lazyArgumentsObject.mark();
</del><ins>+    if (_function &amp;&amp; !_function-&gt;marked()) 
+        _function-&gt;mark();
+    if (_argumentsObject &amp;&amp; !_argumentsObject-&gt;marked())
+        _argumentsObject-&gt;mark();
</ins><span class="cx">     JSObject::mark();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ActivationImp::createArgumentsObject(ExecState* exec)
+{
+  _argumentsObject = new Arguments(exec, _function, _arguments, const_cast&lt;ActivationImp*&gt;(this));
+  // The arguments list is only needed to create the arguments object, so discard it now
+  _arguments.reset();
+}
+
</ins><span class="cx"> // ------------------------------ GlobalFunc -----------------------------------
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsfunctionh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/function.h (27071 => 27072)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/function.h        2007-10-25 22:23:54 UTC (rev 27071)
+++ trunk/JavaScriptCore/kjs/function.h        2007-10-25 22:29:55 UTC (rev 27072)
</span><span class="lines">@@ -143,65 +143,8 @@
</span><span class="cx"> 
</span><span class="cx">   class ActivationImp : public JSObject {
</span><span class="cx">   public:
</span><del>-    class LazyArgumentsObject {
-    public:
-        LazyArgumentsObject(FunctionImp* f, const List&amp; a)
-            : arguments(a)
-        {
-            ASSERT(f);
-            setFunction(f);
-        }
</del><ins>+    ActivationImp(FunctionImp* function, const List&amp; arguments);
</ins><span class="cx"> 
</span><del>-        Arguments* getOrCreate(ExecState* exec, ActivationImp* activationImp)
-        {
-            if (!createdArgumentsObject())
-                createArgumentsObject(exec, activationImp);
-            return argumentsObject();
-        }
-
-        void resetArguments() { arguments.reset(); }
-        void mark();
-
-    private:
-        static const uintptr_t TagMask = 1; // Pointer alignment leaves this bit open for tagging.
-        
-        void setArgumentsObject(Arguments* a)
-        { 
-            u.argumentsObject = a;
-            u.bits |= TagMask;
-        }
-
-        Arguments* argumentsObject()
-        {
-            ASSERT(createdArgumentsObject());
-            return reinterpret_cast&lt;Arguments*&gt;(u.bits &amp; ~TagMask);
-        }
-
-        void setFunction(FunctionImp* f) { u.function = f; }
-        FunctionImp* function()
-        {
-            ASSERT(!createdArgumentsObject());
-            return u.function;
-        }
-
-        bool createdArgumentsObject() { return (u.bits &amp; TagMask) != 0; }
-        void createArgumentsObject(ExecState*, ActivationImp*);
-
-        List arguments;
-        union {
-            // The low bit in this union is a flag: 0 means the union holds a 
-            // FunctionImp*; 1 means the union holds an Arguments*.
-            uintptr_t bits;
-            FunctionImp* function;
-            Arguments* argumentsObject;
-        } u;
-    };
-    
-    ActivationImp::ActivationImp(FunctionImp* function, const List&amp; arguments)
-        : m_lazyArgumentsObject(function, arguments)
-    {
-    }
-
</del><span class="cx">     virtual bool getOwnPropertySlot(ExecState*, const Identifier&amp;, PropertySlot&amp;);
</span><span class="cx">     virtual void put(ExecState*, const Identifier&amp; propertyName, JSValue* value, int attr = None);
</span><span class="cx">     virtual bool deleteProperty(ExecState*, const Identifier&amp; propertyName);
</span><span class="lines">@@ -213,13 +156,16 @@
</span><span class="cx"> 
</span><span class="cx">     bool isActivation() { return true; }
</span><span class="cx"> 
</span><del>-    void resetArguments() { m_lazyArgumentsObject.resetArguments(); }
</del><ins>+    void releaseArguments() { _arguments.reset(); }
</ins><span class="cx"> 
</span><span class="cx">   private:
</span><span class="cx">     static PropertySlot::GetValueFunc getArgumentsGetter();
</span><span class="cx">     static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&amp;, const PropertySlot&amp; slot);
</span><del>-    
-    LazyArgumentsObject m_lazyArgumentsObject;
</del><ins>+    void createArgumentsObject(ExecState*);
+
+    FunctionImp* _function;
+    List _arguments;
+    mutable Arguments* _argumentsObject;
</ins><span class="cx">   };
</span><span class="cx"> 
</span><span class="cx">   class GlobalFuncImp : public InternalFunctionImp {
</span></span></pre>
</div>
</div>

</body>
</html>