<!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>[175724] 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/175724">175724</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2014-11-06 16:18:23 -0800 (Thu, 06 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>slow_path_get_direct_pname() needs to be hardened against a constant baseValue.
&lt;https://webkit.org/b/138476&gt;

Reviewed by Michael Saboff.

Source/JavaScriptCore:

slow_path_get_direct_pname() currently assumes that the baseValue is always a
non-constant virtual register.  However, this is not always the case like in the
following:

    function foo() {
        var o = { a:1 };
        for (var n in o)
            0[n];
    }
    foo();

This patch fixes it to also check for constant virtual register indexes.

* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):

LayoutTests:

* js/get-by-pname-expected.txt:
* js/script-tests/get-by-pname.js:
(getByPnameOnConstant):
(getByPnameOnVar):
- Added more test cases.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsgetbypnameexpectedtxt">trunk/LayoutTests/js/get-by-pname-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsgetbypnamejs">trunk/LayoutTests/js/script-tests/get-by-pname.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp">trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (175723 => 175724)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-11-07 00:02:25 UTC (rev 175723)
+++ trunk/LayoutTests/ChangeLog        2014-11-07 00:18:23 UTC (rev 175724)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2014-11-06  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        slow_path_get_direct_pname() needs to be hardened against a constant baseValue.
+        &lt;https://webkit.org/b/138476&gt;
+
+        Reviewed by Michael Saboff.
+
+        * js/get-by-pname-expected.txt:
+        * js/script-tests/get-by-pname.js:
+        (getByPnameOnConstant):
+        (getByPnameOnVar):
+        - Added more test cases.
+
+2014-11-06  Mark Lam  &lt;mark.lam@apple.com&gt;
+
</ins><span class="cx">         Refactor the get-by-pname.js test.
</span><span class="cx">         &lt;https://webkit.org/b/138483&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsjsgetbypnameexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/get-by-pname-expected.txt (175723 => 175724)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/get-by-pname-expected.txt        2014-11-07 00:02:25 UTC (rev 175723)
+++ trunk/LayoutTests/js/get-by-pname-expected.txt        2014-11-07 00:18:23 UTC (rev 175724)
</span><span class="lines">@@ -9,6 +9,37 @@
</span><span class="cx"> PASS foo(q) is 3467
</span><span class="cx"> PASS foo(r) is 113
</span><span class="cx"> PASS foo(s) is 182
</span><ins>+PASS getByPnameOnConstant(a) is 0
+PASS getByPnameOnVar(a, 100) is 0
+PASS getByPnameOnVar(a, 'abc') is '0abc'
+PASS getByPnameOnVar(a, o) is 0
+PASS getByPnameOnVar(a, o1) is 4
+PASS getByPnameOnVar(a, a) is 6
+PASS getByPnameOnConstant(o1) is 0
+PASS getByPnameOnVar(o1, 100) is 0
+PASS getByPnameOnVar(o1, 'abc') is '0bc0'
+PASS getByPnameOnVar(o1, o) is 0
+PASS getByPnameOnVar(o1, o1) is 11
+PASS getByPnameOnVar(o1, a) is 5
+PASS getByPnameOnConstant(o) is 0
+PASS getByPnameOnVar(o, 100) is 0
+PASS getByPnameOnVar(o, 'abc') is 0
+PASS getByPnameOnVar(o, o) is 11
+PASS getByPnameOnVar(o, o1) is 0
+PASS getByPnameOnVar(o, a) is 0
+PASS getByPnameOnConstant(0) is 0
+PASS getByPnameOnVar(0, 100) is 0
+PASS getByPnameOnVar(0, 'abc') is 0
+PASS getByPnameOnVar(0, o) is 0
+PASS getByPnameOnVar(0, o1) is 0
+PASS getByPnameOnVar(0, a) is 0
+PASS getByPnameOnConstant('abc') is 0
+PASS getByPnameOnVar('abc', 100) is 0
+PASS getByPnameOnVar('abc', 'abc') is '0abc'
+PASS getByPnameOnVar('abc', o) is 0
+PASS getByPnameOnVar('abc', o1) is 4
+PASS getByPnameOnVar('abc', a) is 6
+PASS getByPnameOnVar('def', 'abc') is '0abc'
</ins><span class="cx"> 
</span><span class="cx"> Test tier: llint
</span><span class="cx"> PASS foo(o) is 11
</span><span class="lines">@@ -16,6 +47,37 @@
</span><span class="cx"> PASS foo(q) is 3467
</span><span class="cx"> PASS foo(r) is 113
</span><span class="cx"> PASS foo(s) is 182
</span><ins>+PASS getByPnameOnConstant(a) is 0
+PASS getByPnameOnVar(a, 100) is 0
+PASS getByPnameOnVar(a, 'abc') is '0abc'
+PASS getByPnameOnVar(a, o) is 0
+PASS getByPnameOnVar(a, o1) is 4
+PASS getByPnameOnVar(a, a) is 6
+PASS getByPnameOnConstant(o1) is 0
+PASS getByPnameOnVar(o1, 100) is 0
+PASS getByPnameOnVar(o1, 'abc') is '0bc0'
+PASS getByPnameOnVar(o1, o) is 0
+PASS getByPnameOnVar(o1, o1) is 11
+PASS getByPnameOnVar(o1, a) is 5
+PASS getByPnameOnConstant(o) is 0
+PASS getByPnameOnVar(o, 100) is 0
+PASS getByPnameOnVar(o, 'abc') is 0
+PASS getByPnameOnVar(o, o) is 11
+PASS getByPnameOnVar(o, o1) is 0
+PASS getByPnameOnVar(o, a) is 0
+PASS getByPnameOnConstant(0) is 0
+PASS getByPnameOnVar(0, 100) is 0
+PASS getByPnameOnVar(0, 'abc') is 0
+PASS getByPnameOnVar(0, o) is 0
+PASS getByPnameOnVar(0, o1) is 0
+PASS getByPnameOnVar(0, a) is 0
+PASS getByPnameOnConstant('abc') is 0
+PASS getByPnameOnVar('abc', 100) is 0
+PASS getByPnameOnVar('abc', 'abc') is '0abc'
+PASS getByPnameOnVar('abc', o) is 0
+PASS getByPnameOnVar('abc', o1) is 4
+PASS getByPnameOnVar('abc', a) is 6
+PASS getByPnameOnVar('def', 'abc') is '0abc'
</ins><span class="cx"> 
</span><span class="cx"> Test tier: baseline
</span><span class="cx"> PASS foo(o) is 11
</span><span class="lines">@@ -23,6 +85,37 @@
</span><span class="cx"> PASS foo(q) is 3467
</span><span class="cx"> PASS foo(r) is 113
</span><span class="cx"> PASS foo(s) is 182
</span><ins>+PASS getByPnameOnConstant(a) is 0
+PASS getByPnameOnVar(a, 100) is 0
+PASS getByPnameOnVar(a, 'abc') is '0abc'
+PASS getByPnameOnVar(a, o) is 0
+PASS getByPnameOnVar(a, o1) is 4
+PASS getByPnameOnVar(a, a) is 6
+PASS getByPnameOnConstant(o1) is 0
+PASS getByPnameOnVar(o1, 100) is 0
+PASS getByPnameOnVar(o1, 'abc') is '0bc0'
+PASS getByPnameOnVar(o1, o) is 0
+PASS getByPnameOnVar(o1, o1) is 11
+PASS getByPnameOnVar(o1, a) is 5
+PASS getByPnameOnConstant(o) is 0
+PASS getByPnameOnVar(o, 100) is 0
+PASS getByPnameOnVar(o, 'abc') is 0
+PASS getByPnameOnVar(o, o) is 11
+PASS getByPnameOnVar(o, o1) is 0
+PASS getByPnameOnVar(o, a) is 0
+PASS getByPnameOnConstant(0) is 0
+PASS getByPnameOnVar(0, 100) is 0
+PASS getByPnameOnVar(0, 'abc') is 0
+PASS getByPnameOnVar(0, o) is 0
+PASS getByPnameOnVar(0, o1) is 0
+PASS getByPnameOnVar(0, a) is 0
+PASS getByPnameOnConstant('abc') is 0
+PASS getByPnameOnVar('abc', 100) is 0
+PASS getByPnameOnVar('abc', 'abc') is '0abc'
+PASS getByPnameOnVar('abc', o) is 0
+PASS getByPnameOnVar('abc', o1) is 4
+PASS getByPnameOnVar('abc', a) is 6
+PASS getByPnameOnVar('def', 'abc') is '0abc'
</ins><span class="cx"> 
</span><span class="cx"> Test tier: dfg
</span><span class="cx"> PASS foo(o) is 11
</span><span class="lines">@@ -30,6 +123,37 @@
</span><span class="cx"> PASS foo(q) is 3467
</span><span class="cx"> PASS foo(r) is 113
</span><span class="cx"> PASS foo(s) is 182
</span><ins>+PASS getByPnameOnConstant(a) is 0
+PASS getByPnameOnVar(a, 100) is 0
+PASS getByPnameOnVar(a, 'abc') is '0abc'
+PASS getByPnameOnVar(a, o) is 0
+PASS getByPnameOnVar(a, o1) is 4
+PASS getByPnameOnVar(a, a) is 6
+PASS getByPnameOnConstant(o1) is 0
+PASS getByPnameOnVar(o1, 100) is 0
+PASS getByPnameOnVar(o1, 'abc') is '0bc0'
+PASS getByPnameOnVar(o1, o) is 0
+PASS getByPnameOnVar(o1, o1) is 11
+PASS getByPnameOnVar(o1, a) is 5
+PASS getByPnameOnConstant(o) is 0
+PASS getByPnameOnVar(o, 100) is 0
+PASS getByPnameOnVar(o, 'abc') is 0
+PASS getByPnameOnVar(o, o) is 11
+PASS getByPnameOnVar(o, o1) is 0
+PASS getByPnameOnVar(o, a) is 0
+PASS getByPnameOnConstant(0) is 0
+PASS getByPnameOnVar(0, 100) is 0
+PASS getByPnameOnVar(0, 'abc') is 0
+PASS getByPnameOnVar(0, o) is 0
+PASS getByPnameOnVar(0, o1) is 0
+PASS getByPnameOnVar(0, a) is 0
+PASS getByPnameOnConstant('abc') is 0
+PASS getByPnameOnVar('abc', 100) is 0
+PASS getByPnameOnVar('abc', 'abc') is '0abc'
+PASS getByPnameOnVar('abc', o) is 0
+PASS getByPnameOnVar('abc', o1) is 4
+PASS getByPnameOnVar('abc', a) is 6
+PASS getByPnameOnVar('def', 'abc') is '0abc'
</ins><span class="cx"> 
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsgetbypnamejs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/get-by-pname.js (175723 => 175724)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/get-by-pname.js        2014-11-07 00:02:25 UTC (rev 175723)
+++ trunk/LayoutTests/js/script-tests/get-by-pname.js        2014-11-07 00:18:23 UTC (rev 175724)
</span><span class="lines">@@ -9,18 +9,71 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function getByPnameOnConstant(o) {
+    var result = 0;
+    for (var n in o)
+        result += 0[n] ? 0[n] : 0;
+    return result;
+}
+
+function getByPnameOnVar(o, v) {
+    var result = 0;
+    for (var n in o)
+        result += v[n] ? v[n] : 0;
+    return result;
+}
+
</ins><span class="cx"> var o = {a:1, b:3, c:7};
</span><span class="cx"> var p = {a:1, b:2, c:3, d:4};
</span><span class="cx"> var q = {a:1, b:2, c:3, d:4, e:3457};
</span><span class="cx"> var r = {a:1, b:2, c:3, d:4, e:91, f:12};
</span><span class="cx"> var s = {a:1, b:2, c:3, d:4, e:91, f:12, g:69};
</span><span class="cx"> 
</span><ins>+var a = [1, 2, 3];
+var o1 = {&quot;1&quot;:1, &quot;2&quot;:3, &quot;3&quot;:7};
+
</ins><span class="cx"> var testCases = [
</span><span class="cx">     [ &quot;foo(o)&quot;, &quot;11&quot; ],
</span><span class="cx">     [ &quot;foo(p)&quot;, &quot;10&quot; ],
</span><span class="cx">     [ &quot;foo(q)&quot;, &quot;3467&quot; ],
</span><span class="cx">     [ &quot;foo(r)&quot;, &quot;113&quot; ],
</span><span class="cx">     [ &quot;foo(s)&quot;, &quot;182&quot; ],
</span><ins>+
+    [ &quot;getByPnameOnConstant(a)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(a, 100)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(a, 'abc')&quot;, &quot;'0abc'&quot; ],
+    [ &quot;getByPnameOnVar(a, o)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(a, o1)&quot;, &quot;4&quot; ],
+    [ &quot;getByPnameOnVar(a, a)&quot;, &quot;6&quot; ],
+
+    [ &quot;getByPnameOnConstant(o1)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o1, 100)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o1, 'abc')&quot;, &quot;'0bc0'&quot; ],
+    [ &quot;getByPnameOnVar(o1, o)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o1, o1)&quot;, &quot;11&quot; ],
+    [ &quot;getByPnameOnVar(o1, a)&quot;, &quot;5&quot; ],
+
+    [ &quot;getByPnameOnConstant(o)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o, 100)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o, 'abc')&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o, o)&quot;, &quot;11&quot; ],
+    [ &quot;getByPnameOnVar(o, o1)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(o, a)&quot;, &quot;0&quot; ],
+
+    [ &quot;getByPnameOnConstant(0)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(0, 100)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(0, 'abc')&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(0, o)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(0, o1)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar(0, a)&quot;, &quot;0&quot; ],
+
+    [ &quot;getByPnameOnConstant('abc')&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar('abc', 100)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar('abc', 'abc')&quot;, &quot;'0abc'&quot; ],
+    [ &quot;getByPnameOnVar('abc', o)&quot;, &quot;0&quot; ],
+    [ &quot;getByPnameOnVar('abc', o1)&quot;, &quot;4&quot; ],
+    [ &quot;getByPnameOnVar('abc', a)&quot;, &quot;6&quot; ],
+    [ &quot;getByPnameOnVar('def', 'abc')&quot;, &quot;'0abc'&quot; ],
</ins><span class="cx"> ];
</span><span class="cx"> 
</span><span class="cx"> function testExpr(index) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (175723 => 175724)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-11-07 00:02:25 UTC (rev 175723)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-11-07 00:18:23 UTC (rev 175724)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-11-06  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        slow_path_get_direct_pname() needs to be hardened against a constant baseValue.
+        &lt;https://webkit.org/b/138476&gt;
+
+        Reviewed by Michael Saboff.
+
+        slow_path_get_direct_pname() currently assumes that the baseValue is always a
+        non-constant virtual register.  However, this is not always the case like in the
+        following:
+
+            function foo() {
+                var o = { a:1 };
+                for (var n in o)
+                    0[n];
+            }
+            foo();
+
+        This patch fixes it to also check for constant virtual register indexes.
+
+        * runtime/CommonSlowPaths.cpp:
+        (JSC::SLOW_PATH_DECL):
+
</ins><span class="cx"> 2014-11-06  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r174985-174986): Site display disappears 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (175723 => 175724)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2014-11-07 00:02:25 UTC (rev 175723)
+++ trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2014-11-07 00:18:23 UTC (rev 175724)
</span><span class="lines">@@ -569,7 +569,7 @@
</span><span class="cx"> SLOW_PATH_DECL(slow_path_get_direct_pname)
</span><span class="cx"> {
</span><span class="cx">     BEGIN();
</span><del>-    JSValue baseValue = OP(2).jsValue();
</del><ins>+    JSValue baseValue = OP_C(2).jsValue();
</ins><span class="cx">     JSValue property = OP(3).jsValue();
</span><span class="cx">     ASSERT(property.isString());
</span><span class="cx">     RETURN(baseValue.get(exec, property.toString(exec)-&gt;toIdentifier(exec)));
</span></span></pre>
</div>
</div>

</body>
</html>