<!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>[200422] 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/200422">200422</a></dd>
<dt>Author</dt> <dd>keith_miller@apple.com</dd>
<dt>Date</dt> <dd>2016-05-04 10:59:10 -0700 (Wed, 04 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Speedup array iterators
https://bugs.webkit.org/show_bug.cgi?id=157315

Reviewed by Michael Saboff.

Source/JavaScriptCore:

This patch improves the performance of Array iterators in ES6. There are two main changes
that make things faster. The first is that the value, keys and entries functions have been
moved to JS. This enables us to inline the construction of the iterator. Thus, when we get
to the FTL we are able to sink the allocation of the iterator object. This significantly
improves the performance of any for-of loop since we are now able to have both the iteration
counter and the iterated object in local variables rather than in the heap.

Secondly, instead of using a number to store the iteratation kind we now use a virtual
method on the iteration object to indicate which next function to use. This ends up being
helpful because it means we can eliminate the branches in the old next function that decide
what value to return. With those branches gone the various next functions are now small
enough to inline. Once the next functions are inlined then the FTL is able to sink the
allocation of next() result object. There is still room for optimization in the loop since
we currently don't recognize that the array access in the next function is in bounds or that
the increment to the loop counter cannot overflow.

The overall performance changes appear to be a ~4-6x speedup in a simple microbenchmark that
computes the sum of an array with some extra arithmetic. The variance depends on the exact
body of the loop. Additionally, on a new regress test that changes all the loops in
deltablue into for-of loops this patch is a 1.8x progression. Overall, it still looks like
for-of loops are significantly slower than an indexed for loop. In the first test it's ~2-4x
slower with the difference depending on the body of the loop. If the loop is just the sum
then we see a much larger regression than if the loop does even simple arithmetic. It looks
like the indexed for loop without extra arithmetic is small enough to fit into the x86
replay buffer on my machine, which would explain why there is such a big difference between
the for of loop in that case. On the deltablue benchmark it's 1.4x slower. It's clear from
these numbers that there is still a lot of work we can do to make for of loops faster.

This patch also makes some changes to the way that we decorate our builtin js
functions. Instead of the old syntax (putting the decorated values in [] before the function
declaration i.e. [intrinsic=foo]) this patch changes the syntax to be closer to the way that
decorators are proposed in a future ECMAScript proposal (using @ followed by the entry on a
new line before the function declaration i.e. @intrinsic=foo).

Finally, in the builtin scripts regular expressions re.S has been changed to re.DOTALL since
DOTALL is easier to understand without going to the reference page for python regular
expressions.

* Scripts/builtins/builtins_model.py:
* builtins/ArrayIteratorPrototype.js:
(next):
(arrayIteratorValueNext):
(arrayIteratorKeyNext):
(arrayIteratorKeyValueNext):
* builtins/ArrayPrototype.js:
(createArrayIterator):
(values):
(keys):
(entries):
* builtins/RegExpPrototype.js:
(intrinsic.RegExpTestIntrinsic.test):
* builtins/StringPrototype.js:
(intrinsic.StringPrototypeReplaceIntrinsic.replace):
* builtins/TypedArrayPrototype.js:
(values):
(keys):
(entries):
* inspector/JSInjectedScriptHost.cpp:
(Inspector::cloneArrayIteratorObject):
(Inspector::JSInjectedScriptHost::iteratorEntries):
* jit/ThunkGenerators.cpp:
* runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::finishCreation):
(JSC::arrayProtoFuncValues): Deleted.
(JSC::arrayProtoFuncEntries): Deleted.
(JSC::arrayProtoFuncKeys): Deleted.
* runtime/CommonIdentifiers.h:
* runtime/JSArrayIterator.cpp:
(JSC::JSArrayIterator::clone): Deleted.
* runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
(JSC::genericTypedArrayViewProtoFuncEntries): Deleted.
(JSC::genericTypedArrayViewProtoFuncKeys): Deleted.
(JSC::typedArrayViewProtoFuncValues): Deleted.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSTypedArrayViewPrototype.cpp:
(JSC::JSTypedArrayViewPrototype::finishCreation):
(JSC::typedArrayViewProtoFuncEntries): Deleted.
(JSC::typedArrayViewProtoFuncKeys): Deleted.
(JSC::typedArrayViewProtoFuncValues): Deleted.
* runtime/MapPrototype.cpp:
(JSC::MapPrototype::finishCreation):
* runtime/SetPrototype.cpp:
(JSC::SetPrototype::finishCreation):

LayoutTests:

Add a new regression test for for-of iterators in ES6. The test is a
modification of the deltablue benchmark that converts all the
loops on Arrays into for-of loops.

