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/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 15236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15247 if (HasFastProperties()) { | 15247 if (HasFastProperties()) { |
15248 int real_size = map()->NumberOfOwnDescriptors(); | 15248 int real_size = map()->NumberOfOwnDescriptors(); |
15249 Handle<DescriptorArray> descs(map()->instance_descriptors()); | 15249 Handle<DescriptorArray> descs(map()->instance_descriptors()); |
15250 for (int i = 0; i < real_size; i++) { | 15250 for (int i = 0; i < real_size; i++) { |
15251 if ((descs->GetDetails(i).attributes() & filter) != 0) continue; | 15251 if ((descs->GetDetails(i).attributes() & filter) != 0) continue; |
15252 Name* key = descs->GetKey(i); | 15252 Name* key = descs->GetKey(i); |
15253 if (key->FilterKey(filter)) continue; | 15253 if (key->FilterKey(filter)) continue; |
15254 keys->AddKey(key); | 15254 keys->AddKey(key); |
15255 } | 15255 } |
15256 } else if (IsJSGlobalObject()) { | 15256 } else if (IsJSGlobalObject()) { |
15257 global_dictionary()->CollectKeysTo(keys, filter); | 15257 GlobalDictionary::CollectKeysTo(handle(global_dictionary()), keys, filter); |
15258 } else { | 15258 } else { |
15259 property_dictionary()->CollectKeysTo(keys, filter); | 15259 NameDictionary::CollectKeysTo(handle(property_dictionary()), keys, filter); |
15260 } | 15260 } |
15261 } | 15261 } |
15262 | 15262 |
15263 | 15263 |
15264 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { | 15264 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { |
15265 // Fast case for objects with no elements. | 15265 // Fast case for objects with no elements. |
15266 if (!IsJSValue() && HasFastElements()) { | 15266 if (!IsJSValue() && HasFastElements()) { |
15267 uint32_t length = | 15267 uint32_t length = |
15268 IsJSArray() | 15268 IsJSArray() |
15269 ? static_cast<uint32_t>( | 15269 ? static_cast<uint32_t>( |
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17194 } | 17194 } |
17195 if (sort_mode == Dictionary::SORTED) { | 17195 if (sort_mode == Dictionary::SORTED) { |
17196 storage->SortPairs(storage, index); | 17196 storage->SortPairs(storage, index); |
17197 } | 17197 } |
17198 DCHECK(storage->length() >= index); | 17198 DCHECK(storage->length() >= index); |
17199 return index - start_index; | 17199 return index - start_index; |
17200 } | 17200 } |
17201 | 17201 |
17202 | 17202 |
17203 template <typename Derived, typename Shape, typename Key> | 17203 template <typename Derived, typename Shape, typename Key> |
17204 void Dictionary<Derived, Shape, Key>::CollectKeysTo(KeyAccumulator* keys, | 17204 void Dictionary<Derived, Shape, Key>::CollectKeysTo( |
17205 PropertyAttributes filter) { | 17205 Handle<Dictionary<Derived, Shape, Key> > dictionary, KeyAccumulator* keys, |
17206 int capacity = this->Capacity(); | 17206 PropertyAttributes filter) { |
| 17207 int capacity = dictionary->Capacity(); |
17207 Handle<FixedArray> array = | 17208 Handle<FixedArray> array = |
17208 keys->isolate()->factory()->NewFixedArray(this->NumberOfElements()); | 17209 keys->isolate()->factory()->NewFixedArray(dictionary->NumberOfElements()); |
17209 int array_size = 0; | 17210 int array_size = 0; |
17210 | 17211 |
17211 for (int i = 0; i < capacity; i++) { | 17212 { |
17212 Object* k = this->KeyAt(i); | 17213 DisallowHeapAllocation no_gc; |
17213 if (!this->IsKey(k) || k->FilterKey(filter)) continue; | 17214 Dictionary<Derived, Shape, Key>* raw_dict = *dictionary; |
17214 if (this->IsDeleted(i)) continue; | 17215 for (int i = 0; i < capacity; i++) { |
17215 PropertyDetails details = this->DetailsAt(i); | 17216 Object* k = raw_dict->KeyAt(i); |
17216 PropertyAttributes attr = details.attributes(); | 17217 if (!raw_dict->IsKey(k) || k->FilterKey(filter)) continue; |
17217 if ((attr & filter) != 0) continue; | 17218 if (raw_dict->IsDeleted(i)) continue; |
17218 array->set(array_size++, Smi::FromInt(i)); | 17219 PropertyDetails details = raw_dict->DetailsAt(i); |
| 17220 PropertyAttributes attr = details.attributes(); |
| 17221 if ((attr & filter) != 0) continue; |
| 17222 array->set(array_size++, Smi::FromInt(i)); |
| 17223 } |
| 17224 |
| 17225 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(raw_dict)); |
| 17226 Smi** start = reinterpret_cast<Smi**>(array->GetFirstElementAddress()); |
| 17227 std::sort(start, start + array_size, cmp); |
17219 } | 17228 } |
17220 | 17229 |
17221 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(this)); | |
17222 Smi** start = reinterpret_cast<Smi**>(array->GetFirstElementAddress()); | |
17223 std::sort(start, start + array_size, cmp); | |
17224 for (int i = 0; i < array_size; i++) { | 17230 for (int i = 0; i < array_size; i++) { |
17225 int index = Smi::cast(array->get(i))->value(); | 17231 int index = Smi::cast(array->get(i))->value(); |
17226 keys->AddKey(this->KeyAt(index)); | 17232 keys->AddKey(dictionary->KeyAt(index)); |
17227 } | 17233 } |
17228 } | 17234 } |
17229 | 17235 |
17230 | 17236 |
17231 // Backwards lookup (slow). | 17237 // Backwards lookup (slow). |
17232 template<typename Derived, typename Shape, typename Key> | 17238 template<typename Derived, typename Shape, typename Key> |
17233 Object* Dictionary<Derived, Shape, Key>::SlowReverseLookup(Object* value) { | 17239 Object* Dictionary<Derived, Shape, Key>::SlowReverseLookup(Object* value) { |
17234 int capacity = this->Capacity(); | 17240 int capacity = this->Capacity(); |
17235 for (int i = 0; i < capacity; i++) { | 17241 for (int i = 0; i < capacity; i++) { |
17236 Object* k = this->KeyAt(i); | 17242 Object* k = this->KeyAt(i); |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18430 if (cell->value() != *new_value) { | 18436 if (cell->value() != *new_value) { |
18431 cell->set_value(*new_value); | 18437 cell->set_value(*new_value); |
18432 Isolate* isolate = cell->GetIsolate(); | 18438 Isolate* isolate = cell->GetIsolate(); |
18433 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18439 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18434 isolate, DependentCode::kPropertyCellChangedGroup); | 18440 isolate, DependentCode::kPropertyCellChangedGroup); |
18435 } | 18441 } |
18436 } | 18442 } |
18437 | 18443 |
18438 } // namespace internal | 18444 } // namespace internal |
18439 } // namespace v8 | 18445 } // namespace v8 |
OLD | NEW |