From dd54b0acf74f128571fd16cb26658ffd7489d4ac Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Fri, 1 Jun 2012 09:12:01 +0000 Subject: [PATCH] ClearNonLiveTransitions indepedent of ContentArray Review URL: https://chromiumcodereview.appspot.com/10387231 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11693 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/objects-inl.h | 12 ++++++++++++ src/objects.cc | 17 +++++++---------- src/objects.h | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/objects-inl.h b/src/objects-inl.h index cffad132a9..30ed133657 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1943,6 +1943,12 @@ Object* DescriptorArray::GetValue(int descriptor_number) { } +void DescriptorArray::SetNullValueUnchecked(int descriptor_number, Heap* heap) { + ASSERT(descriptor_number < number_of_descriptors()); + GetContentArray()->set_null_unchecked(heap, ToValueIndex(descriptor_number)); +} + + PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { ASSERT(descriptor_number < number_of_descriptors()); Object* details = GetContentArray()->get(ToDetailsIndex(descriptor_number)); @@ -1950,6 +1956,12 @@ PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { } +void DescriptorArray::SetDetailsUnchecked(int descriptor_number, Smi* value) { + ASSERT(descriptor_number < number_of_descriptors()); + GetContentArray()->set_unchecked(ToDetailsIndex(descriptor_number), value); +} + + PropertyType DescriptorArray::GetType(int descriptor_number) { return GetDetails(descriptor_number).type(); } diff --git a/src/objects.cc b/src/objects.cc index d64e9f812d..1bed135581 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -7440,23 +7440,20 @@ void Map::ClearNonLiveTransitions(Heap* heap) { if (d->IsEmpty()) return; Smi* NullDescriptorDetails = PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi(); - FixedArray* contents = FixedArray::cast( - d->get(DescriptorArray::kContentArrayIndex)); - ASSERT(contents->length() >= 2); - for (int i = 0; i < contents->length(); i += 2) { + for (int i = 0; i < d->number_of_descriptors(); ++i) { // If the pair (value, details) is a map transition, check if the target is // live. If not, null the descriptor. Also drop the back pointer for that // map transition, so that this map is not reached again by following a back // pointer from that non-live map. bool keep_entry = false; - PropertyDetails details(Smi::cast(contents->get(i + 1))); + PropertyDetails details(d->GetDetails(i)); switch (details.type()) { case MAP_TRANSITION: case CONSTANT_TRANSITION: - ClearBackPointer(heap, contents->get(i), &keep_entry); + ClearBackPointer(heap, d->GetValue(i), &keep_entry); break; case ELEMENTS_TRANSITION: { - Object* object = contents->get(i); + Object* object = d->GetValue(i); if (object->IsMap()) { ClearBackPointer(heap, object, &keep_entry); } else { @@ -7470,7 +7467,7 @@ void Map::ClearNonLiveTransitions(Heap* heap) { break; } case CALLBACKS: { - Object* object = contents->get(i); + Object* object = d->GetValue(i); if (object->IsAccessorPair()) { AccessorPair* accessors = AccessorPair::cast(object); if (ClearBackPointer(heap, accessors->getter(), &keep_entry)) { @@ -7497,8 +7494,8 @@ void Map::ClearNonLiveTransitions(Heap* heap) { // What we *really* want to do here is removing this entry completely, but // for technical reasons we can't do this, so we zero it out instead. if (!keep_entry) { - contents->set_unchecked(i + 1, NullDescriptorDetails); - contents->set_null_unchecked(heap, i); + d->SetDetailsUnchecked(i, NullDescriptorDetails); + d->SetNullValueUnchecked(i, heap); } } } diff --git a/src/objects.h b/src/objects.h index 15ce3a9664..16590a20a9 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2451,7 +2451,9 @@ class DescriptorArray: public FixedArray { inline String* GetKey(int descriptor_number); inline Object* GetValue(int descriptor_number); inline Object** GetValueSlot(int descriptor_number); + inline void SetNullValueUnchecked(int descriptor_number, Heap* heap); inline PropertyDetails GetDetails(int descriptor_number); + inline void SetDetailsUnchecked(int descriptor_number, Smi* value); inline PropertyType GetType(int descriptor_number); inline int GetFieldIndex(int descriptor_number); inline JSFunction* GetConstantFunction(int descriptor_number);