| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 6070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6081 // Allocate the array of keys. | 6081 // Allocate the array of keys. |
| 6082 MaybeObject* maybe_array = | 6082 MaybeObject* maybe_array = |
| 6083 heap->AllocateFixedArray(LengthFor(number_of_descriptors)); | 6083 heap->AllocateFixedArray(LengthFor(number_of_descriptors)); |
| 6084 if (!maybe_array->To(&result)) return maybe_array; | 6084 if (!maybe_array->To(&result)) return maybe_array; |
| 6085 | 6085 |
| 6086 result->set(kEnumCacheIndex, Smi::FromInt(0)); | 6086 result->set(kEnumCacheIndex, Smi::FromInt(0)); |
| 6087 return result; | 6087 return result; |
| 6088 } | 6088 } |
| 6089 | 6089 |
| 6090 | 6090 |
| 6091 void DescriptorArray::ClearEnumCache() { |
| 6092 set(kEnumCacheIndex, Smi::FromInt(0)); |
| 6093 } |
| 6094 |
| 6095 |
| 6091 void DescriptorArray::SetEnumCache(FixedArray* bridge_storage, | 6096 void DescriptorArray::SetEnumCache(FixedArray* bridge_storage, |
| 6092 FixedArray* new_cache, | 6097 FixedArray* new_cache, |
| 6093 Object* new_index_cache) { | 6098 Object* new_index_cache) { |
| 6094 ASSERT(bridge_storage->length() >= kEnumCacheBridgeLength); | 6099 ASSERT(bridge_storage->length() >= kEnumCacheBridgeLength); |
| 6095 ASSERT(new_index_cache->IsSmi() || new_index_cache->IsFixedArray()); | 6100 ASSERT(new_index_cache->IsSmi() || new_index_cache->IsFixedArray()); |
| 6096 if (HasEnumCache()) { | 6101 if (HasEnumCache()) { |
| 6097 ASSERT(new_cache->length() > FixedArray::cast(GetEnumCache())->length()); | 6102 ASSERT(new_cache->length() > FixedArray::cast(GetEnumCache())->length()); |
| 6098 FixedArray::cast(get(kEnumCacheIndex))-> | 6103 FixedArray::cast(get(kEnumCacheIndex))-> |
| 6099 set(kEnumCacheBridgeCacheIndex, new_cache); | 6104 set(kEnumCacheBridgeCacheIndex, new_cache); |
| 6100 FixedArray::cast(get(kEnumCacheIndex))-> | 6105 FixedArray::cast(get(kEnumCacheIndex))-> |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7482 // If there are no transitions to be cleared, return. | 7487 // If there are no transitions to be cleared, return. |
| 7483 // TODO(verwaest) Should be an assert, otherwise back pointers are not | 7488 // TODO(verwaest) Should be an assert, otherwise back pointers are not |
| 7484 // properly cleared. | 7489 // properly cleared. |
| 7485 if (transition_index == t->number_of_transitions()) return; | 7490 if (transition_index == t->number_of_transitions()) return; |
| 7486 } | 7491 } |
| 7487 | 7492 |
| 7488 int number_of_own_descriptors = NumberOfOwnDescriptors(); | 7493 int number_of_own_descriptors = NumberOfOwnDescriptors(); |
| 7489 | 7494 |
| 7490 if (descriptors_owner_died) { | 7495 if (descriptors_owner_died) { |
| 7491 if (number_of_own_descriptors > 0) { | 7496 if (number_of_own_descriptors > 0) { |
| 7492 int live_enum = NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); | |
| 7493 int number_of_descriptors = descriptors->number_of_descriptors(); | 7497 int number_of_descriptors = descriptors->number_of_descriptors(); |
| 7494 int to_trim = number_of_descriptors - number_of_own_descriptors; | 7498 int to_trim = number_of_descriptors - number_of_own_descriptors; |
| 7495 if (to_trim > 0) { | 7499 if (to_trim > 0) { |
| 7496 RightTrimFixedArray<FROM_GC>( | 7500 RightTrimFixedArray<FROM_GC>( |
| 7497 heap, descriptors, to_trim * DescriptorArray::kDescriptorSize); | 7501 heap, descriptors, to_trim * DescriptorArray::kDescriptorSize); |
| 7498 if (descriptors->HasEnumCache()) { | 7502 if (descriptors->HasEnumCache()) { |
| 7499 FixedArray* enum_cache = | 7503 int live_enum = |
| 7500 FixedArray::cast(descriptors->GetEnumCache()); | 7504 NumberOfDescribedProperties(OWN_DESCRIPTORS, DONT_ENUM); |
| 7501 to_trim = enum_cache->length() - live_enum; | 7505 if (live_enum == 0) { |
| 7502 if (to_trim > 0) { | 7506 descriptors->ClearEnumCache(); |
| 7503 RightTrimFixedArray<FROM_GC>( | 7507 } else { |
| 7504 heap, FixedArray::cast(descriptors->GetEnumCache()), to_trim); | 7508 FixedArray* enum_cache = |
| 7509 FixedArray::cast(descriptors->GetEnumCache()); |
| 7510 to_trim = enum_cache->length() - live_enum; |
| 7511 if (to_trim > 0) { |
| 7512 RightTrimFixedArray<FROM_GC>( |
| 7513 heap, FixedArray::cast(descriptors->GetEnumCache()), to_trim); |
| 7514 } |
| 7505 } | 7515 } |
| 7506 } | 7516 } |
| 7507 descriptors->Sort(); | 7517 descriptors->Sort(); |
| 7508 } | 7518 } |
| 7509 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); | 7519 ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); |
| 7510 } else { | 7520 } else { |
| 7511 t->set_descriptors(heap->empty_descriptor_array()); | 7521 t->set_descriptors(heap->empty_descriptor_array()); |
| 7512 } | 7522 } |
| 7513 set_owns_descriptors(true); | 7523 set_owns_descriptors(true); |
| 7514 } | 7524 } |
| (...skipping 5977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13492 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13502 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13493 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13503 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13494 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13504 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13495 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13505 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13496 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13506 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13497 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13507 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13498 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13508 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13499 } | 13509 } |
| 13500 | 13510 |
| 13501 } } // namespace v8::internal | 13511 } } // namespace v8::internal |
| OLD | NEW |