Revision: 14909
Author:   [email protected]
Date:     Fri May 31 12:11:09 2013
Log: Move field index into property details, freeing up the value slot of fields.

BUG=
[email protected]

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

Modified:
 /branches/bleeding_edge/src/handles.cc
 /branches/bleeding_edge/src/json-stringifier.h
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/property-details.h
 /branches/bleeding_edge/src/property.h

=======================================
--- /branches/bleeding_edge/src/handles.cc      Mon May 20 23:36:24 2013
+++ /branches/bleeding_edge/src/handles.cc      Fri May 31 12:11:09 2013
@@ -802,7 +802,7 @@
           if (details.type() != FIELD) {
             indices = Handle<FixedArray>();
           } else {
- int field_index = Descriptor::IndexFromValue(descs->GetValue(i));
+            int field_index = descs->GetFieldIndex(i);
             if (field_index >= map->inobject_properties()) {
field_index = -(field_index - map->inobject_properties() + 1);
             }
=======================================
--- /branches/bleeding_edge/src/json-stringifier.h      Thu May 23 06:53:49 2013
+++ /branches/bleeding_edge/src/json-stringifier.h      Fri May 31 12:11:09 2013
@@ -640,7 +640,7 @@
       if (!name->IsString()) continue;
       Handle<String> key = Handle<String>::cast(name);
       PropertyDetails details = map->instance_descriptors()->GetDetails(i);
-      if (details.IsDontEnum() || details.IsDeleted()) continue;
+      if (details.IsDontEnum()) continue;
       Handle<Object> property;
       if (details.type() == FIELD && *map == object->map()) {
         property = Handle<Object>(
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Wed May 29 07:49:28 2013
+++ /branches/bleeding_edge/src/objects-inl.h   Fri May 31 12:11:09 2013
@@ -58,7 +58,10 @@


 Smi* PropertyDetails::AsSmi() {
-  return Smi::FromInt(value_);
+ // Ensure the upper 2 bits have the same value by sign extending it. This is
+  // necessary to be able to use the 31st bit of the property details.
+  int value = value_ << 1;
+  return Smi::FromInt(value >> 1);
 }


@@ -2327,7 +2330,7 @@


 int DescriptorArray::GetFieldIndex(int descriptor_number) {
-  return Descriptor::IndexFromValue(GetValue(descriptor_number));
+  return GetDetails(descriptor_number).field_index();
 }


=======================================
--- /branches/bleeding_edge/src/objects.cc      Fri May 31 04:58:39 2013
+++ /branches/bleeding_edge/src/objects.cc      Fri May 31 12:11:09 2013
@@ -2500,8 +2500,6 @@
     if (details.type() != next_details.type()) break;
     if (details.attributes() != next_details.attributes()) break;
if (!details.representation().Equals(next_details.representation())) break;
-    ASSERT(!details.IsDeleted());
-    ASSERT(!next_details.IsDeleted());

     current = next;
   }
=======================================
--- /branches/bleeding_edge/src/property-details.h      Mon May 27 01:43:58 2013
+++ /branches/bleeding_edge/src/property-details.h      Fri May 31 12:11:09 2013
@@ -169,10 +169,12 @@

   PropertyDetails(PropertyAttributes attributes,
                   PropertyType type,
-                  Representation representation) {
+                  Representation representation,
+                  int field_index = 0) {
     value_ = TypeField::encode(type)
         | AttributesField::encode(attributes)
- | RepresentationField::encode(EncodeRepresentation(representation));
+        | RepresentationField::encode(EncodeRepresentation(representation))
+        | FieldIndexField::encode(field_index);
   }

   int pointer() { return DescriptorPointer::decode(value_); }
@@ -213,6 +215,10 @@
   Representation representation() {
     return DecodeRepresentation(RepresentationField::decode(value_));
   }
+
+  int  field_index() {
+    return FieldIndexField::decode(value_);
+  }

   inline PropertyDetails AsDeleted();

@@ -229,10 +235,15 @@
   // constants can be embedded in generated code.
class TypeField: public BitField<PropertyType, 0, 3> {}; class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
+
+  // Bit fields for normalized objects.
class DeletedField: public BitField<uint32_t, 6, 1> {}; class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; - class DescriptorPointer: public BitField<uint32_t, 7, 11> {}; - class RepresentationField: public BitField<uint32_t, 18, 3> {};
+
+  // Bit fields for fast objects.
+ class DescriptorPointer: public BitField<uint32_t, 6, 11> {}; + class RepresentationField: public BitField<uint32_t, 17, 3> {}; + class FieldIndexField: public BitField<uint32_t, 20, 11> {};

   static const int kInitialIndex = 1;

=======================================
--- /branches/bleeding_edge/src/property.h      Wed May  8 08:02:08 2013
+++ /branches/bleeding_edge/src/property.h      Fri May 31 12:11:09 2013
@@ -44,10 +44,6 @@

 class Descriptor BASE_EMBEDDED {
  public:
-  static int IndexFromValue(Object* value) {
-    return Smi::cast(value)->value();
-  }
-
   MUST_USE_RESULT MaybeObject* KeyToUniqueName() {
     if (!key_->IsUniqueName()) {
MaybeObject* maybe_result = HEAP->InternalizeString(String::cast(key_));
@@ -89,10 +85,11 @@
              Object* value,
              PropertyAttributes attributes,
              PropertyType type,
-             Representation representation)
+             Representation representation,
+             int field_index = 0)
       : key_(key),
         value_(value),
-        details_(attributes, type, representation) { }
+        details_(attributes, type, representation, field_index) { }

   friend class DescriptorArray;
 };
@@ -104,8 +101,8 @@
                   int field_index,
                   PropertyAttributes attributes,
                   Representation representation)
-      : Descriptor(key, Smi::FromInt(field_index), attributes,
-                   FIELD, representation) {}
+      : Descriptor(key, Smi::FromInt(0), attributes,
+                   FIELD, representation, field_index) {}
 };


@@ -311,7 +308,6 @@

   bool IsDontDelete() { return details_.IsDontDelete(); }
   bool IsDontEnum() { return details_.IsDontEnum(); }
-  bool IsDeleted() { return details_.IsDeleted(); }
   bool IsFound() { return lookup_type_ != NOT_FOUND; }
   bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; }
   bool IsHandler() { return lookup_type_ == HANDLER_TYPE; }
@@ -417,14 +413,12 @@
   PropertyIndex GetFieldIndex() {
     ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
     ASSERT(IsField());
-    return PropertyIndex::NewFieldIndex(
-        Descriptor::IndexFromValue(GetValue()));
+ return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map()));
   }

   int GetLocalFieldIndexFromMap(Map* map) {
     ASSERT(IsField());
-    return Descriptor::IndexFromValue(GetValueFromMap(map)) -
-        map->inobject_properties();
+    return GetFieldIndexFromMap(map) - map->inobject_properties();
   }

   int GetDictionaryEntry() {
@@ -465,6 +459,12 @@
     ASSERT(number_ < map->NumberOfOwnDescriptors());
     return map->instance_descriptors()->GetValue(number_);
   }
+
+  int GetFieldIndexFromMap(Map* map) const {
+    ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
+    ASSERT(number_ < map->NumberOfOwnDescriptors());
+    return map->instance_descriptors()->GetFieldIndex(number_);
+  }

   void Iterate(ObjectVisitor* visitor);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to