| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 if (filter == ALL_PROPERTIES) { | 227 if (filter == ALL_PROPERTIES) { |
| 228 // Nothing to do. | 228 // Nothing to do. |
| 229 return keys; | 229 return keys; |
| 230 } | 230 } |
| 231 int store_position = 0; | 231 int store_position = 0; |
| 232 for (int i = 0; i < keys->length(); ++i) { | 232 for (int i = 0; i < keys->length(); ++i) { |
| 233 Handle<Name> key(Name::cast(keys->get(i)), isolate); | 233 Handle<Name> key(Name::cast(keys->get(i)), isolate); |
| 234 if (key->FilterKey(filter)) continue; // Skip this key. | 234 if (key->FilterKey(filter)) continue; // Skip this key. |
| 235 if (filter & ONLY_ENUMERABLE) { | 235 if (filter & ONLY_ENUMERABLE) { |
| 236 PropertyDescriptor desc; | 236 PropertyDescriptor desc; |
| 237 bool found = | 237 Maybe<bool> found = |
| 238 JSProxy::GetOwnPropertyDescriptor(isolate, owner, key, &desc); | 238 JSProxy::GetOwnPropertyDescriptor(isolate, owner, key, &desc); |
| 239 if (isolate->has_pending_exception()) return MaybeHandle<FixedArray>(); | 239 MAYBE_RETURN(found, MaybeHandle<FixedArray>()); |
| 240 if (!found || !desc.enumerable()) continue; // Skip this key. | 240 if (!found.FromJust() || !desc.enumerable()) continue; // Skip this key. |
| 241 } | 241 } |
| 242 // Keep this key. | 242 // Keep this key. |
| 243 if (store_position != i) { | 243 if (store_position != i) { |
| 244 keys->set(store_position, *key); | 244 keys->set(store_position, *key); |
| 245 } | 245 } |
| 246 store_position++; | 246 store_position++; |
| 247 } | 247 } |
| 248 if (store_position == 0) return isolate->factory()->empty_fixed_array(); | 248 if (store_position == 0) return isolate->factory()->empty_fixed_array(); |
| 249 keys->Shrink(store_position); | 249 keys->Shrink(store_position); |
| 250 return keys; | 250 return keys; |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 // Returns "false" in case of exception, "true" on success. | 254 // Returns "nothing" in case of exception, "true" on success. |
| 255 bool KeyAccumulator::AddKeysFromProxy(Handle<JSProxy> proxy, | 255 Maybe<bool> KeyAccumulator::AddKeysFromProxy(Handle<JSProxy> proxy, |
| 256 Handle<FixedArray> keys) { | 256 Handle<FixedArray> keys) { |
| 257 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 257 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 258 isolate_, keys, FilterProxyKeys(isolate_, proxy, keys, filter_), false); | 258 isolate_, keys, FilterProxyKeys(isolate_, proxy, keys, filter_), |
| 259 Nothing<bool>()); |
| 259 // Proxies define a complete list of keys with no distinction of | 260 // Proxies define a complete list of keys with no distinction of |
| 260 // elements and properties, which breaks the normal assumption for the | 261 // elements and properties, which breaks the normal assumption for the |
| 261 // KeyAccumulator. | 262 // KeyAccumulator. |
| 262 AddKeys(keys, PROXY_MAGIC); | 263 AddKeys(keys, PROXY_MAGIC); |
| 263 // Invert the current length to indicate a present proxy, so we can ignore | 264 // Invert the current length to indicate a present proxy, so we can ignore |
| 264 // element keys for this level. Otherwise we would not fully respect the order | 265 // element keys for this level. Otherwise we would not fully respect the order |
| 265 // given by the proxy. | 266 // given by the proxy. |
| 266 level_string_length_ = -level_string_length_; | 267 level_string_length_ = -level_string_length_; |
| 267 return true; | 268 return Just(true); |
| 268 } | 269 } |
| 269 | 270 |
| 270 | 271 |
| 271 void KeyAccumulator::AddElementKeysFromInterceptor( | 272 void KeyAccumulator::AddElementKeysFromInterceptor( |
| 272 Handle<JSObject> array_like) { | 273 Handle<JSObject> array_like) { |
| 273 AddKeys(array_like, CONVERT_TO_ARRAY_INDEX); | 274 AddKeys(array_like, CONVERT_TO_ARRAY_INDEX); |
| 274 // The interceptor might introduce duplicates for the current level, since | 275 // The interceptor might introduce duplicates for the current level, since |
| 275 // these keys get added after the objects's normal element keys. | 276 // these keys get added after the objects's normal element keys. |
| 276 SortCurrentElementsListRemoveDuplicates(); | 277 SortCurrentElementsListRemoveDuplicates(); |
| 277 } | 278 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 305 level_lengths_.push_back(level_symbol_length_); | 306 level_lengths_.push_back(level_symbol_length_); |
| 306 } | 307 } |
| 307 elements_.push_back(new std::vector<uint32_t>()); | 308 elements_.push_back(new std::vector<uint32_t>()); |
| 308 level_string_length_ = 0; | 309 level_string_length_ = 0; |
| 309 level_symbol_length_ = 0; | 310 level_symbol_length_ = 0; |
| 310 } | 311 } |
| 311 | 312 |
| 312 | 313 |
| 313 } // namespace internal | 314 } // namespace internal |
| 314 } // namespace v8 | 315 } // namespace v8 |
| OLD | NEW |