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_PROPERTY_DETAILS_H_ | 5 #ifndef V8_PROPERTY_DETAILS_H_ |
6 #define V8_PROPERTY_DETAILS_H_ | 6 #define V8_PROPERTY_DETAILS_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/utils.h" | 10 #include "src/utils.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 bool IsCompatibleForStore(const Representation& other) const { | 106 bool IsCompatibleForStore(const Representation& other) const { |
107 return Equals(other); | 107 return Equals(other); |
108 } | 108 } |
109 | 109 |
110 bool is_more_general_than(const Representation& other) const { | 110 bool is_more_general_than(const Representation& other) const { |
111 if (kind_ == kExternal && other.kind_ == kNone) return true; | 111 if (kind_ == kExternal && other.kind_ == kNone) return true; |
112 if (kind_ == kExternal && other.kind_ == kExternal) return false; | 112 if (kind_ == kExternal && other.kind_ == kExternal) return false; |
113 if (kind_ == kNone && other.kind_ == kExternal) return false; | 113 if (kind_ == kNone && other.kind_ == kExternal) return false; |
114 | 114 |
115 ASSERT(kind_ != kExternal); | 115 DCHECK(kind_ != kExternal); |
116 ASSERT(other.kind_ != kExternal); | 116 DCHECK(other.kind_ != kExternal); |
117 if (IsHeapObject()) return other.IsNone(); | 117 if (IsHeapObject()) return other.IsNone(); |
118 if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false; | 118 if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false; |
119 if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false; | 119 if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false; |
120 return kind_ > other.kind_; | 120 return kind_ > other.kind_; |
121 } | 121 } |
122 | 122 |
123 bool fits_into(const Representation& other) const { | 123 bool fits_into(const Representation& other) const { |
124 return other.is_more_general_than(*this) || other.Equals(*this); | 124 return other.is_more_general_than(*this) || other.Equals(*this); |
125 } | 125 } |
126 | 126 |
127 bool CanContainDouble(double value); | 127 bool CanContainDouble(double value); |
128 | 128 |
129 Representation generalize(Representation other) { | 129 Representation generalize(Representation other) { |
130 if (other.fits_into(*this)) return *this; | 130 if (other.fits_into(*this)) return *this; |
131 if (other.is_more_general_than(*this)) return other; | 131 if (other.is_more_general_than(*this)) return other; |
132 return Representation::Tagged(); | 132 return Representation::Tagged(); |
133 } | 133 } |
134 | 134 |
135 int size() const { | 135 int size() const { |
136 ASSERT(!IsNone()); | 136 DCHECK(!IsNone()); |
137 if (IsInteger8() || IsUInteger8()) { | 137 if (IsInteger8() || IsUInteger8()) { |
138 return sizeof(uint8_t); | 138 return sizeof(uint8_t); |
139 } | 139 } |
140 if (IsInteger16() || IsUInteger16()) { | 140 if (IsInteger16() || IsUInteger16()) { |
141 return sizeof(uint16_t); | 141 return sizeof(uint16_t); |
142 } | 142 } |
143 if (IsInteger32()) { | 143 if (IsInteger32()) { |
144 return sizeof(uint32_t); | 144 return sizeof(uint32_t); |
145 } | 145 } |
146 return kPointerSize; | 146 return kPointerSize; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // They are used both in property dictionaries and instance descriptors. | 190 // They are used both in property dictionaries and instance descriptors. |
191 class PropertyDetails BASE_EMBEDDED { | 191 class PropertyDetails BASE_EMBEDDED { |
192 public: | 192 public: |
193 PropertyDetails(PropertyAttributes attributes, | 193 PropertyDetails(PropertyAttributes attributes, |
194 PropertyType type, | 194 PropertyType type, |
195 int index) { | 195 int index) { |
196 value_ = TypeField::encode(type) | 196 value_ = TypeField::encode(type) |
197 | AttributesField::encode(attributes) | 197 | AttributesField::encode(attributes) |
198 | DictionaryStorageField::encode(index); | 198 | DictionaryStorageField::encode(index); |
199 | 199 |
200 ASSERT(type == this->type()); | 200 DCHECK(type == this->type()); |
201 ASSERT(attributes == this->attributes()); | 201 DCHECK(attributes == this->attributes()); |
202 } | 202 } |
203 | 203 |
204 PropertyDetails(PropertyAttributes attributes, | 204 PropertyDetails(PropertyAttributes attributes, |
205 PropertyType type, | 205 PropertyType type, |
206 Representation representation, | 206 Representation representation, |
207 int field_index = 0) { | 207 int field_index = 0) { |
208 value_ = TypeField::encode(type) | 208 value_ = TypeField::encode(type) |
209 | AttributesField::encode(attributes) | 209 | AttributesField::encode(attributes) |
210 | RepresentationField::encode(EncodeRepresentation(representation)) | 210 | RepresentationField::encode(EncodeRepresentation(representation)) |
211 | FieldIndexField::encode(field_index); | 211 | FieldIndexField::encode(field_index); |
(...skipping 28 matching lines...) Expand all Loading... |
240 | 240 |
241 PropertyAttributes attributes() const { | 241 PropertyAttributes attributes() const { |
242 return AttributesField::decode(value_); | 242 return AttributesField::decode(value_); |
243 } | 243 } |
244 | 244 |
245 int dictionary_index() const { | 245 int dictionary_index() const { |
246 return DictionaryStorageField::decode(value_); | 246 return DictionaryStorageField::decode(value_); |
247 } | 247 } |
248 | 248 |
249 Representation representation() const { | 249 Representation representation() const { |
250 ASSERT(type() != NORMAL); | 250 DCHECK(type() != NORMAL); |
251 return DecodeRepresentation(RepresentationField::decode(value_)); | 251 return DecodeRepresentation(RepresentationField::decode(value_)); |
252 } | 252 } |
253 | 253 |
254 int field_index() const { | 254 int field_index() const { |
255 return FieldIndexField::decode(value_); | 255 return FieldIndexField::decode(value_); |
256 } | 256 } |
257 | 257 |
258 inline PropertyDetails AsDeleted() const; | 258 inline PropertyDetails AsDeleted() const; |
259 | 259 |
260 static bool IsValidIndex(int index) { | 260 static bool IsValidIndex(int index) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 PropertyDetails(int value, PropertyAttributes attributes) { | 298 PropertyDetails(int value, PropertyAttributes attributes) { |
299 value_ = AttributesField::update(value, attributes); | 299 value_ = AttributesField::update(value, attributes); |
300 } | 300 } |
301 | 301 |
302 uint32_t value_; | 302 uint32_t value_; |
303 }; | 303 }; |
304 | 304 |
305 } } // namespace v8::internal | 305 } } // namespace v8::internal |
306 | 306 |
307 #endif // V8_PROPERTY_DETAILS_H_ | 307 #endif // V8_PROPERTY_DETAILS_H_ |
OLD | NEW |