| 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 FastKeyAccumulator accumulator(isolate, receiver, | 26 FastKeyAccumulator accumulator(isolate, receiver, |
| 26 KeyCollectionMode::kIncludePrototypes, | 27 KeyCollectionMode::kIncludePrototypes, |
| 27 ENUMERABLE_STRINGS); | 28 ENUMERABLE_STRINGS); |
| 28 accumulator.set_filter_proxy_keys(false); | 29 accumulator.set_filter_proxy_keys(false); |
| 29 accumulator.set_is_for_in(true); | 30 accumulator.set_is_for_in(true); |
| 30 // Test if we have an enum cache for {receiver}. | 31 // Test if we have an enum cache for {receiver}. |
| 31 if (!accumulator.is_receiver_simple_enum()) { | 32 if (!accumulator.is_receiver_simple_enum()) { |
| 32 Handle<FixedArray> keys; | 33 Handle<FixedArray> keys; |
| 33 ASSIGN_RETURN_ON_EXCEPTION( | 34 ASSIGN_RETURN_ON_EXCEPTION( |
| 34 isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers), | 35 isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers), |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 SealHandleScope scope(isolate); | 185 SealHandleScope scope(isolate); |
| 185 DCHECK_EQ(1, args.length()); | 186 DCHECK_EQ(1, args.length()); |
| 186 CONVERT_SMI_ARG_CHECKED(index, 0); | 187 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 187 DCHECK_LE(0, index); | 188 DCHECK_LE(0, index); |
| 188 DCHECK_LT(index, Smi::kMaxValue); | 189 DCHECK_LT(index, Smi::kMaxValue); |
| 189 return Smi::FromInt(index + 1); | 190 return Smi::FromInt(index + 1); |
| 190 } | 191 } |
| 191 | 192 |
| 192 } // namespace internal | 193 } // namespace internal |
| 193 } // namespace v8 | 194 } // namespace v8 |
| OLD | NEW |