Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/elements.h" | 10 #include "src/elements.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 } | 193 } |
| 194 | 194 |
| 195 if (!array->elements()->IsDictionary()) { | 195 if (!array->elements()->IsDictionary()) { |
| 196 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || | 196 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || |
| 197 array->HasFastDoubleElements()); | 197 array->HasFastDoubleElements()); |
| 198 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 198 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
| 199 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 199 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 KeyAccumulator accumulator(isolate, OWN_ONLY, ALL_PROPERTIES); | 202 KeyAccumulator accumulator(isolate, OWN_ONLY, ALL_PROPERTIES); |
| 203 // No need to separate prototype levels since we only get element keys. | 203 // No need to separate prototype levels since we only get element keys. |
|
Jakob Kummerow
2016/05/23 16:25:22
outdated comment?
| |
| 204 for (PrototypeIterator iter(isolate, array, | 204 for (PrototypeIterator iter(isolate, array, |
| 205 PrototypeIterator::START_AT_RECEIVER); | 205 PrototypeIterator::START_AT_RECEIVER); |
| 206 !iter.IsAtEnd(); iter.Advance()) { | 206 !iter.IsAtEnd(); iter.Advance()) { |
| 207 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || | 207 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || |
| 208 PrototypeIterator::GetCurrent<JSObject>(iter) | 208 PrototypeIterator::GetCurrent<JSObject>(iter) |
| 209 ->HasIndexedInterceptor()) { | 209 ->HasIndexedInterceptor()) { |
| 210 // Bail out if we find a proxy or interceptor, likely not worth | 210 // Bail out if we find a proxy or interceptor, likely not worth |
| 211 // collecting keys in that case. | 211 // collecting keys in that case. |
| 212 return *isolate->factory()->NewNumberFromUint(length); | 212 return *isolate->factory()->NewNumberFromUint(length); |
| 213 } | 213 } |
| 214 accumulator.NextPrototype(); | |
| 215 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); | 214 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); |
| 216 accumulator.CollectOwnElementIndices(current); | 215 accumulator.CollectOwnElementIndices(array, current); |
| 217 } | 216 } |
| 218 // Erase any keys >= length. | 217 // Erase any keys >= length. |
| 219 Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); | 218 Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); |
| 220 int j = 0; | 219 int j = 0; |
| 221 for (int i = 0; i < keys->length(); i++) { | 220 for (int i = 0; i < keys->length(); i++) { |
| 222 if (NumberToUint32(keys->get(i)) >= length) continue; | 221 if (NumberToUint32(keys->get(i)) >= length) continue; |
| 223 if (i != j) keys->set(j, keys->get(i)); | 222 if (i != j) keys->set(j, keys->get(i)); |
| 224 j++; | 223 j++; |
| 225 } | 224 } |
| 226 | 225 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); | 492 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); |
| 494 Handle<Object> constructor; | 493 Handle<Object> constructor; |
| 495 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 494 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 496 isolate, constructor, | 495 isolate, constructor, |
| 497 Object::ArraySpeciesConstructor(isolate, original_array)); | 496 Object::ArraySpeciesConstructor(isolate, original_array)); |
| 498 return *constructor; | 497 return *constructor; |
| 499 } | 498 } |
| 500 | 499 |
| 501 } // namespace internal | 500 } // namespace internal |
| 502 } // namespace v8 | 501 } // namespace v8 |
| OLD | NEW |