<!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>[171278] trunk</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/171278">171278</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-07-20 09:16:57 -0700 (Sun, 20 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>ES6: Implement Math.sign()
https://bugs.webkit.org/show_bug.cgi?id=134980

Patch by Diego Pino Garcia &lt;dpino@igalia.com&gt; on 2014-07-20
Reviewed by Darin Adler.

Source/JavaScriptCore:
* runtime/MathObject.cpp:
(JSC::MathObject::finishCreation):
(JSC::mathProtoFuncSign):

LayoutTests:
* js/script-tests/Object-getOwnPropertyNames.js:
* js/script-tests/math.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt">trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsmathexpectedtxt">trunk/LayoutTests/js/math-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs">trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsmathjs">trunk/LayoutTests/js/script-tests/math.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeMathObjectcpp">trunk/Source/JavaScriptCore/runtime/MathObject.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/LayoutTests/ChangeLog        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-07-20  Diego Pino Garcia  &lt;dpino@igalia.com&gt;
+
+        ES6: Implement Math.sign()
+        https://bugs.webkit.org/show_bug.cgi?id=134980
+
+        Reviewed by Darin Adler.
+
+        * js/script-tests/Object-getOwnPropertyNames.js:
+        * js/script-tests/math.js:
+
</ins><span class="cx"> 2014-07-19  Carlos Alberto Lopez Perez  &lt;clopez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Unreviewed GTK gardening.
</span></span></pre></div>
<a id="trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Error) is ['length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString']
</span><del>-PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sin','sinh','sqrt','tan','tanh','trunc']
</del><ins>+PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']
</ins><span class="cx"> PASS getSortedOwnPropertyNames(JSON) is ['parse', 'stringify']
</span><span class="cx"> PASS globalPropertyNames.indexOf('NaN') != -1 is true
</span><span class="cx"> PASS globalPropertyNames.indexOf('Infinity') != -1 is true
</span></span></pre></div>
<a id="trunkLayoutTestsjsmathexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/math-expected.txt (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/math-expected.txt        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/LayoutTests/js/math-expected.txt        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -181,6 +181,24 @@
</span><span class="cx"> PASS Math.round(-1.7976931348623157e+308) is -1.7976931348623157e+308
</span><span class="cx"> PASS Math.round(Infinity) is Infinity
</span><span class="cx"> PASS Math.round(-Infinity) is -Infinity
</span><ins>+PASS Math.sign(NaN) is NaN
+PASS Math.sign('string') is NaN
+PASS Math.sign([1, 2, 3]) is NaN
+PASS Math.sign({}) is NaN
+PASS Math.sign(0) is 0
+PASS Math.sign(-0) is -0
+PASS Math.sign(-1) is -1
+PASS Math.sign(1) is 1
+PASS Math.sign(0.1) is 1
+PASS Math.sign(-0.1) is -1
+PASS Math.sign(10000) is 1
+PASS Math.sign(-10000) is -1
+PASS Math.sign(Number.MIN_VALUE) is 1
+PASS Math.sign(-Number.MIN_VALUE) is -1
+PASS Math.sign(Number.MAX_VALUE) is 1
+PASS Math.sign(-Number.MAX_VALUE) is -1
+PASS Math.sign(Infinity) is 1
+PASS Math.sign(-Infinity) is -1
</ins><span class="cx"> PASS Math.sin(NaN) is NaN
</span><span class="cx"> PASS Math.sin(0) is 0
</span><span class="cx"> PASS Math.sin(-0) is -0
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">     &quot;RegExp.prototype&quot;: &quot;['compile', 'constructor', 'exec', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']&quot;,
</span><span class="cx">     &quot;Error&quot;: &quot;['length', 'name', 'prototype']&quot;,
</span><span class="cx">     &quot;Error.prototype&quot;: &quot;['constructor', 'message', 'name', 'toString']&quot;,
</span><del>-    &quot;Math&quot;: &quot;['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sin','sinh','sqrt','tan','tanh','trunc']&quot;,
</del><ins>+    &quot;Math&quot;: &quot;['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']&quot;,
</ins><span class="cx">     &quot;JSON&quot;: &quot;['parse', 'stringify']&quot;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsmathjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/math.js (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/math.js        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/LayoutTests/js/script-tests/math.js        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -254,6 +254,25 @@
</span><span class="cx"> shouldBe(&quot;Math.round(Infinity)&quot;, &quot;Infinity&quot;);
</span><span class="cx"> shouldBe(&quot;Math.round(-Infinity)&quot;, &quot;-Infinity&quot;);
</span><span class="cx"> 
</span><ins>+shouldBe(&quot;Math.sign(NaN)&quot;, &quot;NaN&quot;);
+shouldBe(&quot;Math.sign('string')&quot;, &quot;NaN&quot;);
+shouldBe(&quot;Math.sign([1, 2, 3])&quot;, &quot;NaN&quot;);
+shouldBe(&quot;Math.sign({})&quot;, &quot;NaN&quot;);
+shouldBe(&quot;Math.sign(0)&quot;, &quot;0&quot;);
+shouldBe(&quot;Math.sign(-0)&quot;, &quot;-0&quot;);
+shouldBe(&quot;Math.sign(-1)&quot;, &quot;-1&quot;);
+shouldBe(&quot;Math.sign(1)&quot;, &quot;1&quot;);
+shouldBe(&quot;Math.sign(0.1)&quot;, &quot;1&quot;);
+shouldBe(&quot;Math.sign(-0.1)&quot;, &quot;-1&quot;);
+shouldBe(&quot;Math.sign(10000)&quot;, &quot;1&quot;);
+shouldBe(&quot;Math.sign(-10000)&quot;, &quot;-1&quot;);
+shouldBe(&quot;Math.sign(Number.MIN_VALUE)&quot;, &quot;1&quot;);
+shouldBe(&quot;Math.sign(-Number.MIN_VALUE)&quot;, &quot;-1&quot;);
+shouldBe(&quot;Math.sign(Number.MAX_VALUE)&quot;, &quot;1&quot;);
+shouldBe(&quot;Math.sign(-Number.MAX_VALUE)&quot;, &quot;-1&quot;);
+shouldBe(&quot;Math.sign(Infinity)&quot;, &quot;1&quot;);
+shouldBe(&quot;Math.sign(-Infinity)&quot;, &quot;-1&quot;);
+
</ins><span class="cx"> shouldBe(&quot;Math.sin(NaN)&quot;, &quot;NaN&quot;);
</span><span class="cx"> shouldBe(&quot;Math.sin(0)&quot;, &quot;0&quot;);
</span><span class="cx"> shouldBe(&quot;Math.sin(-0)&quot;, &quot;-0&quot;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-07-20  Diego Pino Garcia  &lt;dpino@igalia.com&gt;
+
+        ES6: Implement Math.sign()
+        https://bugs.webkit.org/show_bug.cgi?id=134980
+
+        Reviewed by Darin Adler.
+
+        * runtime/MathObject.cpp:
+        (JSC::MathObject::finishCreation):
+        (JSC::mathProtoFuncSign):
+
</ins><span class="cx"> 2014-07-18  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Exception fuzzing should work on iOS
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeMathObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/MathObject.cpp (171277 => 171278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/MathObject.cpp        2014-07-20 15:08:06 UTC (rev 171277)
+++ trunk/Source/JavaScriptCore/runtime/MathObject.cpp        2014-07-20 16:16:57 UTC (rev 171278)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState*);
</ins><span class="cx"> static EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL mathProtoFuncSinh(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*);
</span><span class="lines">@@ -120,6 +121,7 @@
</span><span class="cx">     putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;pow&quot;), 2, mathProtoFuncPow, PowIntrinsic, DontEnum | Function);
</span><span class="cx">     putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;random&quot;), 0, mathProtoFuncRandom, NoIntrinsic, DontEnum | Function);
</span><span class="cx">     putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;round&quot;), 1, mathProtoFuncRound, RoundIntrinsic, DontEnum | Function);
</span><ins>+    putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;sign&quot;), 1, mathProtoFuncSign, NoIntrinsic, DontEnum | Function);
</ins><span class="cx">     putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;sin&quot;), 1, mathProtoFuncSin, SinIntrinsic, DontEnum | Function);
</span><span class="cx">     putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;sinh&quot;), 1, mathProtoFuncSinh, NoIntrinsic, DontEnum | Function);
</span><span class="cx">     putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&amp;vm, &quot;sqrt&quot;), 1, mathProtoFuncSqrt, SqrtIntrinsic, DontEnum | Function);
</span><span class="lines">@@ -303,6 +305,16 @@
</span><span class="cx">     return JSValue::encode(jsNumber(integer - (integer - arg &gt; 0.5)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState* exec)
+{
+    double arg = exec-&gt;argument(0).toNumber(exec);
+    if (std::isnan(arg))
+        return JSValue::encode(jsNaN());
+    if (!arg)
+        return JSValue::encode(std::signbit(arg) ? jsNumber(-0.0) : jsNumber(0));
+    return JSValue::encode(jsNumber(std::signbit(arg) ? -1 : 1));
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     return JSValue::encode(jsDoubleNumber(sin(exec-&gt;argument(0).toNumber(exec))));
</span></span></pre>
</div>
</div>

</body>
</html>