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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 13328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13339 } else { | 13339 } else { |
13340 HeapSortPairs(this, numbers, len); | 13340 HeapSortPairs(this, numbers, len); |
13341 return; | 13341 return; |
13342 } | 13342 } |
13343 } | 13343 } |
13344 | 13344 |
13345 | 13345 |
13346 // Fill in the names of own properties into the supplied storage. The main | 13346 // Fill in the names of own properties into the supplied storage. The main |
13347 // purpose of this function is to provide reflection information for the object | 13347 // purpose of this function is to provide reflection information for the object |
13348 // mirrors. | 13348 // mirrors. |
13349 void JSObject::GetOwnPropertyNames( | 13349 int JSObject::GetOwnPropertyNames(FixedArray* storage, int index, |
13350 FixedArray* storage, int index, PropertyAttributes filter) { | 13350 PropertyAttributes filter) { |
13351 DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index)); | 13351 DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index)); |
13352 if (HasFastProperties()) { | 13352 if (HasFastProperties()) { |
13353 int offset = 0; | |
13353 int real_size = map()->NumberOfOwnDescriptors(); | 13354 int real_size = map()->NumberOfOwnDescriptors(); |
13354 DescriptorArray* descs = map()->instance_descriptors(); | 13355 DescriptorArray* descs = map()->instance_descriptors(); |
13355 for (int i = 0; i < real_size; i++) { | 13356 for (int i = 0; i < real_size; i++) { |
13356 if ((descs->GetDetails(i).attributes() & filter) == 0 && | 13357 if ((descs->GetDetails(i).attributes() & filter) == 0 && |
13357 !FilterKey(descs->GetKey(i), filter)) { | 13358 !FilterKey(descs->GetKey(i), filter)) { |
13358 storage->set(index++, descs->GetKey(i)); | 13359 storage->set(index + offset, descs->GetKey(i)); |
13360 offset++; | |
13359 } | 13361 } |
13360 } | 13362 } |
13363 return offset; | |
13361 } else { | 13364 } else { |
13362 property_dictionary()->CopyKeysTo(storage, | 13365 return property_dictionary()->CopyKeysTo(storage, index, filter, |
13363 index, | 13366 NameDictionary::UNSORTED); |
13364 filter, | |
13365 NameDictionary::UNSORTED); | |
13366 } | 13367 } |
13367 } | 13368 } |
13368 | 13369 |
13369 | 13370 |
13370 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { | 13371 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { |
13371 return GetOwnElementKeys(NULL, filter); | 13372 return GetOwnElementKeys(NULL, filter); |
13372 } | 13373 } |
13373 | 13374 |
13374 | 13375 |
13375 int JSObject::NumberOfEnumElements() { | 13376 int JSObject::NumberOfEnumElements() { |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14048 New(Isolate*, int, MinimumCapacity, PretenureFlag); | 14049 New(Isolate*, int, MinimumCapacity, PretenureFlag); |
14049 | 14050 |
14050 template Handle<NameDictionary> | 14051 template Handle<NameDictionary> |
14051 HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >:: | 14052 HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
14052 Shrink(Handle<NameDictionary>, Handle<Name>); | 14053 Shrink(Handle<NameDictionary>, Handle<Name>); |
14053 | 14054 |
14054 template Handle<SeededNumberDictionary> | 14055 template Handle<SeededNumberDictionary> |
14055 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 14056 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
14056 Shrink(Handle<SeededNumberDictionary>, uint32_t); | 14057 Shrink(Handle<SeededNumberDictionary>, uint32_t); |
14057 | 14058 |
14058 template void Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: | 14059 template int |
14059 CopyKeysTo( | 14060 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::CopyKeysTo( |
14060 FixedArray*, | 14061 FixedArray*, int, PropertyAttributes, |
14061 int, | 14062 Dictionary<NameDictionary, NameDictionaryShape, |
14062 PropertyAttributes, | 14063 Handle<Name> >::SortMode); |
14063 Dictionary< | |
14064 NameDictionary, NameDictionaryShape, Handle<Name> >::SortMode); | |
14065 | 14064 |
14066 template int | 14065 template int |
14067 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: | 14066 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
14068 NumberOfElementsFilterAttributes(PropertyAttributes); | 14067 NumberOfElementsFilterAttributes(PropertyAttributes); |
14069 | 14068 |
14070 template Handle<NameDictionary> | 14069 template Handle<NameDictionary> |
14071 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add( | 14070 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add( |
14072 Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails); | 14071 Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails); |
14073 | 14072 |
14074 template void | 14073 template void |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15201 EnumIndexComparator cmp(this); | 15200 EnumIndexComparator cmp(this); |
15202 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); | 15201 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); |
15203 std::sort(start, start + length, cmp); | 15202 std::sort(start, start + length, cmp); |
15204 for (int i = 0; i < length; i++) { | 15203 for (int i = 0; i < length; i++) { |
15205 int index = Smi::cast(storage->get(i))->value(); | 15204 int index = Smi::cast(storage->get(i))->value(); |
15206 storage->set(i, KeyAt(index)); | 15205 storage->set(i, KeyAt(index)); |
15207 } | 15206 } |
15208 } | 15207 } |
15209 | 15208 |
15210 | 15209 |
15211 template<typename Derived, typename Shape, typename Key> | 15210 template <typename Derived, typename Shape, typename Key> |
15212 void Dictionary<Derived, Shape, Key>::CopyKeysTo( | 15211 int Dictionary<Derived, Shape, Key>::CopyKeysTo( |
15213 FixedArray* storage, | 15212 FixedArray* storage, int index, PropertyAttributes filter, |
15214 int index, | |
15215 PropertyAttributes filter, | |
15216 typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) { | 15213 typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) { |
15217 DCHECK(storage->length() >= NumberOfElementsFilterAttributes(filter)); | 15214 DCHECK(storage->length() >= NumberOfElementsFilterAttributes(filter)); |
15218 int capacity = DerivedHashTable::Capacity(); | 15215 int capacity = DerivedHashTable::Capacity(); |
15216 int offset = 0; | |
15219 for (int i = 0; i < capacity; i++) { | 15217 for (int i = 0; i < capacity; i++) { |
15220 Object* k = DerivedHashTable::KeyAt(i); | 15218 Object* k = DerivedHashTable::KeyAt(i); |
15221 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) { | 15219 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) { |
15222 PropertyDetails details = DetailsAt(i); | 15220 PropertyDetails details = DetailsAt(i); |
15223 if (details.IsDeleted()) continue; | 15221 if (details.IsDeleted()) continue; |
15224 PropertyAttributes attr = details.attributes(); | 15222 PropertyAttributes attr = details.attributes(); |
15225 if ((attr & filter) == 0) storage->set(index++, k); | 15223 if ((attr & filter) == 0) storage->set(index + offset, k); |
15224 offset++; | |
15226 } | 15225 } |
15227 } | 15226 } |
15228 if (sort_mode == Dictionary::SORTED) { | 15227 if (sort_mode == Dictionary::SORTED) { |
15229 storage->SortPairs(storage, index); | 15228 storage->SortPairs(storage, index); |
Igor Sheludko
2014/09/17 09:09:50
index + offset?
| |
15230 } | 15229 } |
15231 DCHECK(storage->length() >= index); | 15230 DCHECK(storage->length() >= index + offset); |
15231 return offset; | |
15232 } | 15232 } |
15233 | 15233 |
15234 | 15234 |
15235 // Backwards lookup (slow). | 15235 // Backwards lookup (slow). |
15236 template<typename Derived, typename Shape, typename Key> | 15236 template<typename Derived, typename Shape, typename Key> |
15237 Object* Dictionary<Derived, Shape, Key>::SlowReverseLookup(Object* value) { | 15237 Object* Dictionary<Derived, Shape, Key>::SlowReverseLookup(Object* value) { |
15238 int capacity = DerivedHashTable::Capacity(); | 15238 int capacity = DerivedHashTable::Capacity(); |
15239 for (int i = 0; i < capacity; i++) { | 15239 for (int i = 0; i < capacity; i++) { |
15240 Object* k = DerivedHashTable::KeyAt(i); | 15240 Object* k = DerivedHashTable::KeyAt(i); |
15241 if (Dictionary::IsKey(k)) { | 15241 if (Dictionary::IsKey(k)) { |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16359 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16359 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16360 static const char* error_messages_[] = { | 16360 static const char* error_messages_[] = { |
16361 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16361 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16362 }; | 16362 }; |
16363 #undef ERROR_MESSAGES_TEXTS | 16363 #undef ERROR_MESSAGES_TEXTS |
16364 return error_messages_[reason]; | 16364 return error_messages_[reason]; |
16365 } | 16365 } |
16366 | 16366 |
16367 | 16367 |
16368 } } // namespace v8::internal | 16368 } } // namespace v8::internal |
OLD | NEW |