Revision: 12699
Author:   [email protected]
Date:     Thu Oct 11 05:01:19 2012
Log:      Remove descriptors pointer.

Secondary changes:
- don't transfer ownership back on CNLT
- turned debugging checks back into ASSERT

Review URL: https://chromiumcodereview.appspot.com/11099064
http://code.google.com/p/v8/source/detail?r=12699

Modified:
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects-visiting-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/profile-generator.cc
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/transitions-inl.h
 /branches/bleeding_edge/src/transitions.cc
 /branches/bleeding_edge/src/transitions.h
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Tue Oct 9 08:12:39 2012 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Thu Oct 11 05:01:19 2012
@@ -3727,8 +3727,7 @@
            isolate()->factory()->fixed_array_map(),
            &fail,
            DONT_DO_SMI_CHECK);
- ldr(temp, FieldMemOperand(temp, TransitionArray::kDescriptorsPointerOffset)); - ldr(descriptors, FieldMemOperand(temp, JSGlobalPropertyCell::kValueOffset)); + ldr(descriptors, FieldMemOperand(temp, TransitionArray::kDescriptorsOffset));
   jmp(&ok);

   bind(&fail);
@@ -3739,8 +3738,7 @@

   bind(&load_from_back_pointer);
   ldr(temp, FieldMemOperand(temp, Map::kTransitionsOrBackPointerOffset));
- ldr(temp, FieldMemOperand(temp, TransitionArray::kDescriptorsPointerOffset)); - ldr(descriptors, FieldMemOperand(temp, JSGlobalPropertyCell::kValueOffset)); + ldr(descriptors, FieldMemOperand(temp, TransitionArray::kDescriptorsOffset));

   bind(&ok);
 }
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Wed Sep 12 09:43:57 2012 +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Thu Oct 11 05:01:19 2012
@@ -2581,8 +2581,7 @@
            isolate()->factory()->fixed_array_map(),
            &fail,
            DONT_DO_SMI_CHECK);
- mov(temp, FieldOperand(temp, TransitionArray::kDescriptorsPointerOffset));
-  mov(descriptors, FieldOperand(temp, JSGlobalPropertyCell::kValueOffset));
+ mov(descriptors, FieldOperand(temp, TransitionArray::kDescriptorsOffset));
   jmp(&ok);

   bind(&fail);
@@ -2593,8 +2592,7 @@

   bind(&load_from_back_pointer);
   mov(temp, FieldOperand(temp, Map::kTransitionsOrBackPointerOffset));
- mov(temp, FieldOperand(temp, TransitionArray::kDescriptorsPointerOffset));
-  mov(descriptors, FieldOperand(temp, JSGlobalPropertyCell::kValueOffset));
+ mov(descriptors, FieldOperand(temp, TransitionArray::kDescriptorsOffset));

   bind(&ok);
 }
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Wed Sep 19 07:29:27 2012 +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Thu Oct 11 05:01:19 2012
@@ -5305,8 +5305,7 @@
            isolate()->factory()->fixed_array_map(),
            &fail,
            DONT_DO_SMI_CHECK);
- lw(temp, FieldMemOperand(temp, TransitionArray::kDescriptorsPointerOffset)); - lw(descriptors, FieldMemOperand(temp, JSGlobalPropertyCell::kValueOffset)); + lw(descriptors, FieldMemOperand(temp, TransitionArray::kDescriptorsOffset));
   jmp(&ok);

   bind(&fail);
@@ -5317,8 +5316,7 @@

   bind(&load_from_back_pointer);
   lw(temp, FieldMemOperand(temp, Map::kTransitionsOrBackPointerOffset));
- lw(temp, FieldMemOperand(temp, TransitionArray::kDescriptorsPointerOffset)); - lw(descriptors, FieldMemOperand(temp, JSGlobalPropertyCell::kValueOffset)); + lw(descriptors, FieldMemOperand(temp, TransitionArray::kDescriptorsOffset));

   bind(&ok);
 }
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Wed Oct 10 07:48:07 2012
+++ /branches/bleeding_edge/src/objects-inl.h   Thu Oct 11 05:01:19 2012
@@ -2163,12 +2163,6 @@
   set(ToValueIndex(descriptor_number), desc->GetValue());
   set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi());
 }
