OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/elements.h" | 5 #include "src/elements.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 // handle creation causes noticeable performance degradation of the builtin. | 852 // handle creation causes noticeable performance degradation of the builtin. |
853 ElementsAccessorSubclass::CopyElementsImpl( | 853 ElementsAccessorSubclass::CopyElementsImpl( |
854 from, from_start, *to, from_kind, to_start, packed_size, copy_size); | 854 from, from_start, *to, from_kind, to_start, packed_size, copy_size); |
855 } | 855 } |
856 | 856 |
857 static void CollectElementIndicesImpl(Handle<JSObject> object, | 857 static void CollectElementIndicesImpl(Handle<JSObject> object, |
858 Handle<FixedArrayBase> backing_store, | 858 Handle<FixedArrayBase> backing_store, |
859 KeyAccumulator* keys, uint32_t range, | 859 KeyAccumulator* keys, uint32_t range, |
860 PropertyFilter filter, | 860 PropertyFilter filter, |
861 uint32_t offset) { | 861 uint32_t offset) { |
| 862 if (filter & ONLY_ALL_CAN_READ) { |
| 863 // Non-dictionary elements can't have all-can-read accessors. |
| 864 return; |
| 865 } |
862 uint32_t length = 0; | 866 uint32_t length = 0; |
863 if (object->IsJSArray()) { | 867 if (object->IsJSArray()) { |
864 length = Smi::cast(JSArray::cast(*object)->length())->value(); | 868 length = Smi::cast(JSArray::cast(*object)->length())->value(); |
865 } else { | 869 } else { |
866 length = | 870 length = |
867 ElementsAccessorSubclass::GetCapacityImpl(*object, *backing_store); | 871 ElementsAccessorSubclass::GetCapacityImpl(*object, *backing_store); |
868 } | 872 } |
869 if (range < length) length = range; | 873 if (range < length) length = range; |
870 for (uint32_t i = offset; i < length; i++) { | 874 for (uint32_t i = offset; i < length; i++) { |
871 if (!ElementsAccessorSubclass::HasElementImpl(object, i, backing_store, | 875 if (!ElementsAccessorSubclass::HasElementImpl(object, i, backing_store, |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 for (int i = 0; i < capacity; i++) { | 1137 for (int i = 0; i < capacity; i++) { |
1134 Object* k = dictionary->KeyAt(i); | 1138 Object* k = dictionary->KeyAt(i); |
1135 if (!dictionary->IsKey(k)) continue; | 1139 if (!dictionary->IsKey(k)) continue; |
1136 if (k->FilterKey(filter)) continue; | 1140 if (k->FilterKey(filter)) continue; |
1137 if (dictionary->IsDeleted(i)) continue; | 1141 if (dictionary->IsDeleted(i)) continue; |
1138 DCHECK(k->IsNumber()); | 1142 DCHECK(k->IsNumber()); |
1139 DCHECK_LE(k->Number(), kMaxUInt32); | 1143 DCHECK_LE(k->Number(), kMaxUInt32); |
1140 uint32_t index = static_cast<uint32_t>(k->Number()); | 1144 uint32_t index = static_cast<uint32_t>(k->Number()); |
1141 if (index < offset) continue; | 1145 if (index < offset) continue; |
1142 PropertyDetails details = dictionary->DetailsAt(i); | 1146 PropertyDetails details = dictionary->DetailsAt(i); |
| 1147 if (filter & ONLY_ALL_CAN_READ) { |
| 1148 if (details.kind() != kAccessor) continue; |
| 1149 Object* accessors = dictionary->ValueAt(i); |
| 1150 if (!accessors->IsAccessorInfo()) continue; |
| 1151 if (!AccessorInfo::cast(accessors)->all_can_read()) continue; |
| 1152 } |
1143 PropertyAttributes attr = details.attributes(); | 1153 PropertyAttributes attr = details.attributes(); |
1144 if ((attr & filter) != 0) continue; | 1154 if ((attr & filter) != 0) continue; |
1145 keys->AddKey(index); | 1155 keys->AddKey(index); |
1146 } | 1156 } |
1147 | 1157 |
1148 keys->SortCurrentElementsList(); | 1158 keys->SortCurrentElementsList(); |
1149 } | 1159 } |
1150 }; | 1160 }; |
1151 | 1161 |
1152 | 1162 |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 } | 2385 } |
2376 } | 2386 } |
2377 | 2387 |
2378 DCHECK(j == result_len); | 2388 DCHECK(j == result_len); |
2379 return result_array; | 2389 return result_array; |
2380 } | 2390 } |
2381 | 2391 |
2382 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2392 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
2383 } // namespace internal | 2393 } // namespace internal |
2384 } // namespace v8 | 2394 } // namespace v8 |
OLD | NEW |