Diff
Modified: trunk/LayoutTests/ChangeLog (200421 => 200422)
--- trunk/LayoutTests/ChangeLog 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/LayoutTests/ChangeLog 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,3 +1,90 @@
+2016-05-04 Keith Miller <[email protected]>
+
+ 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):
+
2016-05-04 Ryan Haddad <[email protected]>
Marking imported/w3c/web-platform-tests/html/dom/interfaces.html as failing on ios-simulator release builds
Added: trunk/LayoutTests/js/regress/deltablue-for-of-expected.txt (0 => 200422)
--- 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)
@@ -0,0 +1,10 @@
+JSRegress/deltablue-for-of
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/regress/deltablue-for-of.html (0 => 200422)
--- 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)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/js/regress/script-tests/deltablue-for-of.js (0 => 200422)
--- 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)
@@ -0,0 +1,870 @@
+// 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:
+ *
+ * "The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver"
+ * 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 < 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 < s2.strengthValue;
+}
+
+Strength.weaker = function (s1, s2) {
+ return s1.strengthValue > 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, "required");
+Strength.STONG_PREFERRED = new Strength(1, "strongPreferred");
+Strength.PREFERRED = new Strength(2, "preferred");
+Strength.STRONG_DEFAULT = new Strength(3, "strongDefault");
+Strength.NORMAL = new Strength(4, "normal");
+Strength.WEAK_DEFAULT = new Strength(5, "weakDefault");
+Strength.WEAKEST = new Strength(6, "weakest");
+
+/* --- *
+ * C o n s t r a i n t
+ * --- */
+
+/**
+ * An abstract class representing a system-maintainable relationship
+ * (or "constraint") 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("Could not satisfy a required constraint!");
+ 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("Cycle encountered");
+ 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)
+ && 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 "stay
+ * optimization".
+ */
+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 && Strength.stronger(this.strength, this.v2.walkStrength))
+ ? Direction.FORWARD
+ : Direction.NONE;
+ }
+ if (this.v2.mark == mark) {
+ this.direction = (this.v1.mark != mark && 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: "v2 =
+ * (v1 * scale) + offset". 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 && this.scale.stay && 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() > 0) {
+ var c = todo.removeFirst();
+ if (c.output().mark != mark && 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() && 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() > 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() > 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 && 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 && 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 <= n; i++) {
+ var name = "v" + 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 < 100; i++) {
+ first.value = i;
+ plan.execute();
+ if (last.value != i)
+ alert("Chain test failed.");
+ }
+}
+
+/**
+ * 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("scale", 10);
+ var offset = new Variable("offset", 1000);
+ var src = "" dst = null;
+
+ var dests = new OrderedCollection();
+ for (var i = 0; i < n; i++) {
+ src = "" Variable("src" + i, i);
+ dst = new Variable("dst" + 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("Projection 1 failed");
+ change(dst, 1050);
+ if (src.value != 5) alert("Projection 2 failed");
+ change(scale, 5);
+ for (var i = 0; i < n - 1; i++) {
+ if (dests.at(i).value != i * 5 + 1000)
+ alert("Projection 3 failed");
+ }
+ change(offset, 2000);
+ for (var i = 0; i < n - 1; i++) {
+ if (dests.at(i).value != i * 5 + 2000)
+ alert("Projection 4 failed");
+ }
+}
+
+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 < 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 < 100; ++i)
+// deltaBlue();
Modified: trunk/Source/_javascript_Core/ChangeLog (200421 => 200422)
--- trunk/Source/_javascript_Core/ChangeLog 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,3 +1,96 @@
+2016-05-04 Keith Miller <[email protected]>
+
+ 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):
+
2016-05-04 Yusuke Suzuki <[email protected]>
[JSC] Object constructor need to be aware of new.target
Modified: trunk/Source/_javascript_Core/Scripts/builtins/builtins_model.py (200421 => 200422)
--- trunk/Source/_javascript_Core/Scripts/builtins/builtins_model.py 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/Scripts/builtins/builtins_model.py 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright (c) 2015 Apple Inc. All rights reserved.
+# Copyright (c) 2015-2016 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -40,19 +40,19 @@
},
}
-functionHeadRegExp = re.compile(r"(\[intrinsic=\w+\]\s+)?(?:function|constructor)\s+\w+\s*\(.*?\)", re.MULTILINE | re.S)
-functionIntrinsicRegExp = re.compile(r"^\[intrinsic=(\w+)\]\s+", re.MULTILINE | re.S)
-functionNameRegExp = re.compile(r"(?:function|constructor)\s+(\w+)\s*\(", re.MULTILINE | re.S)
-functionIsConstructorRegExp = re.compile(r"^constructor", re.MULTILINE | re.S)
-functionParameterFinder = re.compile(r"^(?:function|constructor)\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)", re.MULTILINE | re.S)
+functionHeadRegExp = re.compile(r"(?:@[\w|=]+\s*\n)*(?:function)\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL)
+functionIntrinsicRegExp = re.compile(r"^@intrinsic=(\w+)\s*\n", re.MULTILINE | re.DOTALL)
+functionIsConstructorRegExp = re.compile(r"^@constructor", re.MULTILINE | re.DOTALL)
+functionNameRegExp = re.compile(r"(?:function)\s+(\w+)\s*\(", re.MULTILINE | re.DOTALL)
+functionParameterFinder = re.compile(r"^(?:function)\s+(?:\w+)\s*\(((?:\s*\w+)?\s*(?:\s*,\s*\w+)*)?\s*\)", re.MULTILINE | re.DOTALL)
-multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.S)
-singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.S)
-keyValueAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)=([^=]+?)\n", re.MULTILINE | re.S)
-flagAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)[^=]*?\n", re.MULTILINE | re.S)
-lineWithOnlySingleLineCommentRegExp = re.compile(r"^\s*\/\/\n", re.MULTILINE | re.S)
-lineWithTrailingSingleLineCommentRegExp = re.compile(r"\s*\/\/\n", re.MULTILINE | re.S)
-multipleEmptyLinesRegExp = re.compile(r"\n{2,}", re.MULTILINE | re.S)
+multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.DOTALL)
+singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.DOTALL)
+keyValueAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)=([^=]+?)\n", re.MULTILINE | re.DOTALL)
+flagAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)[^=]*?\n", re.MULTILINE | re.DOTALL)
+lineWithOnlySingleLineCommentRegExp = re.compile(r"^\s*\/\/\n", re.MULTILINE | re.DOTALL)
+lineWithTrailingSingleLineCommentRegExp = re.compile(r"\s*\/\/\n", re.MULTILINE | re.DOTALL)
+multipleEmptyLinesRegExp = re.compile(r"\n{2,}", re.MULTILINE | re.DOTALL)
class ParseException(Exception):
pass
Modified: trunk/Source/_javascript_Core/builtins/ArrayIteratorPrototype.js (200421 => 200422)
--- trunk/Source/_javascript_Core/builtins/ArrayIteratorPrototype.js 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/builtins/ArrayIteratorPrototype.js 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Yusuke Suzuki <[email protected]>.
+ * Copyright (C) 2016a Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,33 +29,77 @@
"use strict";
if (this == null)
- throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null or undefined");
+ throw @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null or undefined");
- var itemKind = this.@arrayIterationKind;
- if (itemKind === @undefined)
- throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance");
+ let next = this.@arrayIteratorNext;
+ if (next === @undefined)
+ throw @TypeError("%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance");
+ return next.@call(this);
+}
+
+function arrayIteratorValueNext()
+{
+ "use strict";
var done = true;
var value = @undefined;
var array = this.@iteratedObject;
- if (array !== @undefined) {
+ if (!this.@arrayIteratorIsDone) {
var index = this.@arrayIteratorNextIndex;
var length = array.length >>> 0;
if (index >= length) {
- this.@iteratedObject = @undefined;
+ this.@arrayIteratorIsDone = true;
} else {
this.@arrayIteratorNextIndex = index + 1;
done = false;
- if (itemKind === @arrayIterationKindKey) {
- value = index;
- } else if (itemKind === @arrayIterationKindValue) {
- value = array[index];
- } else {
- value = [ index, array[index] ];
- }
+ value = array[index];
}
}
- return {done, value};
+ return { done, value };
}
+
+function arrayIteratorKeyNext()
+{
+ "use strict";
+ var done = true;
+ var value = @undefined;
+
+ var array = this.@iteratedObject;
+ if (!this.@arrayIteratorIsDone) {
+ var index = this.@arrayIteratorNextIndex;
+ var length = array.length >>> 0;
+ if (index >= length) {
+ this.@arrayIteratorIsDone = true;
+ } else {
+ this.@arrayIteratorNextIndex = index + 1;
+ done = false;
+ value = index;
+ }
+ }
+
+ return { done, value };
+}
+
+function arrayIteratorKeyValueNext()
+{
+ "use strict";
+ var done = true;
+ var value = @undefined;
+
+ var array = this.@iteratedObject;
+ if (!this.@arrayIteratorIsDone) {
+ var index = this.@arrayIteratorNextIndex;
+ var length = array.length >>> 0;
+ if (index >= length) {
+ this.@arrayIteratorIsDone = true;
+ } else {
+ this.@arrayIteratorNextIndex = index + 1;
+ done = false;
+ value = [ index, array[index] ];
+ }
+ }
+
+ return { done, value };
+}
Modified: trunk/Source/_javascript_Core/builtins/ArrayPrototype.js (200421 => 200422)
--- trunk/Source/_javascript_Core/builtins/ArrayPrototype.js 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/builtins/ArrayPrototype.js 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
* Copyright (C) 2015 Yusuke Suzuki <[email protected]>.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,6 +24,50 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+@constructor
+function createArrayIterator(iteratedObject, iterationFunction)
+{
+ this.@iteratedObject = iteratedObject;
+ this.@arrayIteratorNextIndex = 0;
+ this.@arrayIteratorNext = iterationFunction;
+ this.@arrayIteratorIsDone = false;
+}
+
+function values()
+{
+ "use strict";
+ if (this == null) {
+ if (this === null)
+ throw new @TypeError("Array.prototype.values requires that |this| not be null");
+ throw new @TypeError("Array.prototype.values requires that |this| not be undefined");
+ }
+ return new @createArrayIterator(@Object(this), @arrayIteratorValueNext);
+}
+
+function keys()
+{
+ "use strict";
+ if (this == null) {
+ if (this === null)
+ throw new @TypeError("Array.prototype.keys requires that |this| not be null");
+ throw new @TypeError("Array.prototype.keys requires that |this| not be null");
+ }
+
+ return new @createArrayIterator(@Object(this), @arrayIteratorKeyNext);
+}
+
+function entries()
+{
+ "use strict";
+ if (this == null) {
+ if (this === null)
+ throw new @TypeError("Array.prototype.entries requires that |this| not be null");
+ throw new @TypeError("Array.prototype.entries requires that |this| not be null");
+ }
+
+ return new @createArrayIterator(@Object(this), @arrayIteratorKeyValueNext);
+}
+
function reduce(callback /*, initialValue */)
{
"use strict";
Modified: trunk/Source/_javascript_Core/builtins/RegExpPrototype.js (200421 => 200422)
--- trunk/Source/_javascript_Core/builtins/RegExpPrototype.js 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/builtins/RegExpPrototype.js 2016-05-04 17:59:10 UTC (rev 200422)
@@ -489,7 +489,8 @@
}
// ES 21.2.5.13 RegExp.prototype.test(string)
-[intrinsic=RegExpTestIntrinsic] function test(strArg)
+@intrinsic=RegExpTestIntrinsic
+function test(strArg)
{
"use strict";
Modified: trunk/Source/_javascript_Core/builtins/StringPrototype.js (200421 => 200422)
--- trunk/Source/_javascript_Core/builtins/StringPrototype.js 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/builtins/StringPrototype.js 2016-05-04 17:59:10 UTC (rev 200422)
@@ -221,7 +221,8 @@
return !@isRegExpObject(regexp);
}
-[intrinsic=StringPrototypeReplaceIntrinsic] function replace(search, replace)
+@intrinsic=StringPrototypeReplaceIntrinsic
+function replace(search, replace)
{
"use strict";
Modified: trunk/Source/_javascript_Core/builtins/TypedArrayPrototype.js (200421 => 200422)
--- trunk/Source/_javascript_Core/builtins/TypedArrayPrototype.js 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/builtins/TypedArrayPrototype.js 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,27 @@
// Note that the intrisic @typedArrayLength checks the that the argument passed is a typed array
// and throws if it is not.
+function values()
+{
+ "use strict";
+ @typedArrayLength(this);
+ return new @createArrayIterator(this, @arrayIteratorValueNext);
+}
+
+function keys()
+{
+ "use strict";
+ @typedArrayLength(this);
+ return new @createArrayIterator(this, @arrayIteratorKeyNext);
+}
+
+function entries()
+{
+ "use strict";
+ @typedArrayLength(this);
+ return new @createArrayIterator(this, @arrayIteratorKeyValueNext);
+}
+
function every(callback /*, thisArg */)
{
"use strict";
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -26,6 +26,7 @@
#include "config.h"
#include "JSInjectedScriptHost.h"
+#include "BuiltinNames.h"
#include "DateInstance.h"
#include "DirectArguments.h"
#include "Error.h"
@@ -433,16 +434,26 @@
return array;
}
+static JSObject* cloneArrayIteratorObject(ExecState* exec, VM& vm, JSObject* iteratorObject, JSValue nextIndex)
+{
+ ASSERT(iteratorObject->type() == FinalObjectType);
+ JSObject* clone = constructEmptyObject(exec, iteratorObject->structure());
+ clone->putDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextIndexPrivateName(), nextIndex);
+ clone->putDirect(vm, vm.propertyNames->builtinNames().iteratedObjectPrivateName(), iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().iteratedObjectPrivateName()));
+ clone->putDirect(vm, vm.propertyNames->builtinNames().arrayIteratorIsDonePrivateName(), iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorIsDonePrivateName()));
+ clone->putDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextPrivateName(), iteratorObject->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextPrivateName()));
+ return clone;
+}
+
JSValue JSInjectedScriptHost::iteratorEntries(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
+ VM& vm = exec->vm();
JSValue iterator;
JSValue value = exec->uncheckedArgument(0);
- if (JSArrayIterator* arrayIterator = jsDynamicCast<JSArrayIterator*>(value))
- iterator = arrayIterator->clone(exec);
- else if (JSMapIterator* mapIterator = jsDynamicCast<JSMapIterator*>(value))
+ if (JSMapIterator* mapIterator = jsDynamicCast<JSMapIterator*>(value))
iterator = mapIterator->clone(exec);
else if (JSSetIterator* setIterator = jsDynamicCast<JSSetIterator*>(value))
iterator = setIterator->clone(exec);
@@ -452,7 +463,15 @@
iterator = propertyNameIterator->clone(exec);
if (UNLIKELY(exec->hadException()))
return JSValue();
- } else
+ } else {
+ if (JSObject* iteratorObject = jsDynamicCast<JSObject*>(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->getDirect(vm, vm.propertyNames->builtinNames().arrayIteratorNextIndexPrivateName()))
+ iterator = cloneArrayIteratorObject(exec, vm, iteratorObject, nextIndex);
+ }
+ }
+ if (!iterator)
return jsUndefined();
unsigned numberToFetch = 5;
Modified: trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -30,7 +30,6 @@
#include "DFGSpeculativeJIT.h"
#include "JITOperations.h"
#include "JSArray.h"
-#include "JSArrayIterator.h"
#include "JSBoundFunction.h"
#include "JSStack.h"
#include "MathCommon.h"
Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -61,8 +61,6 @@
EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState*);
EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState*);
EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState*);
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncKeys(ExecState*);
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncEntries(ExecState*);
// ------------------------------ ArrayPrototype ----------------------------
@@ -88,7 +86,7 @@
ASSERT(inherits(info()));
vm.prototypeMap.addPrototype(this);
- putDirectWithoutTransition(vm, vm.propertyNames->values, globalObject->arrayProtoValuesFunction(), DontEnum);
+ putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPublicName(), globalObject->arrayProtoValuesFunction(), DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, globalObject->arrayProtoValuesFunction(), DontEnum);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toString, arrayProtoFuncToString, DontEnum, 0);
@@ -115,8 +113,8 @@
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("reduce", arrayPrototypeReduceCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("reduceRight", arrayPrototypeReduceRightCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("map", arrayPrototypeMapCodeGenerator, DontEnum);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->entries, arrayProtoFuncEntries, DontEnum, 0);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->keys, arrayProtoFuncKeys, DontEnum, 0);
+ JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().entriesPublicName(), arrayPrototypeEntriesCodeGenerator, DontEnum);
+ JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().keysPublicName(), arrayPrototypeKeysCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("find", arrayPrototypeFindCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("findIndex", arrayPrototypeFindIndexCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("includes", arrayPrototypeIncludesCodeGenerator, DontEnum);
@@ -1071,30 +1069,6 @@
return JSValue::encode(jsNumber(-1));
}
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncValues(ExecState* exec)
-{
- JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (!thisObj)
- return JSValue::encode(JSValue());
- return JSValue::encode(JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), ArrayIterateValue, thisObj));
-}
-
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncEntries(ExecState* exec)
-{
- JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (!thisObj)
- return JSValue::encode(JSValue());
- return JSValue::encode(JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), ArrayIterateKeyValue, thisObj));
-}
-
-EncodedJSValue JSC_HOST_CALL arrayProtoFuncKeys(ExecState* exec)
-{
- JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (!thisObj)
- return JSValue::encode(JSValue());
- return JSValue::encode(JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), ArrayIterateKey, thisObj));
-}
-
// -------------------- ArrayPrototype.constructor Watchpoint ------------------
class ArrayPrototypeAdaptiveInferredPropertyWatchpoint : public AdaptiveInferredPropertyValueWatchpointBase {
Modified: trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h 2016-05-04 17:59:10 UTC (rev 200422)
@@ -140,7 +140,6 @@
macro(displayName) \
macro(document) \
macro(done) \
- macro(entries) \
macro(enumerable) \
macro(era) \
macro(eval) \
@@ -181,7 +180,6 @@
macro(isWatchpoint) \
macro(jettisonReason) \
macro(join) \
- macro(keys) \
macro(lastIndex) \
macro(length) \
macro(line) \
@@ -247,7 +245,6 @@
macro(usage) \
macro(value) \
macro(valueOf) \
- macro(values) \
macro(webkit) \
macro(webkitIDBCursor) \
macro(webkitIDBDatabase) \
@@ -333,6 +330,8 @@
macro(iteratedObject) \
macro(arrayIteratorNextIndex) \
macro(arrayIterationKind) \
+ macro(arrayIteratorNext) \
+ macro(arrayIteratorIsDone) \
macro(charCodeAt) \
macro(iteratedString) \
macro(stringIteratorNextIndex) \
@@ -340,7 +339,6 @@
macro(fulfillmentHandler) \
macro(rejectionHandler) \
macro(index) \
- macro(values) \
macro(deferred) \
macro(countdownHolder) \
macro(Object) \
Modified: trunk/Source/_javascript_Core/runtime/JSArrayIterator.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/JSArrayIterator.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/JSArrayIterator.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -56,15 +56,5 @@
return getDirect(exec->vm(), exec->vm().propertyNames->iteratedObjectPrivateName);
}
-JSArrayIterator* JSArrayIterator::clone(ExecState* exec)
-{
- VM& vm = exec->vm();
- JSValue iteratedObject = getDirect(vm, vm.propertyNames->iteratedObjectPrivateName);
- JSValue nextIndex = getDirect(vm, vm.propertyNames->arrayIteratorNextIndexPrivateName);
- auto clone = JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), kind(exec), asObject(iteratedObject));
- clone->putDirect(vm, vm.propertyNames->arrayIteratorNextIndexPrivateName, nextIndex);
- return clone;
}
-
-}
Modified: trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewPrototypeFunctions.h (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewPrototypeFunctions.h 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewPrototypeFunctions.h 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -138,17 +138,6 @@
}
template<typename ViewClass>
-EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncEntries(ExecState* exec)
-{
- // 22.2.3.6
- ViewClass* thisObject = jsCast<ViewClass*>(exec->thisValue());
- if (thisObject->isNeutered())
- return throwVMTypeError(exec, typedArrayBufferHasBeenDetachedErrorMessage);
-
- return JSValue::encode(JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), ArrayIterateKeyValue, thisObject));
-}
-
-template<typename ViewClass>
EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncCopyWithin(ExecState* exec)
{
// 22.2.3.5
@@ -268,17 +257,6 @@
}
template<typename ViewClass>
-EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncKeys(ExecState* exec)
-{
- // 22.2.3.15
- ViewClass* thisObject = jsCast<ViewClass*>(exec->thisValue());
- if (thisObject->isNeutered())
- return throwVMTypeError(exec, typedArrayBufferHasBeenDetachedErrorMessage);
-
- return JSValue::encode(JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), ArrayIterateKey, thisObject));
-}
-
-template<typename ViewClass>
EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncLastIndexOf(ExecState* exec)
{
// 22.2.3.16
@@ -507,17 +485,6 @@
return JSValue::encode(result);
}
-template<typename ViewClass>
-EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncValues(ExecState* exec)
-{
- // 22.2.3.29
- ViewClass* thisObject = jsCast<ViewClass*>(exec->thisValue());
- if (thisObject->isNeutered())
- return throwVMTypeError(exec, typedArrayBufferHasBeenDetachedErrorMessage);
-
- return JSValue::encode(JSArrayIterator::create(exec, exec->callee()->globalObject()->arrayIteratorStructure(), ArrayIterateValue, thisObject));
-}
-
} // namespace JSC
#endif /* JSGenericTypedArrayViewPrototypeFunctions_h */
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -303,7 +303,7 @@
m_functionPrototype->addFunctionProperties(exec, this, &callFunction, &applyFunction, &hasInstanceSymbolFunction);
m_callFunction.set(vm, this, callFunction);
m_applyFunction.set(vm, this, applyFunction);
- m_arrayProtoValuesFunction.set(vm, this, JSFunction::create(vm, this, 0, vm.propertyNames->values.string(), arrayProtoFuncValues));
+ m_arrayProtoValuesFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, arrayPrototypeValuesCodeGenerator(vm), this));
m_initializePromiseFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, promiseOperationsInitializePromiseCodeGenerator(vm), this));
m_newPromiseCapabilityFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, promiseOperationsNewPromiseCapabilityCodeGenerator(vm), this));
m_functionProtoHasInstanceSymbolFunction.set(vm, this, hasInstanceSymbolFunction);
@@ -554,6 +554,14 @@
JSFunction* privateFuncThisNumberValue = JSFunction::create(vm, this, 0, String(), numberProtoFuncValueOf);
JSFunction* privateFuncIsArrayConstructor = JSFunction::create(vm, this, 0, String(), arrayConstructorPrivateFuncIsArrayConstructor);
+ JSObject* arrayIteratorPrototype = ArrayIteratorPrototype::create(vm, this, ArrayIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
+ JSFunction* privateFuncCreateArrayIterator = JSFunction::createBuiltinFunction(vm, arrayPrototypeCreateArrayIteratorConstructorCodeGenerator(vm), this);
+ privateFuncCreateArrayIterator->putDirect(vm, vm.propertyNames->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);
+
+
JSObject* regExpProtoFlagsGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->flags);
JSObject* regExpProtoGlobalGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->global);
m_regExpProtoGlobalGetter.set(vm, this, regExpProtoGlobalGetterObject);
@@ -611,6 +619,10 @@
GlobalPropertyInfo(vm.propertyNames->isArrayConstructorPrivateName, privateFuncIsArrayConstructor, DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->MapIteratorPrivateName, JSFunction::create(vm, this, 1, String(), privateFuncMapIterator), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->mapIteratorNextPrivateName, JSFunction::create(vm, this, 0, String(), privateFuncMapIteratorNext), DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().arrayIteratorValueNextPrivateName(), privateFuncArrayIteratorValueNext, DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().arrayIteratorKeyNextPrivateName(), privateFuncArrayIteratorKeyNext, DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().arrayIteratorKeyValueNextPrivateName(), privateFuncArrayIteratorKeyValueNext, DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().createArrayIteratorPrivateName(), privateFuncCreateArrayIterator, DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->builtinNames().toLengthPrivateName(), privateFuncToLength, DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->builtinNames().toIntegerPrivateName(), privateFuncToInteger, DontEnum | DontDelete | ReadOnly),
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2016-05-04 17:59:10 UTC (rev 200422)
@@ -111,7 +111,6 @@
DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
#define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
- DEFINE_STANDARD_BUILTIN(macro, ArrayIterator, arrayIterator) \
DEFINE_STANDARD_BUILTIN(macro, MapIterator, mapIterator) \
DEFINE_STANDARD_BUILTIN(macro, SetIterator, setIterator) \
DEFINE_STANDARD_BUILTIN(macro, StringIterator, stringIterator) \
Modified: trunk/Source/_javascript_Core/runtime/JSTypedArrayViewPrototype.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/JSTypedArrayViewPrototype.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/JSTypedArrayViewPrototype.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
#include "config.h"
#include "JSTypedArrayViewPrototype.h"
+#include "BuiltinNames.h"
#include "CallFrame.h"
#include "GetterSetter.h"
#include "JSCellInlines.h"
@@ -96,14 +97,6 @@
CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSet);
}
-static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncEntries(ExecState* exec)
-{
- JSValue thisValue = exec->thisValue();
- if (!thisValue.isObject())
- return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
- CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncEntries);
-}
-
static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncCopyWithin(ExecState* exec)
{
JSValue thisValue = exec->thisValue();
@@ -144,14 +137,6 @@
CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncJoin);
}
-static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncKeys(ExecState* exec)
-{
- JSValue thisValue = exec->thisValue();
- if (!thisValue.isObject())
- return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
- CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncKeys);
-}
-
static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoGetterFuncBuffer(ExecState* exec)
{
JSValue thisValue = exec->thisValue();
@@ -208,14 +193,6 @@
CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(genericTypedArrayViewProtoFuncSlice);
}
-static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoFuncValues(ExecState* exec)
-{
- JSValue thisValue = exec->thisValue();
- if (!thisValue.isObject())
- return throwVMError(exec, createTypeError(exec, "Receiver should be a typed array view but was not an object"));
- CALL_GENERIC_TYPEDARRAY_PROTOTYPE_FUNCTION(typedArrayViewProtoFuncValues);
-}
-
static EncodedJSValue JSC_HOST_CALL typedArrayViewProtoGetterFuncToStringTag(ExecState* exec)
{
JSValue thisValue = exec->thisValue();
@@ -270,14 +247,14 @@
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("every", typedArrayPrototypeEveryCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("filter", typedArrayPrototypeFilterCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("sort", typedArrayPrototypeSortCodeGenerator, DontEnum);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->entries, typedArrayViewProtoFuncEntries, DontEnum, 0);
+ JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().entriesPublicName(), typedArrayPrototypeEntriesCodeGenerator, DontEnum);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("fill", typedArrayViewProtoFuncFill, DontEnum, 1);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("find", typedArrayPrototypeFindCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("findIndex", typedArrayPrototypeFindIndexCodeGenerator, DontEnum);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->forEach, typedArrayPrototypeForEachCodeGenerator, DontEnum);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("indexOf", typedArrayViewProtoFuncIndexOf, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->join, typedArrayViewProtoFuncJoin, DontEnum, 1);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->keys, typedArrayViewProtoFuncKeys, DontEnum, 0);
+ JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().keysPublicName(), typedArrayPrototypeKeysCodeGenerator, DontEnum);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("lastIndexOf", typedArrayViewProtoFuncLastIndexOf, DontEnum, 1);
JSC_NATIVE_INTRINSIC_GETTER(vm.propertyNames->length, typedArrayViewProtoGetterFuncLength, DontEnum | ReadOnly | DontDelete, TypedArrayLengthIntrinsic);
JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("map", typedArrayPrototypeMapCodeGenerator, DontEnum);
@@ -292,9 +269,9 @@
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toString, arrayProtoFuncToString, DontEnum, 0);
JSC_NATIVE_GETTER(vm.propertyNames->toStringTagSymbol, typedArrayViewProtoGetterFuncToStringTag, DontEnum | ReadOnly);
- JSFunction* valuesFunction = JSFunction::create(vm, globalObject, 0, vm.propertyNames->values.string(), typedArrayViewProtoFuncValues);
+ JSFunction* valuesFunction = JSFunction::createBuiltinFunction(vm, typedArrayPrototypeValuesCodeGenerator(vm), globalObject);
- putDirectWithoutTransition(vm, vm.propertyNames->values, valuesFunction, DontEnum);
+ putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPublicName(), valuesFunction, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, valuesFunction, DontEnum);
}
Modified: trunk/Source/_javascript_Core/runtime/MapPrototype.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/MapPrototype.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/MapPrototype.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
#include "config.h"
#include "MapPrototype.h"
+#include "BuiltinNames.h"
#include "CachedCall.h"
#include "Error.h"
#include "ExceptionHelpers.h"
@@ -73,15 +74,15 @@
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->get, mapProtoFuncGet, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->has, mapProtoFuncHas, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->set, mapProtoFuncSet, DontEnum, 2);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->keys, mapProtoFuncKeys, DontEnum, 0);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->values, mapProtoFuncValues, DontEnum, 0);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().keysPublicName(), mapProtoFuncKeys, DontEnum, 0);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().valuesPublicName(), mapProtoFuncValues, DontEnum, 0);
// Private get / set operations.
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->getPrivateName, mapProtoFuncGet, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->setPrivateName, mapProtoFuncSet, DontEnum, 2);
- JSFunction* entries = JSFunction::create(vm, globalObject, 0, vm.propertyNames->entries.string(), mapProtoFuncEntries);
- putDirectWithoutTransition(vm, vm.propertyNames->entries, entries, DontEnum);
+ JSFunction* entries = JSFunction::create(vm, globalObject, 0, vm.propertyNames->builtinNames().entriesPublicName().string(), mapProtoFuncEntries);
+ putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().entriesPublicName(), entries, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, entries, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Map"), DontEnum | ReadOnly);
Modified: trunk/Source/_javascript_Core/runtime/SetPrototype.cpp (200421 => 200422)
--- trunk/Source/_javascript_Core/runtime/SetPrototype.cpp 2016-05-04 17:40:46 UTC (rev 200421)
+++ trunk/Source/_javascript_Core/runtime/SetPrototype.cpp 2016-05-04 17:59:10 UTC (rev 200422)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
#include "config.h"
#include "SetPrototype.h"
+#include "BuiltinNames.h"
#include "CachedCall.h"
#include "Error.h"
#include "ExceptionHelpers.h"
@@ -71,11 +72,11 @@
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->clear, setProtoFuncClear, DontEnum, 0);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->deleteKeyword, setProtoFuncDelete, DontEnum, 1);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->has, setProtoFuncHas, DontEnum, 1);
- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->entries, setProtoFuncEntries, DontEnum, 0);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().entriesPublicName(), setProtoFuncEntries, DontEnum, 0);
- JSFunction* values = JSFunction::create(vm, globalObject, 0, vm.propertyNames->values.string(), setProtoFuncValues);
- putDirectWithoutTransition(vm, vm.propertyNames->values, values, DontEnum);
- putDirectWithoutTransition(vm, vm.propertyNames->keys, values, DontEnum);
+ JSFunction* values = JSFunction::create(vm, globalObject, 0, vm.propertyNames->builtinNames().valuesPublicName().string(), setProtoFuncValues);
+ putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().valuesPublicName(), values, DontEnum);
+ putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().keysPublicName(), values, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, values, DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Set"), DontEnum | ReadOnly);