-
-
-void DescriptorArray::EraseDescriptor(Heap* heap, int descriptor_number) {
-  set_null_unchecked(heap, ToKeyIndex(descriptor_number));
-  set_null_unchecked(heap, ToValueIndex(descriptor_number));
-}


 void DescriptorArray::Append(Descriptor* desc,
@@ -3552,12 +3546,6 @@
   WRITE_FIELD(this, kPrototypeOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
 }
-
-
-JSGlobalPropertyCell* Map::descriptors_pointer() {
-  ASSERT(HasTransitionArray());
-  return transitions()->descriptors_pointer();
-}


 DescriptorArray* Map::instance_descriptors() {
@@ -3576,22 +3564,20 @@
static MaybeObject* EnsureHasTransitionArray(Map* map, TransitionsKind kind) {
   TransitionArray* transitions;
   MaybeObject* maybe_transitions;
-  if (map->HasTransitionArray()) {
-    if (kind != FULL_TRANSITION_ARRAY ||
-        map->transitions()->IsFullTransitionArray()) {
-      return map;
-    }
-    maybe_transitions = map->transitions()->ExtendToFullTransitionArray();
-    if (!maybe_transitions->To(&transitions)) return maybe_transitions;
-  } else {
-    JSGlobalPropertyCell* pointer = map->RetrieveDescriptorsPointer();
+  if (!map->HasTransitionArray()) {
     if (kind == FULL_TRANSITION_ARRAY) {
-      maybe_transitions = TransitionArray::Allocate(0, pointer);
+      maybe_transitions = TransitionArray::Allocate(0);
     } else {
- maybe_transitions = TransitionArray::AllocateDescriptorsHolder(pointer);
+      maybe_transitions = TransitionArray::AllocateDescriptorsHolder();
     }
     if (!maybe_transitions->To(&transitions)) return maybe_transitions;
     transitions->set_back_pointer_storage(map->GetBackPointer());
+  } else if (kind == FULL_TRANSITION_ARRAY &&
+             !map->transitions()->IsFullTransitionArray()) {
+    maybe_transitions = map->transitions()->ExtendToFullTransitionArray();
+    if (!maybe_transitions->To(&transitions)) return maybe_transitions;
+  } else {
+    return map;
   }
   map->set_transitions(transitions);
   return transitions;
@@ -3699,25 +3685,14 @@
                              TransitionArray::kTransitionSize)
       <= Page::kMaxNonCodeHeapObjectSize;
 }
-
-
-JSGlobalPropertyCell* Map::RetrieveDescriptorsPointer() {
-  if (!owns_descriptors()) return NULL;
-  Object* back_pointer = GetBackPointer();
-  if (back_pointer->IsUndefined()) return NULL;
-  Map* map = Map::cast(back_pointer);
-  ASSERT(map->HasTransitionArray());
-  return map->transitions()->descriptors_pointer();
-}


 MaybeObject* Map::AddTransition(String* key,
                                 Map* target,
                                 SimpleTransitionFlag flag) {
   if (HasTransitionArray()) return transitions()->CopyInsert(key, target);
-  JSGlobalPropertyCell* descriptors_pointer = RetrieveDescriptorsPointer();
   return TransitionArray::NewWith(
-      flag, key, target, descriptors_pointer, GetBackPointer());
+      flag, key, target, instance_descriptors(), GetBackPointer());
 }


@@ -3732,9 +3707,11 @@


 MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) {
+  DescriptorArray* descriptors = instance_descriptors();
   MaybeObject* allow_elements =
       EnsureHasTransitionArray(this, FULL_TRANSITION_ARRAY);
   if (allow_elements->IsFailure()) return allow_elements;
+  transitions()->set_descriptors(descriptors);
   transitions()->set_elements_transition(transitioned_map);
   return this;
 }
@@ -3750,6 +3727,7 @@


 MaybeObject* Map::SetPrototypeTransitions(FixedArray* proto_transitions) {
+  DescriptorArray* descriptors = instance_descriptors();
   MaybeObject* allow_prototype =
       EnsureHasTransitionArray(this, FULL_TRANSITION_ARRAY);
   if (allow_prototype->IsFailure()) return allow_prototype;
@@ -3759,6 +3737,7 @@
     ZapPrototypeTransitions();
   }
 #endif
+  transitions()->set_descriptors(descriptors);
   transitions()->SetPrototypeTransitions(proto_transitions);
   return this;
 }
