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/factory.h" | 8 #include "src/factory.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Returns either a FixedArray or, if the given {receiver} has an enum cache | 17 // Returns either a FixedArray or, if the given {receiver} has an enum cache |
18 // that contains all enumerable properties of the {receiver} and its prototypes | 18 // that contains all enumerable properties of the {receiver} and its prototypes |
19 // have none, the map of the {receiver}. This is used to speed up the check for | 19 // have none, the map of the {receiver}. This is used to speed up the check for |
20 // deletions during a for-in. | 20 // deletions during a for-in. |
21 MaybeHandle<HeapObject> Enumerate(Handle<JSReceiver> receiver) { | 21 MaybeHandle<HeapObject> Enumerate(Handle<JSReceiver> receiver) { |
22 Isolate* const isolate = receiver->GetIsolate(); | 22 Isolate* const isolate = receiver->GetIsolate(); |
23 // Test if we have an enum cache for {receiver}. | 23 // Test if we have an enum cache for {receiver}. |
24 if (!receiver->IsSimpleEnum()) { | 24 if (!receiver->IsSimpleEnum()) { |
25 Handle<FixedArray> keys; | 25 Handle<FixedArray> keys; |
26 ASSIGN_RETURN_ON_EXCEPTION( | 26 ASSIGN_RETURN_ON_EXCEPTION( |
27 isolate, keys, JSReceiver::GetKeys(receiver, JSReceiver::INCLUDE_PROTOS, | 27 isolate, keys, |
28 ENUMERABLE_STRINGS), | 28 JSReceiver::GetKeys(receiver, INCLUDE_PROTOS, ENUMERABLE_STRINGS), |
29 HeapObject); | 29 HeapObject); |
30 // Test again, since cache may have been built by GetKeys() calls above. | 30 // Test again, since cache may have been built by GetKeys() calls above. |
31 if (!receiver->IsSimpleEnum()) return keys; | 31 if (!receiver->IsSimpleEnum()) return keys; |
32 } | 32 } |
33 return handle(receiver->map(), isolate); | 33 return handle(receiver->map(), isolate); |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 MaybeHandle<Object> Filter(Handle<JSReceiver> receiver, Handle<Object> key) { | 37 MaybeHandle<Object> Filter(Handle<JSReceiver> receiver, Handle<Object> key) { |
38 Isolate* const isolate = receiver->GetIsolate(); | 38 Isolate* const isolate = receiver->GetIsolate(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 SealHandleScope scope(isolate); | 133 SealHandleScope scope(isolate); |
134 DCHECK_EQ(1, args.length()); | 134 DCHECK_EQ(1, args.length()); |
135 CONVERT_SMI_ARG_CHECKED(index, 0); | 135 CONVERT_SMI_ARG_CHECKED(index, 0); |
136 DCHECK_LE(0, index); | 136 DCHECK_LE(0, index); |
137 DCHECK_LT(index, Smi::kMaxValue); | 137 DCHECK_LT(index, Smi::kMaxValue); |
138 return Smi::FromInt(index + 1); | 138 return Smi::FromInt(index + 1); |
139 } | 139 } |
140 | 140 |
141 } // namespace internal | 141 } // namespace internal |
142 } // namespace v8 | 142 } // namespace v8 |
OLD | NEW |