Corrections to r200422
https://bugs.webkit.org/show_bug.cgi?id=157351

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Fix some typos in various files. Also, make separate error messages
for the this value being undefined vs null in the ArrayIteratorprototype
next function and add test.

* Scripts/builtins/builtins_model.py:
* builtins/ArrayIteratorPrototype.js:
(next):
(arrayIteratorValueNext):
(arrayIteratorKeyNext):
(arrayIteratorKeyValueNext):
* builtins/ArrayPrototype.js:
(keys):
(entries):
* builtins/TypedArrayPrototype.js:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): Deleted.
* tests/stress/array-iterators-next-error-messages.js: Added.
(assert):
(catch):

LayoutTests:

Test case had some code changed that was not intended.

* js/regress/script-tests/deltablue-for-of.js:
(deltaBlue):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index ce97079..fd473d7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,17 @@
 2016-05-04  Keith Miller  <keith_miller@apple.com>
 
+        Corrections to r200422
+        https://bugs.webkit.org/show_bug.cgi?id=157351
+
+        Reviewed by Joseph Pecoraro.
+
+        Test case had some code changed that was not intended.
+
+        * js/regress/script-tests/deltablue-for-of.js:
+        (deltaBlue):
+
+2016-05-04  Keith Miller  <keith_miller@apple.com>
+
         Unreviewed, reland r200149 since the rollout had inconclusive PLT AB testing results.
 
 2016-05-04  Joseph Pecoraro  <pecoraro@apple.com>
diff --git a/LayoutTests/js/regress/script-tests/deltablue-for-of.js b/LayoutTests/js/regress/script-tests/deltablue-for-of.js
index 6508655..432e023 100644
--- a/LayoutTests/js/regress/script-tests/deltablue-for-of.js
+++ b/LayoutTests/js/regress/script-tests/deltablue-for-of.js
@@ -862,9 +862,9 @@
 var planner = null;
 
 function deltaBlue() {
-  chainTest(100);
-  projectionTest(100);
+  chainTest(50);
+  projectionTest(50);
 }
 
-//for (var i = 0; i < 100; ++i)
-//    deltaBlue();
+for (var i = 0; i < 100; ++i)
+    deltaBlue();
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 647155d..c89b2a4 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,5 +1,32 @@
 2016-05-04  Keith Miller  <keith_miller@apple.com>
 
+        Corrections to r200422
+        https://bugs.webkit.org/show_bug.cgi?id=157351
+
+        Reviewed by Joseph Pecoraro.
+
+        Fix some typos in various files. Also, make separate error messages
+        for the this value being undefined vs null in the ArrayIteratorprototype
+        next function and add test.
+
+        * Scripts/builtins/builtins_model.py:
+        * builtins/ArrayIteratorPrototype.js:
+        (next):
+        (arrayIteratorValueNext):
+        (arrayIteratorKeyNext):
+        (arrayIteratorKeyValueNext):
+        * builtins/ArrayPrototype.js:
+        (keys):
+        (entries):
+        * builtins/TypedArrayPrototype.js:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init): Deleted.
+        * tests/stress/array-iterators-next-error-messages.js: Added.
+        (assert):
+        (catch):
+
+2016-05-04  Keith Miller  <keith_miller@apple.com>
+
         Unreviewed, reland r200149 since the rollout had inconclusive PLT AB testing results.
 
 2016-05-04  Mark Lam  <mark.lam@apple.com>
diff --git a/Source/JavaScriptCore/Scripts/builtins/builtins_model.py b/Source/JavaScriptCore/Scripts/builtins/builtins_model.py
index 360087b..022a98b 100755
--- a/Source/JavaScriptCore/Scripts/builtins/builtins_model.py
+++ b/Source/JavaScriptCore/Scripts/builtins/builtins_model.py
@@ -40,11 +40,11 @@
     },
 }
 