=======================================
--- /branches/bleeding_edge/src/objects-visiting-inl.h Thu Oct 4 04:09:17 2012 +++ /branches/bleeding_edge/src/objects-visiting-inl.h Thu Oct 11 05:01:19 2012
@@ -328,7 +328,11 @@

   // Skip recording the descriptors_pointer slot since the cell space
   // is not compacted and descriptors are referenced through a cell.
-  StaticVisitor::MarkObject(heap, transitions->descriptors_pointer());
+  Object** descriptors_slot = transitions->GetDescriptorsSlot();
+  HeapObject* descriptors = HeapObject::cast(*descriptors_slot);
+  StaticVisitor::MarkObject(heap, descriptors);
+  heap->mark_compact_collector()->RecordSlot(
+      descriptors_slot, descriptors_slot, descriptors);

   // Simple transitions do not have keys nor prototype transitions.
   if (transitions->IsSimpleTransition()) return;
=======================================
--- /branches/bleeding_edge/src/objects.cc      Wed Oct 10 06:13:35 2012
+++ /branches/bleeding_edge/src/objects.cc      Thu Oct 11 05:01:19 2012
@@ -1777,13 +1777,7 @@
   // allocation that may fail.
   if (!old_target->StoresOwnDescriptors()) {
     DescriptorArray* old_descriptors = old_map->instance_descriptors();
-
-    old_target->SetBackPointer(GetHeap()->undefined_value());
MaybeObject* maybe_failure = old_target->SetDescriptors(old_descriptors); - // Reset the backpointer before returning failure, otherwise the map ends up
-    // with an undefined backpointer and no descriptors, losing its own
-    // descriptors. Setting the backpointer always succeeds.
-    old_target->SetBackPointer(old_map);
     if (maybe_failure->IsFailure()) return maybe_failure;
   }

@@ -1802,36 +1796,28 @@
   // invalid back pointers. This will change once we can store multiple
   // transitions with the same key.

-  if (old_map->owns_descriptors()) {
-    // If the old map owns its own descriptors, transfer ownership to the
- // new_map and install its descriptors in the old_map. Since the old_map - // stores the descriptors for the new_map, remove the transition array of
-    // the new_map that is only in place to store the descriptors.
-    old_map->transitions()->descriptors_pointer()->set_value(
-        new_map->instance_descriptors());
-    new_map->ClearTransitions(GetHeap());
-    old_map->set_owns_descriptors(false);
-  } else if (old_target->instance_descriptors() ==
-             old_map->instance_descriptors()) {
+  bool owned_descriptors = old_map->owns_descriptors();
+  if (owned_descriptors ||
+ old_target->instance_descriptors() == old_map->instance_descriptors()) { // Since the conversion above generated a new fast map with an additional // property which can be shared as well, install this descriptor pointer // along the entire chain of smaller maps; and remove the transition array
     // that is only in place to hold the descriptor array in the new map.
     Map* map;
-    JSGlobalPropertyCell* new_pointer =
-        new_map->transitions()->descriptors_pointer();
-    JSGlobalPropertyCell* old_pointer =
-        old_map->transitions()->descriptors_pointer();
+    DescriptorArray* new_descriptors = new_map->instance_descriptors();
+    DescriptorArray* old_descriptors = old_map->instance_descriptors();
     for (Object* current = old_map;
          !current->IsUndefined();
          current = map->GetBackPointer()) {
       map = Map::cast(current);
       if (!map->HasTransitionArray()) break;
       TransitionArray* transitions = map->transitions();
-      if (transitions->descriptors_pointer() != old_pointer) break;
-      map->SetEnumLength(Map::kInvalidEnumCache);
-      transitions->set_descriptors_pointer(new_pointer);
+      if (transitions->descriptors() != old_descriptors) break;
+ // Invalidate the enum caches only if the map did not own its descriptors.
+      if (!owned_descriptors) map->SetEnumLength(Map::kInvalidEnumCache);
+      transitions->set_descriptors(new_descriptors);
     }
+    old_map->set_owns_descriptors(false);
     new_map->ClearTransitions(GetHeap());
   }

@@ -4975,15 +4961,13 @@
 }


