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

Side by Side Diff: src/array.js

Issue 1302533002: Native context: debug.js does not load from js builtins object anymore. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: make importing requirement more explicit Created 5 years, 4 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 | src/arraybuffer.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;
11 var $arrayUnshift; 11 var $arrayUnshift;
12 12
13 (function(global, utils) { 13 (function(global, utils) {
14 14
15 "use strict"; 15 "use strict";
16 16
17 %CheckIsBootstrapping(); 17 %CheckIsBootstrapping();
18 18
19 // ------------------------------------------------------------------- 19 // -------------------------------------------------------------------
20 // Imports 20 // Imports
21 21
22 var Delete;
22 var GlobalArray = global.Array; 23 var GlobalArray = global.Array;
23 var InternalArray = utils.InternalArray; 24 var InternalArray = utils.InternalArray;
24 var InternalPackedArray = utils.InternalPackedArray; 25 var InternalPackedArray = utils.InternalPackedArray;
25
26 var Delete;
27 var MathMin; 26 var MathMin;
28 var ObjectHasOwnProperty; 27 var ObjectHasOwnProperty;
29 var ObjectIsFrozen; 28 var ObjectIsFrozen;
30 var ObjectIsSealed; 29 var ObjectIsSealed;
31 var ObjectToString; 30 var ObjectToString;
31 var ToNumber;
32 var ToString;
32 33
33 utils.Import(function(from) { 34 utils.Import(function(from) {
34 Delete = from.Delete; 35 Delete = from.Delete;
35 MathMin = from.MathMin; 36 MathMin = from.MathMin;
36 ObjectHasOwnProperty = from.ObjectHasOwnProperty; 37 ObjectHasOwnProperty = from.ObjectHasOwnProperty;
37 ObjectIsFrozen = from.ObjectIsFrozen; 38 ObjectIsFrozen = from.ObjectIsFrozen;
38 ObjectIsSealed = from.ObjectIsSealed; 39 ObjectIsSealed = from.ObjectIsSealed;
39 ObjectToString = from.ObjectToString; 40 ObjectToString = from.ObjectToString;
41 ToNumber = from.ToNumber;
42 ToString = from.ToString;
40 }); 43 });
41 44
42 // ------------------------------------------------------------------- 45 // -------------------------------------------------------------------
43 46
44 // Global list of arrays visited during toString, toLocaleString and 47 // Global list of arrays visited during toString, toLocaleString and
45 // join invocations. 48 // join invocations.
46 var visited_arrays = new InternalArray(); 49 var visited_arrays = new InternalArray();
47 50
48 51
49 // Gets a sorted array of array keys. Useful for operations on sparse 52 // Gets a sorted array of array keys. Useful for operations on sparse
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // matter what happens. 212 // matter what happens.
210 if (is_array) visited_arrays.length = visited_arrays.length - 1; 213 if (is_array) visited_arrays.length = visited_arrays.length - 1;
211 } 214 }
212 } 215 }
213 216
214 217
215 function ConvertToString(x) { 218 function ConvertToString(x) {
216 // Assumes x is a non-string. 219 // Assumes x is a non-string.
217 if (IS_NUMBER(x)) return %_NumberToString(x); 220 if (IS_NUMBER(x)) return %_NumberToString(x);
218 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 221 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
219 return (IS_NULL_OR_UNDEFINED(x)) ? '' : $toString($defaultString(x)); 222 return (IS_NULL_OR_UNDEFINED(x)) ? '' : ToString($defaultString(x));
220 } 223 }
221 224
222 225
223 function ConvertToLocaleString(e) { 226 function ConvertToLocaleString(e) {
224 if (IS_NULL_OR_UNDEFINED(e)) { 227 if (IS_NULL_OR_UNDEFINED(e)) {
225 return ''; 228 return '';
226 } else { 229 } else {
227 // According to ES5, section 15.4.4.3, the toLocaleString conversion 230 // According to ES5, section 15.4.4.3, the toLocaleString conversion
228 // must throw a TypeError if ToObject(e).toLocaleString isn't 231 // must throw a TypeError if ToObject(e).toLocaleString isn't
229 // callable. 232 // callable.
230 var e_obj = TO_OBJECT(e); 233 var e_obj = TO_OBJECT(e);
231 return $toString(e_obj.toLocaleString()); 234 return ToString(e_obj.toLocaleString());
232 } 235 }
233 } 236 }
234 237
235 238
236 // This function implements the optimized splice implementation that can use 239 // This function implements the optimized splice implementation that can use
237 // special array operations to handle sparse arrays in a sensible fashion. 240 // special array operations to handle sparse arrays in a sensible fashion.
238 function SparseSlice(array, start_i, del_count, len, deleted_elements) { 241 function SparseSlice(array, start_i, del_count, len, deleted_elements) {
239 // Move deleted elements to a new array (the return value from splice). 242 // Move deleted elements to a new array (the return value from splice).
240 var indices = %GetArrayKeys(array, start_i + del_count); 243 var indices = %GetArrayKeys(array, start_i + del_count);
241 if (IS_NUMBER(indices)) { 244 if (IS_NUMBER(indices)) {
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 function InnerArraySort(length, comparefn) { 910 function InnerArraySort(length, comparefn) {
908 // In-place QuickSort algorithm. 911 // In-place QuickSort algorithm.
909 // For short (length <= 22) arrays, insertion sort is used for efficiency. 912 // For short (length <= 22) arrays, insertion sort is used for efficiency.
910 913
911 if (!IS_SPEC_FUNCTION(comparefn)) { 914 if (!IS_SPEC_FUNCTION(comparefn)) {
912 comparefn = function (x, y) { 915 comparefn = function (x, y) {
913 if (x === y) return 0; 916 if (x === y) return 0;
914 if (%_IsSmi(x) && %_IsSmi(y)) { 917 if (%_IsSmi(x) && %_IsSmi(y)) {
915 return %SmiLexicographicCompare(x, y); 918 return %SmiLexicographicCompare(x, y);
916 } 919 }
917 x = $toString(x); 920 x = ToString(x);
918 y = $toString(y); 921 y = ToString(y);
919 if (x == y) return 0; 922 if (x == y) return 0;
920 else return x < y ? -1 : 1; 923 else return x < y ? -1 : 1;
921 }; 924 };
922 } 925 }
923 var InsertionSort = function InsertionSort(a, from, to) { 926 var InsertionSort = function InsertionSort(a, from, to) {
924 for (var i = from + 1; i < to; i++) { 927 for (var i = from + 1; i < to; i++) {
925 var element = a[i]; 928 var element = a[i];
926 for (var j = i - 1; j >= from; j--) { 929 for (var j = i - 1; j >= from; j--) {
927 var tmp = a[j]; 930 var tmp = a[j];
928 var order = %_CallFunction(UNDEFINED, tmp, element, comparefn); 931 var order = %_CallFunction(UNDEFINED, tmp, element, comparefn);
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 1713
1711 $arrayConcat = ArrayConcatJS; 1714 $arrayConcat = ArrayConcatJS;
1712 $arrayPush = ArrayPush; 1715 $arrayPush = ArrayPush;
1713 $arrayPop = ArrayPop; 1716 $arrayPop = ArrayPop;
1714 $arrayShift = ArrayShift; 1717 $arrayShift = ArrayShift;
1715 $arraySlice = ArraySlice; 1718 $arraySlice = ArraySlice;
1716 $arraySplice = ArraySplice; 1719 $arraySplice = ArraySplice;
1717 $arrayUnshift = ArrayUnshift; 1720 $arrayUnshift = ArrayUnshift;
1718 1721
1719 }); 1722 });
OLDNEW
« no previous file with comments | « no previous file | src/arraybuffer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698