Reviewers: Michael Starzinger,

Message:
PTAL.

Description:
Moving the WhitenessWitness back to DescriptorArray.

TransitionArrays never allocate while being created.


Please review this at https://chromiumcodereview.appspot.com/10908237/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/objects-inl.h
  M src/objects.h
  M src/objects.cc
  M src/transitions-inl.h
  M src/transitions.h
  M src/transitions.cc


Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 65a96612b76b1e321767d05515cfa4401cee445f..36d0b6c15c5be65ccea2b5d09a3894308288fc50 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2167,14 +2167,14 @@ void DescriptorArray::SwapSortedKeys(int first, int second) {
 }


-FixedArray::WhitenessWitness::WhitenessWitness(FixedArray* array)
+DescriptorArray::WhitenessWitness::WhitenessWitness(FixedArray* array)
     : marking_(array->GetHeap()->incremental_marking()) {
   marking_->EnterNoMarkingScope();
   ASSERT(Marking::Color(array) == Marking::WHITE_OBJECT);
 }


-FixedArray::WhitenessWitness::~WhitenessWitness() {
+DescriptorArray::WhitenessWitness::~WhitenessWitness() {
   marking_->LeaveNoMarkingScope();
 }

Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index a7d6faa5e6ca06a8c0e53662dd58bfa1a22a27f1..a5339438add817cf02241fd379846d45d99f6cbb 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5008,7 +5008,7 @@ MaybeObject* Map::ShareDescriptor(Descriptor* descriptor) {
   DescriptorArray* new_descriptors;
   MaybeObject* maybe_descriptors = DescriptorArray::Allocate(old_size + 1);
   if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
-  FixedArray::WhitenessWitness witness(new_descriptors);
+  DescriptorArray::WhitenessWitness witness(new_descriptors);

   for (int i = 0; i < old_size; ++i) {
     new_descriptors->CopyFrom(i, descriptors, i, witness);
@@ -5198,7 +5198,7 @@ MaybeObject* Map::CopyAddDescriptor(Descriptor* descriptor,
   MaybeObject* maybe_descriptors = DescriptorArray::Allocate(old_size + 1);
   if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;

-  FixedArray::WhitenessWitness witness(new_descriptors);
+  DescriptorArray::WhitenessWitness witness(new_descriptors);

   // Copy the descriptors, inserting a descriptor.
   for (int i = 0; i < old_size; ++i) {
@@ -12897,7 +12897,7 @@ MaybeObject* StringDictionary::TransformPropertiesToFastFor(
     return maybe_descriptors;
   }

-  FixedArray::WhitenessWitness witness(descriptors);
+  DescriptorArray::WhitenessWitness witness(descriptors);

   int number_of_allocated_fields =
       number_of_fields + unused_property_fields - inobject_props;
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index e1f1d3bad4df0aaf18bb5379caaf1a5c655d5f5f..76503e7975f85cc7d6e4af6cddfd960914337dfc 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2375,23 +2375,6 @@ class FixedArray: public FixedArrayBase {
     }
   };

-  // WhitenessWitness is used to prove that a descriptor array is white
-  // (unmarked), so incremental write barriers can be skipped because the
-  // marking invariant cannot be broken and slots pointing into evacuation
-  // candidates will be discovered when the object is scanned. A witness is
-  // always stack-allocated right after creating an array. By allocating a
-  // witness, incremental marking is globally disabled. The witness is then
- // passed along wherever needed to statically prove that the array is known to
-  // be white.
-  class WhitenessWitness {
-   public:
-    inline explicit WhitenessWitness(FixedArray* array);
-    inline ~WhitenessWitness();
-
-   private:
-    IncrementalMarking* marking_;
-  };
-
  protected:
   // Set operation on FixedArray without using write barriers. Can
   // only be used for storing old space objects or smis.
@@ -2475,6 +2458,23 @@ class FixedDoubleArray: public FixedArrayBase {
 //   [length() - kDescriptorSize]: last key
 class DescriptorArray: public FixedArray {
  public:
+  // WhitenessWitness is used to prove that a descriptor array is white
+  // (unmarked), so incremental write barriers can be skipped because the
+  // marking invariant cannot be broken and slots pointing into evacuation
+  // candidates will be discovered when the object is scanned. A witness is
+  // always stack-allocated right after creating an array. By allocating a
+  // witness, incremental marking is globally disabled. The witness is then
+ // passed along wherever needed to statically prove that the array is known to
+  // be white.
+  class WhitenessWitness {
+   public:
+    inline explicit WhitenessWitness(FixedArray* array);
+    inline ~WhitenessWitness();
+
+   private:
+    IncrementalMarking* marking_;
+  };
+
// Returns true for both shared empty_descriptor_array and for smis, which the // map uses to encode additional bit fields when the descriptor array is not
   // yet used.
Index: src/transitions-inl.h
diff --git a/src/transitions-inl.h b/src/transitions-inl.h
index fd97ad25ab57d3946245b9e40c618083e2cbd1c4..517e6423ad24ad22d15a613e1d947f22da3245cf 100644
--- a/src/transitions-inl.h
+++ b/src/transitions-inl.h
@@ -200,16 +200,9 @@ int TransitionArray::Search(String* name) {
 }


-void TransitionArray::Set(int transition_number,
-                          String* key,
-                          Map* target,
-                          const WhitenessWitness&) {
-  NoIncrementalWriteBarrierSet(this,
-                               ToKeyIndex(transition_number),
-                               key);
-  NoIncrementalWriteBarrierSet(this,
-                               ToTargetIndex(transition_number),
-                               target);
+void TransitionArray::Set(int transition_number, String* key, Map* target) {
+  NoIncrementalWriteBarrierSet(this, ToKeyIndex(transition_number), key);
+ NoIncrementalWriteBarrierSet(this, ToTargetIndex(transition_number), target);
 }


Index: src/transitions.cc
diff --git a/src/transitions.cc b/src/transitions.cc
index 0ea58c7d5f530164611c5292658ac6a91d275bc0..9955022a3ee205f2bbfbad70a5e195671535c48a 100644
--- a/src/transitions.cc
+++ b/src/transitions.cc
@@ -60,12 +60,10 @@ MaybeObject* TransitionArray::Allocate(int number_of_transitions,

 void TransitionArray::CopyFrom(TransitionArray* origin,
                                int origin_transition,
-                               int target_transition,
-                               const WhitenessWitness& witness) {
+                               int target_transition) {
   Set(target_transition,
       origin->GetKey(origin_transition),
-      origin->GetTarget(origin_transition),
-      witness);
+      origin->GetTarget(origin_transition));
 }


@@ -84,9 +82,7 @@ MaybeObject* TransitionArray::NewWith(
MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer);
   if (!maybe_array->To(&result)) return maybe_array;

-  FixedArray::WhitenessWitness witness(result);
-
-  result->Set(0, name, target, witness);
+  result->Set(0, name, target);
   result->set_back_pointer_storage(back_pointer);
   return result;
 }
@@ -113,26 +109,24 @@ MaybeObject* TransitionArray::CopyInsert(String* name, Map* target) {
     result->SetPrototypeTransitions(GetPrototypeTransitions());
   }

-  FixedArray::WhitenessWitness witness(result);
-
   if (insertion_index != kNotFound) {
     for (int i = 0; i < number_of_transitions; ++i) {
-      if (i != insertion_index) result->CopyFrom(this, i, i, witness);
+      if (i != insertion_index) result->CopyFrom(this, i, i);
     }
-    result->Set(insertion_index, name, target, witness);
+    result->Set(insertion_index, name, target);
     return result;
   }

   insertion_index = 0;
   for (; insertion_index < number_of_transitions; ++insertion_index) {
     if (InsertionPointFound(GetKey(insertion_index), name)) break;
-    result->CopyFrom(this, insertion_index, insertion_index, witness);
+    result->CopyFrom(this, insertion_index, insertion_index);
   }

-  result->Set(insertion_index, name, target, witness);
+  result->Set(insertion_index, name, target);

   for (; insertion_index < number_of_transitions; ++insertion_index) {
-    result->CopyFrom(this, insertion_index, insertion_index + 1, witness);
+    result->CopyFrom(this, insertion_index, insertion_index + 1);
   }

   result->set_back_pointer_storage(back_pointer_storage());
Index: src/transitions.h
diff --git a/src/transitions.h b/src/transitions.h
index e79d6cae54f7d74c51c5380286b974f904ab1fa1..f937e847da91a8d06da02126fe78635bbcd6b460 100644
--- a/src/transitions.h
+++ b/src/transitions.h
@@ -113,8 +113,7 @@ class TransitionArray: public FixedArray {
   // Copy a single transition from the origin array.
   inline void CopyFrom(TransitionArray* origin,
                        int origin_transition,
-                       int target_transition,
-                       const WhitenessWitness& witness);
+                       int target_transition);

   // Search a transition for a given property name.
   inline int Search(String* name);
@@ -184,8 +183,7 @@ class TransitionArray: public FixedArray {

   inline void Set(int transition_number,
                   String* key,
-                  Map* target,
-                  const WhitenessWitness&);
+                  Map* target);

   DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray);
 };


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

Reply via email to