| 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 7571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7582 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); | 7582 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); |
| 7583 dictionary->CopyEnumKeysTo(*storage); | 7583 dictionary->CopyEnumKeysTo(*storage); |
| 7584 return storage; | 7584 return storage; |
| 7585 } | 7585 } |
| 7586 } | 7586 } |
| 7587 | 7587 |
| 7588 | 7588 |
| 7589 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, | 7589 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, |
| 7590 KeyCollectionType type, | 7590 KeyCollectionType type, |
| 7591 KeyFilter filter, | 7591 KeyFilter filter, |
| 7592 GetKeysConversion getConversion, | 7592 GetKeysConversion getConversion) { |
| 7593 Enumerability enum_policy) { | |
| 7594 USE(ContainsOnlyValidKeys); | 7593 USE(ContainsOnlyValidKeys); |
| 7595 Isolate* isolate = object->GetIsolate(); | 7594 Isolate* isolate = object->GetIsolate(); |
| 7596 KeyAccumulator accumulator(isolate, filter); | 7595 KeyAccumulator accumulator(isolate, filter); |
| 7597 Handle<JSFunction> arguments_function( | 7596 Handle<JSFunction> arguments_function( |
| 7598 JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor())); | 7597 JSFunction::cast(isolate->sloppy_arguments_map()->GetConstructor())); |
| 7599 PrototypeIterator::WhereToEnd end = type == OWN_ONLY | 7598 PrototypeIterator::WhereToEnd end = type == OWN_ONLY |
| 7600 ? PrototypeIterator::END_AT_NON_HIDDEN | 7599 ? PrototypeIterator::END_AT_NON_HIDDEN |
| 7601 : PrototypeIterator::END_AT_NULL; | 7600 : PrototypeIterator::END_AT_NULL; |
| 7602 PropertyAttributes attr_filter = static_cast<PropertyAttributes>( | |
| 7603 (enum_policy == RESPECT_ENUMERABILITY ? DONT_ENUM : NONE) | | |
| 7604 PRIVATE_SYMBOL); | |
| 7605 | |
| 7606 // Only collect keys if access is permitted. | 7601 // Only collect keys if access is permitted. |
| 7607 for (PrototypeIterator iter(isolate, object, | 7602 for (PrototypeIterator iter(isolate, object, |
| 7608 PrototypeIterator::START_AT_RECEIVER); | 7603 PrototypeIterator::START_AT_RECEIVER); |
| 7609 !iter.IsAtEnd(end); iter.Advance()) { | 7604 !iter.IsAtEnd(end); iter.Advance()) { |
| 7610 accumulator.NextPrototype(); | 7605 accumulator.NextPrototype(); |
| 7611 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | 7606 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { |
| 7612 Handle<JSProxy> proxy = PrototypeIterator::GetCurrent<JSProxy>(iter); | 7607 Handle<JSProxy> proxy = PrototypeIterator::GetCurrent<JSProxy>(iter); |
| 7613 Handle<Object> args[] = { proxy }; | 7608 Handle<Object> args[] = { proxy }; |
| 7614 Handle<Object> names; | 7609 Handle<Object> names; |
| 7615 ASSIGN_RETURN_ON_EXCEPTION( | 7610 ASSIGN_RETURN_ON_EXCEPTION( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7629 // Check access rights if required. | 7624 // Check access rights if required. |
| 7630 if (current->IsAccessCheckNeeded() && | 7625 if (current->IsAccessCheckNeeded() && |
| 7631 !isolate->MayAccess(handle(isolate->context()), current)) { | 7626 !isolate->MayAccess(handle(isolate->context()), current)) { |
| 7632 if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { | 7627 if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { |
| 7633 isolate->ReportFailedAccessCheck(current); | 7628 isolate->ReportFailedAccessCheck(current); |
| 7634 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); | 7629 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); |
| 7635 } | 7630 } |
| 7636 break; | 7631 break; |
| 7637 } | 7632 } |
| 7638 | 7633 |
| 7639 JSObject::CollectOwnElementKeys(current, &accumulator, attr_filter); | 7634 JSObject::CollectOwnElementKeys(current, &accumulator, |
| 7635 static_cast<PropertyAttributes>(DONT_ENUM)); |
| 7640 | 7636 |
| 7641 // Add the element keys from the interceptor. | 7637 // Add the element keys from the interceptor. |
| 7642 if (current->HasIndexedInterceptor()) { | 7638 if (current->HasIndexedInterceptor()) { |
| 7643 Handle<JSObject> result; | 7639 Handle<JSObject> result; |
| 7644 if (JSObject::GetKeysForIndexedInterceptor(current, object) | 7640 if (JSObject::GetKeysForIndexedInterceptor(current, object) |
| 7645 .ToHandle(&result)) { | 7641 .ToHandle(&result)) { |
| 7646 accumulator.AddElementKeysFromInterceptor(result); | 7642 accumulator.AddElementKeysFromInterceptor(result); |
| 7647 } | 7643 } |
| 7648 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); | 7644 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, FixedArray); |
| 7649 } | 7645 } |
| 7650 | 7646 |
| 7651 if (filter == SKIP_SYMBOLS) { | 7647 if (filter == SKIP_SYMBOLS) { |
| 7652 if (enum_policy == IGNORE_ENUMERABILITY) UNIMPLEMENTED(); | |
| 7653 | |
| 7654 // We can cache the computed property keys if access checks are | 7648 // We can cache the computed property keys if access checks are |
| 7655 // not needed and no interceptors are involved. | 7649 // not needed and no interceptors are involved. |
| 7656 // | 7650 // |
| 7657 // We do not use the cache if the object has elements and | 7651 // We do not use the cache if the object has elements and |
| 7658 // therefore it does not make sense to cache the property names | 7652 // therefore it does not make sense to cache the property names |
| 7659 // for arguments objects. Arguments objects will always have | 7653 // for arguments objects. Arguments objects will always have |
| 7660 // elements. | 7654 // elements. |
| 7661 // Wrapped strings have elements, but don't have an elements | 7655 // Wrapped strings have elements, but don't have an elements |
| 7662 // array or dictionary. So the fast inline test for whether to | 7656 // array or dictionary. So the fast inline test for whether to |
| 7663 // use the cache says yes, so we should not create a cache. | 7657 // use the cache says yes, so we should not create a cache. |
| 7664 bool cache_enum_length = | 7658 bool cache_enum_length = |
| 7665 ((current->map()->GetConstructor() != *arguments_function) && | 7659 ((current->map()->GetConstructor() != *arguments_function) && |
| 7666 !current->IsJSValue() && !current->IsAccessCheckNeeded() && | 7660 !current->IsJSValue() && !current->IsAccessCheckNeeded() && |
| 7667 !current->HasNamedInterceptor() && | 7661 !current->HasNamedInterceptor() && |
| 7668 !current->HasIndexedInterceptor()); | 7662 !current->HasIndexedInterceptor()); |
| 7669 // Compute the property keys and cache them if possible. | 7663 // Compute the property keys and cache them if possible. |
| 7670 Handle<FixedArray> enum_keys = | 7664 Handle<FixedArray> enum_keys = |
| 7671 JSObject::GetEnumPropertyKeys(current, cache_enum_length); | 7665 JSObject::GetEnumPropertyKeys(current, cache_enum_length); |
| 7672 accumulator.AddKeys(enum_keys); | 7666 accumulator.AddKeys(enum_keys); |
| 7673 } else { | 7667 } else { |
| 7674 DCHECK(filter == INCLUDE_SYMBOLS); | 7668 DCHECK(filter == INCLUDE_SYMBOLS); |
| 7669 PropertyAttributes attr_filter = |
| 7670 static_cast<PropertyAttributes>(DONT_ENUM | PRIVATE_SYMBOL); |
| 7675 current->CollectOwnPropertyNames(&accumulator, attr_filter); | 7671 current->CollectOwnPropertyNames(&accumulator, attr_filter); |
| 7676 } | 7672 } |
| 7677 | 7673 |
| 7678 // Add the property keys from the interceptor. | 7674 // Add the property keys from the interceptor. |
| 7679 if (current->HasNamedInterceptor()) { | 7675 if (current->HasNamedInterceptor()) { |
| 7680 Handle<JSObject> result; | 7676 Handle<JSObject> result; |
| 7681 if (JSObject::GetKeysForNamedInterceptor(current, object) | 7677 if (JSObject::GetKeysForNamedInterceptor(current, object) |
| 7682 .ToHandle(&result)) { | 7678 .ToHandle(&result)) { |
| 7683 accumulator.AddKeys(result); | 7679 accumulator.AddKeys(result); |
| 7684 } | 7680 } |
| (...skipping 10223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17908 if (cell->value() != *new_value) { | 17904 if (cell->value() != *new_value) { |
| 17909 cell->set_value(*new_value); | 17905 cell->set_value(*new_value); |
| 17910 Isolate* isolate = cell->GetIsolate(); | 17906 Isolate* isolate = cell->GetIsolate(); |
| 17911 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17907 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17912 isolate, DependentCode::kPropertyCellChangedGroup); | 17908 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17913 } | 17909 } |
| 17914 } | 17910 } |
| 17915 | 17911 |
| 17916 } // namespace internal | 17912 } // namespace internal |
| 17917 } // namespace v8 | 17913 } // namespace v8 |
| OLD | NEW |