<!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>[160670] 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/160670">160670</a></dd>
<dt>Author</dt> <dd>oliver@apple.com</dd>
<dt>Date</dt> <dd>2013-12-16 16:01:01 -0800 (Mon, 16 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cache getters and custom accessors on the prototype chain
https://bugs.webkit.org/show_bug.cgi?id=125602

Reviewed by Michael Saboff.

Source/JavaScriptCore:

Support caching of custom getters and accessors on the prototype chain.
This is relatively trivial and just requires a little work compared to
the direct access mode as we're under more register pressure.

* bytecode/StructureStubInfo.h:
  Removed the unsued initGetByIdProto as it was confusing to still have it present.
* jit/Repatch.cpp:
(JSC::generateProtoChainAccessStub):
(JSC::tryCacheGetByID):
(JSC::tryBuildGetByIDList):

Tools:

Make sure bencher scripts also make noInline exist

* Scripts/bencher:

LayoutTests:

Added a bunch of new tests

* js/regress/chain-custom-getter-expected.txt: Added.
* js/regress/chain-custom-getter.html: Added.
* js/regress/chain-getter-access-expected.txt: Added.
* js/regress/chain-getter-access.html: Added.
* js/regress/proto-custom-getter-expected.txt: Added.
* js/regress/proto-custom-getter.html: Added.
* js/regress/proto-getter-access-expected.txt: Added.
* js/regress/proto-getter-access.html: Added.
* js/regress/resources/regress-pre.js:
  Made sure that noInline always exists (either using testRunner.neverInlineFunction
  or a no-op function if nothing else is available)
* js/regress/script-tests/chain-custom-getter.js: Added.
(foo):
* js/regress/script-tests/chain-getter-access.js: Added.
(o.get value):
(foo):
* js/regress/script-tests/proto-custom-getter.js: Added.
(foo):
* js/regress/script-tests/proto-getter-access.js: Added.
(o.get value):
(foo):
* js/regress/script-tests/simple-custom-getter.js: Added.
(cycles.30000.numberObject.Number.foo):
* js/regress/script-tests/simple-getter-access.js: Added.
(o.get value):
(foo):
* js/regress/simple-custom-getter-expected.txt: Added.
* js/regress/simple-custom-getter.html: Added.
* js/regress/simple-getter-access-expected.txt: Added.
* js/regress/simple-getter-access.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsregressresourcesregressprejs">trunk/LayoutTests/js/regress/resources/regress-pre.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeStructureStubInfoh">trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitRepatchcpp">trunk/Source/JavaScriptCore/jit/Repatch.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptsbencher">trunk/Tools/Scripts/bencher</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsregresschaincustomgetterexpectedtxt">trunk/LayoutTests/js/regress/chain-custom-getter-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregresschaincustomgetterhtml">trunk/LayoutTests/js/regress/chain-custom-getter.html</a></li>
<li><a href="#trunkLayoutTestsjsregresschaingetteraccessexpectedtxt">trunk/LayoutTests/js/regress/chain-getter-access-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregresschaingetteraccesshtml">trunk/LayoutTests/js/regress/chain-getter-access.html</a></li>
<li><a href="#trunkLayoutTestsjsregressprotocustomgetterexpectedtxt">trunk/LayoutTests/js/regress/proto-custom-getter-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregressprotocustomgetterhtml">trunk/LayoutTests/js/regress/proto-custom-getter.html</a></li>
<li><a href="#trunkLayoutTestsjsregressprotogetteraccessexpectedtxt">trunk/LayoutTests/js/regress/proto-getter-access-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregressprotogetteraccesshtml">trunk/LayoutTests/js/regress/proto-getter-access.html</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestschaincustomgetterjs">trunk/LayoutTests/js/regress/script-tests/chain-custom-getter.js</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestschaingetteraccessjs">trunk/LayoutTests/js/regress/script-tests/chain-getter-access.js</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestsprotocustomgetterjs">trunk/LayoutTests/js/regress/script-tests/proto-custom-getter.js</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestsprotogetteraccessjs">trunk/LayoutTests/js/regress/script-tests/proto-getter-access.js</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestssimplecustomgetterjs">trunk/LayoutTests/js/regress/script-tests/simple-custom-getter.js</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestssimplegetteraccessjs">trunk/LayoutTests/js/regress/script-tests/simple-getter-access.js</a></li>
<li><a href="#trunkLayoutTestsjsregresssimplecustomgetterexpectedtxt">trunk/LayoutTests/js/regress/simple-custom-getter-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregresssimplecustomgetterhtml">trunk/LayoutTests/js/regress/simple-custom-getter.html</a></li>
<li><a href="#trunkLayoutTestsjsregresssimplegetteraccessexpectedtxt">trunk/LayoutTests/js/regress/simple-getter-access-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregresssimplegetteraccesshtml">trunk/LayoutTests/js/regress/simple-getter-access.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/LayoutTests/ChangeLog        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2013-12-16  Oliver Hunt  &lt;oliver@apple.com&gt;
+
+        Cache getters and custom accessors on the prototype chain
+        https://bugs.webkit.org/show_bug.cgi?id=125602
+
+        Reviewed by Michael Saboff.
+
+        Added a bunch of new tests
+
+        * js/regress/chain-custom-getter-expected.txt: Added.
+        * js/regress/chain-custom-getter.html: Added.
+        * js/regress/chain-getter-access-expected.txt: Added.
+        * js/regress/chain-getter-access.html: Added.
+        * js/regress/proto-custom-getter-expected.txt: Added.
+        * js/regress/proto-custom-getter.html: Added.
+        * js/regress/proto-getter-access-expected.txt: Added.
+        * js/regress/proto-getter-access.html: Added.
+        * js/regress/resources/regress-pre.js:
+          Made sure that noInline always exists (either using testRunner.neverInlineFunction
+          or a no-op function if nothing else is available)
+        * js/regress/script-tests/chain-custom-getter.js: Added.
+        (foo):
+        * js/regress/script-tests/chain-getter-access.js: Added.
+        (o.get value):
+        (foo):
+        * js/regress/script-tests/proto-custom-getter.js: Added.
+        (foo):
+        * js/regress/script-tests/proto-getter-access.js: Added.
+        (o.get value):
+        (foo):
+        * js/regress/script-tests/simple-custom-getter.js: Added.
+        (cycles.30000.numberObject.Number.foo):
+        * js/regress/script-tests/simple-getter-access.js: Added.
+        (o.get value):
+        (foo):
+        * js/regress/simple-custom-getter-expected.txt: Added.
+        * js/regress/simple-custom-getter.html: Added.
+        * js/regress/simple-getter-access-expected.txt: Added.
+        * js/regress/simple-getter-access.html: Added.
+
</ins><span class="cx"> 2013-12-16  Hans Muller  &lt;hmuller@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSS Shapes] Add support for the computing the included intervals for a BoxShape
</span></span></pre></div>
<a id="trunkLayoutTestsjsregresschaincustomgetterexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/chain-custom-getter-expected.txt (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/chain-custom-getter-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/chain-custom-getter-expected.txt        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/chain-custom-getter
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresschaincustomgetterhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/chain-custom-getter.html (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/chain-custom-getter.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/chain-custom-getter.html        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/chain-custom-getter.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresschaingetteraccessexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/chain-getter-access-expected.txt (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/chain-getter-access-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/chain-getter-access-expected.txt        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/chain-getter-access
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresschaingetteraccesshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/chain-getter-access.html (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/chain-getter-access.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/chain-getter-access.html        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/chain-getter-access.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressprotocustomgetterexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/proto-custom-getter-expected.txt (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/proto-custom-getter-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/proto-custom-getter-expected.txt        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/proto-custom-getter
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressprotocustomgetterhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/proto-custom-getter.html (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/proto-custom-getter.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/proto-custom-getter.html        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/proto-custom-getter.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressprotogetteraccessexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/proto-getter-access-expected.txt (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/proto-getter-access-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/proto-getter-access-expected.txt        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/proto-getter-access
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressprotogetteraccesshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/proto-getter-access.html (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/proto-getter-access.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/proto-getter-access.html        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/chain-getter-access.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressresourcesregressprejs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/regress/resources/regress-pre.js (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/resources/regress-pre.js        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/LayoutTests/js/regress/resources/regress-pre.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -6,3 +6,11 @@
</span><span class="cx">     _JSRegress_didSucceed = false;
</span><span class="cx">     _JSRegress_oldOnError.apply(this, arguments);
</span><span class="cx"> }
</span><ins>+
+if (typeof noInline == &quot;undefined&quot;) {
+    if (window.testRunner)
+        noInline =window.testRunner.neverInlineFunction || function(){};
+    else
+        noInline = function(){}
+}
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestschaincustomgetterjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/chain-custom-getter.js (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/chain-custom-getter.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/chain-custom-getter.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+
+var cycles = 6000;
+var numberObject = { __proto__: Number}
+numberObject ={__proto__: numberObject}
+
+function foo() {
+    var result = 0;
+    var innerCycles = cycles;
+    var Number = numberObject;
+    for (var i = 0; i &lt; innerCycles; ++i)
+        result += 0 | isNaN(Number.NaN);
+
+    return result;
+}
+
+noInline(foo);
+var result = 0;
+for (var i = 0; i &lt; 1500; i++)
+    result += foo();
+if (result != i * cycles)
+    throw &quot;Failed, result was &quot; + (result) + &quot; should be &quot; + (i * cycles);
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestschaingetteraccessjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/chain-getter-access.js (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/chain-getter-access.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/chain-getter-access.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+var x = 1;
+var o = {
+    get value() { 
+        x ^= x * 3;
+        x = x | 1;
+        return x;
+    }
+}
+
+o = {__proto__: o}
+o = {__proto__: o}
+
+function foo(o) {
+    var result = 0;
+    for (var i = 0; i &lt; 64; i++) {
+        result ^= o.value;
+        result |= 1
+    }
+    return result;
+}
+
+noInline(foo);
+var result = 0;
+for (var i = 0; i &lt; 50000; ++i) {
+    result ^= foo(o);
+    result = result | 1;
+}
+
+if (result != -2004318071)
+    throw &quot;Incorrect result: &quot; + result + &quot;. Should be -2004318071&quot;;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestsprotocustomgetterjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/proto-custom-getter.js (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/proto-custom-getter.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/proto-custom-getter.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+var cycles = 6000
+var numberObject = { __proto__: Number}
+function foo() {
+    var result = 0;
+    var innerCycles = cycles;
+    var Number = numberObject;
+    for (var i = 0; i &lt; innerCycles; ++i)
+        result += 0 | isNaN(Number.NaN);
+
+    return result;
+}
+noInline(foo);
+var result = 0;
+for (var i = 0; i &lt; 1500; i++)
+    result += foo();
+if (result != i * cycles)
+    throw &quot;Failed, result was &quot; + (result) + &quot; should be &quot; + (i * cycles)
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestsprotogetteraccessjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/proto-getter-access.js (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/proto-getter-access.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/proto-getter-access.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+var x = 1;
+var o = {
+    get value() { 
+        x ^= x * 3;
+        x = x | 1;
+        return x;
+    }
+}
+
+o = {__proto__: o}
+
+function foo(o) {
+    var result = 0;
+    for (var i = 0; i &lt; 64; i++) {
+        result ^= o.value;
+        result |= 1
+    }
+    return result;
+}
+
+noInline(foo);
+var result = 0;
+for (var i = 0; i &lt; 50000; ++i) {
+    result ^= foo(o);
+    result = result | 1;
+}
+if (result != -2004318071)
+    throw &quot;Incorrect result: &quot; + result + &quot;. Should be -2004318071&quot;;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestssimplecustomgetterjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/simple-custom-getter.js (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/simple-custom-getter.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/simple-custom-getter.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+var cycles = 20000
+var numberObject = Number
+function foo() {
+    var result = 0;
+    var innerCycles = cycles;
+    var Number = numberObject;
+    for (var i = 0; i &lt; innerCycles; ++i)
+        result += 0 | isNaN(Number.NaN);
+
+    return result;
+}
+noInline(foo);
+var result = 0;
+for (var i = 0; i &lt; 1500; i++)
+    result += foo();
+if (result != i * cycles)
+    throw &quot;Failed, result was &quot; + (result) + &quot; should be &quot; + (i * cycles)
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregressscripttestssimplegetteraccessjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/simple-getter-access.js (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/simple-getter-access.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/simple-getter-access.js        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+var x = 1;
+var o = {
+    get value() { 
+        x ^= x * 3;
+        x = x | 1;
+        return x;
+    }
+}
+
+function foo(o) {
+    var result = 0;
+    for (var i = 0; i &lt; 128; i++) {
+        result ^= o.value;
+        result |= 1
+    }
+    return result;
+}
+
+noInline(foo);
+var result = 0;
+for (var i = 0; i &lt; 40000; ++i) {
+    result ^= foo(o);
+    result = result | 1;
+}
+if (result != -2004318071)
+    throw &quot;Incorrect result: &quot; + result + &quot;. Should be -2004318071&quot;;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresssimplecustomgetterexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/simple-custom-getter-expected.txt (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/simple-custom-getter-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/simple-custom-getter-expected.txt        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/simple-custom-getter
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresssimplecustomgetterhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/simple-custom-getter.html (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/simple-custom-getter.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/simple-custom-getter.html        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/simple-custom-getter.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresssimplegetteraccessexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/simple-getter-access-expected.txt (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/simple-getter-access-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/simple-getter-access-expected.txt        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/simple-getter-access
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregresssimplegetteraccesshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/simple-getter-access.html (0 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/simple-getter-access.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/simple-getter-access.html        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script src=&quot;resources/regress-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/chain-getter-access.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/regress-post.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/Source/JavaScriptCore/ChangeLog        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2013-12-16  Oliver Hunt  &lt;oliver@apple.com&gt;
+
+        Cache getters and custom accessors on the prototype chain
+        https://bugs.webkit.org/show_bug.cgi?id=125602
+
+        Reviewed by Michael Saboff.
+
+        Support caching of custom getters and accessors on the prototype chain.
+        This is relatively trivial and just requires a little work compared to
+        the direct access mode as we're under more register pressure.
+
+        * bytecode/StructureStubInfo.h:
+          Removed the unsued initGetByIdProto as it was confusing to still have it present.
+        * jit/Repatch.cpp:
+        (JSC::generateProtoChainAccessStub):
+        (JSC::tryCacheGetByID):
+        (JSC::tryBuildGetByIDList):
+
</ins><span class="cx"> 2013-12-16  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Change slow path result to take a void* instead of a ExecState*.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeStructureStubInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -119,15 +119,6 @@
</span><span class="cx">         u.getByIdSelf.baseObjectStructure.set(vm, owner, baseObjectStructure);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void initGetByIdProto(VM&amp; vm, JSCell* owner, Structure* baseObjectStructure, Structure* prototypeStructure, bool isDirect)
-    {
-        accessType = access_get_by_id_proto;
-
-        u.getByIdProto.baseObjectStructure.set(vm, owner, baseObjectStructure);
-        u.getByIdProto.prototypeStructure.set(vm, owner, prototypeStructure);
-        u.getByIdProto.isDirect = isDirect;
-    }
-
</del><span class="cx">     void initGetByIdChain(VM&amp; vm, JSCell* owner, Structure* baseObjectStructure, StructureChain* chain, unsigned count, bool isDirect)
</span><span class="cx">     {
</span><span class="cx">         accessType = access_get_by_id_chain;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitRepatchcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/Repatch.cpp (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/Repatch.cpp        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/Source/JavaScriptCore/jit/Repatch.cpp        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -220,21 +220,27 @@
</span><span class="cx">     linkRestoreScratch(patchBuffer, needToRestoreScratch, success, fail, failureCases, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void generateProtoChainAccessStub(ExecState* exec, StructureStubInfo&amp; stubInfo, StructureChain* chain, size_t count, PropertyOffset offset, Structure* structure, CodeLocationLabel successLabel, CodeLocationLabel slowCaseLabel, RefPtr&lt;JITStubRoutine&gt;&amp; stubRoutine, const Identifier&amp; propertyName)
</del><ins>+enum ProtoChainGenerationResult {
+    ProtoChainGenerationFailed,
+    ProtoChainGenerationSucceeded
+};
+
+static ProtoChainGenerationResult generateProtoChainAccessStub(ExecState*, const PropertySlot&amp;, const Identifier&amp;, StructureStubInfo&amp;, StructureChain*, size_t, PropertyOffset, Structure*, CodeLocationLabel, CodeLocationLabel, RefPtr&lt;JITStubRoutine&gt;&amp;) WARN_UNUSED_RETURN;
+static ProtoChainGenerationResult generateProtoChainAccessStub(ExecState* exec, const PropertySlot&amp; slot, const Identifier&amp; propertyName, StructureStubInfo&amp; stubInfo, StructureChain* chain, size_t count, PropertyOffset offset, Structure* structure, CodeLocationLabel successLabel, CodeLocationLabel slowCaseLabel, RefPtr&lt;JITStubRoutine&gt;&amp; stubRoutine)
</ins><span class="cx"> {
</span><span class="cx">     VM* vm = &amp;exec-&gt;vm();
</span><del>-
-    MacroAssembler stubJit;
-        
</del><span class="cx">     GPRReg baseGPR = static_cast&lt;GPRReg&gt;(stubInfo.patch.baseGPR);
</span><span class="cx"> #if USE(JSVALUE32_64)
</span><span class="cx">     GPRReg resultTagGPR = static_cast&lt;GPRReg&gt;(stubInfo.patch.valueTagGPR);
</span><span class="cx"> #endif
</span><span class="cx">     GPRReg resultGPR = static_cast&lt;GPRReg&gt;(stubInfo.patch.valueGPR);
</span><span class="cx">     GPRReg scratchGPR = TempRegisterSet(stubInfo.patch.usedRegisters).getFreeGPR();
</span><del>-    bool needToRestoreScratch = false;
</del><ins>+    bool needToRestoreScratch = scratchGPR == InvalidGPRReg;
+    if (needToRestoreScratch &amp;&amp; !slot.isCacheableValue())
+        return ProtoChainGenerationFailed;
</ins><span class="cx">     
</span><del>-    if (scratchGPR == InvalidGPRReg) {
</del><ins>+    CCallHelpers stubJit(&amp;exec-&gt;vm(), exec-&gt;codeBlock());
+    if (needToRestoreScratch) {
</ins><span class="cx"> #if USE(JSVALUE64)
</span><span class="cx">         scratchGPR = AssemblyHelpers::selectScratchGPR(baseGPR, resultGPR);
</span><span class="cx"> #else
</span><span class="lines">@@ -266,36 +272,80 @@
</span><span class="cx">         currStructure = it-&gt;get();
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    if (isInlineOffset(offset)) {
</del><ins>+    bool isAccessor = slot.isCacheableGetter() || slot.isCacheableCustom();
+    if (isAccessor)
+        stubJit.move(baseGPR, scratchGPR);
+
+    if (!slot.isCacheableCustom()) {
+        if (isInlineOffset(offset)) {
</ins><span class="cx"> #if USE(JSVALUE64)
</span><del>-        stubJit.load64(protoObject-&gt;locationForOffset(offset), resultGPR);
</del><ins>+            stubJit.load64(protoObject-&gt;locationForOffset(offset), resultGPR);
</ins><span class="cx"> #elif USE(JSVALUE32_64)
</span><del>-        stubJit.move(MacroAssembler::TrustedImmPtr(protoObject-&gt;locationForOffset(offset)), resultGPR);
-        stubJit.load32(MacroAssembler::Address(resultGPR, OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), resultTagGPR);
-        stubJit.load32(MacroAssembler::Address(resultGPR, OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), resultGPR);
</del><ins>+            stubJit.move(MacroAssembler::TrustedImmPtr(protoObject-&gt;locationForOffset(offset)), resultGPR);
+            stubJit.load32(MacroAssembler::Address(resultGPR, OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), resultTagGPR);
+            stubJit.load32(MacroAssembler::Address(resultGPR, OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), resultGPR);
</ins><span class="cx"> #endif
</span><del>-    } else {
-        stubJit.loadPtr(protoObject-&gt;butterflyAddress(), resultGPR);
</del><ins>+        } else {
+            stubJit.loadPtr(protoObject-&gt;butterflyAddress(), resultGPR);
</ins><span class="cx"> #if USE(JSVALUE64)
</span><del>-        stubJit.load64(MacroAssembler::Address(resultGPR, offsetInButterfly(offset) * sizeof(WriteBarrier&lt;Unknown&gt;)), resultGPR);
</del><ins>+            stubJit.load64(MacroAssembler::Address(resultGPR, offsetInButterfly(offset) * sizeof(WriteBarrier&lt;Unknown&gt;)), resultGPR);
</ins><span class="cx"> #elif USE(JSVALUE32_64)
</span><del>-        stubJit.load32(MacroAssembler::Address(resultGPR, offsetInButterfly(offset) * sizeof(WriteBarrier&lt;Unknown&gt;) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), resultTagGPR);
-        stubJit.load32(MacroAssembler::Address(resultGPR, offsetInButterfly(offset) * sizeof(WriteBarrier&lt;Unknown&gt;) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), resultGPR);
</del><ins>+            stubJit.load32(MacroAssembler::Address(resultGPR, offsetInButterfly(offset) * sizeof(WriteBarrier&lt;Unknown&gt;) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)), resultTagGPR);
+            stubJit.load32(MacroAssembler::Address(resultGPR, offsetInButterfly(offset) * sizeof(WriteBarrier&lt;Unknown&gt;) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)), resultGPR);
</ins><span class="cx"> #endif
</span><ins>+        }
</ins><span class="cx">     }
</span><ins>+    MacroAssembler::Call operationCall;
+    MacroAssembler::Call handlerCall;
+    FunctionPtr operationFunction;
+    MacroAssembler::Jump success, fail;
+    if (isAccessor) {
+        GPRReg callFrameRegister = static_cast&lt;GPRReg&gt;(stubInfo.patch.callFrameRegister);
+        if (slot.isCacheableGetter()) {
+            stubJit.setupArguments(callFrameRegister, scratchGPR, resultGPR);
+            operationFunction = operationCallGetter;
+        } else {
+            stubJit.move(MacroAssembler::TrustedImmPtr(protoObject), scratchGPR);
+            stubJit.setupArguments(callFrameRegister, scratchGPR,
+                MacroAssembler::TrustedImmPtr(FunctionPtr(slot.customGetter()).executableAddress()),
+                MacroAssembler::TrustedImmPtr(propertyName.impl()));
+            operationFunction = operationCallCustomGetter;
+        }
</ins><span class="cx"> 
</span><del>-    MacroAssembler::Jump success, fail;
-    
</del><ins>+        // Need to make sure that whenever this call is made in the future, we remember the
+        // place that we made it from. It just so happens to be the place that we are at
+        // right now!
+        stubJit.store32(MacroAssembler::TrustedImm32(exec-&gt;locationAsRawBits()),
+            CCallHelpers::tagFor(static_cast&lt;VirtualRegister&gt;(JSStack::ArgumentCount)));
+
+        operationCall = stubJit.call();
+#if USE(JSVALUE64)
+        stubJit.move(GPRInfo::returnValueGPR, resultGPR);
+#else
+        stubJit.setupResults(resultGPR, resultTagGPR);
+#endif
+        MacroAssembler::Jump noException = stubJit.emitExceptionCheck(CCallHelpers::InvertedExceptionCheck);
+
+        stubJit.setupArgumentsExecState();
+        handlerCall = stubJit.call();
+        stubJit.jumpToExceptionHandler();
+        
+        noException.link(&amp;stubJit);
+    }
</ins><span class="cx">     emitRestoreScratch(stubJit, needToRestoreScratch, scratchGPR, success, fail, failureCases);
</span><span class="cx">     
</span><span class="cx">     LinkBuffer patchBuffer(*vm, &amp;stubJit, exec-&gt;codeBlock());
</span><span class="cx">     
</span><span class="cx">     linkRestoreScratch(patchBuffer, needToRestoreScratch, success, fail, failureCases, successLabel, slowCaseLabel);
</span><del>-    
</del><ins>+    if (isAccessor) {
+        patchBuffer.link(operationCall, operationFunction);
+        patchBuffer.link(handlerCall, lookupExceptionHandler);
+    }
</ins><span class="cx">     stubRoutine = FINALIZE_CODE_FOR_DFG_STUB(
</span><span class="cx">         patchBuffer,
</span><span class="cx">         (&quot;DFG prototype chain access stub for %s, return point %p&quot;,
</span><span class="cx">             toCString(*exec-&gt;codeBlock()).data(), successLabel.executableAddress()));
</span><ins>+    return ProtoChainGenerationSucceeded;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier&amp; propertyName, const PropertySlot&amp; slot, StructureStubInfo&amp; stubInfo)
</span><span class="lines">@@ -393,25 +443,31 @@
</span><span class="cx">     
</span><span class="cx">     if (structure-&gt;isDictionary())
</span><span class="cx">         return false;
</span><ins>+
+    if (!stubInfo.patch.registersFlushed) {
+        // We cannot do as much inline caching if the registers were not flushed prior to this GetById. In particular,
+        // non-Value cached properties require planting calls, which requires registers to have been flushed. Thus,
+        // if registers were not flushed, don't do non-Value caching.
+        if (!slot.isCacheableValue())
+            return false;
+    }
</ins><span class="cx">     
</span><del>-    // FIXME: optimize getters and setters
-    if (!slot.isCacheableValue())
-        return false;
-    
</del><span class="cx">     PropertyOffset offset = slot.cachedOffset();
</span><span class="cx">     size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), propertyName, offset);
</span><span class="cx">     if (count == InvalidPrototypeChain)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     StructureChain* prototypeChain = structure-&gt;prototypeChain(exec);
</span><ins>+    if (generateProtoChainAccessStub(exec, slot, propertyName, stubInfo, prototypeChain, count, offset,
+        structure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone),
+        stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase), stubInfo.stubRoutine) == ProtoChainGenerationFailed)
+        return false;
</ins><span class="cx">     
</span><del>-    generateProtoChainAccessStub(exec, stubInfo, prototypeChain, count, offset, structure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToSlowCase), stubInfo.stubRoutine, propertyName);
-    
</del><span class="cx">     RepatchBuffer repatchBuffer(codeBlock);
</span><span class="cx">     replaceWithJump(repatchBuffer, stubInfo, stubInfo.stubRoutine-&gt;code().code());
</span><span class="cx">     repatchCall(repatchBuffer, stubInfo.callReturnLocation, operationGetByIdBuildList);
</span><span class="cx">     
</span><del>-    stubInfo.initGetByIdChain(*vm, codeBlock-&gt;ownerExecutable(), structure, prototypeChain, count, true);
</del><ins>+    stubInfo.initGetByIdChain(*vm, codeBlock-&gt;ownerExecutable(), structure, prototypeChain, count, slot.isCacheableValue());
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -629,9 +685,17 @@
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (baseValue.asCell()-&gt;structure()-&gt;typeInfo().prohibitsPropertyCaching()
</span><del>-        || baseValue.asCell()-&gt;structure()-&gt;isDictionary()
-        || !slot.isCacheableValue())
</del><ins>+        || baseValue.asCell()-&gt;structure()-&gt;isDictionary())
</ins><span class="cx">         return false;
</span><ins>+    
+    if (!stubInfo.patch.registersFlushed) {
+        // We cannot do as much inline caching if the registers were not flushed prior to this GetById. In particular,
+        // non-Value cached properties require planting calls, which requires registers to have been flushed. Thus,
+        // if registers were not flushed, don't do non-Value caching.
+        if (!slot.isCacheableValue())
+            return false;
+    }
+    
</ins><span class="cx"> 
</span><span class="cx">     PropertyOffset offset = slot.cachedOffset();
</span><span class="cx">     size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), ident, offset);
</span><span class="lines">@@ -650,9 +714,12 @@
</span><span class="cx">     
</span><span class="cx">     RefPtr&lt;JITStubRoutine&gt; stubRoutine;
</span><span class="cx">     
</span><del>-    generateProtoChainAccessStub(exec, stubInfo, prototypeChain, count, offset, structure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone), slowCase, stubRoutine, ident);
</del><ins>+    if (generateProtoChainAccessStub(exec, slot, ident, stubInfo, prototypeChain, count, offset, structure,
+        stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone),
+        slowCase, stubRoutine) == ProtoChainGenerationFailed)
+        return false;
</ins><span class="cx">     
</span><del>-    polymorphicStructureList-&gt;list[listIndex].set(*vm, codeBlock-&gt;ownerExecutable(), stubRoutine, structure, true);
</del><ins>+    polymorphicStructureList-&gt;list[listIndex].set(*vm, codeBlock-&gt;ownerExecutable(), stubRoutine, structure, slot.isCacheableValue());
</ins><span class="cx">     
</span><span class="cx">     patchJumpToGetByIdStub(codeBlock, stubInfo, stubRoutine.get());
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/Tools/ChangeLog        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2013-12-16  Oliver Hunt  &lt;oliver@apple.com&gt;
+
+        Cache getters and custom accessors on the prototype chain
+        https://bugs.webkit.org/show_bug.cgi?id=125602
+
+        Reviewed by Michael Saboff.
+
+        Make sure bencher scripts also make noInline exist
+
+        * Scripts/bencher:
+
</ins><span class="cx"> 2013-12-16  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix crash when trying to load a null HTML string
</span></span></pre></div>
<a id="trunkToolsScriptsbencher"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/bencher (160669 => 160670)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/bencher        2013-12-16 23:54:09 UTC (rev 160669)
+++ trunk/Tools/Scripts/bencher        2013-12-17 00:01:01 UTC (rev 160670)
</span><span class="lines">@@ -661,7 +661,9 @@
</span><span class="cx">       else
</span><span class="cx">         raise
</span><span class="cx">       end
</span><del>-      
</del><ins>+
+      doublePuts($stderr,file,&quot;if (typeof noInline == 'undefined') noInline = function(){};&quot;)
+
</ins><span class="cx">       if benchDataPath
</span><span class="cx">         doublePuts($stderr,file,&quot;load(#{benchDataPath.inspect});&quot;)
</span><span class="cx">         doublePuts($stderr,file,&quot;gc();&quot;)
</span><span class="lines">@@ -720,6 +722,7 @@
</span><span class="cx">       doublePuts($stderr,file,&quot;if (window.testRunner) {&quot;)
</span><span class="cx">       doublePuts($stderr,file,&quot;    testRunner.dumpAsText(window.enablePixelTesting);&quot;)
</span><span class="cx">       doublePuts($stderr,file,&quot;    testRunner.waitUntilDone();&quot;)
</span><ins>+      doublePuts($stderr,file,&quot;    noInline = testRunner.neverInlineFunction || function(){};&quot;)
</ins><span class="cx">       doublePuts($stderr,file,&quot;}&quot;)
</span><span class="cx">       doublePuts($stderr,file,&quot;&quot;)
</span><span class="cx">       doublePuts($stderr,file,&quot;function debug(msg)&quot;)
</span><span class="lines">@@ -749,7 +752,7 @@
</span><span class="cx">       if benchDataPath
</span><span class="cx">         doublePuts($stderr,file,&quot;        testFrame.contentDocument.write(\&quot;&lt;script src=\\\&quot;#{benchDataPath}\\\&quot;&gt;&lt;/script&gt;\&quot;);&quot;)
</span><span class="cx">       end
</span><del>-      doublePuts($stderr,file,&quot;        testFrame.contentDocument.write(\&quot;&lt;script type=\\\&quot;text/javascript\\\&quot;&gt;__bencher_before = Date.now();&lt;/script&gt;&lt;script src=\\\&quot;#{benchPath}\\\&quot;&gt;&lt;/script&gt;&lt;script type=\\\&quot;text/javascript\\\&quot;&gt;window.parent.reportResult(Date.now() - __bencher_before);&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;\&quot;);&quot;)
</del><ins>+      doublePuts($stderr,file,&quot;        testFrame.contentDocument.write(\&quot;&lt;script type=\\\&quot;text/javascript\\\&quot;&gt;if (window.testRunner) noInline=window.testRunner.neverInlineFunction || function(){}; if (typeof noInline == 'undefined') noInline=function(){}; __bencher_before = Date.now();&lt;/script&gt;&lt;script src=\\\&quot;#{benchPath}\\\&quot;&gt;&lt;/script&gt;&lt;script type=\\\&quot;text/javascript\\\&quot;&gt;window.parent.reportResult(Date.now() - __bencher_before);&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;\&quot;);&quot;)
</ins><span class="cx">       doublePuts($stderr,file,&quot;        testFrame.contentDocument.close();&quot;)
</span><span class="cx">       doublePuts($stderr,file,&quot;    }&quot;)
</span><span class="cx">       doublePuts($stderr,file,&quot;    __bencher_continuation = continuation;&quot;)
</span></span></pre>
</div>
</div>

</body>
</html>