| 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 <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 18029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18040 return da.dictionary_index() < db.dictionary_index(); | 18040 return da.dictionary_index() < db.dictionary_index(); |
| 18041 } | 18041 } |
| 18042 Dictionary* dict; | 18042 Dictionary* dict; |
| 18043 }; | 18043 }; |
| 18044 | 18044 |
| 18045 template <typename Derived, typename Shape, typename Key> | 18045 template <typename Derived, typename Shape, typename Key> |
| 18046 void Dictionary<Derived, Shape, Key>::CopyEnumKeysTo( | 18046 void Dictionary<Derived, Shape, Key>::CopyEnumKeysTo( |
| 18047 Handle<Dictionary<Derived, Shape, Key>> dictionary, | 18047 Handle<Dictionary<Derived, Shape, Key>> dictionary, |
| 18048 Handle<FixedArray> storage, KeyCollectionMode mode, | 18048 Handle<FixedArray> storage, KeyCollectionMode mode, |
| 18049 KeyAccumulator* accumulator) { | 18049 KeyAccumulator* accumulator) { |
| 18050 DCHECK_IMPLIES(mode != KeyCollectionMode::kOwnOnly, accumulator != nullptr); |
| 18050 Isolate* isolate = dictionary->GetIsolate(); | 18051 Isolate* isolate = dictionary->GetIsolate(); |
| 18051 int length = storage->length(); | 18052 int length = storage->length(); |
| 18052 int capacity = dictionary->Capacity(); | 18053 int capacity = dictionary->Capacity(); |
| 18053 int properties = 0; | 18054 int properties = 0; |
| 18054 for (int i = 0; i < capacity; i++) { | 18055 for (int i = 0; i < capacity; i++) { |
| 18055 Object* key = dictionary->KeyAt(i); | 18056 Object* key = dictionary->KeyAt(i); |
| 18056 bool is_shadowing_key = false; | 18057 bool is_shadowing_key = false; |
| 18057 if (!dictionary->IsKey(isolate, key)) continue; | 18058 if (!dictionary->IsKey(isolate, key)) continue; |
| 18058 if (key->IsSymbol()) continue; | 18059 if (key->IsSymbol()) continue; |
| 18059 PropertyDetails details = dictionary->DetailsAt(i); | 18060 PropertyDetails details = dictionary->DetailsAt(i); |
| 18060 if (details.IsDontEnum()) { | 18061 if (details.IsDontEnum()) { |
| 18061 if (mode == KeyCollectionMode::kIncludePrototypes) { | 18062 if (mode == KeyCollectionMode::kIncludePrototypes) { |
| 18062 is_shadowing_key = true; | 18063 is_shadowing_key = true; |
| 18063 } else { | 18064 } else { |
| 18064 continue; | 18065 continue; |
| 18065 } | 18066 } |
| 18066 } | 18067 } |
| 18067 if (dictionary->IsDeleted(i)) continue; | 18068 if (dictionary->IsDeleted(i)) continue; |
| 18068 if (is_shadowing_key) { | 18069 if (is_shadowing_key) { |
| 18069 accumulator->AddShadowingKey(key); | 18070 accumulator->AddShadowingKey(key); |
| 18070 continue; | 18071 continue; |
| 18071 } else { | 18072 } else { |
| 18072 storage->set(properties, Smi::FromInt(i)); | 18073 storage->set(properties, Smi::FromInt(i)); |
| 18073 } | 18074 } |
| 18074 properties++; | 18075 properties++; |
| 18075 if (properties == length) break; | 18076 if (mode == KeyCollectionMode::kOwnOnly && properties == length) break; |
| 18076 } | 18077 } |
| 18077 | 18078 |
| 18078 CHECK_EQ(length, properties); | 18079 CHECK_EQ(length, properties); |
| 18079 DisallowHeapAllocation no_gc; | 18080 DisallowHeapAllocation no_gc; |
| 18080 Dictionary<Derived, Shape, Key>* raw_dictionary = *dictionary; | 18081 Dictionary<Derived, Shape, Key>* raw_dictionary = *dictionary; |
| 18081 FixedArray* raw_storage = *storage; | 18082 FixedArray* raw_storage = *storage; |
| 18082 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(*dictionary)); | 18083 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(*dictionary)); |
| 18083 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); | 18084 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); |
| 18084 std::sort(start, start + length, cmp); | 18085 std::sort(start, start + length, cmp); |
| 18085 for (int i = 0; i < length; i++) { | 18086 for (int i = 0; i < length; i++) { |
| (...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20207 // depend on this. | 20208 // depend on this. |
| 20208 return DICTIONARY_ELEMENTS; | 20209 return DICTIONARY_ELEMENTS; |
| 20209 } | 20210 } |
| 20210 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20211 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20211 return kind; | 20212 return kind; |
| 20212 } | 20213 } |
| 20213 } | 20214 } |
| 20214 | 20215 |
| 20215 } // namespace internal | 20216 } // namespace internal |
| 20216 } // namespace v8 | 20217 } // namespace v8 |
| OLD | NEW |