-MaybeObject* Map::ShareDescriptor(Descriptor* descriptor) {
+MaybeObject* Map::ShareDescriptor(DescriptorArray* descriptors,
+                                  Descriptor* descriptor) {
// Sanity check. This path is only to be taken if the map owns its descriptor
   // array, implying that its NumberOfOwnDescriptors equals the number of
   // descriptors in the descriptor array.
-  if (NumberOfOwnDescriptors() !=
-      instance_descriptors()->number_of_descriptors()) {
-    Isolate::Current()->PushStackTraceAndDie(
-          0xDEAD0002, GetBackPointer(), this, 0xDEAD0003);
-  }
+  ASSERT(NumberOfOwnDescriptors() ==
+         instance_descriptors()->number_of_descriptors());
   Map* result;
   MaybeObject* maybe_result = CopyDropDescriptors();
   if (!maybe_result->To(&result)) return maybe_result;
@@ -4995,7 +4979,6 @@
       AddTransition(name, result, SIMPLE_TRANSITION);
   if (!maybe_transitions->To(&transitions)) return maybe_transitions;

-  DescriptorArray* descriptors = instance_descriptors();
   int old_size = descriptors->number_of_descriptors();

   DescriptorArray* new_descriptors;
@@ -5026,9 +5009,21 @@
     if (descriptors->HasEnumCache()) {
       new_descriptors->CopyEnumCacheFrom(descriptors);
     }
+
+    Map* map;
+    // Replace descriptors by new_descriptors in all maps that share it.
+    for (Object* current = GetBackPointer();
+         !current->IsUndefined();
+         current = map->GetBackPointer()) {
+      map = Map::cast(current);
+      if (!map->HasTransitionArray()) break;
+      TransitionArray* transitions = map->transitions();
+      if (transitions->descriptors() != descriptors) break;
+      transitions->set_descriptors(new_descriptors);
+    }
+
+    transitions->set_descriptors(new_descriptors);
   }
-
-  transitions->set_descriptors(new_descriptors);

   set_transitions(transitions);
   result->SetBackPointer(this);
@@ -5073,7 +5068,7 @@
// If the copied map has no added fields, and the parent map owns its
         // descriptors, those descriptors have to be empty. In that case,
         // transfer ownership of the descriptors to the new child.
-        CHECK(instance_descriptors()->IsEmpty());
+        ASSERT(instance_descriptors()->IsEmpty());
         set_owns_descriptors(false);
       } else {
// If the parent did not own its own descriptors, it may share a larger
@@ -5201,7 +5196,7 @@
   if (flag == INSERT_TRANSITION &&
       owns_descriptors() &&
       CanHaveMoreTransitions()) {
-    return ShareDescriptor(descriptor);
+    return ShareDescriptor(descriptors, descriptor);
   }

   DescriptorArray* new_descriptors;
@@ -5241,7 +5236,7 @@
   // We replace the key if it is already present.
   int index = old_descriptors->SearchWithCache(descriptor->GetKey(), this);
   if (index != DescriptorArray::kNotFound) {
-    return CopyReplaceDescriptor(descriptor, index, flag);
+    return CopyReplaceDescriptor(old_descriptors, descriptor, index, flag);
   }
   return CopyAddDescriptor(descriptor, flag);
 }
@@ -5267,15 +5262,14 @@
 }


-MaybeObject* Map::CopyReplaceDescriptor(Descriptor* descriptor,
+MaybeObject* Map::CopyReplaceDescriptor(DescriptorArray* descriptors,
+                                        Descriptor* descriptor,
                                         int insertion_index,
                                         TransitionFlag flag) {
   // Ensure the key is a symbol.
   MaybeObject* maybe_failure = descriptor->KeyToSymbol();
   if (maybe_failure->IsFailure()) return maybe_failure;

-  DescriptorArray* descriptors = instance_descriptors();
-
   String* key = descriptor->GetKey();
   ASSERT(key == descriptors->GetKey(insertion_index));

@@ -7458,17 +7452,7 @@
   int to_trim = number_of_descriptors - number_of_own_descriptors;
   if (to_trim <= 0) return;

-  // Maximally keep 50% of unused descriptors.
-  int keep = Min(to_trim, number_of_own_descriptors / 2);
-  for (int i = number_of_own_descriptors;
-       i < number_of_own_descriptors + keep;
-       ++i) {
-    descriptors->EraseDescriptor(heap, i);
-  }
-
-  if (to_trim > keep) {
-    RightTrimFixedArray<FROM_GC>(heap, descriptors, to_trim - keep);
-  }
+  RightTrimFixedArray<FROM_GC>(heap, descriptors, to_trim);
   descriptors->SetNumberOfDescriptors(number_of_own_descriptors);

   if (descriptors->HasEnumCache()) TrimEnumCache(heap, map, descriptors);
@@ -7546,7 +7530,6 @@
     } else {
       t->set_descriptors(heap->empty_descriptor_array());
     }
-    set_owns_descriptors(true);
   }

   int trim = t->number_of_transitions() - transition_index;
