OLD | NEW |
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 $arrayJoin; | 6 var $arrayJoin; |
7 var $arrayPush; | 7 var $arrayPush; |
8 var $arrayPop; | 8 var $arrayPop; |
9 var $arrayShift; | 9 var $arrayShift; |
10 var $arraySlice; | 10 var $arraySlice; |
11 var $arraySplice; | 11 var $arraySplice; |
12 var $arrayUnshift; | 12 var $arrayUnshift; |
13 var $innerArrayForEach; | 13 var $innerArrayForEach; |
14 var $innerArrayEvery; | 14 var $innerArrayEvery; |
15 var $innerArrayIndexOf; | 15 var $innerArrayIndexOf; |
16 var $innerArrayLastIndexOf; | 16 var $innerArrayLastIndexOf; |
17 var $innerArrayReverse; | 17 var $innerArrayReverse; |
18 var $innerArraySort; | 18 var $innerArraySort; |
19 | 19 |
20 (function(global, shared, exports) { | 20 (function(global, utils) { |
21 | 21 |
22 "use strict"; | 22 "use strict"; |
23 | 23 |
24 %CheckIsBootstrapping(); | 24 %CheckIsBootstrapping(); |
25 | 25 |
26 // ------------------------------------------------------------------- | 26 // ------------------------------------------------------------------- |
27 // Imports | 27 // Imports |
28 | 28 |
29 var GlobalArray = global.Array; | 29 var GlobalArray = global.Array; |
30 var InternalArray = exports.InternalArray; | 30 var InternalArray = utils.InternalArray; |
31 var InternalPackedArray = exports.InternalPackedArray; | 31 var InternalPackedArray = utils.InternalPackedArray; |
| 32 |
| 33 var MathMin; |
| 34 |
| 35 utils.Import(function(from) { |
| 36 MathMin = from.MathMin; |
| 37 }); |
32 | 38 |
33 // ------------------------------------------------------------------- | 39 // ------------------------------------------------------------------- |
34 | 40 |
35 // Global list of arrays visited during toString, toLocaleString and | 41 // Global list of arrays visited during toString, toLocaleString and |
36 // join invocations. | 42 // join invocations. |
37 var visited_arrays = new InternalArray(); | 43 var visited_arrays = new InternalArray(); |
38 | 44 |
39 | 45 |
40 // Gets a sorted array of array keys. Useful for operations on sparse | 46 // Gets a sorted array of array keys. Useful for operations on sparse |
41 // arrays. Dupes have not been removed. | 47 // arrays. Dupes have not been removed. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 261 |
256 | 262 |
257 // This function implements the optimized splice implementation that can use | 263 // This function implements the optimized splice implementation that can use |
258 // special array operations to handle sparse arrays in a sensible fashion. | 264 // special array operations to handle sparse arrays in a sensible fashion. |
259 function SparseMove(array, start_i, del_count, len, num_additional_args) { | 265 function SparseMove(array, start_i, del_count, len, num_additional_args) { |
260 // Bail out if no moving is necessary. | 266 // Bail out if no moving is necessary. |
261 if (num_additional_args === del_count) return; | 267 if (num_additional_args === del_count) return; |
262 // Move data to new array. | 268 // Move data to new array. |
263 var new_array = new InternalArray( | 269 var new_array = new InternalArray( |
264 // Clamp array length to 2^32-1 to avoid early RangeError. | 270 // Clamp array length to 2^32-1 to avoid early RangeError. |
265 $min(len - del_count + num_additional_args, 0xffffffff)); | 271 MathMin(len - del_count + num_additional_args, 0xffffffff)); |
266 var big_indices; | 272 var big_indices; |
267 var indices = %GetArrayKeys(array, len); | 273 var indices = %GetArrayKeys(array, len); |
268 if (IS_NUMBER(indices)) { | 274 if (IS_NUMBER(indices)) { |
269 var limit = indices; | 275 var limit = indices; |
270 for (var i = 0; i < start_i && i < limit; ++i) { | 276 for (var i = 0; i < start_i && i < limit; ++i) { |
271 var current = array[i]; | 277 var current = array[i]; |
272 if (!IS_UNDEFINED(current) || i in array) { | 278 if (!IS_UNDEFINED(current) || i in array) { |
273 new_array[i] = current; | 279 new_array[i] = current; |
274 } | 280 } |
275 } | 281 } |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 $arrayUnshift = ArrayUnshift; | 1643 $arrayUnshift = ArrayUnshift; |
1638 | 1644 |
1639 $innerArrayForEach = InnerArrayForEach; | 1645 $innerArrayForEach = InnerArrayForEach; |
1640 $innerArrayEvery = InnerArrayEvery; | 1646 $innerArrayEvery = InnerArrayEvery; |
1641 $innerArrayIndexOf = InnerArrayIndexOf; | 1647 $innerArrayIndexOf = InnerArrayIndexOf; |
1642 $innerArrayLastIndexOf = InnerArrayLastIndexOf; | 1648 $innerArrayLastIndexOf = InnerArrayLastIndexOf; |
1643 $innerArrayReverse = InnerArrayReverse; | 1649 $innerArrayReverse = InnerArrayReverse; |
1644 $innerArraySort = InnerArraySort; | 1650 $innerArraySort = InnerArraySort; |
1645 | 1651 |
1646 }); | 1652 }); |
OLD | NEW |