-functionHeadRegExp = re.compile(r"(?:@[\w|=]+\s*\n)*(?:function)\s+\w+\s*\(.*?\)", re.MULTILINE | re.DOTALL)
+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)
+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.DOTALL)
 singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.DOTALL)
diff --git a/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js b/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js
index bcebe21..56595f7 100644
--- a/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js
+++ b/Source/JavaScriptCore/builtins/ArrayIteratorPrototype.js
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
- * Copyright (C) 2016a Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -28,12 +28,15 @@
 {
     "use strict";
 
-    if (this == null)
-        throw @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null or undefined");
+    if (this == null) {
+        if (this === null)
+            throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be null");
+        throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| not be undefined");
+    }
 
     let next = this.@arrayIteratorNext;
     if (next === @undefined)
-        throw @TypeError("%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance");
+        throw new @TypeError("%ArrayIteratorPrototype%.next requires that |this| be an Array Iterator instance");
 
     return next.@call(this);
 }
@@ -42,7 +45,7 @@
 {
     "use strict";
     var done = true;
-    var value = @undefined;
+    var value;
 
     var array = this.@iteratedObject;
     if (!this.@arrayIteratorIsDone) {
@@ -64,7 +67,7 @@
 {
     "use strict";
     var done = true;
-    var value = @undefined;
+    var value;
 
     var array = this.@iteratedObject;
     if (!this.@arrayIteratorIsDone) {
@@ -86,7 +89,7 @@
 {
     "use strict";
     var done = true;
-    var value = @undefined;
+    var value;
 
     var array = this.@iteratedObject;
     if (!this.@arrayIteratorIsDone) {
diff --git a/Source/JavaScriptCore/builtins/ArrayPrototype.js b/Source/JavaScriptCore/builtins/ArrayPrototype.js
index ab26d3e2..1a556f6 100644
--- a/Source/JavaScriptCore/builtins/ArrayPrototype.js
+++ b/Source/JavaScriptCore/builtins/ArrayPrototype.js
@@ -50,7 +50,7 @@
     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");
+        throw new @TypeError("Array.prototype.keys requires that |this| not be undefined");
     }
 
     return new @createArrayIterator(@Object(this), @arrayIteratorKeyNext);
@@ -62,7 +62,7 @@
     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");
+        throw new @TypeError("Array.prototype.entries requires that |this| not be undefined");
     }
 
     return new @createArrayIterator(@Object(this), @arrayIteratorKeyValueNext);
diff --git a/Source/JavaScriptCore/builtins/TypedArrayPrototype.js b/Source/JavaScriptCore/builtins/TypedArrayPrototype.js
index be743c7..d0688cc 100644
--- a/Source/JavaScriptCore/builtins/TypedArrayPrototype.js
+++ b/Source/JavaScriptCore/builtins/TypedArrayPrototype.js
@@ -23,7 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-// Note that the intrisic @typedArrayLength checks the that the argument passed is a typed array
+// Note that the intrisic @typedArrayLength checks that the argument passed is a typed array
 // and throws if it is not.
 
 function values()
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
index 6b0c43c..a7dce89 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -567,7 +567,6 @@
     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);
diff --git a/Source/JavaScriptCore/tests/stress/array-iterators-next-error-messages.js b/Source/JavaScriptCore/tests/stress/array-iterators-next-error-messages.js
new file mode 100644
index 0000000..e56754e
--- /dev/null
+++ b/Source/JavaScriptCore/tests/stress/array-iterators-next-error-messages.js
@@ -0,0 +1,18 @@
+function assert(a, b) {
+    if (a != b)
+        throw new Error("assertion failed");
+}
+
+next = [].values().next;
+
+try {
+    next.call(null);
+} catch(e) {
+    assert(e, "TypeError: %ArrayIteratorPrototype%.next requires that |this| not be null");
+}
+
+try {
+    next.call(undefined);
+} catch(e) {
+    assert(e, "TypeError: %ArrayIteratorPrototype%.next requires that |this| not be undefined");
+}