=======================================
--- /branches/bleeding_edge/src/objects.h       Mon Sep 24 07:23:46 2012
+++ /branches/bleeding_edge/src/objects.h       Thu Oct 11 05:01:19 2012
@@ -2573,7 +2573,6 @@
                   Descriptor* desc,
                   const WhitenessWitness&);
   inline void Set(int descriptor_number, Descriptor* desc);
-  inline void EraseDescriptor(Heap* heap, int descriptor_number);

// Append automatically sets the enumeration index. This should only be used // to add descriptors in bulk at the end, followed by sorting the descriptor
@@ -4890,7 +4889,6 @@

   // [instance descriptors]: describes the object.
   inline DescriptorArray* instance_descriptors();
-  inline JSGlobalPropertyCell* descriptors_pointer();
   MUST_USE_RESULT inline MaybeObject* SetDescriptors(
       DescriptorArray* descriptors);
   static void SetDescriptors(Handle<Map> map,
@@ -5004,14 +5002,17 @@
       String* name,
       TransitionFlag flag,
       int descriptor_index);
-  MUST_USE_RESULT MaybeObject* ShareDescriptor(Descriptor* descriptor);
+ MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors,
+                                               Descriptor* descriptor);
   MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor,
                                                  TransitionFlag flag);
   MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor,
                                                     TransitionFlag flag);
- MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(Descriptor* descriptor,
-                                                     int index,
-                                                     TransitionFlag flag);
+  MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(
+      DescriptorArray* descriptors,
+      Descriptor* descriptor,
+      int index,
+      TransitionFlag flag);
   MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
                                                   TransitionFlag flag);

=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Wed Sep 12 09:43:57 2012 +++ /branches/bleeding_edge/src/profile-generator.cc Thu Oct 11 05:01:19 2012
@@ -2009,14 +2009,11 @@
                        Map::kConstructorOffset);
   if (map->HasTransitionArray()) {
     TransitionArray* transitions = map->transitions();
-    JSGlobalPropertyCell* pointer = transitions->descriptors_pointer();
     DescriptorArray* descriptors = transitions->descriptors();
     TagObject(descriptors, "(map descriptors)");
-    SetInternalReference(pointer, entry,
+    SetInternalReference(transitions, entry,
                          "descriptors", descriptors,
-                         JSGlobalPropertyCell::kValueOffset);
-    IndexedReferencesExtractor pointer_refs(this, pointer, entry);
-    pointer->Iterate(&pointer_refs);
+                         TransitionArray::kDescriptorsOffset);

     Object* back_pointer = transitions->back_pointer_storage();
     TagObject(transitions->back_pointer_storage(), "(back pointer)");
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Mon Sep 17 10:18:27 2012
+++ /branches/bleeding_edge/src/runtime.cc      Thu Oct 11 05:01:19 2012
@@ -2179,7 +2179,7 @@
     Map* new_map;
     MaybeObject* maybe_map =
         function->map()->CopyReplaceDescriptor(
-            &new_desc, index, OMIT_TRANSITION);
+            instance_desc, &new_desc, index, OMIT_TRANSITION);
     if (!maybe_map->To(&new_map)) return maybe_map;

     function->set_map(new_map);
=======================================
--- /branches/bleeding_edge/src/transitions-inl.h       Wed Sep 19 02:54:10 2012
+++ /branches/bleeding_edge/src/transitions-inl.h       Thu Oct 11 05:01:19 2012
@@ -84,27 +84,20 @@
 }


-DescriptorArray* TransitionArray::descriptors() {
-  return DescriptorArray::cast(descriptors_pointer()->value());
+Object** TransitionArray::GetDescriptorsSlot() {
+  return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
+                              kDescriptorsOffset);
 }


