Chromium Code Reviews| 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, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
| 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; | |
| 19 var ObjectHasOwnProperty; | 18 var ObjectHasOwnProperty; |
| 20 var ObjectIsFrozen; | 19 var ObjectIsFrozen; |
| 21 var ObjectIsSealed; | 20 var ObjectIsSealed; |
| 22 var ObjectToString; | 21 var ObjectToString; |
| 23 var ObserveBeginPerformSplice; | 22 var ObserveBeginPerformSplice; |
| 24 var ObserveEndPerformSplice; | 23 var ObserveEndPerformSplice; |
| 25 var ObserveEnqueueSpliceRecord; | 24 var ObserveEnqueueSpliceRecord; |
| 26 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); | 25 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); |
| 26 var MinSimple; | |
|
Jakob Kummerow
2015/10/15 14:18:48
nit: please preserve alpha-sorting
skomski
2015/10/15 15:17:58
Done.
| |
| 27 | 27 |
| 28 utils.Import(function(from) { | 28 utils.Import(function(from) { |
| 29 Delete = from.Delete; | 29 Delete = from.Delete; |
| 30 MathMin = from.MathMin; | |
| 31 ObjectHasOwnProperty = from.ObjectHasOwnProperty; | 30 ObjectHasOwnProperty = from.ObjectHasOwnProperty; |
| 32 ObjectIsFrozen = from.ObjectIsFrozen; | 31 ObjectIsFrozen = from.ObjectIsFrozen; |
| 33 ObjectIsSealed = from.ObjectIsSealed; | 32 ObjectIsSealed = from.ObjectIsSealed; |
| 34 ObjectToString = from.ObjectToString; | 33 ObjectToString = from.ObjectToString; |
| 35 ObserveBeginPerformSplice = from.ObserveBeginPerformSplice; | 34 ObserveBeginPerformSplice = from.ObserveBeginPerformSplice; |
| 36 ObserveEndPerformSplice = from.ObserveEndPerformSplice; | 35 ObserveEndPerformSplice = from.ObserveEndPerformSplice; |
| 37 ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord; | 36 ObserveEnqueueSpliceRecord = from.ObserveEnqueueSpliceRecord; |
| 37 MinSimple = from.MinSimple; | |
| 38 }); | 38 }); |
| 39 | 39 |
| 40 // ------------------------------------------------------------------- | 40 // ------------------------------------------------------------------- |
| 41 | 41 |
| 42 // Global list of arrays visited during toString, toLocaleString and | 42 // Global list of arrays visited during toString, toLocaleString and |
| 43 // join invocations. | 43 // join invocations. |
| 44 var visited_arrays = new InternalArray(); | 44 var visited_arrays = new InternalArray(); |
| 45 | 45 |
| 46 | 46 |
| 47 // Gets a sorted array of array keys. Useful for operations on sparse | 47 // Gets a sorted array of array keys. Useful for operations on sparse |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 | 259 |
| 260 | 260 |
| 261 // This function implements the optimized splice implementation that can use | 261 // This function implements the optimized splice implementation that can use |
| 262 // special array operations to handle sparse arrays in a sensible fashion. | 262 // special array operations to handle sparse arrays in a sensible fashion. |
| 263 function SparseMove(array, start_i, del_count, len, num_additional_args) { | 263 function SparseMove(array, start_i, del_count, len, num_additional_args) { |
| 264 // Bail out if no moving is necessary. | 264 // Bail out if no moving is necessary. |
| 265 if (num_additional_args === del_count) return; | 265 if (num_additional_args === del_count) return; |
| 266 // Move data to new array. | 266 // Move data to new array. |
| 267 var new_array = new InternalArray( | 267 var new_array = new InternalArray( |
| 268 // Clamp array length to 2^32-1 to avoid early RangeError. | 268 // Clamp array length to 2^32-1 to avoid early RangeError. |
| 269 MathMin(len - del_count + num_additional_args, 0xffffffff)); | 269 MinSimple(len - del_count + num_additional_args, 0xffffffff)); |
| 270 var big_indices; | 270 var big_indices; |
| 271 var indices = %GetArrayKeys(array, len); | 271 var indices = %GetArrayKeys(array, len); |
| 272 if (IS_NUMBER(indices)) { | 272 if (IS_NUMBER(indices)) { |
| 273 var limit = indices; | 273 var limit = indices; |
| 274 for (var i = 0; i < start_i && i < limit; ++i) { | 274 for (var i = 0; i < start_i && i < limit; ++i) { |
| 275 var current = array[i]; | 275 var current = array[i]; |
| 276 if (!IS_UNDEFINED(current) || i in array) { | 276 if (!IS_UNDEFINED(current) || i in array) { |
| 277 new_array[i] = current; | 277 new_array[i] = current; |
| 278 } | 278 } |
| 279 } | 279 } |
| (...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1667 %InstallToContext([ | 1667 %InstallToContext([ |
| 1668 "array_pop", ArrayPop, | 1668 "array_pop", ArrayPop, |
| 1669 "array_push", ArrayPush, | 1669 "array_push", ArrayPush, |
| 1670 "array_shift", ArrayShift, | 1670 "array_shift", ArrayShift, |
| 1671 "array_splice", ArraySplice, | 1671 "array_splice", ArraySplice, |
| 1672 "array_slice", ArraySlice, | 1672 "array_slice", ArraySlice, |
| 1673 "array_unshift", ArrayUnshift, | 1673 "array_unshift", ArrayUnshift, |
| 1674 ]); | 1674 ]); |
| 1675 | 1675 |
| 1676 }); | 1676 }); |
| OLD | NEW |