Revision: 11343
Author:   [email protected]
Date:     Tue Apr 17 00:16:19 2012
Log:      Tiny DescriptorArray cleanup.

Removed 2 useless functions, nuked a simple helper function with a single caller, and simplified things by changing a signature.

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

Modified:
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/src/handles.cc
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/property.h
 /branches/bleeding_edge/src/runtime.cc

=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Thu Apr  5 07:01:39 2012
+++ /branches/bleeding_edge/src/bootstrapper.cc Tue Apr 17 00:16:19 2012
@@ -2159,7 +2159,7 @@
     Handle<DescriptorArray> descs =
         Handle<DescriptorArray>(from->map()->instance_descriptors());
     for (int i = 0; i < descs->number_of_descriptors(); i++) {
-      PropertyDetails details = PropertyDetails(descs->GetDetails(i));
+      PropertyDetails details = descs->GetDetails(i);
       switch (details.type()) {
         case FIELD: {
           HandleScope inner;
=======================================
--- /branches/bleeding_edge/src/handles.cc      Mon Mar 12 05:35:28 2012
+++ /branches/bleeding_edge/src/handles.cc      Tue Apr 17 00:16:19 2012
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -729,9 +729,9 @@
Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate);

     for (int i = 0; i < descs->number_of_descriptors(); i++) {
-      if (descs->IsProperty(i) && !descs->IsDontEnum(i)) {
+      if (descs->IsProperty(i) && !descs->GetDetails(i).IsDontEnum()) {
         storage->set(index, descs->GetKey(i));
-        PropertyDetails details(descs->GetDetails(i));
+        PropertyDetails details = descs->GetDetails(i);
         sort_array->set(index, Smi::FromInt(details.index()));
         if (!indices.is_null()) {
           if (details.type() != FIELD) {
=======================================
--- /branches/bleeding_edge/src/heap.cc Mon Apr 16 07:43:27 2012
+++ /branches/bleeding_edge/src/heap.cc Tue Apr 17 00:16:19 2012
@@ -3973,7 +3973,7 @@
   // Fill these accessors into the dictionary.
   DescriptorArray* descs = map->instance_descriptors();
   for (int i = 0; i < descs->number_of_descriptors(); i++) {
-    PropertyDetails details(descs->GetDetails(i));
+    PropertyDetails details = descs->GetDetails(i);
     ASSERT(details.type() == CALLBACKS);  // Only accessors are expected.
     PropertyDetails d =
         PropertyDetails(details.attributes(), CALLBACKS, details.index());
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Mon Apr 16 07:43:27 2012
+++ /branches/bleeding_edge/src/objects-inl.h   Tue Apr 17 00:16:19 2012
@@ -1933,15 +1933,15 @@
 }


-Smi* DescriptorArray::GetDetails(int descriptor_number) {
+PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
   ASSERT(descriptor_number < number_of_descriptors());
- return Smi::cast(GetContentArray()->get(ToDetailsIndex(descriptor_number))); + Object* details = GetContentArray()->get(ToDetailsIndex(descriptor_number));
+  return PropertyDetails(Smi::cast(details));
 }


 PropertyType DescriptorArray::GetType(int descriptor_number) {
-  ASSERT(descriptor_number < number_of_descriptors());
-  return PropertyDetails(GetDetails(descriptor_number)).type();
+  return GetDetails(descriptor_number).type();
 }


@@ -2002,17 +2002,12 @@
 bool DescriptorArray::IsNullDescriptor(int descriptor_number) {
   return GetType(descriptor_number) == NULL_DESCRIPTOR;
 }
-
-
-bool DescriptorArray::IsDontEnum(int descriptor_number) {
-  return PropertyDetails(GetDetails(descriptor_number)).IsDontEnum();
-}


 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) {
   desc->Init(GetKey(descriptor_number),
              GetValue(descriptor_number),
-             PropertyDetails(GetDetails(descriptor_number)));
+             GetDetails(descriptor_number));
 }


=======================================
--- /branches/bleeding_edge/src/objects.cc      Mon Apr 16 07:43:27 2012
+++ /branches/bleeding_edge/src/objects.cc      Tue Apr 17 00:16:19 2012
@@ -2322,7 +2322,7 @@
   }
   // If the transition already exists, return its descriptor.
   if (index != DescriptorArray::kNotFound) {
-    PropertyDetails details(descriptors->GetDetails(index));
+    PropertyDetails details = descriptors->GetDetails(index);
     if (details.type() == ELEMENTS_TRANSITION) {
       return descriptors->GetValue(index);
     } else {
@@ -3344,7 +3344,7 @@

   DescriptorArray* descs = map_of_this->instance_descriptors();
   for (int i = 0; i < descs->number_of_descriptors(); i++) {
-    PropertyDetails details(descs->GetDetails(i));
+    PropertyDetails details = descs->GetDetails(i);
     switch (details.type()) {
       case CONSTANT_FUNCTION: {
         PropertyDetails d =
@@ -4206,7 +4206,7 @@
   int result = 0;
   DescriptorArray* descs = instance_descriptors();
   for (int i = 0; i < descs->number_of_descriptors(); i++) {
-    PropertyDetails details(descs->GetDetails(i));
+    PropertyDetails details = descs->GetDetails(i);
     if (descs->IsProperty(i) && (details.attributes() & filter) == 0) {
       result++;
     }
@@ -5687,7 +5687,7 @@
                                        int src_index,
                                        const WhitenessWitness& witness) {
   Object* value = src->GetValue(src_index);
-  PropertyDetails details(src->GetDetails(src_index));
+  PropertyDetails details = src->GetDetails(src_index);
   if (details.type() == CALLBACKS && value->IsAccessorPair()) {
     MaybeObject* maybe_copy =
         AccessorPair::cast(value)->CopyWithoutTransitions();
@@ -5730,7 +5730,7 @@
   if (replacing) {
     // We are replacing an existing descriptor.  We keep the enumeration
     // index of a visible property.
-    PropertyType t = PropertyDetails(GetDetails(index)).type();
+    PropertyType t = GetDetails(index).type();
     if (t == CONSTANT_FUNCTION ||
         t == FIELD ||
         t == CALLBACKS ||
@@ -5757,8 +5757,7 @@
   int enumeration_index = NextEnumerationIndex();
   if (!descriptor->ContainsTransition()) {
     if (keep_enumeration_index) {
-      descriptor->SetEnumerationIndex(
-          PropertyDetails(GetDetails(index)).index());
+      descriptor->SetEnumerationIndex(GetDetails(index).index());
     } else {
       descriptor->SetEnumerationIndex(enumeration_index);
       ++enumeration_index;
@@ -5902,10 +5901,10 @@
     ASSERT(hash == mid_hash);
     // There might be more, so we find the first one and
     // check them all to see if we have a match.
-    if (name == mid_name  && !is_null_descriptor(mid)) return mid;
+    if (name == mid_name  && !IsNullDescriptor(mid)) return mid;
     while ((mid > low) && (GetKey(mid - 1)->Hash() == hash)) mid--;
     for (; (mid <= high) && (GetKey(mid)->Hash() == hash); mid++) {
- if (GetKey(mid)->Equals(name) && !is_null_descriptor(mid)) return mid;
+      if (GetKey(mid)->Equals(name) && !IsNullDescriptor(mid)) return mid;
     }
     break;
   }
@@ -5919,7 +5918,7 @@
     String* entry = GetKey(number);
     if ((entry->Hash() == hash) &&
         name->Equals(entry) &&
-        !is_null_descriptor(number)) {
+        !IsNullDescriptor(number)) {
       return number;
     }
   }
=======================================
--- /branches/bleeding_edge/src/objects.h       Mon Apr 16 07:43:27 2012
+++ /branches/bleeding_edge/src/objects.h       Tue Apr 17 00:16:19 2012
@@ -2473,7 +2473,7 @@
   // Accessors for fetching instance descriptor at descriptor number.
   inline String* GetKey(int descriptor_number);
   inline Object* GetValue(int descriptor_number);
-  inline Smi* GetDetails(int descriptor_number);
+  inline PropertyDetails GetDetails(int descriptor_number);
   inline PropertyType GetType(int descriptor_number);
   inline int GetFieldIndex(int descriptor_number);
   inline JSFunction* GetConstantFunction(int descriptor_number);
@@ -2482,7 +2482,6 @@
   inline bool IsProperty(int descriptor_number);
   inline bool IsTransitionOnly(int descriptor_number);
   inline bool IsNullDescriptor(int descriptor_number);
-  inline bool IsDontEnum(int descriptor_number);

   class WhitenessWitness {
    public:
@@ -2636,10 +2635,6 @@
     return descriptor_number << 1;
   }

-  bool is_null_descriptor(int descriptor_number) {
-    return PropertyDetails(GetDetails(descriptor_number)).type() ==
-        NULL_DESCRIPTOR;
-  }
   // Swap operation on FixedArray without using write barriers.
   static inline void NoIncrementalWriteBarrierSwap(
       FixedArray* array, int first, int second);
=======================================
--- /branches/bleeding_edge/src/property.h      Tue Mar  6 01:19:25 2012
+++ /branches/bleeding_edge/src/property.h      Tue Apr 17 00:16:19 2012
@@ -213,13 +213,6 @@
     details_ = details;
     number_ = number;
   }
-
-  void DescriptorResult(JSObject* holder, Smi* details, int number) {
-    lookup_type_ = DESCRIPTOR_TYPE;
-    holder_ = holder;
-    details_ = PropertyDetails(details);
-    number_ = number;
-  }

   void ConstantResult(JSObject* holder) {
     lookup_type_ = CONSTANT_TYPE;
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Mon Apr 16 07:43:27 2012
+++ /branches/bleeding_edge/src/runtime.cc      Tue Apr 17 00:16:19 2012
@@ -2094,7 +2094,7 @@
DescriptorArray* instance_desc = function->map()->instance_descriptors();
     int index = instance_desc->Search(name);
     ASSERT(index != DescriptorArray::kNotFound);
-    PropertyDetails details(instance_desc->GetDetails(index));
+    PropertyDetails details = instance_desc->GetDetails(index);
     CallbacksDescriptor new_desc(name,
         instance_desc->GetValue(index),
         static_cast<PropertyAttributes>(details.attributes() | READ_ONLY),

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

Reply via email to