Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: src/elements.cc

Issue 1491743008: [proxies] Add all-can-read/String/Symbol filtering support to GetKeys() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: critical correctness fix ;-) Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/key-accumulator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/key-accumulator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698