OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 value_ = TypeField::encode(type) | 162 value_ = TypeField::encode(type) |
163 | AttributesField::encode(attributes) | 163 | AttributesField::encode(attributes) |
164 | DictionaryStorageField::encode(index); | 164 | DictionaryStorageField::encode(index); |
165 | 165 |
166 ASSERT(type == this->type()); | 166 ASSERT(type == this->type()); |
167 ASSERT(attributes == this->attributes()); | 167 ASSERT(attributes == this->attributes()); |
168 } | 168 } |
169 | 169 |
170 PropertyDetails(PropertyAttributes attributes, | 170 PropertyDetails(PropertyAttributes attributes, |
171 PropertyType type, | 171 PropertyType type, |
172 Representation representation) { | 172 Representation representation, |
173 int field_index = 0) { | |
173 value_ = TypeField::encode(type) | 174 value_ = TypeField::encode(type) |
174 | AttributesField::encode(attributes) | 175 | AttributesField::encode(attributes) |
175 | RepresentationField::encode(EncodeRepresentation(representation)); | 176 | RepresentationField::encode(EncodeRepresentation(representation)) |
177 | FieldIndexField::encode(field_index); | |
176 } | 178 } |
177 | 179 |
178 int pointer() { return DescriptorPointer::decode(value_); } | 180 int pointer() { return DescriptorPointer::decode(value_); } |
179 | 181 |
180 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } | 182 PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); } |
181 | 183 |
182 PropertyDetails CopyWithRepresentation(Representation representation) { | 184 PropertyDetails CopyWithRepresentation(Representation representation) { |
183 return PropertyDetails(value_, representation); | 185 return PropertyDetails(value_, representation); |
184 } | 186 } |
185 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { | 187 PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) { |
(...skipping 21 matching lines...) Expand all Loading... | |
207 } | 209 } |
208 | 210 |
209 int dictionary_index() { | 211 int dictionary_index() { |
210 return DictionaryStorageField::decode(value_); | 212 return DictionaryStorageField::decode(value_); |
211 } | 213 } |
212 | 214 |
213 Representation representation() { | 215 Representation representation() { |
214 return DecodeRepresentation(RepresentationField::decode(value_)); | 216 return DecodeRepresentation(RepresentationField::decode(value_)); |
215 } | 217 } |
216 | 218 |
219 int field_index() { | |
220 return FieldIndexField::decode(value_); | |
221 } | |
222 | |
217 inline PropertyDetails AsDeleted(); | 223 inline PropertyDetails AsDeleted(); |
218 | 224 |
219 static bool IsValidIndex(int index) { | 225 static bool IsValidIndex(int index) { |
220 return DictionaryStorageField::is_valid(index); | 226 return DictionaryStorageField::is_valid(index); |
221 } | 227 } |
222 | 228 |
223 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } | 229 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } |
224 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; } | 230 bool IsDontDelete() const { return (attributes() & DONT_DELETE) != 0; } |
225 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } | 231 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } |
226 bool IsDeleted() const { return DeletedField::decode(value_) != 0;} | 232 bool IsDeleted() const { return DeletedField::decode(value_) != 0;} |
227 | 233 |
228 // Bit fields in value_ (type, shift, size). Must be public so the | 234 // Bit fields in value_ (type, shift, size). Must be public so the |
229 // constants can be embedded in generated code. | 235 // constants can be embedded in generated code. |
230 class TypeField: public BitField<PropertyType, 0, 3> {}; | 236 class TypeField: public BitField<PropertyType, 0, 3> {}; |
231 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; | 237 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; |
232 class DeletedField: public BitField<uint32_t, 6, 1> {}; | 238 class DeletedField: public BitField<uint32_t, 6, 1> {}; |
Jakob Kummerow
2013/05/31 16:44:14
How about separating the groups of BitFields that
| |
233 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; | 239 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; |
234 class DescriptorPointer: public BitField<uint32_t, 7, 11> {}; | 240 class DescriptorPointer: public BitField<uint32_t, 6, 11> {}; |
235 class RepresentationField: public BitField<uint32_t, 18, 3> {}; | 241 class RepresentationField: public BitField<uint32_t, 17, 3> {}; |
242 class FieldIndexField: public BitField<uint32_t, 20, 11> {}; | |
236 | 243 |
237 static const int kInitialIndex = 1; | 244 static const int kInitialIndex = 1; |
238 | 245 |
239 private: | 246 private: |
240 PropertyDetails(int value, int pointer) { | 247 PropertyDetails(int value, int pointer) { |
241 value_ = DescriptorPointer::update(value, pointer); | 248 value_ = DescriptorPointer::update(value, pointer); |
242 } | 249 } |
243 PropertyDetails(int value, Representation representation) { | 250 PropertyDetails(int value, Representation representation) { |
244 value_ = RepresentationField::update( | 251 value_ = RepresentationField::update( |
245 value, EncodeRepresentation(representation)); | 252 value, EncodeRepresentation(representation)); |
246 } | 253 } |
247 PropertyDetails(int value, PropertyAttributes attributes) { | 254 PropertyDetails(int value, PropertyAttributes attributes) { |
248 value_ = AttributesField::update(value, attributes); | 255 value_ = AttributesField::update(value, attributes); |
249 } | 256 } |
250 | 257 |
251 uint32_t value_; | 258 uint32_t value_; |
252 }; | 259 }; |
253 | 260 |
254 } } // namespace v8::internal | 261 } } // namespace v8::internal |
255 | 262 |
256 #endif // V8_PROPERTY_DETAILS_H_ | 263 #endif // V8_PROPERTY_DETAILS_H_ |
OLD | NEW |