* js/regress/deltablue-for-of-expected.txt: Added.
* js/regress/deltablue-for-of.html: Added.
* js/regress/script-tests/deltablue-for-of.js: Added.
(Object.prototype.inheritsFrom):
(OrderedCollection):
(OrderedCollection.prototype.add):
(OrderedCollection.prototype.at):
(OrderedCollection.prototype.size):
(OrderedCollection.prototype.removeFirst):
(OrderedCollection.prototype.remove):
(Strength):
(Strength.stronger):
(Strength.weaker):
(Strength.weakestOf):
(Strength.strongest):
(Strength.prototype.nextWeaker):
(Constraint):
(Constraint.prototype.addConstraint):
(Constraint.prototype.satisfy):
(Constraint.prototype.destroyConstraint):
(Constraint.prototype.isInput):
(UnaryConstraint):
(UnaryConstraint.prototype.addToGraph):
(UnaryConstraint.prototype.chooseMethod):
(UnaryConstraint.prototype.isSatisfied):
(UnaryConstraint.prototype.markInputs):
(UnaryConstraint.prototype.output):
(UnaryConstraint.prototype.recalculate):
(UnaryConstraint.prototype.markUnsatisfied):
(UnaryConstraint.prototype.inputsKnown):
(UnaryConstraint.prototype.removeFromGraph):
(StayConstraint):
(StayConstraint.prototype.execute):
(EditConstraint.prototype.isInput):
(EditConstraint.prototype.execute):
(BinaryConstraint):
(BinaryConstraint.prototype.chooseMethod):
(BinaryConstraint.prototype.addToGraph):
(BinaryConstraint.prototype.isSatisfied):
(BinaryConstraint.prototype.markInputs):
(BinaryConstraint.prototype.input):
(BinaryConstraint.prototype.output):
(BinaryConstraint.prototype.recalculate):
(BinaryConstraint.prototype.markUnsatisfied):
(BinaryConstraint.prototype.inputsKnown):
(BinaryConstraint.prototype.removeFromGraph):
(ScaleConstraint):
(ScaleConstraint.prototype.addToGraph):
(ScaleConstraint.prototype.removeFromGraph):
(ScaleConstraint.prototype.markInputs):
(ScaleConstraint.prototype.execute):
(ScaleConstraint.prototype.recalculate):
(EqualityConstraint):
(EqualityConstraint.prototype.execute):
(Variable):
(Variable.prototype.addConstraint):
(Variable.prototype.removeConstraint):
(Planner):
(Planner.prototype.incrementalAdd):
(Planner.prototype.incrementalRemove):
(Planner.prototype.newMark):
(Planner.prototype.makePlan):
(Planner.prototype.extractPlanFromConstraints):
(Planner.prototype.addPropagate):
(Planner.prototype.removePropagateFrom):
(Planner.prototype.addConstraintsConsumingTo):
(Plan):
(Plan.prototype.addConstraint):
(Plan.prototype.size):
(Plan.prototype.constraintAt):
(Plan.prototype.execute):
(chainTest):
(projectionTest):
(change):
(deltaBlue):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreScriptsbuiltinsbuiltins_modelpy">trunk/Source/JavaScriptCore/Scripts/builtins/builtins_model.py</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsArrayIteratorPrototypejs">trunk/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsArrayPrototypejs">trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsRegExpPrototypejs">trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsStringPrototypejs">trunk/Source/JavaScriptCore/builtins/StringPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsTypedArrayPrototypejs">trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp">trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitThunkGeneratorscpp">trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeArrayPrototypecpp">trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSArrayIteratorcpp">trunk/Source/JavaScriptCore/runtime/JSArrayIterator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGenericTypedArrayViewPrototypeFunctionsh">trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjecth">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSTypedArrayViewPrototypecpp">trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeMapPrototypecpp">trunk/Source/JavaScriptCore/runtime/MapPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeSetPrototypecpp">trunk/Source/JavaScriptCore/runtime/SetPrototype.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsregressdeltablueforofexpectedtxt">trunk/LayoutTests/js/regress/deltablue-for-of-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregressdeltablueforofhtml">trunk/LayoutTests/js/regress/deltablue-for-of.html</a></li>
<li><a href="#trunkLayoutTestsjsregressscripttestsdeltablueforofjs">trunk/LayoutTests/js/regress/script-tests/deltablue-for-of.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/LayoutTests/ChangeLog        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,3 +1,90 @@
</span><ins>+2016-05-04  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Speedup array iterators
+        https://bugs.webkit.org/show_bug.cgi?id=157315
+
+        Reviewed by Michael Saboff.
+
+        Add a new regression test for for-of iterators in ES6. The test is a
+        modification of the deltablue benchmark that converts all the
+        loops on Arrays into for-of loops.
+
+        * js/regress/deltablue-for-of-expected.txt: Added.
+        * js/regress/deltablue-for-of.html: Added.
+        * js/regress/script-tests/deltablue-for-of.js: Added.
+        (Object.prototype.inheritsFrom):
+        (OrderedCollection):
+        (OrderedCollection.prototype.add):
+        (OrderedCollection.prototype.at):
+        (OrderedCollection.prototype.size):
+        (OrderedCollection.prototype.removeFirst):
+        (OrderedCollection.prototype.remove):
+        (Strength):
+        (Strength.stronger):
+        (Strength.weaker):
+        (Strength.weakestOf):
+        (Strength.strongest):
+        (Strength.prototype.nextWeaker):
+        (Constraint):
+        (Constraint.prototype.addConstraint):
+        (Constraint.prototype.satisfy):
+        (Constraint.prototype.destroyConstraint):
+        (Constraint.prototype.isInput):
+        (UnaryConstraint):
+        (UnaryConstraint.prototype.addToGraph):
+        (UnaryConstraint.prototype.chooseMethod):
+        (UnaryConstraint.prototype.isSatisfied):
+        (UnaryConstraint.prototype.markInputs):
+        (UnaryConstraint.prototype.output):
+        (UnaryConstraint.prototype.recalculate):
+        (UnaryConstraint.prototype.markUnsatisfied):
+        (UnaryConstraint.prototype.inputsKnown):
+        (UnaryConstraint.prototype.removeFromGraph):
+        (StayConstraint):
+        (StayConstraint.prototype.execute):
+        (EditConstraint.prototype.isInput):
+        (EditConstraint.prototype.execute):
+        (BinaryConstraint):
+        (BinaryConstraint.prototype.chooseMethod):
+        (BinaryConstraint.prototype.addToGraph):
+        (BinaryConstraint.prototype.isSatisfied):
+        (BinaryConstraint.prototype.markInputs):
+        (BinaryConstraint.prototype.input):
+        (BinaryConstraint.prototype.output):
+        (BinaryConstraint.prototype.recalculate):
+        (BinaryConstraint.prototype.markUnsatisfied):
+        (BinaryConstraint.prototype.inputsKnown):
+        (BinaryConstraint.prototype.removeFromGraph):
+        (ScaleConstraint):
+        (ScaleConstraint.prototype.addToGraph):
+        (ScaleConstraint.prototype.removeFromGraph):
+        (ScaleConstraint.prototype.markInputs):
+        (ScaleConstraint.prototype.execute):
+        (ScaleConstraint.prototype.recalculate):
+        (EqualityConstraint):
+        (EqualityConstraint.prototype.execute):
+        (Variable):
+        (Variable.prototype.addConstraint):
+        (Variable.prototype.removeConstraint):
+        (Planner):
+        (Planner.prototype.incrementalAdd):
+        (Planner.prototype.incrementalRemove):
+        (Planner.prototype.newMark):
+        (Planner.prototype.makePlan):
+        (Planner.prototype.extractPlanFromConstraints):
+        (Planner.prototype.addPropagate):
+        (Planner.prototype.removePropagateFrom):
+        (Planner.prototype.addConstraintsConsumingTo):
+        (Plan):
+        (Plan.prototype.addConstraint):
+        (Plan.prototype.size):
+        (Plan.prototype.constraintAt):
+        (Plan.prototype.execute):
+        (chainTest):
+        (projectionTest):
+        (change):
+        (deltaBlue):
+
</ins><span class="cx"> 2016-05-04  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking imported/w3c/web-platform-tests/html/dom/interfaces.html as failing on ios-simulator release builds
</span></span></pre></div>
<a id="trunkLayoutTestsjsregressdeltablueforofexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/deltablue-for-of-expected.txt (0 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/deltablue-for-of-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/regress/deltablue-for-of-expected.txt        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+JSRegress/deltablue-for-of
+
+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="trunkLayoutTestsjsregressdeltablueforofhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/deltablue-for-of.html (0 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/deltablue-for-of.html                                (rev 0)
+++ trunk/LayoutTests/js/regress/deltablue-for-of.html        2016-05-04 17:59:10 UTC (rev 200422)
</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/deltablue-for-of.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="trunkLayoutTestsjsregressscripttestsdeltablueforofjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress/script-tests/deltablue-for-of.js (0 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress/script-tests/deltablue-for-of.js                                (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/deltablue-for-of.js        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -0,0 +1,870 @@
</span><ins>+// Copyright 2008 the V8 project authors. All rights reserved.
+// Copyright 1996 John Maloney and Mario Wolczko.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+// This implementation of the DeltaBlue benchmark is derived
+// from the Smalltalk implementation by John Maloney and Mario
+// Wolczko. Some parts have been translated directly, whereas
+// others have been modified more aggresively to make it feel
+// more like a JavaScript program.
+
+/**
+ * A JavaScript implementation of the DeltaBlue constraint-solving
+ * algorithm, as described in:
+ *
+ * &quot;The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver&quot;
+ *   Bjorn N. Freeman-Benson and John Maloney
+ *   January 1990 Communications of the ACM,
+ *   also available as University of Washington TR 89-08-06.
+ *
+ * Beware: this benchmark is written in a grotesque style where
+ * the constraint model is built by side-effects from constructors.
+ * I've kept it this way to avoid deviating too much from the original
+ * implementation.
+ */
+
+
+/* --- O b j e c t   M o d e l --- */
+
+Object.prototype.inheritsFrom = function (shuper) {
+  function Inheriter() { }
+  Inheriter.prototype = shuper.prototype;
+  this.prototype = new Inheriter();
+  this.superConstructor = shuper;
+}
+
+function OrderedCollection() {
+  this.elms = new Array();
+}
+
+OrderedCollection.prototype.add = function (elm) {
+  this.elms.push(elm);
+}
+
+OrderedCollection.prototype.at = function (index) {
+  return this.elms[index];
+}
+
+OrderedCollection.prototype.size = function () {
+  return this.elms.length;
+}
+
+OrderedCollection.prototype.removeFirst = function () {
+  return this.elms.pop();
+}
+
+OrderedCollection.prototype.remove = function (elm) {
+  var index = 0, skipped = 0;
+  for (var value of this.elms) {
+    if (value != elm) {
+      this.elms[index] = value;
+      index++;
+    } else {
+      skipped++;
+    }
+  }
+  for (var i = 0; i &lt; skipped; i++)
+    this.elms.pop();
+}
+
+/* --- *
+ * S t r e n g t h
+ * --- */
+
+/**
+ * Strengths are used to measure the relative importance of constraints.
+ * New strengths may be inserted in the strength hierarchy without
+ * disrupting current constraints.  Strengths cannot be created outside
+ * this class, so pointer comparison can be used for value comparison.
+ */
+function Strength(strengthValue, name) {
+  this.strengthValue = strengthValue;
+  this.name = name;
+}
+
+Strength.stronger = function (s1, s2) {
+  return s1.strengthValue &lt; s2.strengthValue;
+}
+
+Strength.weaker = function (s1, s2) {
+  return s1.strengthValue &gt; s2.strengthValue;
+}
+
+Strength.weakestOf = function (s1, s2) {
+  return this.weaker(s1, s2) ? s1 : s2;
+}
+
+Strength.strongest = function (s1, s2) {
+  return this.stronger(s1, s2) ? s1 : s2;
+}
+
+Strength.prototype.nextWeaker = function () {
+  switch (this.strengthValue) {
+    case 0: return Strength.WEAKEST;
+    case 1: return Strength.WEAK_DEFAULT;
+    case 2: return Strength.NORMAL;
+    case 3: return Strength.STRONG_DEFAULT;
+    case 4: return Strength.PREFERRED;
+    case 5: return Strength.REQUIRED;
+  }
+}
+
+// Strength constants.
+Strength.REQUIRED        = new Strength(0, &quot;required&quot;);
+Strength.STONG_PREFERRED = new Strength(1, &quot;strongPreferred&quot;);
+Strength.PREFERRED       = new Strength(2, &quot;preferred&quot;);
+Strength.STRONG_DEFAULT  = new Strength(3, &quot;strongDefault&quot;);
+Strength.NORMAL          = new Strength(4, &quot;normal&quot;);
+Strength.WEAK_DEFAULT    = new Strength(5, &quot;weakDefault&quot;);
+Strength.WEAKEST         = new Strength(6, &quot;weakest&quot;);
+
+/* --- *
+ * C o n s t r a i n t
+ * --- */
+
+/**
+ * An abstract class representing a system-maintainable relationship
+ * (or &quot;constraint&quot;) between a set of variables. A constraint supplies
+ * a strength instance variable; concrete subclasses provide a means
+ * of storing the constrained variables and other information required
+ * to represent a constraint.
+ */
+function Constraint(strength) {
+  this.strength = strength;
+}
+
+/**
+ * Activate this constraint and attempt to satisfy it.
+ */
+Constraint.prototype.addConstraint = function () {
+  this.addToGraph();
+  planner.incrementalAdd(this);
+}
+
+/**
+ * Attempt to find a way to enforce this constraint. If successful,
+ * record the solution, perhaps modifying the current dataflow
+ * graph. Answer the constraint that this constraint overrides, if
+ * there is one, or nil, if there isn't.
+ * Assume: I am not already satisfied.
+ */
+Constraint.prototype.satisfy = function (mark) {
+  this.chooseMethod(mark);
+  if (!this.isSatisfied()) {
+    if (this.strength == Strength.REQUIRED)
+      alert(&quot;Could not satisfy a required constraint!&quot;);
+    return null;
+  }
+  this.markInputs(mark);
+  var out = this.output();
+  var overridden = out.determinedBy;
+  if (overridden != null) overridden.markUnsatisfied();
+  out.determinedBy = this;
+  if (!planner.addPropagate(this, mark))
+    alert(&quot;Cycle encountered&quot;);
+  out.mark = mark;
+  return overridden;
+}
+
+Constraint.prototype.destroyConstraint = function () {
+  if (this.isSatisfied()) planner.incrementalRemove(this);
+  else this.removeFromGraph();
+}
+
+/**
+ * Normal constraints are not input constraints.  An input constraint
+ * is one that depends on external state, such as the mouse, the
+ * keybord, a clock, or some arbitraty piece of imperative code.
+ */
+Constraint.prototype.isInput = function () {
+  return false;
+}
+
+/* --- *
+ * U n a r y   C o n s t r a i n t
+ * --- */
+
+/**
+ * Abstract superclass for constraints having a single possible output
+ * variable.
+ */
+function UnaryConstraint(v, strength) {
+  UnaryConstraint.superConstructor.call(this, strength);
+  this.myOutput = v;
+  this.satisfied = false;
+  this.addConstraint();
+}
+
+UnaryConstraint.inheritsFrom(Constraint);
+
+/**
+ * Adds this constraint to the constraint graph
+ */
+UnaryConstraint.prototype.addToGraph = function () {
+  this.myOutput.addConstraint(this);
+  this.satisfied = false;
+}
+
+/**
+ * Decides if this constraint can be satisfied and records that
+ * decision.
+ */
+UnaryConstraint.prototype.chooseMethod = function (mark) {
+  this.satisfied = (this.myOutput.mark != mark)
+    &amp;&amp; Strength.stronger(this.strength, this.myOutput.walkStrength);
+}
+
+/**
+ * Returns true if this constraint is satisfied in the current solution.
+ */
+UnaryConstraint.prototype.isSatisfied = function () {
+  return this.satisfied;
+}
+
+UnaryConstraint.prototype.markInputs = function (mark) {
+  // has no inputs
+}
+
+/**
+ * Returns the current output variable.
+ */
+UnaryConstraint.prototype.output = function () {
+  return this.myOutput;
+}
+
+/**
+ * Calculate the walkabout strength, the stay flag, and, if it is
+ * 'stay', the value for the current output of this constraint. Assume
+ * this constraint is satisfied.
+ */
+UnaryConstraint.prototype.recalculate = function () {
+  this.myOutput.walkStrength = this.strength;
+  this.myOutput.stay = !this.isInput();
+  if (this.myOutput.stay) this.execute(); // Stay optimization
+}
+
+/**
+ * Records that this constraint is unsatisfied
+ */
+UnaryConstraint.prototype.markUnsatisfied = function () {
+  this.satisfied = false;
+}
+
+UnaryConstraint.prototype.inputsKnown = function () {
+  return true;
+}
+
+UnaryConstraint.prototype.removeFromGraph = function () {
+  if (this.myOutput != null) this.myOutput.removeConstraint(this);
+  this.satisfied = false;
+}
+
+/* --- *
+ * S t a y   C o n s t r a i n t
+ * --- */
+
+/**
+ * Variables that should, with some level of preference, stay the same.
+ * Planners may exploit the fact that instances, if satisfied, will not
+ * change their output during plan execution.  This is called &quot;stay
+ * optimization&quot;.
+ */
+function StayConstraint(v, str) {
+  StayConstraint.superConstructor.call(this, v, str);
+}
+
+StayConstraint.inheritsFrom(UnaryConstraint);
+
+StayConstraint.prototype.execute = function () {
+  // Stay constraints do nothing
+}
+
+/* --- *
+ * E d i t   C o n s t r a i n t
+ * --- */
+
+/**
+ * A unary input constraint used to mark a variable that the client
+ * wishes to change.
+ */
+function EditConstraint(v, str) {
+  EditConstraint.superConstructor.call(this, v, str);
+}
+
+EditConstraint.inheritsFrom(UnaryConstraint);
+
+/**
+ * Edits indicate that a variable is to be changed by imperative code.
+ */
+EditConstraint.prototype.isInput = function () {
+  return true;
+}
+
+EditConstraint.prototype.execute = function () {
+  // Edit constraints do nothing
+}
+
+/* --- *
+ * B i n a r y   C o n s t r a i n t
+ * --- */
+
+var Direction = new Object();
+Direction.NONE     = 0;
+Direction.FORWARD  = 1;
+Direction.BACKWARD = -1;
+
+/**
+ * Abstract superclass for constraints having two possible output
+ * variables.
+ */
+function BinaryConstraint(var1, var2, strength) {
+  BinaryConstraint.superConstructor.call(this, strength);
+  this.v1 = var1;
+  this.v2 = var2;
+  this.direction = Direction.NONE;
+  this.addConstraint();
+}
+
+BinaryConstraint.inheritsFrom(Constraint);
+
+/**
+ * Decides if this constraint can be satisfied and which way it
+ * should flow based on the relative strength of the variables related,
+ * and record that decision.
+ */
+BinaryConstraint.prototype.chooseMethod = function (mark) {
+  if (this.v1.mark == mark) {
+    this.direction = (this.v2.mark != mark &amp;&amp; Strength.stronger(this.strength, this.v2.walkStrength))
+      ? Direction.FORWARD
+      : Direction.NONE;
+  }
+  if (this.v2.mark == mark) {
+    this.direction = (this.v1.mark != mark &amp;&amp; Strength.stronger(this.strength, this.v1.walkStrength))
+      ? Direction.BACKWARD
+      : Direction.NONE;
+  }
+  if (Strength.weaker(this.v1.walkStrength, this.v2.walkStrength)) {
+    this.direction = Strength.stronger(this.strength, this.v1.walkStrength)
+      ? Direction.BACKWARD
+      : Direction.NONE;
+  } else {
+    this.direction = Strength.stronger(this.strength, this.v2.walkStrength)
+      ? Direction.FORWARD
+      : Direction.BACKWARD
+  }
+}
+
+/**
+ * Add this constraint to the constraint graph
+ */
+BinaryConstraint.prototype.addToGraph = function () {
+  this.v1.addConstraint(this);
+  this.v2.addConstraint(this);
+  this.direction = Direction.NONE;
+}
+
+/**
+ * Answer true if this constraint is satisfied in the current solution.
+ */
+BinaryConstraint.prototype.isSatisfied = function () {
+  return this.direction != Direction.NONE;
+}
+
+/**
+ * Mark the input variable with the given mark.
+ */
+BinaryConstraint.prototype.markInputs = function (mark) {
+  this.input().mark = mark;
+}
+
+/**
+ * Returns the current input variable
+ */
+BinaryConstraint.prototype.input = function () {
+  return (this.direction == Direction.FORWARD) ? this.v1 : this.v2;
+}
+
+/**
+ * Returns the current output variable
+ */
+BinaryConstraint.prototype.output = function () {
+  return (this.direction == Direction.FORWARD) ? this.v2 : this.v1;
+}
+
+/**
+ * Calculate the walkabout strength, the stay flag, and, if it is
+ * 'stay', the value for the current output of this
+ * constraint. Assume this constraint is satisfied.
+ */
+BinaryConstraint.prototype.recalculate = function () {
+  var ihn = this.input(), out = this.output();
+  out.walkStrength = Strength.weakestOf(this.strength, ihn.walkStrength);
+  out.stay = ihn.stay;
+  if (out.stay) this.execute();
+}
+
+/**
+ * Record the fact that this constraint is unsatisfied.
+ */
+BinaryConstraint.prototype.markUnsatisfied = function () {
+  this.direction = Direction.NONE;
+}
+
+BinaryConstraint.prototype.inputsKnown = function (mark) {
+  var i = this.input();
+  return i.mark == mark || i.stay || i.determinedBy == null;
+}
+
+BinaryConstraint.prototype.removeFromGraph = function () {
+  if (this.v1 != null) this.v1.removeConstraint(this);
+  if (this.v2 != null) this.v2.removeConstraint(this);
+  this.direction = Direction.NONE;
+}
+
+/* --- *
+ * S c a l e   C o n s t r a i n t
+ * --- */
+
+/**
+ * Relates two variables by the linear scaling relationship: &quot;v2 =
+ * (v1 * scale) + offset&quot;. Either v1 or v2 may be changed to maintain
+ * this relationship but the scale factor and offset are considered
+ * read-only.
+ */
+function ScaleConstraint(src, scale, offset, dest, strength) {
+  this.direction = Direction.NONE;
+  this.scale = scale;
+  this.offset = offset;
+  ScaleConstraint.superConstructor.call(this, src, dest, strength);
+}
+
+ScaleConstraint.inheritsFrom(BinaryConstraint);
+
+/**
+ * Adds this constraint to the constraint graph.
+ */
+ScaleConstraint.prototype.addToGraph = function () {
+  ScaleConstraint.superConstructor.prototype.addToGraph.call(this);
+  this.scale.addConstraint(this);
+  this.offset.addConstraint(this);
+}
+
+ScaleConstraint.prototype.removeFromGraph = function () {
+  ScaleConstraint.superConstructor.prototype.removeFromGraph.call(this);
+  if (this.scale != null) this.scale.removeConstraint(this);
+  if (this.offset != null) this.offset.removeConstraint(this);
+}
+
+ScaleConstraint.prototype.markInputs = function (mark) {
+  ScaleConstraint.superConstructor.prototype.markInputs.call(this, mark);
+  this.scale.mark = this.offset.mark = mark;
+}
+
+/**
+ * Enforce this constraint. Assume that it is satisfied.
+ */
+ScaleConstraint.prototype.execute = function () {
+  if (this.direction == Direction.FORWARD) {
+    this.v2.value = this.v1.value * this.scale.value + this.offset.value;
+  } else {
+    this.v1.value = (this.v2.value - this.offset.value) / this.scale.value;
+  }
+}
+
+/**
+ * Calculate the walkabout strength, the stay flag, and, if it is
+ * 'stay', the value for the current output of this constraint. Assume
+ * this constraint is satisfied.
+ */
+ScaleConstraint.prototype.recalculate = function () {
+  var ihn = this.input(), out = this.output();
+  out.walkStrength = Strength.weakestOf(this.strength, ihn.walkStrength);
+  out.stay = ihn.stay &amp;&amp; this.scale.stay &amp;&amp; this.offset.stay;
+  if (out.stay) this.execute();
+}
+
+/* --- *
+ * E q u a l i t  y   C o n s t r a i n t
+ * --- */
+
+/**
+ * Constrains two variables to have the same value.
+ */
+function EqualityConstraint(var1, var2, strength) {
+  EqualityConstraint.superConstructor.call(this, var1, var2, strength);
+}
+
+EqualityConstraint.inheritsFrom(BinaryConstraint);
+
+/**
+ * Enforce this constraint. Assume that it is satisfied.
+ */
+EqualityConstraint.prototype.execute = function () {
+  this.output().value = this.input().value;
+}
+
+/* --- *
+ * V a r i a b l e
+ * --- */
+
+/**
+ * A constrained variable. In addition to its value, it maintain the
+ * structure of the constraint graph, the current dataflow graph, and
+ * various parameters of interest to the DeltaBlue incremental
+ * constraint solver.
+ **/
+function Variable(name, initialValue) {
+  this.value = initialValue || 0;
+  this.constraints = new OrderedCollection();
+  this.determinedBy = null;
+  this.mark = 0;
+  this.walkStrength = Strength.WEAKEST;
+  this.stay = true;
+  this.name = name;
+}
+
+/**
+ * Add the given constraint to the set of all constraints that refer
+ * this variable.
+ */
+Variable.prototype.addConstraint = function (c) {
+  this.constraints.add(c);
+}
+
+/**
+ * Removes all traces of c from this variable.
+ */
+Variable.prototype.removeConstraint = function (c) {
+  this.constraints.remove(c);
+  if (this.determinedBy == c) this.determinedBy = null;
+}
+
+/* --- *
+ * P l a n n e r
+ * --- */
+
+/**
+ * The DeltaBlue planner
+ */
+function Planner() {
+  this.currentMark = 0;
+}
+
+/**
+ * Attempt to satisfy the given constraint and, if successful,
+ * incrementally update the dataflow graph.  Details: If satifying
+ * the constraint is successful, it may override a weaker constraint
+ * on its output. The algorithm attempts to resatisfy that
+ * constraint using some other method. This process is repeated
+ * until either a) it reaches a variable that was not previously
+ * determined by any constraint or b) it reaches a constraint that
+ * is too weak to be satisfied using any of its methods. The
+ * variables of constraints that have been processed are marked with
+ * a unique mark value so that we know where we've been. This allows
+ * the algorithm to avoid getting into an infinite loop even if the
+ * constraint graph has an inadvertent cycle.
+ */
+Planner.prototype.incrementalAdd = function (c) {
+  var mark = this.newMark();
+  var overridden = c.satisfy(mark);
+  while (overridden != null)
+    overridden = overridden.satisfy(mark);
+}
+
+/**
+ * Entry point for retracting a constraint. Remove the given
+ * constraint and incrementally update the dataflow graph.
+ * Details: Retracting the given constraint may allow some currently
+ * unsatisfiable downstream constraint to be satisfied. We therefore collect
+ * a list of unsatisfied downstream constraints and attempt to
+ * satisfy each one in turn. This list is traversed by constraint
+ * strength, strongest first, as a heuristic for avoiding
+ * unnecessarily adding and then overriding weak constraints.
+ * Assume: c is satisfied.
+ */
+Planner.prototype.incrementalRemove = function (c) {
+  var out = c.output();
+  c.markUnsatisfied();
+  c.removeFromGraph();
+  var unsatisfied = this.removePropagateFrom(out);
+  var strength = Strength.REQUIRED;
+  do {
+    for (var u of unsatisfied.elms) {
+      if (u.strength == strength)
+        this.incrementalAdd(u);
+    }
+    strength = strength.nextWeaker();
+  } while (strength != Strength.WEAKEST);
+}
+
+/**
+ * Select a previously unused mark value.
+ */
+Planner.prototype.newMark = function () {
+  return ++this.currentMark;
+}
+
+/**
+ * Extract a plan for resatisfaction starting from the given source
+ * constraints, usually a set of input constraints. This method
+ * assumes that stay optimization is desired; the plan will contain
+ * only constraints whose output variables are not stay. Constraints
+ * that do no computation, such as stay and edit constraints, are
+ * not included in the plan.
+ * Details: The outputs of a constraint are marked when it is added
+ * to the plan under construction. A constraint may be appended to
+ * the plan when all its input variables are known. A variable is
+ * known if either a) the variable is marked (indicating that has
+ * been computed by a constraint appearing earlier in the plan), b)
+ * the variable is 'stay' (i.e. it is a constant at plan execution
+ * time), or c) the variable is not determined by any
+ * constraint. The last provision is for past states of history
+ * variables, which are not stay but which are also not computed by
+ * any constraint.
+ * Assume: sources are all satisfied.
+ */
+Planner.prototype.makePlan = function (sources) {
+  var mark = this.newMark();
+  var plan = new Plan();
+  var todo = sources;
+  while (todo.size() &gt; 0) {
+    var c = todo.removeFirst();
+    if (c.output().mark != mark &amp;&amp; c.inputsKnown(mark)) {
+      plan.addConstraint(c);
+      c.output().mark = mark;
+      this.addConstraintsConsumingTo(c.output(), todo);
+    }
+  }
+  return plan;
+}
+
+/**
+ * Extract a plan for resatisfying starting from the output of the
+ * given constraints, usually a set of input constraints.
+ */
+Planner.prototype.extractPlanFromConstraints = function (constraints) {
+  var sources = new OrderedCollection();
+  for (var c of constraints.elms) {
+    if (c.isInput() &amp;&amp; c.isSatisfied())
+      // not in plan already and eligible for inclusion
+      sources.add(c);
+  }
+  return this.makePlan(sources);
+}
+
+/**
+ * Recompute the walkabout strengths and stay flags of all variables
+ * downstream of the given constraint and recompute the actual
+ * values of all variables whose stay flag is true. If a cycle is
+ * detected, remove the given constraint and answer
+ * false. Otherwise, answer true.
+ * Details: Cycles are detected when a marked variable is
+ * encountered downstream of the given constraint. The sender is
+ * assumed to have marked the inputs of the given constraint with
+ * the given mark. Thus, encountering a marked node downstream of
+ * the output constraint means that there is a path from the
+ * constraint's output to one of its inputs.
+ */
+Planner.prototype.addPropagate = function (c, mark) {
+  var todo = new OrderedCollection();
+  todo.add(c);
+  while (todo.size() &gt; 0) {
+    var d = todo.removeFirst();
+    if (d.output().mark == mark) {
+      this.incrementalRemove(c);
+      return false;
+    }
+    d.recalculate();
+    this.addConstraintsConsumingTo(d.output(), todo);
+  }
+  return true;
+}
+
+
+/**
+ * Update the walkabout strengths and stay flags of all variables
+ * downstream of the given constraint. Answer a collection of
+ * unsatisfied constraints sorted in order of decreasing strength.
+ */
+Planner.prototype.removePropagateFrom = function (out) {
+  out.determinedBy = null;
+  out.walkStrength = Strength.WEAKEST;
+  out.stay = true;
+  var unsatisfied = new OrderedCollection();
+  var todo = new OrderedCollection();
+  todo.add(out);
+  while (todo.size() &gt; 0) {
+    var v = todo.removeFirst();
+    for (var c of v.constraints.elms) {
+      if (!c.isSatisfied())
+        unsatisfied.add(c);
+    }
+    var determining = v.determinedBy;
+    for (var next of v.constraints.elms) {
+      if (next != determining &amp;&amp; next.isSatisfied()) {
+        next.recalculate();
+        todo.add(next.output());
+      }
+    }
+  }
+  return unsatisfied;
+}
+
+Planner.prototype.addConstraintsConsumingTo = function (v, coll) {
+  var determining = v.determinedBy;
+  var cc = v.constraints;
+  for (var c of cc.elms) {
+    if (c != determining &amp;&amp; c.isSatisfied())
+      coll.add(c);
+  }
+}
+
+/* --- *
+ * P l a n
+ * --- */
+
+/**
+ * A Plan is an ordered list of constraints to be executed in sequence
+ * to resatisfy all currently satisfiable constraints in the face of
+ * one or more changing inputs.
+ */
+function Plan() {
+  this.v = new OrderedCollection();
+}
+
+Plan.prototype.addConstraint = function (c) {
+  this.v.add(c);
+}
+
+Plan.prototype.size = function () {
+  return this.v.size();
+}
+
+Plan.prototype.constraintAt = function (index) {
+  return this.v.at(index);
+}
+
+Plan.prototype.execute = function () {
+  for (var c of this.v.elms) {
+    c.execute();
+  }
+}
+
+/* --- *
+ * M a i n
+ * --- */
+
+/**
+ * This is the standard DeltaBlue benchmark. A long chain of equality
+ * constraints is constructed with a stay constraint on one end. An
+ * edit constraint is then added to the opposite end and the time is
+ * measured for adding and removing this constraint, and extracting
+ * and executing a constraint satisfaction plan. There are two cases.
+ * In case 1, the added constraint is stronger than the stay
+ * constraint and values must propagate down the entire length of the
+ * chain. In case 2, the added constraint is weaker than the stay
+ * constraint so it cannot be accomodated. The cost in this case is,
+ * of course, very low. Typical situations lie somewhere between these
+ * two extremes.
+ */
+function chainTest(n) {
+  planner = new Planner();
+  var prev = null, first = null, last = null;
+
+  // Build chain of n equality constraints
+  for (var i = 0; i &lt;= n; i++) {
+    var name = &quot;v&quot; + i;
+    var v = new Variable(name);
+    if (prev != null)
+      new EqualityConstraint(prev, v, Strength.REQUIRED);
+    if (i == 0) first = v;
+    if (i == n) last = v;
+    prev = v;
+  }
+
+  new StayConstraint(last, Strength.STRONG_DEFAULT);
+  var edit = new EditConstraint(first, Strength.PREFERRED);
+  var edits = new OrderedCollection();
+  edits.add(edit);
+  var plan = planner.extractPlanFromConstraints(edits);
+  for (var i = 0; i &lt; 100; i++) {
+    first.value = i;
+    plan.execute();
+    if (last.value != i)
+      alert(&quot;Chain test failed.&quot;);
+  }
+}
+
+/**
+ * This test constructs a two sets of variables related to each
+ * other by a simple linear transformation (scale and offset). The
+ * time is measured to change a variable on either side of the
+ * mapping and to change the scale and offset factors.
+ */
+function projectionTest(n) {
+  planner = new Planner();
+  var scale = new Variable(&quot;scale&quot;, 10);
+  var offset = new Variable(&quot;offset&quot;, 1000);
+  var src = null, dst = null;
+
+  var dests = new OrderedCollection();
+  for (var i = 0; i &lt; n; i++) {
+    src = new Variable(&quot;src&quot; + i, i);
+    dst = new Variable(&quot;dst&quot; + i, i);
+    dests.add(dst);
+    new StayConstraint(src, Strength.NORMAL);
+    new ScaleConstraint(src, scale, offset, dst, Strength.REQUIRED);
+  }
+
+  change(src, 17);
+  if (dst.value != 1170) alert(&quot;Projection 1 failed&quot;);
+  change(dst, 1050);
+  if (src.value != 5) alert(&quot;Projection 2 failed&quot;);
+  change(scale, 5);
+  for (var i = 0; i &lt; n - 1; i++) {
+    if (dests.at(i).value != i * 5 + 1000)
+      alert(&quot;Projection 3 failed&quot;);
+  }
+  change(offset, 2000);
+  for (var i = 0; i &lt; n - 1; i++) {
+    if (dests.at(i).value != i * 5 + 2000)
+      alert(&quot;Projection 4 failed&quot;);
+  }
+}
+
+function change(v, newValue) {
+  var edit = new EditConstraint(v, Strength.PREFERRED);
+  var edits = new OrderedCollection();
+  edits.add(edit);
+  var plan = planner.extractPlanFromConstraints(edits);
+  for (var i = 0; i &lt; 10; i++) {
+    v.value = newValue;
+    plan.execute();
+  }
+  edit.destroyConstraint();
+}
+
+// Global variable holding the current planner.
+var planner = null;
+
+function deltaBlue() {
+  chainTest(100);
+  projectionTest(100);
+}
+
+//for (var i = 0; i &lt; 100; ++i)
+//    deltaBlue();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,3 +1,96 @@
</span><ins>+2016-05-04  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Speedup array iterators
+        https://bugs.webkit.org/show_bug.cgi?id=157315
+
+        Reviewed by Michael Saboff.
+
+        This patch improves the performance of Array iterators in ES6. There are two main changes
+        that make things faster. The first is that the value, keys and entries functions have been
+        moved to JS. This enables us to inline the construction of the iterator. Thus, when we get
+        to the FTL we are able to sink the allocation of the iterator object. This significantly
+        improves the performance of any for-of loop since we are now able to have both the iteration
+        counter and the iterated object in local variables rather than in the heap.
+
+        Secondly, instead of using a number to store the iteratation kind we now use a virtual
+        method on the iteration object to indicate which next function to use. This ends up being
+        helpful because it means we can eliminate the branches in the old next function that decide
+        what value to return. With those branches gone the various next functions are now small
+        enough to inline. Once the next functions are inlined then the FTL is able to sink the
+        allocation of next() result object. There is still room for optimization in the loop since
+        we currently don't recognize that the array access in the next function is in bounds or that
+        the increment to the loop counter cannot overflow.
+
+        The overall performance changes appear to be a ~4-6x speedup in a simple microbenchmark that
+        computes the sum of an array with some extra arithmetic. The variance depends on the exact
+        body of the loop. Additionally, on a new regress test that changes all the loops in
+        deltablue into for-of loops this patch is a 1.8x progression. Overall, it still looks like
+        for-of loops are significantly slower than an indexed for loop. In the first test it's ~2-4x
+        slower with the difference depending on the body of the loop. If the loop is just the sum
+        then we see a much larger regression than if the loop does even simple arithmetic. It looks
+        like the indexed for loop without extra arithmetic is small enough to fit into the x86
+        replay buffer on my machine, which would explain why there is such a big difference between
+        the for of loop in that case. On the deltablue benchmark it's 1.4x slower. It's clear from
+        these numbers that there is still a lot of work we can do to make for of loops faster.
+
+        This patch also makes some changes to the way that we decorate our builtin js
+        functions. Instead of the old syntax (putting the decorated values in [] before the function
+        declaration i.e. [intrinsic=foo]) this patch changes the syntax to be closer to the way that
+        decorators are proposed in a future ECMAScript proposal (using @ followed by the entry on a
+        new line before the function declaration i.e. @intrinsic=foo).
+
+        Finally, in the builtin scripts regular expressions re.S has been changed to re.DOTALL since
+        DOTALL is easier to understand without going to the reference page for python regular
+        expressions.
+
+        * Scripts/builtins/builtins_model.py:
+        * builtins/ArrayIteratorPrototype.js:
+        (next):
+        (arrayIteratorValueNext):
+        (arrayIteratorKeyNext):
+        (arrayIteratorKeyValueNext):
+        * builtins/ArrayPrototype.js:
+        (createArrayIterator):
+        (values):
+        (keys):
+        (entries):
+        * builtins/RegExpPrototype.js:
+        (intrinsic.RegExpTestIntrinsic.test):
+        * builtins/StringPrototype.js:
+        (intrinsic.StringPrototypeReplaceIntrinsic.replace):
+        * builtins/TypedArrayPrototype.js:
+        (values):
+        (keys):
+        (entries):
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::cloneArrayIteratorObject):
+        (Inspector::JSInjectedScriptHost::iteratorEntries):
+        * jit/ThunkGenerators.cpp:
+        * runtime/ArrayPrototype.cpp:
+        (JSC::ArrayPrototype::finishCreation):
+        (JSC::arrayProtoFuncValues): Deleted.
+        (JSC::arrayProtoFuncEntries): Deleted.
+        (JSC::arrayProtoFuncKeys): Deleted.
+        * runtime/CommonIdentifiers.h:
+        * runtime/JSArrayIterator.cpp:
+        (JSC::JSArrayIterator::clone): Deleted.
+        * runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
+        (JSC::genericTypedArrayViewProtoFuncEntries): Deleted.
+        (JSC::genericTypedArrayViewProtoFuncKeys): Deleted.
+        (JSC::typedArrayViewProtoFuncValues): Deleted.
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        * runtime/JSGlobalObject.h:
+        * runtime/JSTypedArrayViewPrototype.cpp:
+        (JSC::JSTypedArrayViewPrototype::finishCreation):
+        (JSC::typedArrayViewProtoFuncEntries): Deleted.
+        (JSC::typedArrayViewProtoFuncKeys): Deleted.
+        (JSC::typedArrayViewProtoFuncValues): Deleted.
+        * runtime/MapPrototype.cpp:
+        (JSC::MapPrototype::finishCreation):
+        * runtime/SetPrototype.cpp:
+        (JSC::SetPrototype::finishCreation):
+
</ins><span class="cx"> 2016-05-04  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Object constructor need to be aware of new.target
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreScriptsbuiltinsbuiltins_modelpy"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/Scripts/builtins/builtins_model.py (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/Scripts/builtins/builtins_model.py        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/Scripts/builtins/builtins_model.py        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> #!/usr/bin/env python
</span><span class="cx"> #
</span><del>-# Copyright (c) 2015 Apple Inc. All rights reserved.
</del><ins>+# Copyright (c) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> #
</span><span class="cx"> # Redistribution and use in source and binary forms, with or without
</span><span class="cx"> # modification, are permitted provided that the following conditions
</span><span class="lines">@@ -40,19 +40,19 @@
</span><span class="cx">     },
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-functionHeadRegExp = re.compile(r&quot;(\[intrinsic=\w+\]\s+)?(?:function|constructor)\s+\w+\s*\(.*?\)&quot;, re.MULTILINE | re.S)
-functionIntrinsicRegExp = re.compile(r&quot;^\[intrinsic=(\w+)\]\s+&quot;, re.MULTILINE | re.S)
-functionNameRegExp = re.compile(r&quot;(?:function|constructor)\s+(\w+)\s*\(&quot;, re.MULTILINE | re.S)
-functionIsConstructorRegExp = re.compile(r&quot;^constructor&quot;, re.MULTILINE | re.S)
-functionParameterFinder = re.compile(r&quot;^(?:function|constructor)\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)&quot;, re.MULTILINE | re.S)
</del><ins>+functionHeadRegExp = re.compile(r&quot;(?:@[\w|=]+\s*\n)*(?:function)\s+\w+\s*\(.*?\)&quot;, re.MULTILINE | re.DOTALL)
+functionIntrinsicRegExp = re.compile(r&quot;^@intrinsic=(\w+)\s*\n&quot;, re.MULTILINE | re.DOTALL)
+functionIsConstructorRegExp = re.compile(r&quot;^@constructor&quot;, re.MULTILINE | re.DOTALL)
+functionNameRegExp = re.compile(r&quot;(?:function)\s+(\w+)\s*\(&quot;, re.MULTILINE | re.DOTALL)
+functionParameterFinder = re.compile(r&quot;^(?:function)\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)&quot;, re.MULTILINE | re.DOTALL)
</ins><span class="cx"> 
</span><del>-multilineCommentRegExp = re.compile(r&quot;\/\*.*?\*\/&quot;, re.MULTILINE | re.S)
-singleLineCommentRegExp = re.compile(r&quot;\/\/.*?\n&quot;, re.MULTILINE | re.S)
-keyValueAnnotationCommentRegExp = re.compile(r&quot;^\/\/ @(\w+)=([^=]+?)\n&quot;, re.MULTILINE | re.S)
-flagAnnotationCommentRegExp = re.compile(r&quot;^\/\/ @(\w+)[^=]*?\n&quot;, re.MULTILINE | re.S)
-lineWithOnlySingleLineCommentRegExp = re.compile(r&quot;^\s*\/\/\n&quot;, re.MULTILINE | re.S)
-lineWithTrailingSingleLineCommentRegExp = re.compile(r&quot;\s*\/\/\n&quot;, re.MULTILINE | re.S)
-multipleEmptyLinesRegExp = re.compile(r&quot;\n{2,}&quot;, re.MULTILINE | re.S)
</del><ins>+multilineCommentRegExp = re.compile(r&quot;\/\*.*?\*\/&quot;, re.MULTILINE | re.DOTALL)
+singleLineCommentRegExp = re.compile(r&quot;\/\/.*?\n&quot;, re.MULTILINE | re.DOTALL)
+keyValueAnnotationCommentRegExp = re.compile(r&quot;^\/\/ @(\w+)=([^=]+?)\n&quot;, re.MULTILINE | re.DOTALL)
+flagAnnotationCommentRegExp = re.compile(r&quot;^\/\/ @(\w+)[^=]*?\n&quot;, re.MULTILINE | re.DOTALL)
+lineWithOnlySingleLineCommentRegExp = re.compile(r&quot;^\s*\/\/\n&quot;, re.MULTILINE | re.DOTALL)
+lineWithTrailingSingleLineCommentRegExp = re.compile(r&quot;\s*\/\/\n&quot;, re.MULTILINE | re.DOTALL)
+multipleEmptyLinesRegExp = re.compile(r&quot;\n{2,}&quot;, re.MULTILINE | re.DOTALL)
</ins><span class="cx"> 
</span><span class="cx"> class ParseException(Exception):
</span><span class="cx">     pass
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsArrayIteratorPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2015 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;.
</span><ins>+ * Copyright (C) 2016a Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,33 +29,77 @@
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span><span class="cx">     if (this == null)
</span><del>-        throw new @TypeError(&quot;%ArrayIteratorPrototype%.next requires that |this| not be null or undefined&quot;);
</del><ins>+        throw @TypeError(&quot;%ArrayIteratorPrototype%.next requires that |this| not be null or undefined&quot;);
</ins><span class="cx"> 
</span><del>-    var itemKind = this.@arrayIterationKind;
-    if (itemKind === @undefined)
-        throw new @TypeError(&quot;%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance&quot;);
</del><ins>+    let next = this.@arrayIteratorNext;
+    if (next === @undefined)
+        throw @TypeError(&quot;%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance&quot;);
</ins><span class="cx"> 
</span><ins>+    return next.@call(this);
+}
+
+function arrayIteratorValueNext()
+{
+    &quot;use strict&quot;;
</ins><span class="cx">     var done = true;
</span><span class="cx">     var value = @undefined;
</span><span class="cx"> 
</span><span class="cx">     var array = this.@iteratedObject;
</span><del>-    if (array !== @undefined) {
</del><ins>+    if (!this.@arrayIteratorIsDone) {
</ins><span class="cx">         var index = this.@arrayIteratorNextIndex;
</span><span class="cx">         var length = array.length &gt;&gt;&gt; 0;
</span><span class="cx">         if (index &gt;= length) {
</span><del>-            this.@iteratedObject = @undefined;
</del><ins>+            this.@arrayIteratorIsDone = true;
</ins><span class="cx">         } else {
</span><span class="cx">             this.@arrayIteratorNextIndex = index + 1;
</span><span class="cx">             done = false;
</span><del>-            if (itemKind === @arrayIterationKindKey) {
-                value = index;
-            } else if (itemKind === @arrayIterationKindValue) {
-                value = array[index];
-            } else {
-                value = [ index, array[index] ];
-            }
</del><ins>+            value = array[index];
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return {done, value};
</del><ins>+    return { done, value };
</ins><span class="cx"> }
</span><ins>+
+function arrayIteratorKeyNext()
+{
+    &quot;use strict&quot;;
+    var done = true;
+    var value = @undefined;
+
+    var array = this.@iteratedObject;
+    if (!this.@arrayIteratorIsDone) {
+        var index = this.@arrayIteratorNextIndex;
+        var length = array.length &gt;&gt;&gt; 0;
+        if (index &gt;= length) {
+            this.@arrayIteratorIsDone = true;
+        } else {
+            this.@arrayIteratorNextIndex = index + 1;
+            done = false;
+            value = index;
+        }
+    }
+
+    return { done, value };
+}
+
+function arrayIteratorKeyValueNext()
+{
+    &quot;use strict&quot;;
+    var done = true;
+    var value = @undefined;
+
+    var array = this.@iteratedObject;
+    if (!this.@arrayIteratorIsDone) {
+        var index = this.@arrayIteratorNextIndex;
+        var length = array.length &gt;&gt;&gt; 0;
+        if (index &gt;= length) {
+            this.@arrayIteratorIsDone = true;
+        } else {
+            this.@arrayIteratorNextIndex = index + 1;
+            done = false;
+            value = [ index, array[index] ];
+        }
+    }
+
+    return { done, value };
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsArrayPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2015 Yusuke Suzuki &lt;utatane.tea@gmail.com&gt;.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -24,6 +24,50 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+@constructor
+function createArrayIterator(iteratedObject, iterationFunction)
+{
+    this.@iteratedObject = iteratedObject;
+    this.@arrayIteratorNextIndex = 0;
+    this.@arrayIteratorNext = iterationFunction;
+    this.@arrayIteratorIsDone = false;
+}
+
+function values()
+{
+    &quot;use strict&quot;;
+    if (this == null) {
+        if (this === null)
+            throw new @TypeError(&quot;Array.prototype.values requires that |this| not be null&quot;);
+        throw new @TypeError(&quot;Array.prototype.values requires that |this| not be undefined&quot;);
+    }
+    return new @createArrayIterator(@Object(this), @arrayIteratorValueNext);
+}
+
+function keys()
+{
+    &quot;use strict&quot;;
+    if (this == null) {
+        if (this === null)
+            throw new @TypeError(&quot;Array.prototype.keys requires that |this| not be null&quot;);
+        throw new @TypeError(&quot;Array.prototype.keys requires that |this| not be null&quot;);
+    }
+
+    return new @createArrayIterator(@Object(this), @arrayIteratorKeyNext);
+}
+
+function entries()
+{
+    &quot;use strict&quot;;
+    if (this == null) {
+        if (this === null)
+            throw new @TypeError(&quot;Array.prototype.entries requires that |this| not be null&quot;);
+        throw new @TypeError(&quot;Array.prototype.entries requires that |this| not be null&quot;);
+    }
+
+    return new @createArrayIterator(@Object(this), @arrayIteratorKeyValueNext);
+}
+
</ins><span class="cx"> function reduce(callback /*, initialValue */)
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsRegExpPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -489,7 +489,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ES 21.2.5.13 RegExp.prototype.test(string)
</span><del>-[intrinsic=RegExpTestIntrinsic] function test(strArg)
</del><ins>+@intrinsic=RegExpTestIntrinsic
+function test(strArg)
</ins><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsStringPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/StringPrototype.js (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/StringPrototype.js        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/builtins/StringPrototype.js        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -221,7 +221,8 @@
</span><span class="cx">     return !@isRegExpObject(regexp);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-[intrinsic=StringPrototypeReplaceIntrinsic] function replace(search, replace)
</del><ins>+@intrinsic=StringPrototypeReplaceIntrinsic
+function replace(search, replace)
</ins><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsTypedArrayPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/builtins/TypedArrayPrototype.js        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,6 +26,27 @@
</span><span class="cx"> // Note that the intrisic @typedArrayLength checks the that the argument passed is a typed array
</span><span class="cx"> // and throws if it is not.
</span><span class="cx"> 
</span><ins>+function values()
+{
+    &quot;use strict&quot;;
+    @typedArrayLength(this);
+    return new @createArrayIterator(this, @arrayIteratorValueNext);
+}
+
+function keys()
+{
+    &quot;use strict&quot;;
+    @typedArrayLength(this);
+    return new @createArrayIterator(this, @arrayIteratorKeyNext);
+}
+
+function entries()
+{
+    &quot;use strict&quot;;
+    @typedArrayLength(this);
+    return new @createArrayIterator(this, @arrayIteratorKeyValueNext);
+}
+
</ins><span class="cx"> function every(callback /*, thisArg */)
</span><span class="cx"> {
</span><span class="cx">     &quot;use strict&quot;;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;JSInjectedScriptHost.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BuiltinNames.h&quot;
</ins><span class="cx"> #include &quot;DateInstance.h&quot;
</span><span class="cx"> #include &quot;DirectArguments.h&quot;
</span><span class="cx"> #include &quot;Error.h&quot;
</span><span class="lines">@@ -433,16 +434,26 @@
</span><span class="cx">     return array;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static JSObject* cloneArrayIteratorObject(ExecState* exec, VM&amp; vm, JSObject* iteratorObject, JSValue nextIndex)
+{
+    ASSERT(iteratorObject-&gt;type() == FinalObjectType);
+    JSObject* clone = constructEmptyObject(exec, iteratorObject-&gt;structure());
+    clone-&gt;putDirect(vm, vm.propertyNames-&gt;builtinNames().arrayIteratorNextIndexPrivateName(), nextIndex);
+    clone-&gt;putDirect(vm, vm.propertyNames-&gt;builtinNames().iteratedObjectPrivateName(), iteratorObject-&gt;getDirect(vm, vm.propertyNames-&gt;builtinNames().iteratedObjectPrivateName()));
+    clone-&gt;putDirect(vm, vm.propertyNames-&gt;builtinNames().arrayIteratorIsDonePrivateName(), iteratorObject-&gt;getDirect(vm, vm.propertyNames-&gt;builtinNames().arrayIteratorIsDonePrivateName()));
+    clone-&gt;putDirect(vm, vm.propertyNames-&gt;builtinNames().arrayIteratorNextPrivateName(), iteratorObject-&gt;getDirect(vm, vm.propertyNames-&gt;builtinNames().arrayIteratorNextPrivateName()));
+    return clone;
+}
+
</ins><span class="cx"> JSValue JSInjectedScriptHost::iteratorEntries(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     if (exec-&gt;argumentCount() &lt; 1)
</span><span class="cx">         return jsUndefined();
</span><span class="cx"> 
</span><ins>+    VM&amp; vm = exec-&gt;vm();
</ins><span class="cx">     JSValue iterator;
</span><span class="cx">     JSValue value = exec-&gt;uncheckedArgument(0);
</span><del>-    if (JSArrayIterator* arrayIterator = jsDynamicCast&lt;JSArrayIterator*&gt;(value))
-        iterator = arrayIterator-&gt;clone(exec);
-    else if (JSMapIterator* mapIterator = jsDynamicCast&lt;JSMapIterator*&gt;(value))
</del><ins>+    if (JSMapIterator* mapIterator = jsDynamicCast&lt;JSMapIterator*&gt;(value))
</ins><span class="cx">         iterator = mapIterator-&gt;clone(exec);
</span><span class="cx">     else if (JSSetIterator* setIterator = jsDynamicCast&lt;JSSetIterator*&gt;(value))
</span><span class="cx">         iterator = setIterator-&gt;clone(exec);
</span><span class="lines">@@ -452,7 +463,15 @@
</span><span class="cx">         iterator = propertyNameIterator-&gt;clone(exec);
</span><span class="cx">         if (UNLIKELY(exec-&gt;hadException()))
</span><span class="cx">             return JSValue();
</span><del>-    } else
</del><ins>+    } else {
+        if (JSObject* iteratorObject = jsDynamicCast&lt;JSObject*&gt;(value)) {
+            // Array Iterators are created in JS for performance reasons. Thus the only way to know we have one is to
+            // look for a property that is unique to them.
+            if (JSValue nextIndex = iteratorObject-&gt;getDirect(vm, vm.propertyNames-&gt;builtinNames().arrayIteratorNextIndexPrivateName()))
+                iterator = cloneArrayIteratorObject(exec, vm, iteratorObject, nextIndex);
+        }
+    }
+    if (!iterator)
</ins><span class="cx">         return jsUndefined();
</span><span class="cx"> 
</span><span class="cx">     unsigned numberToFetch = 5;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitThunkGeneratorscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include &quot;DFGSpeculativeJIT.h&quot;
</span><span class="cx"> #include &quot;JITOperations.h&quot;
</span><span class="cx"> #include &quot;JSArray.h&quot;
</span><del>-#include &quot;JSArrayIterator.h&quot;
</del><span class="cx"> #include &quot;JSBoundFunction.h&quot;
</span><span class="cx"> #include &quot;JSStack.h&quot;
</span><span class="cx"> #include &quot;MathCommon.h&quot;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeArrayPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -61,8 +61,6 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*);
</span><del>-EncodedJSValue JSC_HOST_CALL arrayProtoFuncKeys(ExecState*);
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncEntries(ExecState*);
</del><span class="cx"> 
</span><span class="cx"> // ------------------------------ ArrayPrototype ----------------------------
</span><span class="cx"> 
</span><span class="lines">@@ -88,7 +86,7 @@
</span><span class="cx">     ASSERT(inherits(info()));
</span><span class="cx">     vm.prototypeMap.addPrototype(this);
</span><span class="cx"> 
</span><del>-    putDirectWithoutTransition(vm, vm.propertyNames-&gt;values, globalObject-&gt;arrayProtoValuesFunction(), DontEnum);
</del><ins>+    putDirectWithoutTransition(vm, vm.propertyNames-&gt;builtinNames().valuesPublicName(), globalObject-&gt;arrayProtoValuesFunction(), DontEnum);
</ins><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;iteratorSymbol, globalObject-&gt;arrayProtoValuesFunction(), DontEnum);
</span><span class="cx">     
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;toString, arrayProtoFuncToString, DontEnum, 0);
</span><span class="lines">@@ -115,8 +113,8 @@
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;reduce&quot;, arrayPrototypeReduceCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;reduceRight&quot;, arrayPrototypeReduceRightCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;map&quot;, arrayPrototypeMapCodeGenerator, DontEnum);
</span><del>-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;entries, arrayProtoFuncEntries, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;keys, arrayProtoFuncKeys, DontEnum, 0);
</del><ins>+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().entriesPublicName(), arrayPrototypeEntriesCodeGenerator, DontEnum);
+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().keysPublicName(), arrayPrototypeKeysCodeGenerator, DontEnum);
</ins><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;find&quot;, arrayPrototypeFindCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;findIndex&quot;, arrayPrototypeFindIndexCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;includes&quot;, arrayPrototypeIncludesCodeGenerator, DontEnum);
</span><span class="lines">@@ -1071,30 +1069,6 @@
</span><span class="cx">     return JSValue::encode(jsNumber(-1));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-EncodedJSValue JSC_HOST_CALL arrayProtoFuncValues(ExecState* exec)
-{
-    JSObject* thisObj = exec-&gt;thisValue().toThis(exec, StrictMode).toObject(exec);
-    if (!thisObj)
-        return JSValue::encode(JSValue());
-    return JSValue::encode(JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), ArrayIterateValue, thisObj));
-}
-
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncEntries(ExecState* exec)
-{
-    JSObject* thisObj = exec-&gt;thisValue().toThis(exec, StrictMode).toObject(exec);
-    if (!thisObj)
-        return JSValue::encode(JSValue());
-    return JSValue::encode(JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), ArrayIterateKeyValue, thisObj));
-}
-    
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncKeys(ExecState* exec)
-{
-    JSObject* thisObj = exec-&gt;thisValue().toThis(exec, StrictMode).toObject(exec);
-    if (!thisObj)
-        return JSValue::encode(JSValue());
-    return JSValue::encode(JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), ArrayIterateKey, thisObj));
-}
-
</del><span class="cx"> // -------------------- ArrayPrototype.constructor Watchpoint ------------------
</span><span class="cx"> 
</span><span class="cx"> class ArrayPrototypeAdaptiveInferredPropertyWatchpoint : public AdaptiveInferredPropertyValueWatchpointBase {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -140,7 +140,6 @@
</span><span class="cx">     macro(displayName) \
</span><span class="cx">     macro(document) \
</span><span class="cx">     macro(done) \
</span><del>-    macro(entries) \
</del><span class="cx">     macro(enumerable) \
</span><span class="cx">     macro(era) \
</span><span class="cx">     macro(eval) \
</span><span class="lines">@@ -181,7 +180,6 @@
</span><span class="cx">     macro(isWatchpoint) \
</span><span class="cx">     macro(jettisonReason) \
</span><span class="cx">     macro(join) \
</span><del>-    macro(keys) \
</del><span class="cx">     macro(lastIndex) \
</span><span class="cx">     macro(length) \
</span><span class="cx">     macro(line) \
</span><span class="lines">@@ -247,7 +245,6 @@
</span><span class="cx">     macro(usage) \
</span><span class="cx">     macro(value) \
</span><span class="cx">     macro(valueOf) \
</span><del>-    macro(values) \
</del><span class="cx">     macro(webkit) \
</span><span class="cx">     macro(webkitIDBCursor) \
</span><span class="cx">     macro(webkitIDBDatabase) \
</span><span class="lines">@@ -333,6 +330,8 @@
</span><span class="cx">     macro(iteratedObject) \
</span><span class="cx">     macro(arrayIteratorNextIndex) \
</span><span class="cx">     macro(arrayIterationKind) \
</span><ins>+    macro(arrayIteratorNext) \
+    macro(arrayIteratorIsDone) \
</ins><span class="cx">     macro(charCodeAt) \
</span><span class="cx">     macro(iteratedString) \
</span><span class="cx">     macro(stringIteratorNextIndex) \
</span><span class="lines">@@ -340,7 +339,6 @@
</span><span class="cx">     macro(fulfillmentHandler) \
</span><span class="cx">     macro(rejectionHandler) \
</span><span class="cx">     macro(index) \
</span><del>-    macro(values) \
</del><span class="cx">     macro(deferred) \
</span><span class="cx">     macro(countdownHolder) \
</span><span class="cx">     macro(Object) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSArrayIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSArrayIterator.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSArrayIterator.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/JSArrayIterator.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -56,15 +56,5 @@
</span><span class="cx">     return getDirect(exec-&gt;vm(), exec-&gt;vm().propertyNames-&gt;iteratedObjectPrivateName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSArrayIterator* JSArrayIterator::clone(ExecState* exec)
-{
-    VM&amp; vm = exec-&gt;vm();
-    JSValue iteratedObject = getDirect(vm, vm.propertyNames-&gt;iteratedObjectPrivateName);
-    JSValue nextIndex = getDirect(vm, vm.propertyNames-&gt;arrayIteratorNextIndexPrivateName);
</del><span class="cx"> 
</span><del>-    auto clone = JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), kind(exec), asObject(iteratedObject));
-    clone-&gt;putDirect(vm, vm.propertyNames-&gt;arrayIteratorNextIndexPrivateName, nextIndex);
-    return clone;
</del><span class="cx"> }
</span><del>-
-}
</del></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGenericTypedArrayViewPrototypeFunctionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -138,17 +138,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename ViewClass&gt;
</span><del>-EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncEntries(ExecState* exec)
-{
-    // 22.2.3.6
-    ViewClass* thisObject = jsCast&lt;ViewClass*&gt;(exec-&gt;thisValue());
-    if (thisObject-&gt;isNeutered())
-        return throwVMTypeError(exec, typedArrayBufferHasBeenDetachedErrorMessage);
-
-    return JSValue::encode(JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), ArrayIterateKeyValue, thisObject));
-}
-
-template&lt;typename ViewClass&gt;
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncCopyWithin(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     // 22.2.3.5
</span><span class="lines">@@ -268,17 +257,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename ViewClass&gt;
</span><del>-EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncKeys(ExecState* exec)
-{
-    // 22.2.3.15
-    ViewClass* thisObject = jsCast&lt;ViewClass*&gt;(exec-&gt;thisValue());
-    if (thisObject-&gt;isNeutered())
-        return throwVMTypeError(exec, typedArrayBufferHasBeenDetachedErrorMessage);
-
-    return JSValue::encode(JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), ArrayIterateKey, thisObject));
-}
-
-template&lt;typename ViewClass&gt;
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncLastIndexOf(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     // 22.2.3.16
</span><span class="lines">@@ -507,17 +485,6 @@
</span><span class="cx">     return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;typename ViewClass&gt;
-EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncValues(ExecState* exec)
-{
-    // 22.2.3.29
-    ViewClass* thisObject = jsCast&lt;ViewClass*&gt;(exec-&gt;thisValue());
-    if (thisObject-&gt;isNeutered())
-        return throwVMTypeError(exec, typedArrayBufferHasBeenDetachedErrorMessage);
-
-    return JSValue::encode(JSArrayIterator::create(exec, exec-&gt;callee()-&gt;globalObject()-&gt;arrayIteratorStructure(), ArrayIterateValue, thisObject));
-}
-
</del><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif /* JSGenericTypedArrayViewPrototypeFunctions_h */
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -303,7 +303,7 @@
</span><span class="cx">     m_functionPrototype-&gt;addFunctionProperties(exec, this, &amp;callFunction, &amp;applyFunction, &amp;hasInstanceSymbolFunction);
</span><span class="cx">     m_callFunction.set(vm, this, callFunction);
</span><span class="cx">     m_applyFunction.set(vm, this, applyFunction);
</span><del>-    m_arrayProtoValuesFunction.set(vm, this, JSFunction::create(vm, this, 0, vm.propertyNames-&gt;values.string(), arrayProtoFuncValues));
</del><ins>+    m_arrayProtoValuesFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, arrayPrototypeValuesCodeGenerator(vm), this));
</ins><span class="cx">     m_initializePromiseFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, promiseOperationsInitializePromiseCodeGenerator(vm), this));
</span><span class="cx">     m_newPromiseCapabilityFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, promiseOperationsNewPromiseCapabilityCodeGenerator(vm), this));
</span><span class="cx">     m_functionProtoHasInstanceSymbolFunction.set(vm, this, hasInstanceSymbolFunction);
</span><span class="lines">@@ -554,6 +554,14 @@
</span><span class="cx">     JSFunction* privateFuncThisNumberValue = JSFunction::create(vm, this, 0, String(), numberProtoFuncValueOf);
</span><span class="cx">     JSFunction* privateFuncIsArrayConstructor = JSFunction::create(vm, this, 0, String(), arrayConstructorPrivateFuncIsArrayConstructor);
</span><span class="cx"> 
</span><ins>+    JSObject* arrayIteratorPrototype = ArrayIteratorPrototype::create(vm, this, ArrayIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
+    JSFunction* privateFuncCreateArrayIterator = JSFunction::createBuiltinFunction(vm, arrayPrototypeCreateArrayIteratorConstructorCodeGenerator(vm), this);
+    privateFuncCreateArrayIterator-&gt;putDirect(vm, vm.propertyNames-&gt;prototype, arrayIteratorPrototype);
+    JSFunction* privateFuncArrayIteratorValueNext = JSFunction::createBuiltinFunction(vm, arrayIteratorPrototypeArrayIteratorValueNextCodeGenerator(vm), this);
+    JSFunction* privateFuncArrayIteratorKeyNext = JSFunction::createBuiltinFunction(vm, arrayIteratorPrototypeArrayIteratorKeyNextCodeGenerator(vm), this);
+    JSFunction* privateFuncArrayIteratorKeyValueNext = JSFunction::createBuiltinFunction(vm, arrayIteratorPrototypeArrayIteratorKeyValueNextCodeGenerator(vm), this);
+
+
</ins><span class="cx">     JSObject* regExpProtoFlagsGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames-&gt;flags);
</span><span class="cx">     JSObject* regExpProtoGlobalGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames-&gt;global);
</span><span class="cx">     m_regExpProtoGlobalGetter.set(vm, this, regExpProtoGlobalGetterObject);
</span><span class="lines">@@ -611,6 +619,10 @@
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;isArrayConstructorPrivateName, privateFuncIsArrayConstructor, DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;MapIteratorPrivateName, JSFunction::create(vm, this, 1, String(), privateFuncMapIterator), DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;mapIteratorNextPrivateName, JSFunction::create(vm, this, 0, String(), privateFuncMapIteratorNext), DontEnum | DontDelete | ReadOnly),
</span><ins>+        GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().arrayIteratorValueNextPrivateName(), privateFuncArrayIteratorValueNext, DontEnum | DontDelete | ReadOnly),
+        GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().arrayIteratorKeyNextPrivateName(), privateFuncArrayIteratorKeyNext, DontEnum | DontDelete | ReadOnly),
+        GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().arrayIteratorKeyValueNextPrivateName(), privateFuncArrayIteratorKeyValueNext, DontEnum | DontDelete | ReadOnly),
+        GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().createArrayIteratorPrivateName(), privateFuncCreateArrayIterator, DontEnum | DontDelete | ReadOnly),
</ins><span class="cx"> 
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().toLengthPrivateName(), privateFuncToLength, DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().toIntegerPrivateName(), privateFuncToInteger, DontEnum | DontDelete | ReadOnly),
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -111,7 +111,6 @@
</span><span class="cx">     DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
</span><span class="cx"> 
</span><span class="cx"> #define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
</span><del>-    DEFINE_STANDARD_BUILTIN(macro, ArrayIterator, arrayIterator) \
</del><span class="cx">     DEFINE_STANDARD_BUILTIN(macro, MapIterator, mapIterator) \
</span><span class="cx">     DEFINE_STANDARD_BUILTIN(macro, SetIterator, setIterator) \
</span><span class="cx">     DEFINE_STANDARD_BUILTIN(macro, StringIterator, stringIterator) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSTypedArrayViewPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;JSTypedArrayViewPrototype.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BuiltinNames.h&quot;
</ins><span class="cx"> #include &quot;CallFrame.h&quot;
</span><span class="cx"> #include &quot;GetterSetter.h&quot;
</span><span class="cx"> #include &quot;JSCellInlines.h&quot;
</span><span class="lines">@@ -96,14 +97,6 @@
</span><span class="cx">     CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSet);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncEntries(ExecState* exec)
-{
-    JSValue thisValue = exec-&gt;thisValue();
-    if (!thisValue.isObject())
-        return throwVMError(exec, createTypeError(exec, &quot;Receiver should be a typed array view but was not an object&quot;));
-    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncEntries);
-}
-
</del><span class="cx"> static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncCopyWithin(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><span class="lines">@@ -144,14 +137,6 @@
</span><span class="cx">     CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncJoin);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncKeys(ExecState* exec)
-{
-    JSValue thisValue = exec-&gt;thisValue();
-    if (!thisValue.isObject())
-        return throwVMError(exec, createTypeError(exec, &quot;Receiver should be a typed array view but was not an object&quot;));
-    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncKeys);
-}
-
</del><span class="cx"> static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoGetterFuncBuffer(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><span class="lines">@@ -208,14 +193,6 @@
</span><span class="cx">     CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSlice);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncValues(ExecState* exec)
-{
-    JSValue thisValue = exec-&gt;thisValue();
-    if (!thisValue.isObject())
-        return throwVMError(exec, createTypeError(exec, &quot;Receiver should be a typed array view but was not an object&quot;));
-    CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(typedArrayViewProtoFuncValues);
-}
-
</del><span class="cx"> static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoGetterFuncToStringTag(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><span class="lines">@@ -270,14 +247,14 @@
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;every&quot;, typedArrayPrototypeEveryCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;filter&quot;, typedArrayPrototypeFilterCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;sort&quot;, typedArrayPrototypeSortCodeGenerator, DontEnum);
</span><del>-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;entries, typedArrayViewProtoFuncEntries, DontEnum, 0);
</del><ins>+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().entriesPublicName(), typedArrayPrototypeEntriesCodeGenerator, DontEnum);
</ins><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;fill&quot;, typedArrayViewProtoFuncFill, DontEnum, 1);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;find&quot;, typedArrayPrototypeFindCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;findIndex&quot;, typedArrayPrototypeFindIndexCodeGenerator, DontEnum);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;forEach, typedArrayPrototypeForEachCodeGenerator, DontEnum);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;indexOf&quot;, typedArrayViewProtoFuncIndexOf, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;join, typedArrayViewProtoFuncJoin, DontEnum, 1);
</span><del>-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;keys, typedArrayViewProtoFuncKeys, DontEnum, 0);
</del><ins>+    JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().keysPublicName(), typedArrayPrototypeKeysCodeGenerator, DontEnum);
</ins><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;lastIndexOf&quot;, typedArrayViewProtoFuncLastIndexOf, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_INTRINSIC_GETTER(vm.propertyNames-&gt;length, typedArrayViewProtoGetterFuncLength, DontEnum | ReadOnly | DontDelete, TypedArrayLengthIntrinsic);
</span><span class="cx">     JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(&quot;map&quot;, typedArrayPrototypeMapCodeGenerator, DontEnum);
</span><span class="lines">@@ -292,9 +269,9 @@
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;toString, arrayProtoFuncToString, DontEnum, 0);
</span><span class="cx">     JSC_NATIVE_GETTER(vm.propertyNames-&gt;toStringTagSymbol, typedArrayViewProtoGetterFuncToStringTag, DontEnum | ReadOnly);
</span><span class="cx"> 
</span><del>-    JSFunction* valuesFunction = JSFunction::create(vm, globalObject, 0, vm.propertyNames-&gt;values.string(), typedArrayViewProtoFuncValues);
</del><ins>+    JSFunction* valuesFunction = JSFunction::createBuiltinFunction(vm, typedArrayPrototypeValuesCodeGenerator(vm), globalObject);
</ins><span class="cx"> 
</span><del>-    putDirectWithoutTransition(vm, vm.propertyNames-&gt;values, valuesFunction, DontEnum);
</del><ins>+    putDirectWithoutTransition(vm, vm.propertyNames-&gt;builtinNames().valuesPublicName(), valuesFunction, DontEnum);
</ins><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;iteratorSymbol, valuesFunction, DontEnum);
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeMapPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/MapPrototype.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/MapPrototype.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/MapPrototype.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;MapPrototype.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BuiltinNames.h&quot;
</ins><span class="cx"> #include &quot;CachedCall.h&quot;
</span><span class="cx"> #include &quot;Error.h&quot;
</span><span class="cx"> #include &quot;ExceptionHelpers.h&quot;
</span><span class="lines">@@ -73,15 +74,15 @@
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;get, mapProtoFuncGet, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;has, mapProtoFuncHas, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;set, mapProtoFuncSet, DontEnum, 2);
</span><del>-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;keys, mapProtoFuncKeys, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;values, mapProtoFuncValues, DontEnum, 0);
</del><ins>+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().keysPublicName(), mapProtoFuncKeys, DontEnum, 0);
+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().valuesPublicName(), mapProtoFuncValues, DontEnum, 0);
</ins><span class="cx"> 
</span><span class="cx">     // Private get / set operations.
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;getPrivateName, mapProtoFuncGet, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;setPrivateName, mapProtoFuncSet, DontEnum, 2);
</span><span class="cx"> 
</span><del>-    JSFunction* entries = JSFunction::create(vm, globalObject, 0, vm.propertyNames-&gt;entries.string(), mapProtoFuncEntries);
-    putDirectWithoutTransition(vm, vm.propertyNames-&gt;entries, entries, DontEnum);
</del><ins>+    JSFunction* entries = JSFunction::create(vm, globalObject, 0, vm.propertyNames-&gt;builtinNames().entriesPublicName().string(), mapProtoFuncEntries);
+    putDirectWithoutTransition(vm, vm.propertyNames-&gt;builtinNames().entriesPublicName(), entries, DontEnum);
</ins><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;iteratorSymbol, entries, DontEnum);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;toStringTagSymbol, jsString(&amp;vm, &quot;Map&quot;), DontEnum | ReadOnly);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeSetPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/SetPrototype.cpp (200421 => 200422)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/SetPrototype.cpp        2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/JavaScriptCore/runtime/SetPrototype.cpp        2016-05-04 17:59:10 UTC (rev 200422)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;SetPrototype.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BuiltinNames.h&quot;
</ins><span class="cx"> #include &quot;CachedCall.h&quot;
</span><span class="cx"> #include &quot;Error.h&quot;
</span><span class="cx"> #include &quot;ExceptionHelpers.h&quot;
</span><span class="lines">@@ -71,11 +72,11 @@
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;clear, setProtoFuncClear, DontEnum, 0);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;deleteKeyword, setProtoFuncDelete, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;has, setProtoFuncHas, DontEnum, 1);
</span><del>-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;entries, setProtoFuncEntries, DontEnum, 0);
</del><ins>+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames-&gt;builtinNames().entriesPublicName(), setProtoFuncEntries, DontEnum, 0);
</ins><span class="cx"> 
</span><del>-    JSFunction* values = JSFunction::create(vm, globalObject, 0, vm.propertyNames-&gt;values.string(), setProtoFuncValues);
-    putDirectWithoutTransition(vm, vm.propertyNames-&gt;values, values, DontEnum);
-    putDirectWithoutTransition(vm, vm.propertyNames-&gt;keys, values, DontEnum);
</del><ins>+    JSFunction* values = JSFunction::create(vm, globalObject, 0, vm.propertyNames-&gt;builtinNames().valuesPublicName().string(), setProtoFuncValues);
+    putDirectWithoutTransition(vm, vm.propertyNames-&gt;builtinNames().valuesPublicName(), values, DontEnum);
+    putDirectWithoutTransition(vm, vm.propertyNames-&gt;builtinNames().keysPublicName(), values, DontEnum);
</ins><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;iteratorSymbol, values, DontEnum);
</span><span class="cx">     putDirectWithoutTransition(vm, vm.propertyNames-&gt;toStringTagSymbol, jsString(&amp;vm, &quot;Set&quot;), DontEnum | ReadOnly);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>