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

Side by Side Diff: src/runtime/runtime-forin.cc

Issue 2002203002: [api] Add more parameters to Object::GetPropertyNames (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2016-05-06_keys_fast_path_1995263002
Patch Set: addressing nits Created 4 years, 6 months 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 | « src/runtime/runtime-array.cc ('k') | src/runtime/runtime-object.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 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 FastKeyAccumulator accumulator(isolate, receiver, INCLUDE_PROTOS, 25 FastKeyAccumulator accumulator(isolate, receiver,
26 KeyCollectionMode::kIncludePrototypes,
26 ENUMERABLE_STRINGS); 27 ENUMERABLE_STRINGS);
27 accumulator.set_filter_proxy_keys(false); 28 accumulator.set_filter_proxy_keys(false);
28 accumulator.set_is_for_in(true); 29 accumulator.set_is_for_in(true);
29 // Test if we have an enum cache for {receiver}. 30 // Test if we have an enum cache for {receiver}.
30 if (!accumulator.is_receiver_simple_enum()) { 31 if (!accumulator.is_receiver_simple_enum()) {
31 Handle<FixedArray> keys; 32 Handle<FixedArray> keys;
32 ASSIGN_RETURN_ON_EXCEPTION(isolate, keys, accumulator.GetKeys(KEEP_NUMBERS), 33 ASSIGN_RETURN_ON_EXCEPTION(
33 HeapObject); 34 isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers),
35 HeapObject);
34 // 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.
35 if (!accumulator.is_receiver_simple_enum()) return keys; 37 if (!accumulator.is_receiver_simple_enum()) return keys;
36 } 38 }
37 return handle(receiver->map(), isolate); 39 return handle(receiver->map(), isolate);
38 } 40 }
39 41
40 // This is a slight modifcation of JSReceiver::HasProperty, dealing with 42 // This is a slight modifcation of JSReceiver::HasProperty, dealing with
41 // the oddities of JSProxy in for-in filter. 43 // the oddities of JSProxy in for-in filter.
42 MaybeHandle<Object> HasEnumerableProperty(Isolate* isolate, 44 MaybeHandle<Object> HasEnumerableProperty(Isolate* isolate,
43 Handle<JSReceiver> receiver, 45 Handle<JSReceiver> receiver,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 SealHandleScope scope(isolate); 184 SealHandleScope scope(isolate);
183 DCHECK_EQ(1, args.length()); 185 DCHECK_EQ(1, args.length());
184 CONVERT_SMI_ARG_CHECKED(index, 0); 186 CONVERT_SMI_ARG_CHECKED(index, 0);
185 DCHECK_LE(0, index); 187 DCHECK_LE(0, index);
186 DCHECK_LT(index, Smi::kMaxValue); 188 DCHECK_LT(index, Smi::kMaxValue);
187 return Smi::FromInt(index + 1); 189 return Smi::FromInt(index + 1);
188 } 190 }
189 191
190 } // namespace internal 192 } // namespace internal
191 } // namespace v8 193 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698