<!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" />
<title>[37714] trunk/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/37714">37714</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2008-10-20 00:29:28 -0700 (Mon, 20 Oct 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>2008-10-19  Darin Adler  &lt;darin@apple.com&gt;

        Reviewed by Cameron Zwarich.

        - finish https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        * VM/Machine.cpp:
        (JSC::Machine::cti_op_call_profiler): Use asFunction.
        (JSC::Machine::cti_vm_lazyLinkCall): Ditto.
        (JSC::Machine::cti_op_construct_JSConstructFast): Use asObject.

        * kjs/JSCell.h: Re-sort friend classes. Eliminate inheritance from
        JSValue. Changed cast in asCell from static_cast to reinterpret_cast.
        Removed JSValue::getNumber(double&amp;) and one of JSValue::getObject
        overloads.

        * kjs/JSValue.h: Made the private constructor and destructor both
        non-virtual and also remove the definitions. This class can never
        be instantiated or derived.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCoreVMMachinecpp">trunk/JavaScriptCore/VM/Machine.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsJSCellh">trunk/JavaScriptCore/kjs/JSCell.h</a></li>
<li><a href="#trunkJavaScriptCorekjsJSValueh">trunk/JavaScriptCore/kjs/JSValue.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (37713 => 37714)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2008-10-20 06:29:32 UTC (rev 37713)
+++ trunk/JavaScriptCore/ChangeLog        2008-10-20 07:29:28 UTC (rev 37714)
</span><span class="lines">@@ -2,6 +2,27 @@
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Cameron Zwarich.
</span><span class="cx"> 
</span><ins>+        - finish https://bugs.webkit.org/show_bug.cgi?id=21732
+          improve performance by eliminating JSValue as a base class for JSCell
+
+        * VM/Machine.cpp:
+        (JSC::Machine::cti_op_call_profiler): Use asFunction.
+        (JSC::Machine::cti_vm_lazyLinkCall): Ditto.
+        (JSC::Machine::cti_op_construct_JSConstructFast): Use asObject.
+
+        * kjs/JSCell.h: Re-sort friend classes. Eliminate inheritance from
+        JSValue. Changed cast in asCell from static_cast to reinterpret_cast.
+        Removed JSValue::getNumber(double&amp;) and one of JSValue::getObject
+        overloads.
+
+        * kjs/JSValue.h: Made the private constructor and destructor both
+        non-virtual and also remove the definitions. This class can never
+        be instantiated or derived.
+
+2008-10-19  Darin Adler  &lt;darin@apple.com&gt;
+
+        Reviewed by Cameron Zwarich.
+
</ins><span class="cx">         - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
</span><span class="cx">           improve performance by eliminating JSValue as a base class for JSCell
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJavaScriptCoreVMMachinecpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/VM/Machine.cpp (37713 => 37714)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/VM/Machine.cpp        2008-10-20 06:29:32 UTC (rev 37713)
+++ trunk/JavaScriptCore/VM/Machine.cpp        2008-10-20 07:29:28 UTC (rev 37714)
</span><span class="lines">@@ -4616,7 +4616,7 @@
</span><span class="cx">     CTI_STACK_HACK();
</span><span class="cx"> 
</span><span class="cx">     ASSERT(*ARG_profilerReference);
</span><del>-    (*ARG_profilerReference)-&gt;willExecute(ARG_callFrame, static_cast&lt;JSFunction*&gt;(ARG_src1));
</del><ins>+    (*ARG_profilerReference)-&gt;willExecute(ARG_callFrame, asFunction(ARG_src1));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> VoidPtrPair Machine::cti_op_call_JSFunction(CTI_ARGS)
</span><span class="lines">@@ -4676,7 +4676,7 @@
</span><span class="cx">     CallFrame* callerCallFrame = callFrame-&gt;callerFrame();
</span><span class="cx">     CodeBlock* callerCodeBlock = callerCallFrame-&gt;codeBlock();
</span><span class="cx"> 
</span><del>-    JSFunction* callee = static_cast&lt;JSFunction*&gt;(ARG_src1);
</del><ins>+    JSFunction* callee = asFunction(ARG_src1);
</ins><span class="cx">     CodeBlock* codeBlock = &amp;callee-&gt;m_body-&gt;byteCode(callee-&gt;m_scopeChain.node());
</span><span class="cx">     if (!codeBlock-&gt;ctiCode)
</span><span class="cx">         CTI::compile(machine, callFrame, codeBlock);
</span><span class="lines">@@ -4841,14 +4841,14 @@
</span><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     ConstructData constructData;
</span><del>-    ASSERT(static_cast&lt;JSFunction*&gt;(ARG_src1)-&gt;getConstructData(constructData) == ConstructTypeJS);
</del><ins>+    ASSERT(asFunction(ARG_src1)-&gt;getConstructData(constructData) == ConstructTypeJS);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     StructureID* structure;
</span><span class="cx">     if (ARG_src2-&gt;isObject())
</span><del>-        structure = static_cast&lt;JSObject*&gt;(ARG_src2)-&gt;inheritorID();
</del><ins>+        structure = asObject(ARG_src2)-&gt;inheritorID();
</ins><span class="cx">     else
</span><del>-        structure = static_cast&lt;JSFunction*&gt;(ARG_src1)-&gt;m_scopeChain.node()-&gt;globalObject()-&gt;emptyObjectStructure();
</del><ins>+        structure = asFunction(ARG_src1)-&gt;m_scopeChain.node()-&gt;globalObject()-&gt;emptyObjectStructure();
</ins><span class="cx">     return new (ARG_globalData) JSObject(structure);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsJSCellh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/JSCell.h (37713 => 37714)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/JSCell.h        2008-10-20 06:29:32 UTC (rev 37713)
+++ trunk/JavaScriptCore/kjs/JSCell.h        2008-10-20 07:29:28 UTC (rev 37714)
</span><span class="lines">@@ -29,16 +29,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-    class JSCell : public JSValue {
-        friend class Heap;
</del><ins>+    class JSCell : Noncopyable {
+        friend class CTI;
</ins><span class="cx">         friend class GetterSetter;
</span><ins>+        friend class Heap;
+        friend class JSNumberCell;
</ins><span class="cx">         friend class JSObject;
</span><span class="cx">         friend class JSPropertyNameIterator;
</span><del>-        friend class JSValue;
-        friend class JSNumberCell;
</del><span class="cx">         friend class JSString;
</span><ins>+        friend class JSValue;
</ins><span class="cx">         friend class Machine;
</span><del>-        friend class CTI;
</del><ins>+
</ins><span class="cx">     private:
</span><span class="cx">         explicit JSCell(StructureID*);
</span><span class="cx">         virtual ~JSCell();
</span><span class="lines">@@ -110,7 +111,7 @@
</span><span class="cx">     inline JSCell* asCell(JSValuePtr value)
</span><span class="cx">     {
</span><span class="cx">         ASSERT(!JSImmediate::isImmediate(value));
</span><del>-        return static_cast&lt;JSCell*&gt;(value.payload());
</del><ins>+        return reinterpret_cast&lt;JSCell*&gt;(value.payload());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     inline JSCell::JSCell(StructureID* structureID)
</span><span class="lines">@@ -196,15 +197,6 @@
</span><span class="cx">         return !JSImmediate::isImmediate(asValue()) &amp;&amp; asCell()-&gt;isObject();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    inline bool JSValue::getNumber(double&amp; v) const
-    {
-        if (JSImmediate::isImmediate(asValue())) {
-            v = JSImmediate::toDouble(asValue());
-            return true;
-        }
-        return asCell()-&gt;getNumber(v);
-    }
-
</del><span class="cx">     inline double JSValue::getNumber() const
</span><span class="cx">     {
</span><span class="cx">         return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : asCell()-&gt;getNumber();
</span><span class="lines">@@ -220,16 +212,11 @@
</span><span class="cx">         return JSImmediate::isImmediate(asValue()) ? UString() : asCell()-&gt;getString();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    inline JSObject* JSValue::getObject()
</del><ins>+    inline JSObject* JSValue::getObject() const
</ins><span class="cx">     {
</span><span class="cx">         return JSImmediate::isImmediate(asValue()) ? 0 : asCell()-&gt;getObject();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    inline const JSObject* JSValue::getObject() const
-    {
-        return JSImmediate::isImmediate(asValue()) ? 0 : asCell()-&gt;getObject();
-    }
-
</del><span class="cx">     inline CallType JSValue::getCallData(CallData&amp; callData)
</span><span class="cx">     {
</span><span class="cx">         return JSImmediate::isImmediate(asValue()) ? CallTypeNone : asCell()-&gt;getCallData(callData);
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsJSValueh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/JSValue.h (37713 => 37714)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/JSValue.h        2008-10-20 06:29:32 UTC (rev 37713)
+++ trunk/JavaScriptCore/kjs/JSValue.h        2008-10-20 07:29:28 UTC (rev 37714)
</span><span class="lines">@@ -35,33 +35,20 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-    class ExecState;
</del><span class="cx">     class Identifier;
</span><del>-    class JSCell;
-    class JSObject;
</del><span class="cx">     class JSString;
</span><span class="cx">     class PropertySlot;
</span><span class="cx">     class PutPropertySlot;
</span><del>-    class StructureID;
</del><span class="cx"> 
</span><span class="cx">     struct ClassInfo;
</span><span class="cx">     struct Instruction;
</span><span class="cx"> 
</span><span class="cx">     enum PreferredPrimitiveType { NoPreference, PreferNumber, PreferString };
</span><span class="cx"> 
</span><del>-    /**
-     * JSValue is the base type for all primitives (Undefined, Null, Boolean,
-     * String, Number) and objects in ECMAScript.
-     *
-     * Note: you should never inherit from JSValue as it is for primitive types
-     * only (all of which are provided internally by KJS). Instead, inherit from
-     * JSObject.
-     */
</del><span class="cx">     class JSValue : Noncopyable {
</span><del>-        friend class JSCell; // so it can derive from this class
</del><span class="cx">     private:
</span><span class="cx">         JSValue();
</span><del>-        virtual ~JSValue();
</del><ins>+        ~JSValue();
</ins><span class="cx"> 
</span><span class="cx">     public:
</span><span class="cx">         // Querying the type.
</span><span class="lines">@@ -73,18 +60,16 @@
</span><span class="cx">         bool isString() const;
</span><span class="cx">         bool isGetterSetter() const;
</span><span class="cx">         bool isObject() const;
</span><del>-        bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
</del><ins>+        bool isObject(const ClassInfo*) const;
</ins><span class="cx">         
</span><span class="cx">         // Extracting the value.
</span><span class="cx">         bool getBoolean(bool&amp;) const;
</span><span class="cx">         bool getBoolean() const; // false if not a boolean
</span><del>-        bool getNumber(double&amp;) const;
</del><span class="cx">         double getNumber() const; // NaN if not a number
</span><span class="cx">         double uncheckedGetNumber() const;
</span><span class="cx">         bool getString(UString&amp;) const;
</span><span class="cx">         UString getString() const; // null string if not a string
</span><del>-        JSObject* getObject(); // NULL if not an object
-        const JSObject* getObject() const; // NULL if not an object
</del><ins>+        JSObject* getObject() const; // 0 if not an object
</ins><span class="cx"> 
</span><span class="cx">         CallType getCallData(CallData&amp;);
</span><span class="cx">         ConstructType getConstructData(ConstructData&amp;);
</span><span class="lines">@@ -104,6 +89,7 @@
</span><span class="cx">         // been set in the ExecState already.
</span><span class="cx">         double toNumber(ExecState*) const;
</span><span class="cx">         JSValuePtr toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number.
</span><ins>+
</ins><span class="cx">         UString toString(ExecState*) const;
</span><span class="cx">         JSObject* toObject(ExecState*) const;
</span><span class="cx"> 
</span><span class="lines">@@ -159,14 +145,6 @@
</span><span class="cx">     int32_t toInt32SlowCase(double, bool&amp; ok);
</span><span class="cx">     uint32_t toUInt32SlowCase(double, bool&amp; ok);
</span><span class="cx"> 
</span><del>-    inline JSValue::JSValue()
-    {
-    }
-
-    inline JSValue::~JSValue()
-    {
-    }
-
</del><span class="cx">     inline JSValuePtr JSValue::asValue() const
</span><span class="cx">     {
</span><span class="cx">         return const_cast&lt;JSValue*&gt;(this);
</span></span></pre>
</div>
</div>

</body>
</html>