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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/elements.h" | 8 #include "src/elements.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
11 #include "src/keys.h" | 11 #include "src/keys.h" |
12 #include "src/objects-inl.h" | 12 #include "src/objects-inl.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Returns either a FixedArray or, if the given {receiver} has an enum cache | 19 // Returns either a FixedArray or, if the given {receiver} has an enum cache |
20 // that contains all enumerable properties of the {receiver} and its prototypes | 20 // that contains all enumerable properties of the {receiver} and its prototypes |
21 // have none, the map of the {receiver}. This is used to speed up the check for | 21 // have none, the map of the {receiver}. This is used to speed up the check for |
22 // deletions during a for-in. | 22 // deletions during a for-in. |
23 MaybeHandle<HeapObject> Enumerate(Handle<JSReceiver> receiver) { | 23 MaybeHandle<HeapObject> Enumerate(Handle<JSReceiver> receiver) { |
24 Isolate* const isolate = receiver->GetIsolate(); | 24 Isolate* const isolate = receiver->GetIsolate(); |
25 JSObject::MakePrototypesFast(receiver, kStartAtReceiver, isolate); | 25 JSObject::MakePrototypesFast(receiver, kStartAtReceiver, isolate); |
26 FastKeyAccumulator accumulator(isolate, receiver, | 26 FastKeyAccumulator accumulator(isolate, receiver, |
27 KeyCollectionMode::kIncludePrototypes, | 27 KeyCollectionMode::kIncludePrototypes, |
28 ENUMERABLE_STRINGS); | 28 ENUMERABLE_STRINGS); |
29 accumulator.set_filter_proxy_keys(false); | |
30 accumulator.set_is_for_in(true); | 29 accumulator.set_is_for_in(true); |
31 // Test if we have an enum cache for {receiver}. | 30 // Test if we have an enum cache for {receiver}. |
32 if (!accumulator.is_receiver_simple_enum()) { | 31 if (!accumulator.is_receiver_simple_enum()) { |
33 Handle<FixedArray> keys; | 32 Handle<FixedArray> keys; |
34 ASSIGN_RETURN_ON_EXCEPTION( | 33 ASSIGN_RETURN_ON_EXCEPTION( |
35 isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers), | 34 isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers), |
36 HeapObject); | 35 HeapObject); |
37 // Test again, since cache may have been built by GetKeys() calls above. | 36 // Test again, since cache may have been built by GetKeys() calls above. |
38 if (!accumulator.is_receiver_simple_enum()) return keys; | 37 if (!accumulator.is_receiver_simple_enum()) return keys; |
39 } | 38 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 SealHandleScope scope(isolate); | 193 SealHandleScope scope(isolate); |
195 DCHECK_EQ(1, args.length()); | 194 DCHECK_EQ(1, args.length()); |
196 CONVERT_SMI_ARG_CHECKED(index, 0); | 195 CONVERT_SMI_ARG_CHECKED(index, 0); |
197 DCHECK_LE(0, index); | 196 DCHECK_LE(0, index); |
198 DCHECK_LT(index, Smi::kMaxValue); | 197 DCHECK_LT(index, Smi::kMaxValue); |
199 return Smi::FromInt(index + 1); | 198 return Smi::FromInt(index + 1); |
200 } | 199 } |
201 | 200 |
202 } // namespace internal | 201 } // namespace internal |
203 } // namespace v8 | 202 } // namespace v8 |
OLD | NEW |