| 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/keys.h" | 5 #include "src/keys.h" |
| 6 | 6 |
| 7 #include "src/api-arguments.h" | 7 #include "src/api-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/identity-map.h" | 10 #include "src/identity-map.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { | 24 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { |
| 25 int len = array->length(); | 25 int len = array->length(); |
| 26 for (int i = 0; i < len; i++) { | 26 for (int i = 0; i < len; i++) { |
| 27 Object* e = array->get(i); | 27 Object* e = array->get(i); |
| 28 if (!(e->IsName() || e->IsNumber())) return false; | 28 if (!(e->IsName() || e->IsNumber())) return false; |
| 29 } | 29 } |
| 30 return true; | 30 return true; |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 |
| 35 // static |
| 34 MaybeHandle<FixedArray> KeyAccumulator::GetKeys( | 36 MaybeHandle<FixedArray> KeyAccumulator::GetKeys( |
| 35 Handle<JSReceiver> object, KeyCollectionMode mode, PropertyFilter filter, | 37 Handle<JSReceiver> object, KeyCollectionMode mode, PropertyFilter filter, |
| 36 GetKeysConversion keys_conversion, bool filter_proxy_keys, bool is_for_in) { | 38 GetKeysConversion keys_conversion, bool filter_proxy_keys, bool is_for_in) { |
| 37 Isolate* isolate = object->GetIsolate(); | 39 Isolate* isolate = object->GetIsolate(); |
| 38 KeyAccumulator accumulator(isolate, mode, filter); | 40 FastKeyAccumulator accumulator(isolate, object, mode, filter); |
| 39 accumulator.set_filter_proxy_keys(filter_proxy_keys); | 41 accumulator.set_filter_proxy_keys(filter_proxy_keys); |
| 40 accumulator.set_is_for_in(is_for_in); | 42 accumulator.set_is_for_in(is_for_in); |
| 41 MAYBE_RETURN(accumulator.CollectKeys(object, object), | |
| 42 MaybeHandle<FixedArray>()); | |
| 43 return accumulator.GetKeys(keys_conversion); | 43 return accumulator.GetKeys(keys_conversion); |
| 44 } | 44 } |
| 45 | 45 |
| 46 Handle<FixedArray> KeyAccumulator::GetKeys(GetKeysConversion convert) { | 46 Handle<FixedArray> KeyAccumulator::GetKeys(GetKeysConversion convert) { |
| 47 if (keys_.is_null()) { | 47 if (keys_.is_null()) { |
| 48 return isolate_->factory()->empty_fixed_array(); | 48 return isolate_->factory()->empty_fixed_array(); |
| 49 } | 49 } |
| 50 if (mode_ == KeyCollectionMode::kOwnOnly && | 50 if (mode_ == KeyCollectionMode::kOwnOnly && |
| 51 keys_->map() == isolate_->heap()->fixed_array_map()) { | 51 keys_->map() == isolate_->heap()->fixed_array_map()) { |
| 52 return Handle<FixedArray>::cast(keys_); | 52 return Handle<FixedArray>::cast(keys_); |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 Nothing<bool>()); | 860 Nothing<bool>()); |
| 861 bool prev_filter_proxy_keys_ = filter_proxy_keys_; | 861 bool prev_filter_proxy_keys_ = filter_proxy_keys_; |
| 862 filter_proxy_keys_ = false; | 862 filter_proxy_keys_ = false; |
| 863 Maybe<bool> result = AddKeysFromJSProxy(proxy, keys); | 863 Maybe<bool> result = AddKeysFromJSProxy(proxy, keys); |
| 864 filter_proxy_keys_ = prev_filter_proxy_keys_; | 864 filter_proxy_keys_ = prev_filter_proxy_keys_; |
| 865 return result; | 865 return result; |
| 866 } | 866 } |
| 867 | 867 |
| 868 } // namespace internal | 868 } // namespace internal |
| 869 } // namespace v8 | 869 } // namespace v8 |
| OLD | NEW |