Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1227 // Verify a pointer is a valid HeapObject pointer that points to object | 1227 // Verify a pointer is a valid HeapObject pointer that points to object |
| 1228 // areas in the heap. | 1228 // areas in the heap. |
| 1229 static void VerifyHeapPointer(Object* p); | 1229 static void VerifyHeapPointer(Object* p); |
| 1230 #endif | 1230 #endif |
| 1231 | 1231 |
| 1232 // Layout description. | 1232 // Layout description. |
| 1233 // First field in a heap object is map. | 1233 // First field in a heap object is map. |
| 1234 static const int kMapOffset = Object::kHeaderSize; | 1234 static const int kMapOffset = Object::kHeaderSize; |
| 1235 static const int kHeaderSize = kMapOffset + kPointerSize; | 1235 static const int kHeaderSize = kMapOffset + kPointerSize; |
| 1236 | 1236 |
| 1237 // This constant is also hardcoded in the api so if one changes the | |
| 1238 // other also has to. | |
|
Mads Ager (chromium)
2009/08/26 06:22:20
Maybe add this comment for the other STATIC_CHECKs
Christian Plesner Hansen
2009/08/26 10:31:06
Removed it instead. It's pretty easy to see what'
| |
| 1239 STATIC_CHECK(kMapOffset == Internals::kHeapObjectMapOffset); | |
| 1240 | |
| 1237 protected: | 1241 protected: |
| 1238 // helpers for calling an ObjectVisitor to iterate over pointers in the | 1242 // helpers for calling an ObjectVisitor to iterate over pointers in the |
| 1239 // half-open range [start, end) specified as integer offsets | 1243 // half-open range [start, end) specified as integer offsets |
| 1240 inline void IteratePointers(ObjectVisitor* v, int start, int end); | 1244 inline void IteratePointers(ObjectVisitor* v, int start, int end); |
| 1241 // as above, for the single element at "offset" | 1245 // as above, for the single element at "offset" |
| 1242 inline void IteratePointer(ObjectVisitor* v, int offset); | 1246 inline void IteratePointer(ObjectVisitor* v, int offset); |
| 1243 | 1247 |
| 1244 // Computes the object size from the map. | 1248 // Computes the object size from the map. |
| 1245 // Should only be used from SizeFromMap. | 1249 // Should only be used from SizeFromMap. |
| 1246 int SlowSizeFromMap(Map* map); | 1250 int SlowSizeFromMap(Map* map); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1657 // When extending the backing storage for property values, we increase | 1661 // When extending the backing storage for property values, we increase |
| 1658 // its size by more than the 1 entry necessary, so sequentially adding fields | 1662 // its size by more than the 1 entry necessary, so sequentially adding fields |
| 1659 // to the same object requires fewer allocations and copies. | 1663 // to the same object requires fewer allocations and copies. |
| 1660 static const int kFieldsAdded = 3; | 1664 static const int kFieldsAdded = 3; |
| 1661 | 1665 |
| 1662 // Layout description. | 1666 // Layout description. |
| 1663 static const int kPropertiesOffset = HeapObject::kHeaderSize; | 1667 static const int kPropertiesOffset = HeapObject::kHeaderSize; |
| 1664 static const int kElementsOffset = kPropertiesOffset + kPointerSize; | 1668 static const int kElementsOffset = kPropertiesOffset + kPointerSize; |
| 1665 static const int kHeaderSize = kElementsOffset + kPointerSize; | 1669 static const int kHeaderSize = kElementsOffset + kPointerSize; |
| 1666 | 1670 |
| 1671 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize); | |
| 1672 | |
| 1667 Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index); | 1673 Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index); |
| 1668 | 1674 |
| 1669 private: | 1675 private: |
| 1670 Object* SetElementWithInterceptor(uint32_t index, Object* value); | 1676 Object* SetElementWithInterceptor(uint32_t index, Object* value); |
| 1671 Object* SetElementWithoutInterceptor(uint32_t index, Object* value); | 1677 Object* SetElementWithoutInterceptor(uint32_t index, Object* value); |
| 1672 | 1678 |
| 1673 Object* GetElementPostInterceptor(JSObject* receiver, uint32_t index); | 1679 Object* GetElementPostInterceptor(JSObject* receiver, uint32_t index); |
| 1674 | 1680 |
| 1675 Object* DeletePropertyPostInterceptor(String* name, DeleteMode mode); | 1681 Object* DeletePropertyPostInterceptor(String* name, DeleteMode mode); |
| 1676 Object* DeletePropertyWithInterceptor(String* name); | 1682 Object* DeletePropertyWithInterceptor(String* name); |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2890 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; | 2896 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; |
| 2891 static const int kPreAllocatedPropertyFieldsOffset = kInstanceSizesOffset + 2; | 2897 static const int kPreAllocatedPropertyFieldsOffset = kInstanceSizesOffset + 2; |
| 2892 // The byte at position 3 is not in use at the moment. | 2898 // The byte at position 3 is not in use at the moment. |
| 2893 | 2899 |
| 2894 // Byte offsets within kInstanceAttributesOffset attributes. | 2900 // Byte offsets within kInstanceAttributesOffset attributes. |
| 2895 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 2901 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
| 2896 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 2902 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
| 2897 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 2903 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
| 2898 static const int kBitField2Offset = kInstanceAttributesOffset + 3; | 2904 static const int kBitField2Offset = kInstanceAttributesOffset + 3; |
| 2899 | 2905 |
| 2906 STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); | |
| 2907 | |
| 2900 // Bit positions for bit field. | 2908 // Bit positions for bit field. |
| 2901 static const int kUnused = 0; // To be used for marking recently used maps. | 2909 static const int kUnused = 0; // To be used for marking recently used maps. |
| 2902 static const int kHasNonInstancePrototype = 1; | 2910 static const int kHasNonInstancePrototype = 1; |
| 2903 static const int kIsHiddenPrototype = 2; | 2911 static const int kIsHiddenPrototype = 2; |
| 2904 static const int kHasNamedInterceptor = 3; | 2912 static const int kHasNamedInterceptor = 3; |
| 2905 static const int kHasIndexedInterceptor = 4; | 2913 static const int kHasIndexedInterceptor = 4; |
| 2906 static const int kIsUndetectable = 5; | 2914 static const int kIsUndetectable = 5; |
| 2907 static const int kHasInstanceCallHandler = 6; | 2915 static const int kHasInstanceCallHandler = 6; |
| 2908 static const int kIsAccessCheckNeeded = 7; | 2916 static const int kIsAccessCheckNeeded = 7; |
| 2909 | 2917 |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4121 // API. Therefore, ExternalStrings should not be used internally. | 4129 // API. Therefore, ExternalStrings should not be used internally. |
| 4122 class ExternalString: public String { | 4130 class ExternalString: public String { |
| 4123 public: | 4131 public: |
| 4124 // Casting | 4132 // Casting |
| 4125 static inline ExternalString* cast(Object* obj); | 4133 static inline ExternalString* cast(Object* obj); |
| 4126 | 4134 |
| 4127 // Layout description. | 4135 // Layout description. |
| 4128 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); | 4136 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); |
| 4129 static const int kSize = kResourceOffset + kPointerSize; | 4137 static const int kSize = kResourceOffset + kPointerSize; |
| 4130 | 4138 |
| 4139 STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset); | |
| 4140 | |
| 4131 private: | 4141 private: |
| 4132 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString); | 4142 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString); |
| 4133 }; | 4143 }; |
| 4134 | 4144 |
| 4135 | 4145 |
| 4136 // The ExternalAsciiString class is an external string backed by an | 4146 // The ExternalAsciiString class is an external string backed by an |
| 4137 // ASCII string. | 4147 // ASCII string. |
| 4138 class ExternalAsciiString: public ExternalString { | 4148 class ExternalAsciiString: public ExternalString { |
| 4139 public: | 4149 public: |
| 4140 typedef v8::String::ExternalAsciiStringResource Resource; | 4150 typedef v8::String::ExternalAsciiStringResource Resource; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4334 #ifdef DEBUG | 4344 #ifdef DEBUG |
| 4335 void ProxyPrint(); | 4345 void ProxyPrint(); |
| 4336 void ProxyVerify(); | 4346 void ProxyVerify(); |
| 4337 #endif | 4347 #endif |
| 4338 | 4348 |
| 4339 // Layout description. | 4349 // Layout description. |
| 4340 | 4350 |
| 4341 static const int kProxyOffset = HeapObject::kHeaderSize; | 4351 static const int kProxyOffset = HeapObject::kHeaderSize; |
| 4342 static const int kSize = kProxyOffset + kPointerSize; | 4352 static const int kSize = kProxyOffset + kPointerSize; |
| 4343 | 4353 |
| 4354 STATIC_CHECK(kProxyOffset == Internals::kProxyProxyOffset); | |
| 4355 | |
| 4344 private: | 4356 private: |
| 4345 DISALLOW_IMPLICIT_CONSTRUCTORS(Proxy); | 4357 DISALLOW_IMPLICIT_CONSTRUCTORS(Proxy); |
| 4346 }; | 4358 }; |
| 4347 | 4359 |
| 4348 | 4360 |
| 4349 // The JSArray describes JavaScript Arrays | 4361 // The JSArray describes JavaScript Arrays |
| 4350 // Such an array can be in one of two modes: | 4362 // Such an array can be in one of two modes: |
| 4351 // - fast, backing storage is a FixedArray and length <= elements.length(); | 4363 // - fast, backing storage is a FixedArray and length <= elements.length(); |
| 4352 // Please note: push and pop can be used to grow and shrink the array. | 4364 // Please note: push and pop can be used to grow and shrink the array. |
| 4353 // - slow, backing storage is a HashTable with numbers as keys. | 4365 // - slow, backing storage is a HashTable with numbers as keys. |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4837 } else { | 4849 } else { |
| 4838 value &= ~(1 << bit_position); | 4850 value &= ~(1 << bit_position); |
| 4839 } | 4851 } |
| 4840 return value; | 4852 return value; |
| 4841 } | 4853 } |
| 4842 }; | 4854 }; |
| 4843 | 4855 |
| 4844 } } // namespace v8::internal | 4856 } } // namespace v8::internal |
| 4845 | 4857 |
| 4846 #endif // V8_OBJECTS_H_ | 4858 #endif // V8_OBJECTS_H_ |
| OLD | NEW |