| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/keys.h" | 5 #include "src/keys.h" |
| 6 | 6 |
| 7 #include "src/api-arguments.h" | 7 #include "src/api-arguments.h" |
| 8 #include "src/elements.h" | 8 #include "src/elements.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/identity-map.h" | 10 #include "src/identity-map.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 DCHECK(index == storage->length()); | 341 DCHECK(index == storage->length()); |
| 342 | 342 |
| 343 DescriptorArray::SetEnumCache(descs, isolate, storage, indices); | 343 DescriptorArray::SetEnumCache(descs, isolate, storage, indices); |
| 344 if (cache_enum_length) { | 344 if (cache_enum_length) { |
| 345 map->SetEnumLength(own_property_count); | 345 map->SetEnumLength(own_property_count); |
| 346 } | 346 } |
| 347 return storage; | 347 return storage; |
| 348 } | 348 } |
| 349 | 349 |
| 350 template <bool fast_properties> | 350 template <bool fast_properties> |
| 351 Handle<FixedArray> GetOwnKeysWithElements(Isolate* isolate, | 351 MaybeHandle<FixedArray> GetOwnKeysWithElements(Isolate* isolate, |
| 352 Handle<JSObject> object, | 352 Handle<JSObject> object, |
| 353 GetKeysConversion convert) { | 353 GetKeysConversion convert) { |
| 354 Handle<FixedArray> keys; | 354 Handle<FixedArray> keys; |
| 355 ElementsAccessor* accessor = object->GetElementsAccessor(); | 355 ElementsAccessor* accessor = object->GetElementsAccessor(); |
| 356 if (fast_properties) { | 356 if (fast_properties) { |
| 357 keys = GetFastEnumPropertyKeys(isolate, object); | 357 keys = GetFastEnumPropertyKeys(isolate, object); |
| 358 } else { | 358 } else { |
| 359 // TODO(cbruni): preallocate big enough array to also hold elements. | 359 // TODO(cbruni): preallocate big enough array to also hold elements. |
| 360 keys = KeyAccumulator::GetOwnEnumPropertyKeys(isolate, object); | 360 keys = KeyAccumulator::GetOwnEnumPropertyKeys(isolate, object); |
| 361 } | 361 } |
| 362 Handle<FixedArray> result = | 362 MaybeHandle<FixedArray> result = |
| 363 accessor->PrependElementIndices(object, keys, convert, ONLY_ENUMERABLE); | 363 accessor->PrependElementIndices(object, keys, convert, ONLY_ENUMERABLE); |
| 364 | 364 |
| 365 if (FLAG_trace_for_in_enumerate) { | 365 if (FLAG_trace_for_in_enumerate) { |
| 366 PrintF("| strings=%d symbols=0 elements=%u || prototypes>=1 ||\n", | 366 PrintF("| strings=%d symbols=0 elements=%u || prototypes>=1 ||\n", |
| 367 keys->length(), result->length() - keys->length()); | 367 keys->length(), result.ToHandleChecked()->length() - keys->length()); |
| 368 } | 368 } |
| 369 return result; | 369 return result; |
| 370 } | 370 } |
| 371 | 371 |
| 372 MaybeHandle<FixedArray> GetOwnKeysWithUninitializedEnumCache( | 372 MaybeHandle<FixedArray> GetOwnKeysWithUninitializedEnumCache( |
| 373 Isolate* isolate, Handle<JSObject> object) { | 373 Isolate* isolate, Handle<JSObject> object) { |
| 374 // Uninitalized enum cache | 374 // Uninitalized enum cache |
| 375 Map* map = object->map(); | 375 Map* map = object->map(); |
| 376 if (object->elements() != isolate->heap()->empty_fixed_array() || | 376 if (object->elements() != isolate->heap()->empty_fixed_array() || |
| 377 object->elements() != isolate->heap()->empty_slow_element_dictionary()) { | 377 object->elements() != isolate->heap()->empty_slow_element_dictionary()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool OnlyHasSimpleProperties(Map* map) { | 391 bool OnlyHasSimpleProperties(Map* map) { |
| 392 return map->instance_type() > LAST_CUSTOM_ELEMENTS_RECEIVER; | 392 return map->instance_type() > LAST_CUSTOM_ELEMENTS_RECEIVER; |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace | 395 } // namespace |
| 396 | 396 |
| 397 MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys( | 397 MaybeHandle<FixedArray> FastKeyAccumulator::GetKeys( |
| 398 GetKeysConversion keys_conversion) { | 398 GetKeysConversion keys_conversion) { |
| 399 Handle<FixedArray> keys; | 399 if (filter_ == ENUMERABLE_STRINGS) { |
| 400 if (filter_ == ENUMERABLE_STRINGS && | 400 Handle<FixedArray> keys; |
| 401 GetKeysFast(keys_conversion).ToHandle(&keys)) { | 401 if (GetKeysFast(keys_conversion).ToHandle(&keys)) { |
| 402 return keys; | 402 return keys; |
| 403 } |
| 404 if (isolate_->has_pending_exception()) return MaybeHandle<FixedArray>(); |
| 403 } | 405 } |
| 406 |
| 404 return GetKeysSlow(keys_conversion); | 407 return GetKeysSlow(keys_conversion); |
| 405 } | 408 } |
| 406 | 409 |
| 407 MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast( | 410 MaybeHandle<FixedArray> FastKeyAccumulator::GetKeysFast( |
| 408 GetKeysConversion keys_conversion) { | 411 GetKeysConversion keys_conversion) { |
| 409 bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly; | 412 bool own_only = has_empty_prototype_ || mode_ == KeyCollectionMode::kOwnOnly; |
| 410 Map* map = receiver_->map(); | 413 Map* map = receiver_->map(); |
| 411 if (!own_only || !OnlyHasSimpleProperties(map)) { | 414 if (!own_only || !OnlyHasSimpleProperties(map)) { |
| 412 return MaybeHandle<FixedArray>(); | 415 return MaybeHandle<FixedArray>(); |
| 413 } | 416 } |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 isolate_, keys, | 862 isolate_, keys, |
| 860 KeyAccumulator::GetKeys(target, KeyCollectionMode::kOwnOnly, filter_, | 863 KeyAccumulator::GetKeys(target, KeyCollectionMode::kOwnOnly, filter_, |
| 861 GetKeysConversion::kConvertToString, is_for_in_), | 864 GetKeysConversion::kConvertToString, is_for_in_), |
| 862 Nothing<bool>()); | 865 Nothing<bool>()); |
| 863 Maybe<bool> result = AddKeysFromJSProxy(proxy, keys); | 866 Maybe<bool> result = AddKeysFromJSProxy(proxy, keys); |
| 864 return result; | 867 return result; |
| 865 } | 868 } |
| 866 | 869 |
| 867 } // namespace internal | 870 } // namespace internal |
| 868 } // namespace v8 | 871 } // namespace v8 |
| OLD | NEW |