OLD | NEW |
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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 6161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6172 Handle<JSReceiver> props; | 6172 Handle<JSReceiver> props; |
6173 if (!Object::ToObject(isolate, properties).ToHandle(&props)) { | 6173 if (!Object::ToObject(isolate, properties).ToHandle(&props)) { |
6174 THROW_NEW_ERROR(isolate, | 6174 THROW_NEW_ERROR(isolate, |
6175 NewTypeError(MessageTemplate::kUndefinedOrNullToObject), | 6175 NewTypeError(MessageTemplate::kUndefinedOrNullToObject), |
6176 Object); | 6176 Object); |
6177 } | 6177 } |
6178 // 4. Let keys be props.[[OwnPropertyKeys]](). | 6178 // 4. Let keys be props.[[OwnPropertyKeys]](). |
6179 // 5. ReturnIfAbrupt(keys). | 6179 // 5. ReturnIfAbrupt(keys). |
6180 Handle<FixedArray> keys; | 6180 Handle<FixedArray> keys; |
6181 ASSIGN_RETURN_ON_EXCEPTION( | 6181 ASSIGN_RETURN_ON_EXCEPTION( |
6182 isolate, keys, KeyAccumulator::GetKeys(props, OWN_ONLY, ALL_PROPERTIES), | 6182 isolate, keys, KeyAccumulator::GetKeys(props, KeyCollectionMode::kOwnOnly, |
| 6183 ALL_PROPERTIES), |
6183 Object); | 6184 Object); |
6184 // 6. Let descriptors be an empty List. | 6185 // 6. Let descriptors be an empty List. |
6185 int capacity = keys->length(); | 6186 int capacity = keys->length(); |
6186 std::vector<PropertyDescriptor> descriptors(capacity); | 6187 std::vector<PropertyDescriptor> descriptors(capacity); |
6187 size_t descriptors_index = 0; | 6188 size_t descriptors_index = 0; |
6188 // 7. Repeat for each element nextKey of keys in List order, | 6189 // 7. Repeat for each element nextKey of keys in List order, |
6189 for (int i = 0; i < keys->length(); ++i) { | 6190 for (int i = 0; i < keys->length(); ++i) { |
6190 Handle<Object> next_key(keys->get(i), isolate); | 6191 Handle<Object> next_key(keys->get(i), isolate); |
6191 // 7a. Let propDesc be props.[[GetOwnProperty]](nextKey). | 6192 // 7a. Let propDesc be props.[[GetOwnProperty]](nextKey). |
6192 // 7b. ReturnIfAbrupt(propDesc). | 6193 // 7b. ReturnIfAbrupt(propDesc). |
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7850 } | 7851 } |
7851 } | 7852 } |
7852 } | 7853 } |
7853 } | 7854 } |
7854 } else { | 7855 } else { |
7855 // Only deep copy fields from the object literal expression. | 7856 // Only deep copy fields from the object literal expression. |
7856 // In particular, don't try to copy the length attribute of | 7857 // In particular, don't try to copy the length attribute of |
7857 // an array. | 7858 // an array. |
7858 PropertyFilter filter = static_cast<PropertyFilter>( | 7859 PropertyFilter filter = static_cast<PropertyFilter>( |
7859 ONLY_WRITABLE | ONLY_ENUMERABLE | ONLY_CONFIGURABLE); | 7860 ONLY_WRITABLE | ONLY_ENUMERABLE | ONLY_CONFIGURABLE); |
7860 KeyAccumulator accumulator(isolate, OWN_ONLY, filter); | 7861 KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly, filter); |
7861 accumulator.CollectOwnPropertyNames(copy, copy); | 7862 accumulator.CollectOwnPropertyNames(copy, copy); |
7862 Handle<FixedArray> names = accumulator.GetKeys(); | 7863 Handle<FixedArray> names = accumulator.GetKeys(); |
7863 for (int i = 0; i < names->length(); i++) { | 7864 for (int i = 0; i < names->length(); i++) { |
7864 DCHECK(names->get(i)->IsName()); | 7865 DCHECK(names->get(i)->IsName()); |
7865 Handle<Name> name(Name::cast(names->get(i))); | 7866 Handle<Name> name(Name::cast(names->get(i))); |
7866 Handle<Object> value = | 7867 Handle<Object> value = |
7867 JSObject::GetProperty(copy, name).ToHandleChecked(); | 7868 JSObject::GetProperty(copy, name).ToHandleChecked(); |
7868 if (value->IsJSObject()) { | 7869 if (value->IsJSObject()) { |
7869 Handle<JSObject> result; | 7870 Handle<JSObject> result; |
7870 ASSIGN_RETURN_ON_EXCEPTION( | 7871 ASSIGN_RETURN_ON_EXCEPTION( |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8246 Handle<FixedArray> values_or_entries; | 8247 Handle<FixedArray> values_or_entries; |
8247 if (filter == ENUMERABLE_STRINGS) { | 8248 if (filter == ENUMERABLE_STRINGS) { |
8248 Maybe<bool> fast_values_or_entries = FastGetOwnValuesOrEntries( | 8249 Maybe<bool> fast_values_or_entries = FastGetOwnValuesOrEntries( |
8249 isolate, object, get_entries, &values_or_entries); | 8250 isolate, object, get_entries, &values_or_entries); |
8250 if (fast_values_or_entries.IsNothing()) return MaybeHandle<FixedArray>(); | 8251 if (fast_values_or_entries.IsNothing()) return MaybeHandle<FixedArray>(); |
8251 if (fast_values_or_entries.FromJust()) return values_or_entries; | 8252 if (fast_values_or_entries.FromJust()) return values_or_entries; |
8252 } | 8253 } |
8253 | 8254 |
8254 PropertyFilter key_filter = | 8255 PropertyFilter key_filter = |
8255 static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE); | 8256 static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE); |
8256 KeyAccumulator accumulator(isolate, OWN_ONLY, key_filter); | 8257 KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly, key_filter); |
8257 MAYBE_RETURN(accumulator.CollectKeys(object, object), | 8258 MAYBE_RETURN(accumulator.CollectKeys(object, object), |
8258 MaybeHandle<FixedArray>()); | 8259 MaybeHandle<FixedArray>()); |
8259 Handle<FixedArray> keys = accumulator.GetKeys(CONVERT_TO_STRING); | 8260 Handle<FixedArray> keys = |
| 8261 accumulator.GetKeys(GetKeysConversion::kConvertToString); |
8260 | 8262 |
8261 values_or_entries = isolate->factory()->NewFixedArray(keys->length()); | 8263 values_or_entries = isolate->factory()->NewFixedArray(keys->length()); |
8262 int length = 0; | 8264 int length = 0; |
8263 | 8265 |
8264 for (int i = 0; i < keys->length(); ++i) { | 8266 for (int i = 0; i < keys->length(); ++i) { |
8265 Handle<Name> key = Handle<Name>::cast(handle(keys->get(i), isolate)); | 8267 Handle<Name> key = Handle<Name>::cast(handle(keys->get(i), isolate)); |
8266 | 8268 |
8267 if (filter & ONLY_ENUMERABLE) { | 8269 if (filter & ONLY_ENUMERABLE) { |
8268 PropertyDescriptor descriptor; | 8270 PropertyDescriptor descriptor; |
8269 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( | 8271 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( |
(...skipping 9230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17500 Isolate* isolate = table->GetIsolate(); | 17502 Isolate* isolate = table->GetIsolate(); |
17501 int length = table->NumberOfElements(); | 17503 int length = table->NumberOfElements(); |
17502 int nof_buckets = table->NumberOfBuckets(); | 17504 int nof_buckets = table->NumberOfBuckets(); |
17503 // Convert the dictionary to a linear list. | 17505 // Convert the dictionary to a linear list. |
17504 Handle<FixedArray> result = Handle<FixedArray>::cast(table); | 17506 Handle<FixedArray> result = Handle<FixedArray>::cast(table); |
17505 // From this point on table is no longer a valid OrderedHashSet. | 17507 // From this point on table is no longer a valid OrderedHashSet. |
17506 result->set_map(isolate->heap()->fixed_array_map()); | 17508 result->set_map(isolate->heap()->fixed_array_map()); |
17507 for (int i = 0; i < length; i++) { | 17509 for (int i = 0; i < length; i++) { |
17508 int index = kHashTableStartIndex + nof_buckets + (i * kEntrySize); | 17510 int index = kHashTableStartIndex + nof_buckets + (i * kEntrySize); |
17509 Object* key = table->get(index); | 17511 Object* key = table->get(index); |
17510 if (convert == CONVERT_TO_STRING && key->IsNumber()) { | 17512 if (convert == GetKeysConversion::kConvertToString && key->IsNumber()) { |
17511 key = *isolate->factory()->NumberToString(handle(key, isolate)); | 17513 key = *isolate->factory()->NumberToString(handle(key, isolate)); |
17512 } | 17514 } |
17513 result->set(i, key); | 17515 result->set(i, key); |
17514 } | 17516 } |
17515 result->Shrink(length); | 17517 result->Shrink(length); |
17516 return result; | 17518 return result; |
17517 } | 17519 } |
17518 | 17520 |
17519 template<class Derived, class Iterator, int entrysize> | 17521 template<class Derived, class Iterator, int entrysize> |
17520 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Rehash( | 17522 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Rehash( |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18465 if (cell->value() != *new_value) { | 18467 if (cell->value() != *new_value) { |
18466 cell->set_value(*new_value); | 18468 cell->set_value(*new_value); |
18467 Isolate* isolate = cell->GetIsolate(); | 18469 Isolate* isolate = cell->GetIsolate(); |
18468 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18470 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18469 isolate, DependentCode::kPropertyCellChangedGroup); | 18471 isolate, DependentCode::kPropertyCellChangedGroup); |
18470 } | 18472 } |
18471 } | 18473 } |
18472 | 18474 |
18473 } // namespace internal | 18475 } // namespace internal |
18474 } // namespace v8 | 18476 } // namespace v8 |
OLD | NEW |