Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: src/array.js

Issue 1178193004: Add ToObject call in Array.prototype.sort (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/array-sort.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $arrayConcat; 5 var $arrayConcat;
6 var $arrayPush; 6 var $arrayPush;
7 var $arrayPop; 7 var $arrayPop;
8 var $arrayShift; 8 var $arrayShift;
9 var $arraySlice; 9 var $arraySlice;
10 var $arraySplice; 10 var $arraySplice;
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 ShadowPrototypeElements(this, num_non_undefined, max_prototype_element); 1169 ShadowPrototypeElements(this, num_non_undefined, max_prototype_element);
1170 } 1170 }
1171 1171
1172 return this; 1172 return this;
1173 } 1173 }
1174 1174
1175 1175
1176 function ArraySort(comparefn) { 1176 function ArraySort(comparefn) {
1177 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort"); 1177 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort");
1178 1178
1179 var length = TO_UINT32(this.length); 1179 var array = $toObject(this);
1180 return %_CallFunction(this, length, comparefn, InnerArraySort); 1180 var length = TO_UINT32(array.length);
1181 return %_CallFunction(array, length, comparefn, InnerArraySort);
1181 } 1182 }
1182 1183
1183 1184
1184 // The following functions cannot be made efficient on sparse arrays while 1185 // The following functions cannot be made efficient on sparse arrays while
1185 // preserving the semantics, since the calls to the receiver function can add 1186 // preserving the semantics, since the calls to the receiver function can add
1186 // or delete elements from the array. 1187 // or delete elements from the array.
1187 function InnerArrayFilter(f, receiver, array, length) { 1188 function InnerArrayFilter(f, receiver, array, length) {
1188 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); 1189 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f);
1189 var needs_wrapper = false; 1190 var needs_wrapper = false;
1190 if (IS_NULL(receiver)) { 1191 if (IS_NULL(receiver)) {
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 1695
1695 $arrayConcat = ArrayConcatJS; 1696 $arrayConcat = ArrayConcatJS;
1696 $arrayPush = ArrayPush; 1697 $arrayPush = ArrayPush;
1697 $arrayPop = ArrayPop; 1698 $arrayPop = ArrayPop;
1698 $arrayShift = ArrayShift; 1699 $arrayShift = ArrayShift;
1699 $arraySlice = ArraySlice; 1700 $arraySlice = ArraySlice;
1700 $arraySplice = ArraySplice; 1701 $arraySplice = ArraySplice;
1701 $arrayUnshift = ArrayUnshift; 1702 $arrayUnshift = ArrayUnshift;
1702 1703
1703 }); 1704 });
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/array-sort.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698