Chromium Code Reviews| 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 7565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7576 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); | 7576 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); |
| 7577 dictionary->CopyEnumKeysTo(*storage); | 7577 dictionary->CopyEnumKeysTo(*storage); |
| 7578 return storage; | 7578 return storage; |
| 7579 } | 7579 } |
| 7580 } | 7580 } |
| 7581 | 7581 |
| 7582 | 7582 |
| 7583 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, | 7583 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, |
| 7584 KeyCollectionType type, | 7584 KeyCollectionType type, |
| 7585 KeyFilter filter, | 7585 KeyFilter filter, |
| 7586 GetKeysConversion getConversion) { | 7586 GetKeysConversion getConversion, |
| 7587 bool only_enumerables) { | |
| 7587 USE(ContainsOnlyValidKeys); | 7588 USE(ContainsOnlyValidKeys); |
| 7588 Isolate* isolate = object->GetIsolate(); | 7589 Isolate* isolate = object->GetIsolate(); |
| 7589 KeyAccumulator accumulator(isolate, filter); | 7590 KeyAccumulator accumulator(isolate, filter); |
| 7590 Handle<JSFunction> arguments_function( | 7591 Handle<JSFunction> arguments_function( |
| 7591 JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor())); | 7592 JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor())); |
| 7592 PrototypeIterator::WhereToEnd end = type == OWN_ONLY | 7593 PrototypeIterator::WhereToEnd end = type == OWN_ONLY |
| 7593 ? PrototypeIterator::END_AT_NON_HIDDEN | 7594 ? PrototypeIterator::END_AT_NON_HIDDEN |
| 7594 : PrototypeIterator::END_AT_NULL; | 7595 : PrototypeIterator::END_AT_NULL; |
| 7595 // Only collect keys if access is permitted. | 7596 // Only collect keys if access is permitted. |
| 7596 for (PrototypeIterator iter(isolate, object, | 7597 for (PrototypeIterator iter(isolate, object, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 7618 // Check access rights if required. | 7619 // Check access rights if required. |
| 7619 if (current->IsAccessCheckNeeded() && | 7620 if (current->IsAccessCheckNeeded() && |
| 7620 !isolate->MayAccess(handle(isolate->context()), current)) { | 7621 !isolate->MayAccess(handle(isolate->context()), current)) { |
| 7621 if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { | 7622 if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { |
| 7622 isolate->ReportFailedAccessCheck(current); | 7623 isolate->ReportFailedAccessCheck(current); |
| 7623 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); | 7624 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); |
| 7624 } | 7625 } |
| 7625 break; | 7626 break; |
| 7626 } | 7627 } |
| 7627 | 7628 |
| 7628 JSObject::CollectOwnElementKeys(current, &accumulator, | 7629 JSObject::CollectOwnElementKeys( |
| 7629 static_cast<PropertyAttributes>(DONT_ENUM)); | 7630 current, &accumulator, |
| 7631 static_cast<PropertyAttributes>(only_enumerables ? DONT_ENUM : NONE)); | |
| 7630 | 7632 |
| 7631 // Add the element keys from the interceptor. | 7633 // Add the element keys from the interceptor. |
| 7632 if (current->HasIndexedInterceptor()) { | 7634 if (current->HasIndexedInterceptor()) { |
| 7633 Handle<JSObject> result; | 7635 Handle<JSObject> result; |
| 7634 if (JSObject::GetKeysForIndexedInterceptor(current, object) | 7636 if (JSObject::GetKeysForIndexedInterceptor(current, object) |
| 7635 .ToHandle(&result)) { | 7637 .ToHandle(&result)) { |
| 7636 accumulator.AddElementKeysFromInterceptor(result); | 7638 accumulator.AddElementKeysFromInterceptor(result); |
| 7637 } | 7639 } |
| 7638 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); | 7640 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); |
| 7639 } | 7641 } |
| 7640 | 7642 |
| 7641 if (filter == SKIP_SYMBOLS) { | 7643 if (filter == SKIP_SYMBOLS) { |
| 7644 if (!only_enumerables) UNIMPLEMENTED(); | |
| 7645 | |
| 7642 // We can cache the computed property keys if access checks are | 7646 // We can cache the computed property keys if access checks are |
| 7643 // not needed and no interceptors are involved. | 7647 // not needed and no interceptors are involved. |
| 7644 // | 7648 // |
| 7645 // We do not use the cache if the object has elements and | 7649 // We do not use the cache if the object has elements and |
| 7646 // therefore it does not make sense to cache the property names | 7650 // therefore it does not make sense to cache the property names |
| 7647 // for arguments objects. Arguments objects will always have | 7651 // for arguments objects. Arguments objects will always have |
| 7648 // elements. | 7652 // elements. |
| 7649 // Wrapped strings have elements, but don't have an elements | 7653 // Wrapped strings have elements, but don't have an elements |
| 7650 // array or dictionary. So the fast inline test for whether to | 7654 // array or dictionary. So the fast inline test for whether to |
| 7651 // use the cache says yes, so we should not create a cache. | 7655 // use the cache says yes, so we should not create a cache. |
| 7652 bool cache_enum_length = | 7656 bool cache_enum_length = |
| 7653 ((current->map()->GetConstructor() != *arguments_function) && | 7657 ((current->map()->GetConstructor() != *arguments_function) && |
| 7654 !current->IsJSValue() && !current->IsAccessCheckNeeded() && | 7658 !current->IsJSValue() && !current->IsAccessCheckNeeded() && |
| 7655 !current->HasNamedInterceptor() && | 7659 !current->HasNamedInterceptor() && |
| 7656 !current->HasIndexedInterceptor()); | 7660 !current->HasIndexedInterceptor()); |
| 7657 // Compute the property keys and cache them if possible. | 7661 // Compute the property keys and cache them if possible. |
| 7658 Handle<FixedArray> enum_keys = | 7662 Handle<FixedArray> enum_keys = |
| 7659 JSObject::GetEnumPropertyKeys(current, cache_enum_length); | 7663 JSObject::GetEnumPropertyKeys(current, cache_enum_length); |
| 7660 accumulator.AddKeys(enum_keys); | 7664 accumulator.AddKeys(enum_keys); |
| 7661 } else { | 7665 } else { |
| 7662 DCHECK(filter == INCLUDE_SYMBOLS); | 7666 DCHECK(filter == INCLUDE_SYMBOLS); |
| 7663 PropertyAttributes attr_filter = | 7667 PropertyAttributes attr_filter = static_cast<PropertyAttributes>( |
| 7664 static_cast<PropertyAttributes>(DONT_ENUM | PRIVATE_SYMBOL); | 7668 (only_enumerables ? DONT_ENUM : NONE) | PRIVATE_SYMBOL); |
|
Camillo Bruni
2015/11/05 08:29:35
If we're already at it, could you move attr_filter
| |
| 7665 current->CollectOwnPropertyNames(&accumulator, attr_filter); | 7669 current->CollectOwnPropertyNames(&accumulator, attr_filter); |
| 7666 } | 7670 } |
| 7667 | 7671 |
| 7668 // Add the property keys from the interceptor. | 7672 // Add the property keys from the interceptor. |
| 7669 if (current->HasNamedInterceptor()) { | 7673 if (current->HasNamedInterceptor()) { |
| 7670 Handle<JSObject> result; | 7674 Handle<JSObject> result; |
| 7671 if (JSObject::GetKeysForNamedInterceptor(current, object) | 7675 if (JSObject::GetKeysForNamedInterceptor(current, object) |
| 7672 .ToHandle(&result)) { | 7676 .ToHandle(&result)) { |
| 7673 accumulator.AddKeys(result); | 7677 accumulator.AddKeys(result); |
| 7674 } | 7678 } |
| (...skipping 10205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17880 if (cell->value() != *new_value) { | 17884 if (cell->value() != *new_value) { |
| 17881 cell->set_value(*new_value); | 17885 cell->set_value(*new_value); |
| 17882 Isolate* isolate = cell->GetIsolate(); | 17886 Isolate* isolate = cell->GetIsolate(); |
| 17883 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17887 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17884 isolate, DependentCode::kPropertyCellChangedGroup); | 17888 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17885 } | 17889 } |
| 17886 } | 17890 } |
| 17887 | 17891 |
| 17888 } // namespace internal | 17892 } // namespace internal |
| 17889 } // namespace v8 | 17893 } // namespace v8 |
| OLD | NEW |