-void TransitionArray::set_descriptors(DescriptorArray* descriptors) {
-  ASSERT(!this->descriptors()->IsDescriptorArray() ||
-         descriptors->number_of_descriptors() == 0 ||
-         descriptors->HasEnumCache() ||
-         !this->descriptors()->HasEnumCache());
-  descriptors_pointer()->set_value(descriptors);
-}
-
-
-JSGlobalPropertyCell* TransitionArray::descriptors_pointer() {
-  return JSGlobalPropertyCell::cast(get(kDescriptorsPointerIndex));
+DescriptorArray* TransitionArray::descriptors() {
+  return DescriptorArray::cast(get(kDescriptorsIndex));
 }


-void TransitionArray::set_descriptors_pointer(JSGlobalPropertyCell* pointer) {
-  set(kDescriptorsPointerIndex, pointer);
+void TransitionArray::set_descriptors(DescriptorArray* descriptors) {
+  ASSERT(descriptors->IsDescriptorArray());
+  set(kDescriptorsIndex, descriptors);
 }


=======================================
--- /branches/bleeding_edge/src/transitions.cc  Wed Sep 19 02:54:10 2012
+++ /branches/bleeding_edge/src/transitions.cc  Thu Oct 11 05:01:19 2012
@@ -35,31 +35,20 @@
 namespace internal {


-static MaybeObject* AllocateRaw(int length,
-                                JSGlobalPropertyCell* descriptors_cell) {
+static MaybeObject* AllocateRaw(int length) {
   Heap* heap = Isolate::Current()->heap();

-  if (descriptors_cell == NULL) {
-    MaybeObject* maybe_cell =
-        heap->AllocateJSGlobalPropertyCell(heap->empty_descriptor_array());
-    if (!maybe_cell->To(&descriptors_cell)) return maybe_cell;
-  }
-
   // Use FixedArray to not use TransitionArray::cast on incomplete object.
   FixedArray* array;
   MaybeObject* maybe_array = heap->AllocateFixedArray(length);
   if (!maybe_array->To(&array)) return maybe_array;
-
-  array->set(TransitionArray::kDescriptorsPointerIndex, descriptors_cell);
   return array;
 }


-MaybeObject* TransitionArray::Allocate(int number_of_transitions,
- JSGlobalPropertyCell* descriptors_cell) {
+MaybeObject* TransitionArray::Allocate(int number_of_transitions) {
   FixedArray* array;
-  MaybeObject* maybe_array =
-      AllocateRaw(ToKeyIndex(number_of_transitions), descriptors_cell);
+ MaybeObject* maybe_array = AllocateRaw(ToKeyIndex(number_of_transitions));
   if (!maybe_array->To(&array)) return maybe_array;
   array->set(kElementsTransitionIndex, Smi::FromInt(0));
   array->set(kPrototypeTransitionsIndex, Smi::FromInt(0));
@@ -84,28 +73,28 @@
 MaybeObject* TransitionArray::NewWith(SimpleTransitionFlag flag,
                                       String* key,
                                       Map* target,
- JSGlobalPropertyCell* descriptors_pointer,
+                                      DescriptorArray* descriptors,
                                       Object* back_pointer) {
   TransitionArray* result;
   MaybeObject* maybe_result;

   if (flag == SIMPLE_TRANSITION) {
-    maybe_result = AllocateRaw(kSimpleTransitionSize, descriptors_pointer);
+    maybe_result = AllocateRaw(kSimpleTransitionSize);
     if (!maybe_result->To(&result)) return maybe_result;
     result->set(kSimpleTransitionTarget, target);
   } else {
-    maybe_result = Allocate(1, descriptors_pointer);
+    maybe_result = Allocate(1);
     if (!maybe_result->To(&result)) return maybe_result;
     result->NoIncrementalWriteBarrierSet(0, key, target);
   }
   result->set_back_pointer_storage(back_pointer);
+  result->set_descriptors(descriptors);
   return result;
 }


-MaybeObject* TransitionArray::AllocateDescriptorsHolder(
-    JSGlobalPropertyCell* descriptors_pointer) {
-  return AllocateRaw(kDescriptorsHolderSize, descriptors_pointer);
+MaybeObject* TransitionArray::AllocateDescriptorsHolder() {
+  return AllocateRaw(kDescriptorsHolderSize);
 }


@@ -113,13 +102,14 @@
   ASSERT(!IsFullTransitionArray());
   int nof = number_of_transitions();
   TransitionArray* result;
-  MaybeObject* maybe_result = Allocate(nof, descriptors_pointer());
+  MaybeObject* maybe_result = Allocate(nof);
   if (!maybe_result->To(&result)) return maybe_result;

   if (nof == 1) {
result->NoIncrementalWriteBarrierCopyFrom(this, kSimpleTransitionIndex, 0);
   }

+  result->set_descriptors(descriptors());
   result->set_back_pointer_storage(back_pointer_storage());
   return result;
 }
@@ -135,9 +125,11 @@
   if (insertion_index == kNotFound) ++new_size;

   MaybeObject* maybe_array;
-  maybe_array = TransitionArray::Allocate(new_size, descriptors_pointer());
+  maybe_array = TransitionArray::Allocate(new_size);
   if (!maybe_array->To(&result)) return maybe_array;

+  result->set_descriptors(descriptors());
+
   if (HasElementsTransition()) {
     result->set_elements_transition(elements_transition());
   }
=======================================
--- /branches/bleeding_edge/src/transitions.h   Wed Sep 19 02:54:10 2012
+++ /branches/bleeding_edge/src/transitions.h   Thu Oct 11 05:01:19 2012
@@ -71,10 +71,9 @@
   inline bool HasElementsTransition();
   inline void ClearElementsTransition();

+  inline Object** GetDescriptorsSlot();
   inline DescriptorArray* descriptors();
   inline void set_descriptors(DescriptorArray* descriptors);
-  inline JSGlobalPropertyCell* descriptors_pointer();
-  inline void set_descriptors_pointer(JSGlobalPropertyCell* pointer);

   inline Object* back_pointer_storage();
   inline void set_back_pointer_storage(
@@ -103,11 +102,10 @@
       SimpleTransitionFlag flag,
       String* key,
       Map* target,
-      JSGlobalPropertyCell* descriptor_pointer,
+      DescriptorArray* descriptors,
       Object* back_pointer);

-  static MUST_USE_RESULT MaybeObject* AllocateDescriptorsHolder(
-      JSGlobalPropertyCell* descriptor_pointer);
+  static MUST_USE_RESULT MaybeObject* AllocateDescriptorsHolder();

   MUST_USE_RESULT MaybeObject* ExtendToFullTransitionArray();

@@ -125,9 +123,7 @@
   inline int Search(String* name);

   // Allocates a TransitionArray.
-  MUST_USE_RESULT static MaybeObject* Allocate(
-      int number_of_transitions,
-      JSGlobalPropertyCell* descriptors_cell);
+  MUST_USE_RESULT static MaybeObject* Allocate(int number_of_transitions);

   bool IsDescriptorsHolder() { return length() == kDescriptorsHolderSize; }
   bool IsSimpleTransition() { return length() == kSimpleTransitionSize; }
@@ -139,7 +135,7 @@
   // Constant for denoting key was not found.
   static const int kNotFound = -1;

-  static const int kDescriptorsPointerIndex = 0;
+  static const int kDescriptorsIndex = 0;
   static const int kBackPointerStorageIndex = 1;
   static const int kDescriptorsHolderSize = 2;

@@ -154,8 +150,8 @@
   static const int kSimpleTransitionIndex = 0;
   STATIC_ASSERT(kSimpleTransitionIndex != kNotFound);

-  static const int kDescriptorsPointerOffset = FixedArray::kHeaderSize;
-  static const int kBackPointerStorageOffset = kDescriptorsPointerOffset +
+  static const int kDescriptorsOffset = FixedArray::kHeaderSize;
+  static const int kBackPointerStorageOffset = kDescriptorsOffset +
                                                kPointerSize;

   // Layout for the full transition array header.
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Wed Sep 12 09:43:57 2012 +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Thu Oct 11 05:01:19 2012
@@ -2925,8 +2925,7 @@
            isolate()->factory()->fixed_array_map(),
            &fail,
            DONT_DO_SMI_CHECK);
- movq(temp, FieldOperand(temp, TransitionArray::kDescriptorsPointerOffset)); - movq(descriptors, FieldOperand(temp, JSGlobalPropertyCell::kValueOffset)); + movq(descriptors, FieldOperand(temp, TransitionArray::kDescriptorsOffset));
   jmp(&ok);

   bind(&fail);
@@ -2937,8 +2936,7 @@

   bind(&load_from_back_pointer);
   movq(temp, FieldOperand(temp, Map::kTransitionsOrBackPointerOffset));
- movq(temp, FieldOperand(temp, TransitionArray::kDescriptorsPointerOffset)); - movq(descriptors, FieldOperand(temp, JSGlobalPropertyCell::kValueOffset)); + movq(descriptors, FieldOperand(temp, TransitionArray::kDescriptorsOffset));

   bind(&ok);
 }

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to