OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8192 Handle<Object> tmp2 = GetElement(jsobject, index2); | 8192 Handle<Object> tmp2 = GetElement(jsobject, index2); |
8193 | 8193 |
8194 SetElement(jsobject, index1, tmp2); | 8194 SetElement(jsobject, index1, tmp2); |
8195 SetElement(jsobject, index2, tmp1); | 8195 SetElement(jsobject, index2, tmp1); |
8196 | 8196 |
8197 return Heap::undefined_value(); | 8197 return Heap::undefined_value(); |
8198 } | 8198 } |
8199 | 8199 |
8200 | 8200 |
8201 // Returns an array that tells you where in the [0, length) interval an array | 8201 // Returns an array that tells you where in the [0, length) interval an array |
8202 // might have elements. Can either return keys or intervals. Keys can have | 8202 // might have elements. Can either return keys (positive integers) or |
8203 // gaps in (undefined). Intervals can also span over some undefined keys. | 8203 // intervals (pair of a negative integer (-start-1) followed by a |
| 8204 // positive (length)) or undefined values. |
| 8205 // Intervals can span over some keys that are not in the object. |
8204 static Object* Runtime_GetArrayKeys(Arguments args) { | 8206 static Object* Runtime_GetArrayKeys(Arguments args) { |
8205 ASSERT(args.length() == 2); | 8207 ASSERT(args.length() == 2); |
8206 HandleScope scope; | 8208 HandleScope scope; |
8207 CONVERT_ARG_CHECKED(JSObject, array, 0); | 8209 CONVERT_ARG_CHECKED(JSObject, array, 0); |
8208 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 8210 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
8209 if (array->elements()->IsDictionary()) { | 8211 if (array->elements()->IsDictionary()) { |
8210 // Create an array and get all the keys into it, then remove all the | 8212 // Create an array and get all the keys into it, then remove all the |
8211 // keys that are not integers in the range 0 to length-1. | 8213 // keys that are not integers in the range 0 to length-1. |
8212 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); | 8214 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); |
8213 int keys_length = keys->length(); | 8215 int keys_length = keys->length(); |
(...skipping 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10708 } else { | 10710 } else { |
10709 // Handle last resort GC and make sure to allow future allocations | 10711 // Handle last resort GC and make sure to allow future allocations |
10710 // to grow the heap without causing GCs (if possible). | 10712 // to grow the heap without causing GCs (if possible). |
10711 Counters::gc_last_resort_from_js.Increment(); | 10713 Counters::gc_last_resort_from_js.Increment(); |
10712 Heap::CollectAllGarbage(false); | 10714 Heap::CollectAllGarbage(false); |
10713 } | 10715 } |
10714 } | 10716 } |
10715 | 10717 |
10716 | 10718 |
10717 } } // namespace v8::internal | 10719 } } // namespace v8::internal |
OLD | NEW |