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

Side by Side Diff: src/keys.h

Issue 2169523002: [keys] Postpone shadowed key checking in the KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: typo Created 4 years, 5 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/elements.cc ('k') | src/keys.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 #ifndef V8_KEYS_H_ 5 #ifndef V8_KEYS_H_
6 #define V8_KEYS_H_ 6 #define V8_KEYS_H_
7 7
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void set_is_for_in(bool value) { is_for_in_ = value; } 76 void set_is_for_in(bool value) { is_for_in_ = value; }
77 void set_skip_indices(bool value) { skip_indices_ = value; } 77 void set_skip_indices(bool value) { skip_indices_ = value; }
78 // The last_non_empty_prototype is used to limit the prototypes for which 78 // The last_non_empty_prototype is used to limit the prototypes for which
79 // we have to keep track of non-enumerable keys that can shadow keys 79 // we have to keep track of non-enumerable keys that can shadow keys
80 // repeated on the prototype chain. 80 // repeated on the prototype chain.
81 void set_last_non_empty_prototype(Handle<JSReceiver> object) { 81 void set_last_non_empty_prototype(Handle<JSReceiver> object) {
82 last_non_empty_prototype_ = object; 82 last_non_empty_prototype_ = object;
83 } 83 }
84 // Shadowing keys are used to filter keys. This happens when non-enumerable 84 // Shadowing keys are used to filter keys. This happens when non-enumerable
85 // keys appear again on the prototype chain. 85 // keys appear again on the prototype chain.
86 void AddShadowKey(Object* key); 86 void AddShadowingKey(Object* key);
87 void AddShadowKey(Handle<Object> key); 87 void AddShadowingKey(Handle<Object> key);
88 88
89 private: 89 private:
90 Maybe<bool> CollectOwnKeys(Handle<JSReceiver> receiver, 90 Maybe<bool> CollectOwnKeys(Handle<JSReceiver> receiver,
91 Handle<JSObject> object); 91 Handle<JSObject> object);
92 Maybe<bool> CollectOwnJSProxyKeys(Handle<JSReceiver> receiver, 92 Maybe<bool> CollectOwnJSProxyKeys(Handle<JSReceiver> receiver,
93 Handle<JSProxy> proxy); 93 Handle<JSProxy> proxy);
94 Maybe<bool> CollectOwnJSProxyTargetKeys(Handle<JSProxy> proxy, 94 Maybe<bool> CollectOwnJSProxyTargetKeys(Handle<JSProxy> proxy,
95 Handle<JSReceiver> target); 95 Handle<JSReceiver> target);
96 Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy, 96 Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy,
97 Handle<FixedArray> keys); 97 Handle<FixedArray> keys);
98 bool IsShadowed(Handle<Object> key); 98 bool IsShadowed(Handle<Object> key);
99 bool HasShadowingKeys();
99 Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); } 100 Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); }
100 101
101 Isolate* isolate_; 102 Isolate* isolate_;
102 // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy 103 // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy
103 // keys a Handle<FixedArray>. The OrderedHashSet is in-place converted to the 104 // keys a Handle<FixedArray>. The OrderedHashSet is in-place converted to the
104 // result list, a FixedArray containing all collected keys. 105 // result list, a FixedArray containing all collected keys.
105 Handle<FixedArray> keys_; 106 Handle<FixedArray> keys_;
106 Handle<JSReceiver> last_non_empty_prototype_; 107 Handle<JSReceiver> last_non_empty_prototype_;
107 Handle<ObjectHashSet> shadowed_keys_; 108 Handle<ObjectHashSet> shadowing_keys_;
108 KeyCollectionMode mode_; 109 KeyCollectionMode mode_;
109 PropertyFilter filter_; 110 PropertyFilter filter_;
110 bool filter_proxy_keys_ = true; 111 bool filter_proxy_keys_ = true;
111 bool is_for_in_ = false; 112 bool is_for_in_ = false;
112 bool skip_indices_ = false; 113 bool skip_indices_ = false;
114 // For all the keys on the first receiver adding a shadowing key we can skip
115 // the shadow check.
116 bool skip_shadow_check_ = true;
113 117
114 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); 118 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator);
115 }; 119 };
116 120
117 // The FastKeyAccumulator handles the cases where there are no elements on the 121 // The FastKeyAccumulator handles the cases where there are no elements on the
118 // prototype chain and forwords the complex/slow cases to the normal 122 // prototype chain and forwords the complex/slow cases to the normal
119 // KeyAccumulator. This significantly speeds up the cases where the OWN_ONLY 123 // KeyAccumulator. This significantly speeds up the cases where the OWN_ONLY
120 // case where we do not have to walk the prototype chain. 124 // case where we do not have to walk the prototype chain.
121 class FastKeyAccumulator { 125 class FastKeyAccumulator {
122 public: 126 public:
(...skipping 26 matching lines...) Expand all
149 bool is_receiver_simple_enum_ = false; 153 bool is_receiver_simple_enum_ = false;
150 bool has_empty_prototype_ = false; 154 bool has_empty_prototype_ = false;
151 155
152 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); 156 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator);
153 }; 157 };
154 158
155 } // namespace internal 159 } // namespace internal
156 } // namespace v8 160 } // namespace v8
157 161
158 #endif // V8_KEYS_H_ 162 #endif // V8_KEYS_H_
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698