From 8aca22b1ef0d48a0164adc00a40e796fc48c30f6 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 18 Jun 2012 11:43:09 +0000 Subject: [PATCH] Implementing weak referencing elements transition maps. Review URL: https://chromiumcodereview.appspot.com/10559032 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11842 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mark-compact.cc | 3 --- src/objects-debug.cc | 5 +++++ src/objects-inl.h | 5 +++++ src/objects.cc | 5 +++++ src/objects.h | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 27f48d3..67f6e8e 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -1881,12 +1881,9 @@ void Marker::MarkDescriptorArray(DescriptorArray* descriptors) { enum_cache); } - // TODO(verwaest) Make sure we free unused transitions. if (descriptors->elements_transition_map() != NULL) { Object** transitions_slot = descriptors->GetTransitionsSlot(); Object* transitions = *transitions_slot; - base_marker()->MarkObjectAndPush( - reinterpret_cast(transitions)); mark_compact_collector()->RecordSlot(descriptor_start, transitions_slot, transitions); diff --git a/src/objects-debug.cc b/src/objects-debug.cc index fc593d5..cefa3f8 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -922,6 +922,11 @@ static bool CheckOneBackPointer(Map* current_map, Object* target) { bool DescriptorArray::IsConsistentWithBackPointers(Map* current_map) { + Map* elements_transition = elements_transition_map(); + if (elements_transition != NULL && + !CheckOneBackPointer(current_map, elements_transition)) { + return false; + } for (int i = 0; i < number_of_descriptors(); ++i) { switch (GetType(i)) { case MAP_TRANSITION: diff --git a/src/objects-inl.h b/src/objects-inl.h index 8a8f5d9..93e0b39 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1958,6 +1958,11 @@ void DescriptorArray::set_elements_transition_map( } +void DescriptorArray::ClearElementsTransition() { + WRITE_FIELD(this, kTransitionsOffset, Smi::FromInt(0)); +} + + Object** DescriptorArray::GetKeySlot(int descriptor_number) { ASSERT(descriptor_number < number_of_descriptors()); return HeapObject::RawField( diff --git a/src/objects.cc b/src/objects.cc index c0f102f..3b2db22 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -7353,6 +7353,11 @@ void Map::ClearNonLiveTransitions(Heap* heap) { DescriptorArray* d = DescriptorArray::cast( *RawField(this, Map::kInstanceDescriptorsOrBitField3Offset)); if (d->IsEmpty()) return; + Map* elements_transition = d->elements_transition_map(); + if (elements_transition != NULL && + ClearBackPointer(heap, elements_transition)) { + d->ClearElementsTransition(); + } Smi* NullDescriptorDetails = PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi(); for (int i = 0; i < d->number_of_descriptors(); ++i) { diff --git a/src/objects.h b/src/objects.h index da93bb1..1c249a9 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2438,6 +2438,7 @@ class DescriptorArray: public FixedArray { inline bool MayContainTransitions(); DECL_ACCESSORS(elements_transition_map, Map) + inline void ClearElementsTransition(); // Returns the number of descriptors in the array. int number_of_descriptors() { -- 2.7.4