Bug 1260673 - Stop using _DefineDataProperty in MoveHoles; r=jorendorff
authorMorgan Phillips <winter2718@gmail.com>
Thu, 31 Mar 2016 14:44:12 -0700
changeset 291152 0d2dd90e33f4957e20a78cb08e49fedb1161056b
parent 291151 f2375d1e124a0d64564c732759755793558fcde0
child 291153 ebee3c43dfac7613ef1fed463f9b83ce6fa50ef9
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1260673
milestone48.0a1
Bug 1260673 - Stop using _DefineDataProperty in MoveHoles; r=jorendorff _DefineDataProperty was used to ensure that modifying Array's setter wouldn't impact sorting, however, this is both not necessary and against the spec.
js/src/builtin/Sorting.js
js/src/tests/ecma_6/Array/sort_holes.js
--- a/js/src/builtin/Sorting.js
+++ b/js/src/builtin/Sorting.js
@@ -215,17 +215,17 @@ function Merge(list, start, mid, end, lB
         k++;
     }
 }
 
 // Helper function for overwriting a sparse array with a
 // dense array, filling remaining slots with holes.
 function MoveHoles(sparse, sparseLen, dense, denseLen) {
     for (var i = 0; i < denseLen; i++)
-        _DefineDataProperty(sparse, i, dense[i]);
+        sparse[i] = dense[i];
     for (var j = denseLen; j < sparseLen; j++)
         delete sparse[j];
 }
 
 // Iterative, bottom up, mergesort.
 function MergeSort(array, len, comparefn) {
     // To save effort we will do all of our work on a dense list,
     // then create holes at the end.
--- a/js/src/tests/ecma_6/Array/sort_holes.js
+++ b/js/src/tests/ecma_6/Array/sort_holes.js
@@ -49,24 +49,10 @@ let oneHole = new Array(2600);
 oneHole[1399] = {size: 27};
 assertEq(oneHole.length, 2600);
 assertEq(denseCount(oneHole), 1);
 oneHole.sort((a, b) => {+a.size - +b.size});
 assertDeepEq(oneHole[0], {size: 27});
 assertEq(oneHole.length, 2600);
 assertEq(denseCount(oneHole), 1);
 
-// Ensure that the array setter is touch touched during sorting.
-
-Object.defineProperty(Array.prototype, "0", {
-    set: (value) => {throw "Illegally touched the array's setter!"},
-    configurable: true
-});
-
-assertThrows(() => {o[1] = 11;});
-
-let o = [,,,,,,,,,,,,,,,,,,,,{size: 1},{size: 2}];
-o.sort((a, b) => {+a.size - +b.size});
-
-delete Array.prototype["0"];
-
 if (typeof reportCompare === 'function')
     reportCompare(0, 0);