| 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 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 | 1204 |
| 1205 | 1205 |
| 1206 // The JSObject describes real heap allocated JavaScript objects with | 1206 // The JSObject describes real heap allocated JavaScript objects with |
| 1207 // properties. | 1207 // properties. |
| 1208 // Note that the map of JSObject changes during execution to enable inline | 1208 // Note that the map of JSObject changes during execution to enable inline |
| 1209 // caching. | 1209 // caching. |
| 1210 class JSObject: public HeapObject { | 1210 class JSObject: public HeapObject { |
| 1211 public: | 1211 public: |
| 1212 enum DeleteMode { NORMAL_DELETION, FORCE_DELETION }; | 1212 enum DeleteMode { NORMAL_DELETION, FORCE_DELETION }; |
| 1213 enum ElementsKind { | 1213 enum ElementsKind { |
| 1214 // The only "fast" kind. |
| 1214 FAST_ELEMENTS, | 1215 FAST_ELEMENTS, |
| 1216 // All the kinds below are "slow". |
| 1215 DICTIONARY_ELEMENTS, | 1217 DICTIONARY_ELEMENTS, |
| 1216 PIXEL_ELEMENTS, | 1218 PIXEL_ELEMENTS, |
| 1217 EXTERNAL_BYTE_ELEMENTS, | 1219 EXTERNAL_BYTE_ELEMENTS, |
| 1218 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1220 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
| 1219 EXTERNAL_SHORT_ELEMENTS, | 1221 EXTERNAL_SHORT_ELEMENTS, |
| 1220 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1222 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
| 1221 EXTERNAL_INT_ELEMENTS, | 1223 EXTERNAL_INT_ELEMENTS, |
| 1222 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1224 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
| 1223 EXTERNAL_FLOAT_ELEMENTS | 1225 EXTERNAL_FLOAT_ELEMENTS |
| 1224 }; | 1226 }; |
| 1225 | 1227 |
| 1226 // [properties]: Backing storage for properties. | 1228 // [properties]: Backing storage for properties. |
| 1227 // properties is a FixedArray in the fast case and a Dictionary in the | 1229 // properties is a FixedArray in the fast case and a Dictionary in the |
| 1228 // slow case. | 1230 // slow case. |
| 1229 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1231 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
| 1230 inline void initialize_properties(); | 1232 inline void initialize_properties(); |
| 1231 inline bool HasFastProperties(); | 1233 inline bool HasFastProperties(); |
| 1232 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1234 inline StringDictionary* property_dictionary(); // Gets slow properties. |
| 1233 | 1235 |
| 1234 // [elements]: The elements (properties with names that are integers). | 1236 // [elements]: The elements (properties with names that are integers). |
| 1235 // elements is a FixedArray in the fast case, a Dictionary in the slow | 1237 // |
| 1236 // case, and a PixelArray or ExternalArray in special cases. | 1238 // Elements can be in two general modes: fast and slow. Each mode |
| 1239 // corrensponds to a set of object representations of elements that |
| 1240 // have something in common. |
| 1241 // |
| 1242 // In the fast mode elements is a FixedArray and so each element can |
| 1243 // be quickly accessed. This fact is used in the generated code. The |
| 1244 // elements array can have one of the two maps in this mode: |
| 1245 // fixed_array_map or fixed_cow_array_map (for copy-on-write |
| 1246 // arrays). In the latter case the elements array may be shared by a |
| 1247 // few objects and so before writing to any element the array must |
| 1248 // be copied. Use EnsureWritableFastElements in this case. |
| 1249 // |
| 1250 // In the slow mode elements is either a NumberDictionary or a |
| 1251 // PixelArray or an ExternalArray. |
| 1237 DECL_ACCESSORS(elements, HeapObject) | 1252 DECL_ACCESSORS(elements, HeapObject) |
| 1238 inline void initialize_elements(); | 1253 inline void initialize_elements(); |
| 1239 inline Object* ResetElements(); | 1254 inline Object* ResetElements(); |
| 1240 inline ElementsKind GetElementsKind(); | 1255 inline ElementsKind GetElementsKind(); |
| 1241 inline bool HasFastElements(); | 1256 inline bool HasFastElements(); |
| 1242 inline bool HasDictionaryElements(); | 1257 inline bool HasDictionaryElements(); |
| 1243 inline bool HasPixelElements(); | 1258 inline bool HasPixelElements(); |
| 1244 inline bool HasExternalArrayElements(); | 1259 inline bool HasExternalArrayElements(); |
| 1245 inline bool HasExternalByteElements(); | 1260 inline bool HasExternalByteElements(); |
| 1246 inline bool HasExternalUnsignedByteElements(); | 1261 inline bool HasExternalUnsignedByteElements(); |
| 1247 inline bool HasExternalShortElements(); | 1262 inline bool HasExternalShortElements(); |
| 1248 inline bool HasExternalUnsignedShortElements(); | 1263 inline bool HasExternalUnsignedShortElements(); |
| 1249 inline bool HasExternalIntElements(); | 1264 inline bool HasExternalIntElements(); |
| 1250 inline bool HasExternalUnsignedIntElements(); | 1265 inline bool HasExternalUnsignedIntElements(); |
| 1251 inline bool HasExternalFloatElements(); | 1266 inline bool HasExternalFloatElements(); |
| 1252 inline bool AllowsSetElementsLength(); | 1267 inline bool AllowsSetElementsLength(); |
| 1253 inline NumberDictionary* element_dictionary(); // Gets slow elements. | 1268 inline NumberDictionary* element_dictionary(); // Gets slow elements. |
| 1269 // Requires: this->HasFastElements(). |
| 1270 inline Object* EnsureWritableFastElements(); |
| 1254 | 1271 |
| 1255 // Collects elements starting at index 0. | 1272 // Collects elements starting at index 0. |
| 1256 // Undefined values are placed after non-undefined values. | 1273 // Undefined values are placed after non-undefined values. |
| 1257 // Returns the number of non-undefined values. | 1274 // Returns the number of non-undefined values. |
| 1258 Object* PrepareElementsForSort(uint32_t limit); | 1275 Object* PrepareElementsForSort(uint32_t limit); |
| 1259 // As PrepareElementsForSort, but only on objects where elements is | 1276 // As PrepareElementsForSort, but only on objects where elements is |
| 1260 // a dictionary, and it will stay a dictionary. | 1277 // a dictionary, and it will stay a dictionary. |
| 1261 Object* PrepareSlowElementsForSort(uint32_t limit); | 1278 Object* PrepareSlowElementsForSort(uint32_t limit); |
| 1262 | 1279 |
| 1263 Object* SetProperty(String* key, | 1280 Object* SetProperty(String* key, |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 // Setter that doesn't need write barrier). | 1713 // Setter that doesn't need write barrier). |
| 1697 inline void set(int index, Smi* value); | 1714 inline void set(int index, Smi* value); |
| 1698 // Setter with explicit barrier mode. | 1715 // Setter with explicit barrier mode. |
| 1699 inline void set(int index, Object* value, WriteBarrierMode mode); | 1716 inline void set(int index, Object* value, WriteBarrierMode mode); |
| 1700 | 1717 |
| 1701 // Setters for frequently used oddballs located in old space. | 1718 // Setters for frequently used oddballs located in old space. |
| 1702 inline void set_undefined(int index); | 1719 inline void set_undefined(int index); |
| 1703 inline void set_null(int index); | 1720 inline void set_null(int index); |
| 1704 inline void set_the_hole(int index); | 1721 inline void set_the_hole(int index); |
| 1705 | 1722 |
| 1723 // Setters with less debug checks for the GC to use. |
| 1724 inline void set_unchecked(int index, Smi* value); |
| 1725 inline void set_null_unchecked(int index); |
| 1726 |
| 1706 // Gives access to raw memory which stores the array's data. | 1727 // Gives access to raw memory which stores the array's data. |
| 1707 inline Object** data_start(); | 1728 inline Object** data_start(); |
| 1708 | 1729 |
| 1709 // Copy operations. | 1730 // Copy operations. |
| 1710 inline Object* Copy(); | 1731 inline Object* Copy(); |
| 1711 Object* CopySize(int new_length); | 1732 Object* CopySize(int new_length); |
| 1712 | 1733 |
| 1713 // Add the elements of a JSArray to this FixedArray. | 1734 // Add the elements of a JSArray to this FixedArray. |
| 1714 Object* AddKeysFromJSArray(JSArray* array); | 1735 Object* AddKeysFromJSArray(JSArray* array); |
| 1715 | 1736 |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3054 } | 3075 } |
| 3055 | 3076 |
| 3056 inline bool has_instance_call_handler() { | 3077 inline bool has_instance_call_handler() { |
| 3057 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; | 3078 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; |
| 3058 } | 3079 } |
| 3059 | 3080 |
| 3060 inline void set_is_extensible(bool value); | 3081 inline void set_is_extensible(bool value); |
| 3061 inline bool is_extensible(); | 3082 inline bool is_extensible(); |
| 3062 | 3083 |
| 3063 // Tells whether the instance has fast elements. | 3084 // Tells whether the instance has fast elements. |
| 3064 void set_has_fast_elements(bool value) { | 3085 // Equivalent to instance->GetElementsKind() == FAST_ELEMENTS. |
| 3086 inline void set_has_fast_elements(bool value) { |
| 3065 if (value) { | 3087 if (value) { |
| 3066 set_bit_field2(bit_field2() | (1 << kHasFastElements)); | 3088 set_bit_field2(bit_field2() | (1 << kHasFastElements)); |
| 3067 } else { | 3089 } else { |
| 3068 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); | 3090 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); |
| 3069 } | 3091 } |
| 3070 } | 3092 } |
| 3071 | 3093 |
| 3072 bool has_fast_elements() { | 3094 inline bool has_fast_elements() { |
| 3073 return ((1 << kHasFastElements) & bit_field2()) != 0; | 3095 return ((1 << kHasFastElements) & bit_field2()) != 0; |
| 3074 } | 3096 } |
| 3075 | 3097 |
| 3076 // Tells whether the instance needs security checks when accessing its | 3098 // Tells whether the instance needs security checks when accessing its |
| 3077 // properties. | 3099 // properties. |
| 3078 inline void set_is_access_check_needed(bool access_check_needed); | 3100 inline void set_is_access_check_needed(bool access_check_needed); |
| 3079 inline bool is_access_check_needed(); | 3101 inline bool is_access_check_needed(); |
| 3080 | 3102 |
| 3081 // [prototype]: implicit prototype object. | 3103 // [prototype]: implicit prototype object. |
| 3082 DECL_ACCESSORS(prototype, Object) | 3104 DECL_ACCESSORS(prototype, Object) |
| (...skipping 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5455 } else { | 5477 } else { |
| 5456 value &= ~(1 << bit_position); | 5478 value &= ~(1 << bit_position); |
| 5457 } | 5479 } |
| 5458 return value; | 5480 return value; |
| 5459 } | 5481 } |
| 5460 }; | 5482 }; |
| 5461 | 5483 |
| 5462 } } // namespace v8::internal | 5484 } } // namespace v8::internal |
| 5463 | 5485 |
| 5464 #endif // V8_OBJECTS_H_ | 5486 #endif // V8_OBJECTS_H_ |
| OLD | NEW |