Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / v8 / src / field-index.h
index 0f77c8c..8650c8f 100644 (file)
@@ -5,8 +5,8 @@
 #ifndef V8_FIELD_INDEX_H_
 #define V8_FIELD_INDEX_H_
 
-#include "src/utils.h"
 #include "src/property-details.h"
+#include "src/utils.h"
 
 namespace v8 {
 namespace internal {
@@ -28,6 +28,8 @@ class FieldIndex V8_FINAL {
   static FieldIndex ForLoadByFieldIndex(Map* map, int index);
   static FieldIndex ForKeyedLookupCacheIndex(Map* map, int index);
 
+  int GetLoadByFieldIndex() const;
+
   bool is_inobject() const {
     return IsInObjectBits::decode(bit_field_);
   }
@@ -40,17 +42,20 @@ class FieldIndex V8_FINAL {
     return index() * kPointerSize;
   }
 
+  // Zero-indexed from beginning of the object.
   int index() const {
     return IndexBits::decode(bit_field_);
   }
 
   int outobject_array_index() const {
-    ASSERT(!is_inobject());
+    DCHECK(!is_inobject());
     return index() - first_inobject_property_offset() / kPointerSize;
   }
 
+  // Zero-based from the first inobject property. Overflows to out-of-object
+  // properties.
   int property_index() const {
-    ASSERT(!IsHiddenField::decode(bit_field_));
+    DCHECK(!IsHiddenField::decode(bit_field_));
     int result = index() - first_inobject_property_offset() / kPointerSize;
     if (!is_inobject()) {
       result += InObjectPropertyBits::decode(bit_field_);
@@ -58,24 +63,9 @@ class FieldIndex V8_FINAL {
     return result;
   }
 
-  int GetLoadByFieldIndex() const {
-    // For efficiency, the LoadByFieldIndex instruction takes an index that is
-    // optimized for quick access. If the property is inline, the index is
-    // positive. If it's out-of-line, the encoded index is -raw_index - 1 to
-    // disambiguate the zero out-of-line index from the zero inobject case.
-    // The index itself is shifted up by one bit, the lower-most bit
-    // signifying if the field is a mutable double box (1) or not (0).
-    int result = index() - first_inobject_property_offset() / kPointerSize;
-    if (!is_inobject()) {
-      result = -result - 1;
-    }
-    result <<= 1;
-    return is_double() ? (result | 1) : result;
-  }
-
   int GetKeyedLookupCacheIndex() const;
 
-  int GetLoadFieldStubKey() const {
+  int GetFieldAccessStubKey() const {
     return bit_field_ &
         (IsInObjectBits::kMask | IsDoubleBits::kMask | IndexBits::kMask);
   }
@@ -84,7 +74,7 @@ class FieldIndex V8_FINAL {
   FieldIndex(bool is_inobject, int local_index, bool is_double,
              int inobject_properties, int first_inobject_property_offset,
              bool is_hidden = false) {
-    ASSERT((first_inobject_property_offset & (kPointerSize - 1)) == 0);
+    DCHECK((first_inobject_property_offset & (kPointerSize - 1)) == 0);
     bit_field_ = IsInObjectBits::encode(is_inobject) |
       IsDoubleBits::encode(is_double) |
       FirstInobjectPropertyOffsetBits::encode(first_inobject_property_offset) |
@@ -94,21 +84,24 @@ class FieldIndex V8_FINAL {
   }
 
   int first_inobject_property_offset() const {
-    ASSERT(!IsHiddenField::decode(bit_field_));
+    DCHECK(!IsHiddenField::decode(bit_field_));
     return FirstInobjectPropertyOffsetBits::decode(bit_field_);
   }
 
   static const int kIndexBitsSize = kDescriptorIndexBitCount + 1;
 
+  // Index from beginning of object.
   class IndexBits: public BitField<int, 0, kIndexBitsSize> {};
   class IsInObjectBits: public BitField<bool, IndexBits::kNext, 1> {};
   class IsDoubleBits: public BitField<bool, IsInObjectBits::kNext, 1> {};
-  class InObjectPropertyBits: public BitField<int, IsDoubleBits::kNext,
-                                              kDescriptorIndexBitCount> {};
-  class FirstInobjectPropertyOffsetBits:
-      public BitField<int, InObjectPropertyBits::kNext, 7> {};
-  class IsHiddenField:
-      public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {};
+  // Number of inobject properties.
+  class InObjectPropertyBits
+      : public BitField<int, IsDoubleBits::kNext, kDescriptorIndexBitCount> {};
+  // Offset of first inobject property from beginning of object.
+  class FirstInobjectPropertyOffsetBits
+      : public BitField<int, InObjectPropertyBits::kNext, 7> {};
+  class IsHiddenField
+      : public BitField<bool, FirstInobjectPropertyOffsetBits::kNext, 1> {};
   STATIC_ASSERT(IsHiddenField::kNext <= 32);
 
   int bit_field_;