Bug 1780517 - Part 2: Always use undefined instead of void 0 in self-hosted JS. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Thu, 21 Jul 2022 14:23:06 +0000
changeset 624775 28d512ea39d561a96dc2c77eaf92bf6ff93ab05b
parent 624774 72664babe2c66b35c0a8f63672ce3cfd745736b7
child 624776 1300bb7f770b9b55b11b6d9f451f9b2168542cb0
push id166582
push userarai_a@mac.com
push dateThu, 21 Jul 2022 14:31:41 +0000
treeherderautoland@1300bb7f770b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1780517
milestone104.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1780517 - Part 2: Always use undefined instead of void 0 in self-hosted JS. r=jandem Depends on D152387 Differential Revision: https://phabricator.services.mozilla.com/D152390
js/src/builtin/Array.js
js/src/builtin/Tuple.js
js/src/builtin/TypedArray.js
--- a/js/src/builtin/Array.js
+++ b/js/src/builtin/Array.js
@@ -12,17 +12,17 @@ function ArrayEvery(callbackfn/*, thisAr
 
     /* Step 4. */
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "Array.prototype.every");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     /* Step 5. */
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Steps 6-7. */
     /* Steps a (implicit), and d. */
     for (var k = 0; k < len; k++) {
         /* Step b */
         if (k in O) {
             /* Step c. */
             if (!callContentFunction(callbackfn, T, O[k], k, O))
@@ -46,17 +46,17 @@ function ArraySome(callbackfn/*, thisArg
 
     /* Step 4. */
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "Array.prototype.some");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     /* Step 5. */
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Steps 6-7. */
     /* Steps a (implicit), and d. */
     for (var k = 0; k < len; k++) {
         /* Step b */
         if (k in O) {
             /* Step c. */
             if (callContentFunction(callbackfn, T, O[k], k, O))
@@ -129,30 +129,30 @@ function ArrayForEach(callbackfn/*, this
 
     /* Step 4. */
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "Array.prototype.forEach");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     /* Step 5. */
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Steps 6-7. */
     /* Steps a (implicit), and d. */
     for (var k = 0; k < len; k++) {
         /* Step b */
         if (k in O) {
             /* Step c. */
             callContentFunction(callbackfn, T, O[k], k, O);
         }
     }
 
     /* Step 8. */
-    return void 0;
+    return undefined;
 }
 // Inlining this enables inlining of the callback function.
 SetIsInlinableLargeFunction(ArrayForEach);
 
 /* ES 2016 draft Mar 25, 2016 22.1.3.15. */
 function ArrayMap(callbackfn/*, thisArg*/) {
     /* Step 1. */
     var O = ToObject(this);
@@ -162,17 +162,17 @@ function ArrayMap(callbackfn/*, thisArg*
 
     /* Step 3. */
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "Array.prototype.map");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     /* Step 4. */
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Steps 5. */
     var A = ArraySpeciesCreate(O, len);
 
     /* Steps 6-7. */
     /* Steps 7.a (implicit), and 7.d. */
     for (var k = 0; k < len; k++) {
         /* Steps 7.b-c. */
@@ -199,17 +199,17 @@ function ArrayFilter(callbackfn/*, thisA
 
     /* Step 3. */
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "Array.prototype.filter");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     /* Step 4. */
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Step 5. */
     var A = ArraySpeciesCreate(O, 0);
 
     /* Steps 6-8. */
     /* Steps 8.a (implicit), and 8.d. */
     for (var k = 0, to = 0; k < len; k++) {
         /* Steps 8.b-c. */
@@ -243,17 +243,17 @@ function ArrayGroup(callbackfn/*, thisAr
     /* Step 3. If IsCallable(callbackfn) is false, throw a TypeError exception. */
     if (!IsCallable(callbackfn)) {
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
     }
 
     /* Step 5. Let groups be a new empty List. */
     var groups = new_List();
 
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Steps 4, 6. */
     for (var k = 0; k < len; k++) {
 
         /* Skip Step 6.a. Let Pk be ! ToString(𝔽(k)).
          *
          * k is coerced into a string through the property access. */
 
@@ -317,17 +317,17 @@ function ArrayGroupToMap(callbackfn/*, t
      * Intermediate object isn't necessary as we have direct access
      * to the map constructor and set/get methods.
      */
 
     /* Step 7. Let map be ! Construct(%Map%). */
     var C = GetBuiltinConstructor("Map");
     var map = new C();
 
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     /* Combine Step 6. and Step 8.
      *
      * We have direct access to the map constructor and set/get methods.
      * We can treat these two loops as one, as there isn't a risk that user
      * polyfilling will impact the implementation.
      */
     for (var k = 0; k < len; k++) {
--- a/js/src/builtin/Tuple.js
+++ b/js/src/builtin/Tuple.js
@@ -358,17 +358,17 @@ function TupleFilter(callbackfn) {
     /* Step 5. */
     var newList = [];
 
     /* Step 6. */
     var k = 0;
     var newK = 0;
 
     /* Step 7. */
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
     while(k < len) {
         /* Step 7a. */
         var kValue = list[k];
         /* Step 7b. */
         var selected = ToBoolean(callContentFunction(callbackfn, T, kValue, k, list));
         /* Step 7c. */
         if (selected) {
             /* Step 7c.i. */
@@ -416,17 +416,17 @@ function TupleMap(callbackfn) {
     /* Step 4. */
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     /* Step 5. */
     var newList = [];
 
     /* Steps 6-7. */
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
     for(var k = 0; k < len; k++) {
         /* Step 7a. */
         var kValue = list[k];
         /* Step 7b. */
         var mappedValue = callContentFunction(callbackfn, thisArg, kValue, k, list);
         /* Step 7c */
         if (IsObject(mappedValue)) {
             ThrowTypeError(JSMSG_RECORD_TUPLE_NO_OBJECT);
@@ -556,17 +556,17 @@ function TupleFlatMap(mapperFunction /*,
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "Tuple.prototype.flatMap");
     if (!IsCallable(mapperFunction))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, mapperFunction));
 
     /* Step 4. */
     var flat = [];
 
     /* Step 5. */
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
     FlattenIntoTuple(flat, list, 1, mapperFunction, thisArg);
 
     /* Step 6. */
     return std_Tuple_unchecked(flat);
 }
 
 function TupleFrom(items, /*, mapFn, thisArg */) {
     /* Step 1 */
--- a/js/src/builtin/TypedArray.js
+++ b/js/src/builtin/TypedArray.js
@@ -233,17 +233,17 @@ function TypedArrayEvery(callbackfn/*, t
         len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.every");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = 0; k < len; k++) {
         // Steps 6.b-d.
         var kValue = O[k];
 
         // Step 6.c.
         var testResult = callContentFunction(callbackfn, thisArg, kValue, k, O);
@@ -342,17 +342,17 @@ function TypedArrayFilter(callbackfn/*, 
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.filter");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     // Step 5.
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     // Step 6.
     var kept = new_List();
 
     // Step 8.
     var captured = 0;
 
     // Steps 7 and 9.e.
@@ -403,17 +403,17 @@ function TypedArrayFind(predicate/*, thi
         len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.find");
     if (!IsCallable(predicate))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, predicate));
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = 0; k < len; k++) {
         // Steps 6.a-b.
         var kValue = O[k];
 
         // Steps 6.c-d.
         if (callContentFunction(predicate, thisArg, kValue, k, O))
@@ -444,17 +444,17 @@ function TypedArrayFindIndex(predicate/*
         len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.findIndex");
     if (!IsCallable(predicate))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, predicate));
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = 0; k < len; k++) {
         // Steps 6.a-f.
         if (callContentFunction(predicate, thisArg, O[k], k, O))
             return k;
     }
 
@@ -482,17 +482,17 @@ function TypedArrayForEach(callbackfn/*,
         len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "TypedArray.prototype.forEach");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = 0; k < len; k++) {
         // Steps 6.a-c.
         callContentFunction(callbackfn, thisArg, O[k], k, O);
     }
 
     // Step 7.
@@ -718,17 +718,17 @@ function TypedArrayMap(callbackfn/*, thi
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.map");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
     // Step 5.
-    var T = arguments.length > 1 ? arguments[1] : void 0;
+    var T = arguments.length > 1 ? arguments[1] : undefined;
 
     // Step 6.
     var A = TypedArraySpeciesCreateWithLength(O, len);
 
     // Steps 7, 8.a (implicit) and 8.e.
     for (var k = 0; k < len; k++) {
         // Steps 8.b-c.
         var mappedValue = callContentFunction(callbackfn, T, O[k], k, O);
@@ -961,17 +961,17 @@ function TypedArraySome(callbackfn/*, th
         len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
 
     // Step 4.
     if (arguments.length === 0)
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.some");
     if (!IsCallable(callbackfn))
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = 0; k < len; k++) {
         // Steps 6.a-b.
         var kValue = O[k];
 
         // Step 6.c.
         var testResult = callContentFunction(callbackfn, thisArg, kValue, k, O);
@@ -1223,17 +1223,17 @@ function TypedArrayFindLast(predicate/*,
     // Step 4.
     if (arguments.length === 0) {
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.findLast");
     }
     if (!IsCallable(predicate)) {
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, predicate));
     }
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = len - 1; k >= 0; k--) {
         // Steps 6.a-b.
         var kValue = O[k];
 
         // Steps 6.c-d.
         if (callContentFunction(predicate, thisArg, kValue, k, O)) {
@@ -1267,17 +1267,17 @@ function TypedArrayFindLastIndex(predica
     // Step 4.
     if (arguments.length === 0) {
         ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.findLastIndex");
     }
     if (!IsCallable(predicate)) {
         ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, predicate));
     }
 
-    var thisArg = arguments.length > 1 ? arguments[1] : void 0;
+    var thisArg = arguments.length > 1 ? arguments[1] : undefined;
 
     // Steps 5-6.
     for (var k = len - 1; k >= 0; k--) {
         // Steps 6.a-f.
         if (callContentFunction(predicate, thisArg, O[k], k, O)) {
             return k;
         }
     }