Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
| 10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
| (...skipping 6705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6716 static const int kInObjectPropertiesByte = 1; | 6716 static const int kInObjectPropertiesByte = 1; |
| 6717 static const int kInObjectPropertiesOffset = | 6717 static const int kInObjectPropertiesOffset = |
| 6718 kInstanceSizesOffset + kInObjectPropertiesByte; | 6718 kInstanceSizesOffset + kInObjectPropertiesByte; |
| 6719 static const int kPreAllocatedPropertyFieldsByte = 2; | 6719 static const int kPreAllocatedPropertyFieldsByte = 2; |
| 6720 static const int kPreAllocatedPropertyFieldsOffset = | 6720 static const int kPreAllocatedPropertyFieldsOffset = |
| 6721 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 6721 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
| 6722 static const int kVisitorIdByte = 3; | 6722 static const int kVisitorIdByte = 3; |
| 6723 static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte; | 6723 static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte; |
| 6724 | 6724 |
| 6725 // Byte offsets within kInstanceAttributesOffset attributes. | 6725 // Byte offsets within kInstanceAttributesOffset attributes. |
| 6726 #if V8_TARGET_LITTLE_ENDIAN | |
| 6727 // Order instance type and bit field together such that they can be loaded | |
| 6728 // together as a 16-bit word with instance type in the lower 8 bits regardless | |
| 6729 // of endianess. | |
| 6726 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 6730 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
| 6727 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 6731 static const int kBitFieldOffset = kInstanceAttributesOffset + 1; |
| 6728 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 6732 #else |
| 6729 static const int kBitField2Offset = kInstanceAttributesOffset + 3; | 6733 static const int kBitFieldOffset = kInstanceAttributesOffset + 0; |
| 6734 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 1; | |
| 6735 #endif | |
| 6736 static const int kBitField2Offset = kInstanceAttributesOffset + 2; | |
| 6737 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3; | |
| 6730 | 6738 |
| 6731 STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); | 6739 STATIC_ASSERT(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); |
|
mtbrandy
2014/06/17 13:45:40
This change introduces a mismatch between kInstanc
| |
| 6732 | 6740 |
| 6733 // Bit positions for bit field. | 6741 // Bit positions for bit field. |
| 6734 static const int kHasNonInstancePrototype = 0; | 6742 static const int kHasNonInstancePrototype = 0; |
| 6735 static const int kIsHiddenPrototype = 1; | 6743 static const int kIsHiddenPrototype = 1; |
| 6736 static const int kHasNamedInterceptor = 2; | 6744 static const int kHasNamedInterceptor = 2; |
| 6737 static const int kHasIndexedInterceptor = 3; | 6745 static const int kHasIndexedInterceptor = 3; |
| 6738 static const int kIsUndetectable = 4; | 6746 static const int kIsUndetectable = 4; |
| 6739 static const int kIsObserved = 5; | 6747 static const int kIsObserved = 5; |
| 6740 static const int kIsAccessCheckNeeded = 6; | 6748 static const int kIsAccessCheckNeeded = 6; |
| 6741 class FunctionWithPrototype: public BitField<bool, 7, 1> {}; | 6749 class FunctionWithPrototype: public BitField<bool, 7, 1> {}; |
| (...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9041 // Ecma-262: | 9049 // Ecma-262: |
| 9042 // 4.3.16 String Value | 9050 // 4.3.16 String Value |
| 9043 // A string value is a member of the type String and is a finite | 9051 // A string value is a member of the type String and is a finite |
| 9044 // ordered sequence of zero or more 16-bit unsigned integer values. | 9052 // ordered sequence of zero or more 16-bit unsigned integer values. |
| 9045 // | 9053 // |
| 9046 // All string values have a length field. | 9054 // All string values have a length field. |
| 9047 class String: public Name { | 9055 class String: public Name { |
| 9048 public: | 9056 public: |
| 9049 enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING }; | 9057 enum Encoding { ONE_BYTE_ENCODING, TWO_BYTE_ENCODING }; |
| 9050 | 9058 |
| 9059 // Array index strings this short can keep their index in the hash field. | |
| 9060 static const int kMaxCachedArrayIndexLength = 7; | |
| 9061 | |
| 9062 // For strings which are array indexes the hash value has the string length | |
| 9063 // mixed into the hash, mainly to avoid a hash value of zero which would be | |
| 9064 // the case for the string '0'. 24 bits are used for the array index value. | |
| 9065 static const int kArrayIndexValueBits = 24; | |
| 9066 static const int kArrayIndexLengthBits = | |
| 9067 kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields; | |
| 9068 | |
| 9069 STATIC_ASSERT((kArrayIndexLengthBits > 0)); | |
| 9070 | |
| 9071 class ArrayIndexValueBits : public BitField<unsigned int, kNofHashBitFields, | |
| 9072 kArrayIndexValueBits> {}; // NOLINT | |
| 9073 class ArrayIndexLengthBits : public BitField<unsigned int, | |
| 9074 kNofHashBitFields + kArrayIndexValueBits, | |
| 9075 kArrayIndexLengthBits> {}; // NOLINT | |
| 9076 | |
| 9077 // Check that kMaxCachedArrayIndexLength + 1 is a power of two so we | |
| 9078 // could use a mask to test if the length of string is less than or equal to | |
| 9079 // kMaxCachedArrayIndexLength. | |
| 9080 STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1)); | |
| 9081 | |
| 9082 static const unsigned int kContainsCachedArrayIndexMask = | |
| 9083 (~kMaxCachedArrayIndexLength << ArrayIndexLengthBits::kShift) | | |
| 9084 kIsNotArrayIndexMask; | |
| 9085 | |
| 9051 // Representation of the flat content of a String. | 9086 // Representation of the flat content of a String. |
| 9052 // A non-flat string doesn't have flat content. | 9087 // A non-flat string doesn't have flat content. |
| 9053 // A flat string has content that's encoded as a sequence of either | 9088 // A flat string has content that's encoded as a sequence of either |
| 9054 // ASCII chars or two-byte UC16. | 9089 // ASCII chars or two-byte UC16. |
| 9055 // Returned by String::GetFlatContent(). | 9090 // Returned by String::GetFlatContent(). |
| 9056 class FlatContent { | 9091 class FlatContent { |
| 9057 public: | 9092 public: |
| 9058 // Returns true if the string is flat and this structure contains content. | 9093 // Returns true if the string is flat and this structure contains content. |
| 9059 bool IsFlat() { return state_ != NON_FLAT; } | 9094 bool IsFlat() { return state_ != NON_FLAT; } |
| 9060 // Returns true if the structure contains ASCII content. | 9095 // Returns true if the structure contains ASCII content. |
| (...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11234 } else { | 11269 } else { |
| 11235 value &= ~(1 << bit_position); | 11270 value &= ~(1 << bit_position); |
| 11236 } | 11271 } |
| 11237 return value; | 11272 return value; |
| 11238 } | 11273 } |
| 11239 }; | 11274 }; |
| 11240 | 11275 |
| 11241 } } // namespace v8::internal | 11276 } } // namespace v8::internal |
| 11242 | 11277 |
| 11243 #endif // V8_OBJECTS_H_ | 11278 #endif // V8_OBJECTS_H_ |
| OLD | NEW |