Implementing weak referencing elements transition maps.
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 18 Jun 2012 11:43:09 +0000 (11:43 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 18 Jun 2012 11:43:09 +0000 (11:43 +0000)
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
src/objects-debug.cc
src/objects-inl.h
src/objects.cc
src/objects.h

index 27f48d3..67f6e8e 100644 (file)
@@ -1881,12 +1881,9 @@ void Marker<T>::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<HeapObject*>(transitions));
     mark_compact_collector()->RecordSlot(descriptor_start,
                                          transitions_slot,
                                          transitions);
index fc593d5..cefa3f8 100644 (file)
@@ -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:
index 8a8f5d9..93e0b39 100644 (file)
@@ -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(
index c0f102f..3b2db22 100644 (file)
@@ -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) {
index da93bb1..1c249a9 100644 (file)
@@ -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() {