OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/key-accumulator.h" | 5 #include "src/key-accumulator.h" |
6 | 6 |
7 #include "src/elements.h" | 7 #include "src/elements.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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 | 24 |
25 Handle<FixedArray> KeyAccumulator::GetKeys(GetKeysConversion convert) { | 25 Handle<FixedArray> KeyAccumulator::GetKeys(GetKeysConversion convert) { |
26 if (length_ == 0) { | 26 if (length_ == 0) { |
27 return isolate_->factory()->empty_fixed_array(); | 27 return isolate_->factory()->empty_fixed_array(); |
28 } | 28 } |
29 // Make sure we have all the lengths collected. | 29 // Make sure we have all the lengths collected. |
30 NextPrototype(); | 30 NextPrototype(); |
31 | 31 |
| 32 if (type_ == KeyCollectionType::OWN_ONLY && !ownProxyKeys_.is_null()) { |
| 33 return ownProxyKeys_; |
| 34 } |
32 // Assemble the result array by first adding the element keys and then the | 35 // Assemble the result array by first adding the element keys and then the |
33 // property keys. We use the total number of String + Symbol keys per level in | 36 // property keys. We use the total number of String + Symbol keys per level in |
34 // |level_lengths_| and the available element keys in the corresponding bucket | 37 // |level_lengths_| and the available element keys in the corresponding bucket |
35 // in |elements_| to deduce the number of keys to take from the | 38 // in |elements_| to deduce the number of keys to take from the |
36 // |string_properties_| and |symbol_properties_| set. | 39 // |string_properties_| and |symbol_properties_| set. |
37 Handle<FixedArray> result = isolate_->factory()->NewFixedArray(length_); | 40 Handle<FixedArray> result = isolate_->factory()->NewFixedArray(length_); |
38 int insertion_index = 0; | 41 int insertion_index = 0; |
39 int string_properties_index = 0; | 42 int string_properties_index = 0; |
40 int symbol_properties_index = 0; | 43 int symbol_properties_index = 0; |
41 // String and Symbol lengths always come in pairs: | 44 // String and Symbol lengths always come in pairs: |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 256 |
254 // Returns "nothing" in case of exception, "true" on success. | 257 // Returns "nothing" in case of exception, "true" on success. |
255 Maybe<bool> KeyAccumulator::AddKeysFromProxy(Handle<JSProxy> proxy, | 258 Maybe<bool> KeyAccumulator::AddKeysFromProxy(Handle<JSProxy> proxy, |
256 Handle<FixedArray> keys) { | 259 Handle<FixedArray> keys) { |
257 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 260 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
258 isolate_, keys, FilterProxyKeys(isolate_, proxy, keys, filter_), | 261 isolate_, keys, FilterProxyKeys(isolate_, proxy, keys, filter_), |
259 Nothing<bool>()); | 262 Nothing<bool>()); |
260 // Proxies define a complete list of keys with no distinction of | 263 // Proxies define a complete list of keys with no distinction of |
261 // elements and properties, which breaks the normal assumption for the | 264 // elements and properties, which breaks the normal assumption for the |
262 // KeyAccumulator. | 265 // KeyAccumulator. |
263 AddKeys(keys, PROXY_MAGIC); | 266 if (type_ == KeyCollectionType::OWN_ONLY) { |
| 267 ownProxyKeys_ = keys; |
| 268 level_string_length_ = keys->length(); |
| 269 length_ = level_string_length_; |
| 270 } else { |
| 271 AddKeys(keys, PROXY_MAGIC); |
| 272 } |
264 // Invert the current length to indicate a present proxy, so we can ignore | 273 // Invert the current length to indicate a present proxy, so we can ignore |
265 // element keys for this level. Otherwise we would not fully respect the order | 274 // element keys for this level. Otherwise we would not fully respect the order |
266 // given by the proxy. | 275 // given by the proxy. |
267 level_string_length_ = -level_string_length_; | 276 level_string_length_ = -level_string_length_; |
268 return Just(true); | 277 return Just(true); |
269 } | 278 } |
270 | 279 |
271 | 280 |
272 void KeyAccumulator::AddElementKeysFromInterceptor( | 281 void KeyAccumulator::AddElementKeysFromInterceptor( |
273 Handle<JSObject> array_like) { | 282 Handle<JSObject> array_like) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 level_lengths_.push_back(level_symbol_length_); | 315 level_lengths_.push_back(level_symbol_length_); |
307 } | 316 } |
308 elements_.push_back(new std::vector<uint32_t>()); | 317 elements_.push_back(new std::vector<uint32_t>()); |
309 level_string_length_ = 0; | 318 level_string_length_ = 0; |
310 level_symbol_length_ = 0; | 319 level_symbol_length_ = 0; |
311 } | 320 } |
312 | 321 |
313 | 322 |
314 } // namespace internal | 323 } // namespace internal |
315 } // namespace v8 | 324 } // namespace v8 |
OLD | NEW |