| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 static const int kElementsKindCount = | 173 static const int kElementsKindCount = |
| 174 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | 174 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
| 175 | 175 |
| 176 // PropertyDetails captures type and attributes for a property. | 176 // PropertyDetails captures type and attributes for a property. |
| 177 // They are used both in property dictionaries and instance descriptors. | 177 // They are used both in property dictionaries and instance descriptors. |
| 178 class PropertyDetails BASE_EMBEDDED { | 178 class PropertyDetails BASE_EMBEDDED { |
| 179 public: | 179 public: |
| 180 PropertyDetails(PropertyAttributes attributes, | 180 PropertyDetails(PropertyAttributes attributes, |
| 181 PropertyType type, | 181 PropertyType type, |
| 182 int index = 0) { | 182 int index = 0) { |
| 183 ASSERT(type != ELEMENTS_TRANSITION); | |
| 184 ASSERT(TypeField::is_valid(type)); | 183 ASSERT(TypeField::is_valid(type)); |
| 185 ASSERT(AttributesField::is_valid(attributes)); | 184 ASSERT(AttributesField::is_valid(attributes)); |
| 186 ASSERT(StorageField::is_valid(index)); | 185 ASSERT(StorageField::is_valid(index)); |
| 187 | 186 |
| 188 value_ = TypeField::encode(type) | 187 value_ = TypeField::encode(type) |
| 189 | AttributesField::encode(attributes) | 188 | AttributesField::encode(attributes) |
| 190 | StorageField::encode(index); | 189 | StorageField::encode(index); |
| 191 | 190 |
| 192 ASSERT(type == this->type()); | 191 ASSERT(type == this->type()); |
| 193 ASSERT(attributes == this->attributes()); | 192 ASSERT(attributes == this->attributes()); |
| 194 ASSERT(index == this->index()); | 193 ASSERT(index == this->index()); |
| 195 } | 194 } |
| 196 | 195 |
| 197 PropertyDetails(PropertyAttributes attributes, | |
| 198 PropertyType type, | |
| 199 ElementsKind elements_kind) { | |
| 200 ASSERT(type == ELEMENTS_TRANSITION); | |
| 201 ASSERT(TypeField::is_valid(type)); | |
| 202 ASSERT(AttributesField::is_valid(attributes)); | |
| 203 ASSERT(StorageField::is_valid(static_cast<int>(elements_kind))); | |
| 204 | |
| 205 value_ = TypeField::encode(type) | |
| 206 | AttributesField::encode(attributes) | |
| 207 | StorageField::encode(static_cast<int>(elements_kind)); | |
| 208 | |
| 209 ASSERT(type == this->type()); | |
| 210 ASSERT(attributes == this->attributes()); | |
| 211 ASSERT(elements_kind == this->elements_kind()); | |
| 212 } | |
| 213 | |
| 214 // Conversion for storing details as Object*. | 196 // Conversion for storing details as Object*. |
| 215 explicit inline PropertyDetails(Smi* smi); | 197 explicit inline PropertyDetails(Smi* smi); |
| 216 inline Smi* AsSmi(); | 198 inline Smi* AsSmi(); |
| 217 | 199 |
| 218 PropertyType type() { return TypeField::decode(value_); } | 200 PropertyType type() { return TypeField::decode(value_); } |
| 219 | 201 |
| 220 bool IsTransition() { | 202 bool IsTransition() { |
| 221 PropertyType t = type(); | 203 PropertyType t = type(); |
| 222 ASSERT(t != INTERCEPTOR); | 204 ASSERT(t != INTERCEPTOR); |
| 223 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || | 205 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || |
| 224 t == ELEMENTS_TRANSITION; | 206 t == ELEMENTS_TRANSITION; |
| 225 } | 207 } |
| 226 | 208 |
| 227 bool IsProperty() { | 209 bool IsProperty() { |
| 228 return type() < FIRST_PHANTOM_PROPERTY_TYPE; | 210 return type() < FIRST_PHANTOM_PROPERTY_TYPE; |
| 229 } | 211 } |
| 230 | 212 |
| 231 PropertyAttributes attributes() { return AttributesField::decode(value_); } | 213 PropertyAttributes attributes() { return AttributesField::decode(value_); } |
| 232 | 214 |
| 233 int index() { return StorageField::decode(value_); } | 215 int index() { return StorageField::decode(value_); } |
| 234 | 216 |
| 235 ElementsKind elements_kind() { | |
| 236 ASSERT(type() == ELEMENTS_TRANSITION); | |
| 237 return static_cast<ElementsKind>(StorageField::decode(value_)); | |
| 238 } | |
| 239 | |
| 240 inline PropertyDetails AsDeleted(); | 217 inline PropertyDetails AsDeleted(); |
| 241 | 218 |
| 242 static bool IsValidIndex(int index) { | 219 static bool IsValidIndex(int index) { |
| 243 return StorageField::is_valid(index); | 220 return StorageField::is_valid(index); |
| 244 } | 221 } |
| 245 | 222 |
| 246 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } | 223 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } |
| 247 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } | 224 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } |
| 248 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } | 225 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } |
| 249 bool IsDeleted() { return DeletedField::decode(value_) != 0;} | 226 bool IsDeleted() { return DeletedField::decode(value_) != 0;} |
| (...skipping 7244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7494 } else { | 7471 } else { |
| 7495 value &= ~(1 << bit_position); | 7472 value &= ~(1 << bit_position); |
| 7496 } | 7473 } |
| 7497 return value; | 7474 return value; |
| 7498 } | 7475 } |
| 7499 }; | 7476 }; |
| 7500 | 7477 |
| 7501 } } // namespace v8::internal | 7478 } } // namespace v8::internal |
| 7502 | 7479 |
| 7503 #endif // V8_OBJECTS_H_ | 7480 #endif // V8_OBJECTS_H_ |
| OLD | NEW |