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 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
14 var Delete; | 14 var Delete; |
15 var GlobalArray = global.Array; | 15 var GlobalArray = global.Array; |
16 var InternalArray = utils.InternalArray; | 16 var InternalArray = utils.InternalArray; |
17 var InternalPackedArray = utils.InternalPackedArray; | 17 var InternalPackedArray = utils.InternalPackedArray; |
| 18 var MathMin; |
18 var ObjectHasOwnProperty; | 19 var ObjectHasOwnProperty; |
19 var ObjectIsFrozen; | 20 var ObjectIsFrozen; |
20 var ObjectIsSealed; | 21 var ObjectIsSealed; |
21 var ObjectToString; | 22 var ObjectToString; |
22 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); | 23 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); |
23 | 24 |
24 utils.Import(function(from) { | 25 utils.Import(function(from) { |
25 Delete = from.Delete; | 26 Delete = from.Delete; |
| 27 MathMin = from.MathMin; |
26 ObjectHasOwnProperty = from.ObjectHasOwnProperty; | 28 ObjectHasOwnProperty = from.ObjectHasOwnProperty; |
27 ObjectIsFrozen = from.ObjectIsFrozen; | 29 ObjectIsFrozen = from.ObjectIsFrozen; |
28 ObjectIsSealed = from.ObjectIsSealed; | 30 ObjectIsSealed = from.ObjectIsSealed; |
29 ObjectToString = from.ObjectToString; | 31 ObjectToString = from.ObjectToString; |
30 }); | 32 }); |
31 | 33 |
32 // ------------------------------------------------------------------- | 34 // ------------------------------------------------------------------- |
33 | 35 |
34 // Global list of arrays visited during toString, toLocaleString and | 36 // Global list of arrays visited during toString, toLocaleString and |
35 // join invocations. | 37 // join invocations. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 257 |
256 | 258 |
257 // This function implements the optimized splice implementation that can use | 259 // This function implements the optimized splice implementation that can use |
258 // special array operations to handle sparse arrays in a sensible fashion. | 260 // special array operations to handle sparse arrays in a sensible fashion. |
259 function SparseMove(array, start_i, del_count, len, num_additional_args) { | 261 function SparseMove(array, start_i, del_count, len, num_additional_args) { |
260 // Bail out if no moving is necessary. | 262 // Bail out if no moving is necessary. |
261 if (num_additional_args === del_count) return; | 263 if (num_additional_args === del_count) return; |
262 // Move data to new array. | 264 // Move data to new array. |
263 var new_array = new InternalArray( | 265 var new_array = new InternalArray( |
264 // Clamp array length to 2^32-1 to avoid early RangeError. | 266 // Clamp array length to 2^32-1 to avoid early RangeError. |
265 MIN_SIMPLE(len - del_count + num_additional_args, 0xffffffff)); | 267 MathMin(len - del_count + num_additional_args, 0xffffffff)); |
266 var big_indices; | 268 var big_indices; |
267 var indices = %GetArrayKeys(array, len); | 269 var indices = %GetArrayKeys(array, len); |
268 if (IS_NUMBER(indices)) { | 270 if (IS_NUMBER(indices)) { |
269 var limit = indices; | 271 var limit = indices; |
270 for (var i = 0; i < start_i && i < limit; ++i) { | 272 for (var i = 0; i < start_i && i < limit; ++i) { |
271 var current = array[i]; | 273 var current = array[i]; |
272 if (!IS_UNDEFINED(current) || i in array) { | 274 if (!IS_UNDEFINED(current) || i in array) { |
273 new_array[i] = current; | 275 new_array[i] = current; |
274 } | 276 } |
275 } | 277 } |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 %InstallToContext([ | 1654 %InstallToContext([ |
1653 "array_pop", ArrayPop, | 1655 "array_pop", ArrayPop, |
1654 "array_push", ArrayPush, | 1656 "array_push", ArrayPush, |
1655 "array_shift", ArrayShift, | 1657 "array_shift", ArrayShift, |
1656 "array_splice", ArraySplice, | 1658 "array_splice", ArraySplice, |
1657 "array_slice", ArraySlice, | 1659 "array_slice", ArraySlice, |
1658 "array_unshift", ArrayUnshift, | 1660 "array_unshift", ArrayUnshift, |
1659 ]); | 1661 ]); |
1660 | 1662 |
1661 }); | 1663 }); |
OLD | NEW |