| 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_OBJECTS_H_ | 28 #ifndef V8_OBJECTS_H_ |
| 29 #define V8_OBJECTS_H_ | 29 #define V8_OBJECTS_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "builtins.h" | 32 #include "builtins.h" |
| 33 #include "list.h" | 33 #include "list.h" |
| 34 #include "property-details.h" |
| 34 #include "smart-array-pointer.h" | 35 #include "smart-array-pointer.h" |
| 35 #include "unicode-inl.h" | 36 #include "unicode-inl.h" |
| 36 #if V8_TARGET_ARCH_ARM | 37 #if V8_TARGET_ARCH_ARM |
| 37 #include "arm/constants-arm.h" | 38 #include "arm/constants-arm.h" |
| 38 #elif V8_TARGET_ARCH_MIPS | 39 #elif V8_TARGET_ARCH_MIPS |
| 39 #include "mips/constants-mips.h" | 40 #include "mips/constants-mips.h" |
| 40 #endif | 41 #endif |
| 41 #include "v8checks.h" | 42 #include "v8checks.h" |
| 42 | 43 |
| 43 | 44 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // - TypeSwitchInfo | 118 // - TypeSwitchInfo |
| 118 // - DebugInfo | 119 // - DebugInfo |
| 119 // - BreakPointInfo | 120 // - BreakPointInfo |
| 120 // - CodeCache | 121 // - CodeCache |
| 121 // | 122 // |
| 122 // Formats of Object*: | 123 // Formats of Object*: |
| 123 // Smi: [31 bit signed int] 0 | 124 // Smi: [31 bit signed int] 0 |
| 124 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 | 125 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 |
| 125 // Failure: [30 bit signed int] 11 | 126 // Failure: [30 bit signed int] 11 |
| 126 | 127 |
| 127 // Ecma-262 3rd 8.6.1 | |
| 128 enum PropertyAttributes { | |
| 129 NONE = v8::None, | |
| 130 READ_ONLY = v8::ReadOnly, | |
| 131 DONT_ENUM = v8::DontEnum, | |
| 132 DONT_DELETE = v8::DontDelete, | |
| 133 ABSENT = 16 // Used in runtime to indicate a property is absent. | |
| 134 // ABSENT can never be stored in or returned from a descriptor's attributes | |
| 135 // bitfield. It is only used as a return value meaning the attributes of | |
| 136 // a non-existent property. | |
| 137 }; | |
| 138 | |
| 139 namespace v8 { | 128 namespace v8 { |
| 140 namespace internal { | 129 namespace internal { |
| 141 | 130 |
| 142 enum ElementsKind { | 131 enum ElementsKind { |
| 143 // The "fast" kind for elements that only contain SMI values. Must be first | 132 // The "fast" kind for elements that only contain SMI values. Must be first |
| 144 // to make it possible to efficiently check maps for this kind. | 133 // to make it possible to efficiently check maps for this kind. |
| 145 FAST_SMI_ONLY_ELEMENTS, | 134 FAST_SMI_ONLY_ELEMENTS, |
| 146 | 135 |
| 147 // The "fast" kind for tagged values. Must be second to make it possible to | 136 // The "fast" kind for tagged values. Must be second to make it possible to |
| 148 // efficiently check maps for this and the FAST_SMI_ONLY_ELEMENTS kind | 137 // efficiently check maps for this and the FAST_SMI_ONLY_ELEMENTS kind |
| (...skipping 22 matching lines...) Expand all Loading... |
| 171 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, | 160 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, |
| 172 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, | 161 FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, |
| 173 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS | 162 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS |
| 174 }; | 163 }; |
| 175 | 164 |
| 176 static const int kElementsKindCount = | 165 static const int kElementsKindCount = |
| 177 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | 166 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
| 178 | 167 |
| 179 void PrintElementsKind(FILE* out, ElementsKind kind); | 168 void PrintElementsKind(FILE* out, ElementsKind kind); |
| 180 | 169 |
| 181 // PropertyDetails captures type and attributes for a property. | |
| 182 // They are used both in property dictionaries and instance descriptors. | |
| 183 class PropertyDetails BASE_EMBEDDED { | |
| 184 public: | |
| 185 PropertyDetails(PropertyAttributes attributes, | |
| 186 PropertyType type, | |
| 187 int index = 0) { | |
| 188 ASSERT(TypeField::is_valid(type)); | |
| 189 ASSERT(AttributesField::is_valid(attributes)); | |
| 190 ASSERT(StorageField::is_valid(index)); | |
| 191 | |
| 192 value_ = TypeField::encode(type) | |
| 193 | AttributesField::encode(attributes) | |
| 194 | StorageField::encode(index); | |
| 195 | |
| 196 ASSERT(type == this->type()); | |
| 197 ASSERT(attributes == this->attributes()); | |
| 198 ASSERT(index == this->index()); | |
| 199 } | |
| 200 | |
| 201 // Conversion for storing details as Object*. | |
| 202 explicit inline PropertyDetails(Smi* smi); | |
| 203 inline Smi* AsSmi(); | |
| 204 | |
| 205 PropertyType type() { return TypeField::decode(value_); } | |
| 206 | |
| 207 bool IsTransition() { | |
| 208 PropertyType t = type(); | |
| 209 ASSERT(t != INTERCEPTOR); | |
| 210 return IsTransitionType(t); | |
| 211 } | |
| 212 | |
| 213 bool IsProperty() { | |
| 214 return type() < FIRST_PHANTOM_PROPERTY_TYPE; | |
| 215 } | |
| 216 | |
| 217 PropertyAttributes attributes() { return AttributesField::decode(value_); } | |
| 218 | |
| 219 int index() { return StorageField::decode(value_); } | |
| 220 | |
| 221 inline PropertyDetails AsDeleted(); | |
| 222 | |
| 223 static bool IsValidIndex(int index) { | |
| 224 return StorageField::is_valid(index); | |
| 225 } | |
| 226 | |
| 227 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } | |
| 228 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } | |
| 229 bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; } | |
| 230 bool IsDeleted() { return DeletedField::decode(value_) != 0;} | |
| 231 | |
| 232 // Bit fields in value_ (type, shift, size). Must be public so the | |
| 233 // constants can be embedded in generated code. | |
| 234 class TypeField: public BitField<PropertyType, 0, 4> {}; | |
| 235 class AttributesField: public BitField<PropertyAttributes, 4, 3> {}; | |
| 236 class DeletedField: public BitField<uint32_t, 7, 1> {}; | |
| 237 class StorageField: public BitField<uint32_t, 8, 32-8> {}; | |
| 238 | |
| 239 static const int kInitialIndex = 1; | |
| 240 | |
| 241 private: | |
| 242 uint32_t value_; | |
| 243 }; | |
| 244 | |
| 245 | 170 |
| 246 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. | 171 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. |
| 247 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; | 172 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; |
| 248 | 173 |
| 249 | 174 |
| 250 // PropertyNormalizationMode is used to specify whether to keep | 175 // PropertyNormalizationMode is used to specify whether to keep |
| 251 // inobject properties when normalizing properties of a JSObject. | 176 // inobject properties when normalizing properties of a JSObject. |
| 252 enum PropertyNormalizationMode { | 177 enum PropertyNormalizationMode { |
| 253 CLEAR_INOBJECT_PROPERTIES, | 178 CLEAR_INOBJECT_PROPERTIES, |
| 254 KEEP_INOBJECT_PROPERTIES | 179 KEEP_INOBJECT_PROPERTIES |
| (...skipping 7682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7937 } else { | 7862 } else { |
| 7938 value &= ~(1 << bit_position); | 7863 value &= ~(1 << bit_position); |
| 7939 } | 7864 } |
| 7940 return value; | 7865 return value; |
| 7941 } | 7866 } |
| 7942 }; | 7867 }; |
| 7943 | 7868 |
| 7944 } } // namespace v8::internal | 7869 } } // namespace v8::internal |
| 7945 | 7870 |
| 7946 #endif // V8_OBJECTS_H_ | 7871 #endif // V8_OBJECTS_H_ |
| OLD | NEW |