Revision: 10685
Author:   [email protected]
Date:     Mon Feb 13 06:15:43 2012
Log: DescriptorArray::CopyFrom should always drop transitions for CALLBACKS.

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

Modified:
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/src/factory.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h

=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Mon Jan 30 04:25:29 2012
+++ /branches/bleeding_edge/src/bootstrapper.cc Mon Feb 13 06:15:43 2012
@@ -1743,7 +1743,9 @@
     Handle<DescriptorArray> array_descriptors(
         array_function->initial_map()->instance_descriptors());
int index = array_descriptors->SearchWithCache(heap()->length_symbol());
-    reresult_descriptors->CopyFrom(0, *array_descriptors, index, witness);
+    MaybeObject* copy_result =
+ reresult_descriptors->CopyFrom(0, *array_descriptors, index, witness);
+    if (copy_result->IsFailure()) return false;

     int enum_index = 0;
     {
=======================================
--- /branches/bleeding_edge/src/factory.cc      Thu Jan 26 13:47:57 2012
+++ /branches/bleeding_edge/src/factory.cc      Mon Feb 13 06:15:43 2012
@@ -865,7 +865,7 @@
   // Copy the descriptors from the array.
   for (int i = 0; i < array->number_of_descriptors(); i++) {
     if (!array->IsNullDescriptor(i)) {
-      result->CopyFrom(descriptor_count++, *array, i, witness);
+ DescriptorArray::CopyFrom(result, descriptor_count++, array, i, witness);
     }
   }

@@ -899,7 +899,7 @@
     Handle<DescriptorArray> new_result =
         NewDescriptorArray(number_of_descriptors);
     for (int i = 0; i < number_of_descriptors; i++) {
-      new_result->CopyFrom(i, *result, i, witness);
+      DescriptorArray::CopyFrom(new_result, i, result, i, witness);
     }
     result = new_result;
   }
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Fri Feb 10 04:36:05 2012
+++ /branches/bleeding_edge/src/objects-inl.h   Mon Feb 13 06:15:43 2012
@@ -2051,16 +2051,6 @@
                                ToDetailsIndex(descriptor_number),
                                desc->GetDetails().AsSmi());
 }
-
-
-void DescriptorArray::CopyFrom(int index,
-                               DescriptorArray* src,
-                               int src_index,
-                               const WhitenessWitness& witness) {
-  Descriptor desc;
-  src->Get(src_index, &desc);
-  Set(index, &desc, witness);
-}


 void DescriptorArray::NoIncrementalWriteBarrierSwapDescriptors(
=======================================
--- /branches/bleeding_edge/src/objects.cc      Thu Feb  9 02:46:50 2012
+++ /branches/bleeding_edge/src/objects.cc      Mon Feb 13 06:15:43 2012
@@ -5733,6 +5733,33 @@
 static bool InsertionPointFound(String* key1, String* key2) {
   return key1->Hash() > key2->Hash() || key1 == key2;
 }
+
+
+void DescriptorArray::CopyFrom(Handle<DescriptorArray> dst,
+                               int dst_index,
+                               Handle<DescriptorArray> src,
+                               int src_index,
+                               const WhitenessWitness& witness) {
+  CALL_HEAP_FUNCTION_VOID(dst->GetIsolate(),
+ dst->CopyFrom(dst_index, *src, src_index, witness));
+}
+
+
+MaybeObject* DescriptorArray::CopyFrom(int dst_index,
+                                       DescriptorArray* src,
+                                       int src_index,
+                                       const WhitenessWitness& witness) {
+  Object* value = src->GetValue(src_index);
+  PropertyDetails details(src->GetDetails(src_index));
+  if (details.type() == CALLBACKS && value->IsAccessorPair()) {
+    MaybeObject* maybe_copy =
+        AccessorPair::cast(value)->CopyWithoutTransitions();
+    if (!maybe_copy->To(&value)) return maybe_copy;
+  }
+  Descriptor desc(src->GetKey(src_index), value, details);
+  Set(dst_index, &desc, witness);
+  return this;
+}


 MaybeObject* DescriptorArray::CopyInsert(Descriptor* descriptor,
@@ -5818,7 +5845,9 @@
     } else {
       if (!(IsNullDescriptor(from_index) ||
             (remove_transitions && IsTransitionOnly(from_index)))) {
-        new_descriptors->CopyFrom(to_index++, this, from_index, witness);
+        MaybeObject* copy_result =
+ new_descriptors->CopyFrom(to_index++, this, from_index, witness);
+        if (copy_result->IsFailure()) return copy_result;
       }
       from_index++;
     }
@@ -5858,7 +5887,9 @@
   int next_descriptor = 0;
   for (int i = 0; i < number_of_descriptors(); i++) {
     if (IsProperty(i)) {
-      new_descriptors->CopyFrom(next_descriptor++, this, i, witness);
+      MaybeObject* copy_result =
+          new_descriptors->CopyFrom(next_descriptor++, this, i, witness);
+      if (copy_result->IsFailure()) return copy_result;
     }
   }
   ASSERT(next_descriptor == new_descriptors->number_of_descriptors());
@@ -5969,6 +6000,18 @@
   }
   return kNotFound;
 }
+
+
+MaybeObject* AccessorPair::CopyWithoutTransitions() {
+  Heap* heap = GetHeap();
+  AccessorPair* copy;
+  { MaybeObject* maybe_copy = heap->AllocateAccessorPair();
+    if (!maybe_copy->To(&copy)) return maybe_copy;
+  }
+  copy->set_getter(getter()->IsMap() ? heap->the_hole_value() : getter());
+  copy->set_setter(setter()->IsMap() ? heap->the_hole_value() : setter());
+  return copy;
+}


 MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count,
=======================================
--- /branches/bleeding_edge/src/objects.h       Fri Feb 10 04:36:05 2012
+++ /branches/bleeding_edge/src/objects.h       Mon Feb 13 06:15:43 2012
@@ -2434,12 +2434,20 @@
                   Descriptor* desc,
                   const WhitenessWitness&);

-  // Transfer complete descriptor from another descriptor array to
-  // this one.
-  inline void CopyFrom(int index,
-                       DescriptorArray* src,
+ // Transfer a complete descriptor from the src descriptor array to the dst
+  // one, dropping map transitions in CALLBACKS.
+  static void CopyFrom(Handle<DescriptorArray> dst,
+                       int dst_index,
+                       Handle<DescriptorArray> src,
                        int src_index,
-                       const WhitenessWitness&);
+                       const WhitenessWitness& witness);
+
+  // Transfer a complete descriptor from the src descriptor array to this
+  // descriptor array, dropping map transitions in CALLBACKS.
+  MUST_USE_RESULT MaybeObject* CopyFrom(int dst_index,
+                                        DescriptorArray* src,
+                                        int src_index,
+                                        const WhitenessWitness&);

   // Copy the descriptor array, insert a new descriptor and optionally
   // remove map transitions.  If the descriptor is already present, it is
@@ -7782,6 +7790,8 @@

   static inline AccessorPair* cast(Object* obj);

+  MUST_USE_RESULT MaybeObject* CopyWithoutTransitions();
+
 #ifdef OBJECT_PRINT
   void AccessorPairPrint(FILE* out = stdout);
 #endif

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

Reply via email to