OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 8821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8832 MaybeHandle<FixedArray>()); | 8832 MaybeHandle<FixedArray>()); |
8833 Handle<FixedArray> keys = accumulator.GetKeys(keys_conversion); | 8833 Handle<FixedArray> keys = accumulator.GetKeys(keys_conversion); |
8834 DCHECK(ContainsOnlyValidKeys(keys)); | 8834 DCHECK(ContainsOnlyValidKeys(keys)); |
8835 return keys; | 8835 return keys; |
8836 } | 8836 } |
8837 | 8837 |
8838 MaybeHandle<FixedArray> GetOwnValuesOrEntries(Isolate* isolate, | 8838 MaybeHandle<FixedArray> GetOwnValuesOrEntries(Isolate* isolate, |
8839 Handle<JSReceiver> object, | 8839 Handle<JSReceiver> object, |
8840 PropertyFilter filter, | 8840 PropertyFilter filter, |
8841 bool get_entries) { | 8841 bool get_entries) { |
8842 PropertyFilter key_filter = | 8842 Handle<FixedArray> keys; |
8843 static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE); | 8843 bool did_use_enum_cache = false; |
8844 KeyAccumulator accumulator(isolate, OWN_ONLY, key_filter); | 8844 int enum_length = object->map()->EnumLength(); |
8845 MAYBE_RETURN(GetKeys_Internal(isolate, object, object, OWN_ONLY, key_filter, | 8845 if ((filter == ENUMERABLE_STRINGS) && |
8846 &accumulator), | 8846 enum_length != kInvalidEnumCacheSentinel && |
8847 JSObject::cast(*object)->elements() == | |
8848 isolate->heap()->empty_fixed_array()) { | |
8849 DCHECK(!object->IsJSProxy()); | |
8850 if (enum_length == 0) { | |
8851 return isolate->factory()->empty_fixed_array(); | |
8852 } | |
8853 Handle<FixedArray> cache( | |
8854 object->map()->instance_descriptors()->GetEnumCache()); | |
8855 keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length); | |
8856 did_use_enum_cache = true; | |
Camillo Bruni
2016/03/01 20:50:13
I've got a long-term project running that eventual
caitp (gmail)
2016/03/01 21:02:40
It's not just for getting the property keys that I
Camillo Bruni
2016/03/02 09:21:51
Right, probably we could make the new key accumula
| |
8857 } else { | |
8858 PropertyFilter key_filter = | |
8859 static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE); | |
8860 KeyAccumulator accumulator(isolate, OWN_ONLY, key_filter); | |
8861 MAYBE_RETURN(GetKeys_Internal(isolate, object, object, OWN_ONLY, key_filter, | |
8862 &accumulator), | |
8847 MaybeHandle<FixedArray>()); | 8863 MaybeHandle<FixedArray>()); |
8848 Handle<FixedArray> keys = accumulator.GetKeys(CONVERT_TO_STRING); | 8864 keys = accumulator.GetKeys(CONVERT_TO_STRING); |
8849 DCHECK(ContainsOnlyValidKeys(keys)); | 8865 DCHECK(ContainsOnlyValidKeys(keys)); |
8866 } | |
8850 | 8867 |
8851 Handle<FixedArray> values_or_entries = | 8868 Handle<FixedArray> values_or_entries = |
8852 isolate->factory()->NewFixedArray(keys->length()); | 8869 isolate->factory()->NewFixedArray(keys->length()); |
8853 int length = 0; | 8870 int length = 0; |
8854 | 8871 |
8855 for (int i = 0; i < keys->length(); ++i) { | 8872 for (int i = 0; i < keys->length(); ++i) { |
8856 Handle<Name> key = Handle<Name>::cast(handle(keys->get(i), isolate)); | 8873 Handle<Name> key = Handle<Name>::cast(handle(keys->get(i), isolate)); |
8857 | 8874 |
8858 if (filter & ONLY_ENUMERABLE) { | 8875 if ((filter & ONLY_ENUMERABLE) && (!did_use_enum_cache || |
8876 object->map()->EnumLength() == kInvalidEnumCacheSentinel)) { | |
Camillo Bruni
2016/03/01 20:50:13
why the redundant check for the enum_length again
caitp (gmail)
2016/03/01 21:02:40
On line 8885, we [[GET]] the property, which can r
caitp (gmail)
2016/03/01 21:12:24
***work can be skipped if the EnumLength() is __no
Camillo Bruni
2016/03/02 09:21:51
I realised this once I fell asleep ;) too tired to
| |
8859 PropertyDescriptor descriptor; | 8877 PropertyDescriptor descriptor; |
8860 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( | 8878 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( |
8861 isolate, object, key, &descriptor); | 8879 isolate, object, key, &descriptor); |
8862 MAYBE_RETURN(did_get_descriptor, MaybeHandle<FixedArray>()); | 8880 MAYBE_RETURN(did_get_descriptor, MaybeHandle<FixedArray>()); |
8863 if (!did_get_descriptor.FromJust() || !descriptor.enumerable()) continue; | 8881 if (!did_get_descriptor.FromJust() || !descriptor.enumerable()) continue; |
8864 } | 8882 } |
8865 | 8883 |
8866 Handle<Object> value; | 8884 Handle<Object> value; |
8867 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 8885 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
8868 isolate, value, JSReceiver::GetPropertyOrElement(object, key), | 8886 isolate, value, JSReceiver::GetPropertyOrElement(object, key), |
(...skipping 10955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19824 if (cell->value() != *new_value) { | 19842 if (cell->value() != *new_value) { |
19825 cell->set_value(*new_value); | 19843 cell->set_value(*new_value); |
19826 Isolate* isolate = cell->GetIsolate(); | 19844 Isolate* isolate = cell->GetIsolate(); |
19827 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19845 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19828 isolate, DependentCode::kPropertyCellChangedGroup); | 19846 isolate, DependentCode::kPropertyCellChangedGroup); |
19829 } | 19847 } |
19830 } | 19848 } |
19831 | 19849 |
19832 } // namespace internal | 19850 } // namespace internal |
19833 } // namespace v8 | 19851 } // namespace v8 |
OLD | NEW |