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

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/27086">27086</a></dd>
<dt>Author</dt> <dd>mjs</dd>
<dt>Date</dt> <dd>2007-10-25 20:58:18 -0700 (Thu, 25 Oct 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Oliver.

        - fold together toPrimitive() and toNumber() conversions for 0.5% gain on SunSpider

        * kjs/nodes.cpp:
        (KJS::SubNode::evaluate): Subtract directly, since toPrimitive() is not
        adding any value over toNumber() here.
        (KJS::valueForReadModifyAssignment): Ditto.
        (KJS::lessThan): Use new getPrimitiveNumber() method to avoid some virtual calls
        and branches.
        (KJS::lessThanEq): Ditto.
        * JavaScriptCore.exp: Export new functions as needed.
        * kjs/value.h:
        (KJS::JSValue::toPrimitive): Fixed formatting.
        (KJS::JSValue::getPrimitiveNumber): New method - this simultaneously converts
        to number and tells you whether a toPrimitive() conversion with a Number hint
        would have given a string.
        * kjs/internal.cpp:
        (KJS::StringImp::getPrimitiveNumber): Implemented. 
        (KJS::NumberImp::getPrimitiveNumber): ditto
        (KJS::GetterSetterImp::getPrimitiveNumber): ditto
        (KJS::StringImp::toPrimitive): Fixed formatting.
        (KJS::NumberImp::toPrimitive): ditto
        (KJS::GetterSetterImp::toPrimitive): ditto
        * kjs/internal.h:
        * kjs/object.cpp:
        (KJS::JSObject::getPrimitiveNumber): Implemented.
        * kjs/object.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCoreJavaScriptCoreexp">trunk/JavaScriptCore/JavaScriptCore.exp</a></li>
<li><a href="#trunkJavaScriptCorekjsinternalcpp">trunk/JavaScriptCore/kjs/internal.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsinternalh">trunk/JavaScriptCore/kjs/internal.h</a></li>
<li><a href="#trunkJavaScriptCorekjsnodescpp">trunk/JavaScriptCore/kjs/nodes.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsobjectcpp">trunk/JavaScriptCore/kjs/object.cpp</a></li>
<li><a href="#trunkJavaScriptCorekjsobjecth">trunk/JavaScriptCore/kjs/object.h</a></li>
<li><a href="#trunkJavaScriptCorekjsvalueh">trunk/JavaScriptCore/kjs/value.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/ChangeLog        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2007-10-25  Maciej Stachowiak  &lt;mjs@apple.com&gt;
+
+        Reviewed by Oliver.
+
+        - fold together toPrimitive() and toNumber() conversions for 0.5% gain on SunSpider
+
+        * kjs/nodes.cpp:
+        (KJS::SubNode::evaluate): Subtract directly, since toPrimitive() is not
+        adding any value over toNumber() here.
+        (KJS::valueForReadModifyAssignment): Ditto.
+        (KJS::lessThan): Use new getPrimitiveNumber() method to avoid some virtual calls
+        and branches.
+        (KJS::lessThanEq): Ditto.
+        * JavaScriptCore.exp: Export new functions as needed.
+        * kjs/value.h:
+        (KJS::JSValue::toPrimitive): Fixed formatting.
+        (KJS::JSValue::getPrimitiveNumber): New method - this simultaneously converts
+        to number and tells you whether a toPrimitive() conversion with a Number hint
+        would have given a string.
+        * kjs/internal.cpp:
+        (KJS::StringImp::getPrimitiveNumber): Implemented. 
+        (KJS::NumberImp::getPrimitiveNumber): ditto
+        (KJS::GetterSetterImp::getPrimitiveNumber): ditto
+        (KJS::StringImp::toPrimitive): Fixed formatting.
+        (KJS::NumberImp::toPrimitive): ditto
+        (KJS::GetterSetterImp::toPrimitive): ditto
+        * kjs/internal.h:
+        * kjs/object.cpp:
+        (KJS::JSObject::getPrimitiveNumber): Implemented.
+        * kjs/object.h:
+
</ins><span class="cx"> 2007-10-25  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Adam Roben.
</span></span></pre></div>
<a id="trunkJavaScriptCoreJavaScriptCoreexp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/JavaScriptCore.exp (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/JavaScriptCore.exp        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/JavaScriptCore.exp        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -123,8 +123,8 @@
</span><span class="cx"> __ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
</span><span class="cx"> __ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE
</span><span class="cx"> __ZN3KJS11InterpreterC1EPNS_14JSGlobalObjectE
</span><ins>+__ZN3KJS11InterpreterC1Ev
</ins><span class="cx"> __ZN3KJS11InterpreterC2EPNS_14JSGlobalObjectE
</span><del>-__ZN3KJS11InterpreterC1Ev
</del><span class="cx"> __ZN3KJS11InterpreterD1Ev
</span><span class="cx"> __ZN3KJS11InterpreterD2Ev
</span><span class="cx"> __ZN3KJS11JSImmediate4typeEPKNS_7JSValueE
</span><span class="lines">@@ -264,6 +264,7 @@
</span><span class="cx"> __ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
</span><span class="cx"> __ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
</span><span class="cx"> __ZNK3KJS8JSObject14implementsCallEv
</span><ins>+__ZNK3KJS8JSObject18getPrimitiveNumberEPNS_9ExecStateERd
</ins><span class="cx"> __ZNK3KJS8JSObject19implementsConstructEv
</span><span class="cx"> __ZNK3KJS8JSObject21implementsHasInstanceEv
</span><span class="cx"> __ZNK3KJS8JSObject3getEPNS_9ExecStateERKNS_10IdentifierE
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsinternalcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/internal.cpp (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/internal.cpp        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/kjs/internal.cpp        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -55,11 +55,17 @@
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ StringImp ------------------------------------
</span><span class="cx"> 
</span><del>-JSValue *StringImp::toPrimitive(ExecState *, JSType) const
</del><ins>+JSValue* StringImp::toPrimitive(ExecState*, JSType) const
</ins><span class="cx"> {
</span><del>-  return const_cast&lt;StringImp *&gt;(this);
</del><ins>+  return const_cast&lt;StringImp*&gt;(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool StringImp::getPrimitiveNumber(ExecState*, double&amp; number) const
+{
+    number = val.toDouble();
+    return false;
+}
+
</ins><span class="cx"> bool StringImp::toBoolean(ExecState *) const
</span><span class="cx"> {
</span><span class="cx">   return (val.size() &gt; 0);
</span><span class="lines">@@ -82,11 +88,17 @@
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ NumberImp ------------------------------------
</span><span class="cx"> 
</span><del>-JSValue *NumberImp::toPrimitive(ExecState *, JSType) const
</del><ins>+JSValue* NumberImp::toPrimitive(ExecState*, JSType) const
</ins><span class="cx"> {
</span><del>-  return const_cast&lt;NumberImp *&gt;(this);
</del><ins>+    return const_cast&lt;NumberImp*&gt;(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool NumberImp::getPrimitiveNumber(ExecState*, double&amp; number) const
+{
+    number = val;
+    return true;
+}
+
</ins><span class="cx"> bool NumberImp::toBoolean(ExecState *) const
</span><span class="cx"> {
</span><span class="cx">   return val &lt; 0.0 || val &gt; 0.0; // false for NaN
</span><span class="lines">@@ -144,12 +156,19 @@
</span><span class="cx">         setter-&gt;mark();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue *GetterSetterImp::toPrimitive(ExecState*, JSType) const
</del><ins>+JSValue* GetterSetterImp::toPrimitive(ExecState*, JSType) const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(false);
</span><span class="cx">     return jsNull();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool GetterSetterImp::getPrimitiveNumber(ExecState*, double&amp; number) const
+{
+    ASSERT(false);
+    number = 0;
+    return true;
+}
+
</ins><span class="cx"> bool GetterSetterImp::toBoolean(ExecState*) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(false);
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsinternalh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/internal.h (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/internal.h        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/kjs/internal.h        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -53,7 +53,8 @@
</span><span class="cx"> 
</span><span class="cx">     JSType type() const { return StringType; }
</span><span class="cx"> 
</span><del>-    JSValue *toPrimitive(ExecState *exec, JSType preferred = UnspecifiedType) const;
</del><ins>+    JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
+    bool getPrimitiveNumber(ExecState*, double&amp; number) const;
</ins><span class="cx">     bool toBoolean(ExecState *exec) const;
</span><span class="cx">     double toNumber(ExecState *exec) const;
</span><span class="cx">     UString toString(ExecState *exec) const;
</span><span class="lines">@@ -71,7 +72,8 @@
</span><span class="cx"> 
</span><span class="cx">     JSType type() const { return NumberType; }
</span><span class="cx"> 
</span><del>-    JSValue *toPrimitive(ExecState *exec, JSType preferred = UnspecifiedType) const;
</del><ins>+    JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
+    bool getPrimitiveNumber(ExecState*, double&amp; number) const;
</ins><span class="cx">     bool toBoolean(ExecState *exec) const;
</span><span class="cx">     double toNumber(ExecState *exec) const;
</span><span class="cx">     UString toString(ExecState *exec) const;
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsnodescpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/nodes.cpp (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/nodes.cpp        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/kjs/nodes.cpp        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -1240,14 +1240,6 @@
</span><span class="cx">     return jsNumber(p1-&gt;toNumber(exec) + p2-&gt;toNumber(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline JSValue *sub(ExecState *exec, JSValue *v1, JSValue *v2)
-{
-    JSValue *p1 = v1-&gt;toPrimitive(exec, NumberType);
-    JSValue *p2 = v2-&gt;toPrimitive(exec, NumberType);
-
-    return jsNumber(p1-&gt;toNumber(exec) - p2-&gt;toNumber(exec));
-}
-
</del><span class="cx"> // ECMA 11.6.1
</span><span class="cx"> JSValue *AddNode::evaluate(ExecState *exec)
</span><span class="cx"> {
</span><span class="lines">@@ -1270,7 +1262,7 @@
</span><span class="cx">     JSValue *v2 = term2-&gt;evaluate(exec);
</span><span class="cx">     KJS_CHECKEXCEPTIONVALUE
</span><span class="cx">         
</span><del>-    return sub(exec, v1, v2);
</del><ins>+    return jsNumber(v1-&gt;toNumber(exec) - v2-&gt;toNumber(exec));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ Shift Nodes ------------------------------------
</span><span class="lines">@@ -1318,24 +1310,28 @@
</span><span class="cx"> 
</span><span class="cx"> static inline JSValue* lessThan(ExecState *exec, JSValue* v1, JSValue* v2) 
</span><span class="cx"> {
</span><del>-  JSValue *p1 = v1-&gt;toPrimitive(exec, NumberType);
-  JSValue *p2 = v2-&gt;toPrimitive(exec, NumberType);
</del><ins>+    double n1;
+    double n2;
+    bool wasNotString1 = v1-&gt;getPrimitiveNumber(exec, n1);
+    bool wasNotString2 = v2-&gt;getPrimitiveNumber(exec, n2);
</ins><span class="cx">     
</span><del>-  if (p1-&gt;isString() &amp;&amp; p2-&gt;isString())
-    return jsBoolean(p1-&gt;toString(exec) &lt; p2-&gt;toString(exec));
-    
-  return jsBoolean(p1-&gt;toNumber(exec) &lt; p2-&gt;toNumber(exec));
</del><ins>+    if (wasNotString1 | wasNotString2)
+        return jsBoolean(n1 &lt; n2);
+
+    return jsBoolean(v1-&gt;toString(exec) &lt; v2-&gt;toString(exec));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline JSValue* lessThanEq(ExecState *exec, JSValue* v1, JSValue* v2) 
</span><span class="cx"> {
</span><del>-  JSValue *p1 = v1-&gt;toPrimitive(exec, NumberType);
-  JSValue *p2 = v2-&gt;toPrimitive(exec, NumberType);
</del><ins>+    double n1;
+    double n2;
+    bool wasNotString1 = v1-&gt;getPrimitiveNumber(exec, n1);
+    bool wasNotString2 = v2-&gt;getPrimitiveNumber(exec, n2);
</ins><span class="cx">     
</span><del>-  if (p1-&gt;isString() &amp;&amp; p2-&gt;isString())
-    return jsBoolean(!(p2-&gt;toString(exec) &lt; p1-&gt;toString(exec)));
</del><ins>+    if (wasNotString1 | wasNotString2)
+        return jsBoolean(n1 &lt;= n2);
</ins><span class="cx"> 
</span><del>-  return jsBoolean(p1-&gt;toNumber(exec) &lt;= p2-&gt;toNumber(exec));
</del><ins>+    return jsBoolean(!(v2-&gt;toString(exec) &lt; v1-&gt;toString(exec)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ECMA 11.8.1
</span><span class="lines">@@ -1564,7 +1560,7 @@
</span><span class="cx">     v = add(exec, v1, v2);
</span><span class="cx">     break;
</span><span class="cx">   case OpMinusEq:
</span><del>-    v = sub(exec, v1, v2);
</del><ins>+    v = jsNumber(v1-&gt;toNumber(exec) - v2-&gt;toNumber(exec));
</ins><span class="cx">     break;
</span><span class="cx">   case OpLShift:
</span><span class="cx">     i1 = v1-&gt;toInt32(exec);
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsobjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/object.cpp (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/object.cpp        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/kjs/object.cpp        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -354,6 +354,13 @@
</span><span class="cx">   return NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool JSObject::getPrimitiveNumber(ExecState* exec, double&amp; number) const
+{
+    JSValue* result = defaultValue(exec, NumberType);
+    number = result-&gt;toNumber(exec);
+    return !result-&gt;isString();
+}
+
</ins><span class="cx"> // ECMA 8.6.2.6
</span><span class="cx"> JSValue* JSObject::defaultValue(ExecState* exec, JSType hint) const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsobjecth"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/object.h (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/object.h        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/kjs/object.h        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -83,7 +83,8 @@
</span><span class="cx">       
</span><span class="cx">     GetterSetterImp() : getter(0), setter(0) { }
</span><span class="cx">       
</span><del>-    virtual JSValue *toPrimitive(ExecState *exec, JSType preferred = UnspecifiedType) const;
</del><ins>+    virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
+    virtual bool getPrimitiveNumber(ExecState*, double&amp; number) const;
</ins><span class="cx">     virtual bool toBoolean(ExecState *exec) const;
</span><span class="cx">     virtual double toNumber(ExecState *exec) const;
</span><span class="cx">     virtual UString toString(ExecState *exec) const;
</span><span class="lines">@@ -416,7 +417,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void getPropertyNames(ExecState*, PropertyNameArray&amp;);
</span><span class="cx"> 
</span><del>-    virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const;
</del><ins>+    virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
+    virtual bool getPrimitiveNumber(ExecState*, double&amp; number) const;
</ins><span class="cx">     virtual bool toBoolean(ExecState *exec) const;
</span><span class="cx">     virtual double toNumber(ExecState *exec) const;
</span><span class="cx">     virtual UString toString(ExecState *exec) const;
</span></span></pre></div>
<a id="trunkJavaScriptCorekjsvalueh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/kjs/value.h (27085 => 27086)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/kjs/value.h        2007-10-26 03:42:35 UTC (rev 27085)
+++ trunk/JavaScriptCore/kjs/value.h        2007-10-26 03:58:18 UTC (rev 27086)
</span><span class="lines">@@ -81,7 +81,9 @@
</span><span class="cx">     bool getTruncatedUInt32(uint32_t&amp;) const;
</span><span class="cx"> 
</span><span class="cx">     // Basic conversions.
</span><del>-    JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const;
</del><ins>+    JSValue* toPrimitive(ExecState* exec, JSType preferredType = UnspecifiedType) const;
+    bool getPrimitiveNumber(ExecState* exec, double&amp; number) const;
+
</ins><span class="cx">     bool toBoolean(ExecState *exec) const;
</span><span class="cx">     double toNumber(ExecState *exec) const;
</span><span class="cx">     UString toString(ExecState *exec) const;
</span><span class="lines">@@ -147,6 +149,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Basic conversions.
</span><span class="cx">     virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const = 0;
</span><ins>+    virtual bool getPrimitiveNumber(ExecState* exec, double&amp; number) const = 0;
</ins><span class="cx">     virtual bool toBoolean(ExecState *exec) const = 0;
</span><span class="cx">     virtual double toNumber(ExecState *exec) const = 0;
</span><span class="cx">     virtual UString toString(ExecState *exec) const = 0;
</span><span class="lines">@@ -365,11 +368,20 @@
</span><span class="cx">     return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()-&gt;type();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline JSValue *JSValue::toPrimitive(ExecState *exec, JSType preferredType) const
</del><ins>+inline JSValue* JSValue::toPrimitive(ExecState* exec, JSType preferredType) const
</ins><span class="cx"> {
</span><del>-    return JSImmediate::isImmediate(this) ? const_cast&lt;JSValue *&gt;(this) : asCell()-&gt;toPrimitive(exec, preferredType);
</del><ins>+    return JSImmediate::isImmediate(this) ? const_cast&lt;JSValue*&gt;(this) : asCell()-&gt;toPrimitive(exec, preferredType);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool JSValue::getPrimitiveNumber(ExecState* exec, double&amp; number) const
+{
+    if (JSImmediate::isImmediate(this)) {
+        number = JSImmediate::toDouble(this);
+        return true;
+    }
+    return asCell()-&gt;getPrimitiveNumber(exec, number);
+}
+
</ins><span class="cx"> inline bool JSValue::toBoolean(ExecState *exec) const
</span><span class="cx"> {
</span><span class="cx">     return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()-&gt;toBoolean(exec);
</span></span></pre>
</div>
</div>

</body>
</html>