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 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1184 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
1185 inline void initialize_properties(); | 1185 inline void initialize_properties(); |
1186 inline bool HasFastProperties(); | 1186 inline bool HasFastProperties(); |
1187 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1187 inline StringDictionary* property_dictionary(); // Gets slow properties. |
1188 | 1188 |
1189 // [elements]: The elements (properties with names that are integers). | 1189 // [elements]: The elements (properties with names that are integers). |
1190 // elements is a FixedArray in the fast case, a Dictionary in the slow | 1190 // elements is a FixedArray in the fast case, a Dictionary in the slow |
1191 // case, and a PixelArray or ExternalArray in special cases. | 1191 // case, and a PixelArray or ExternalArray in special cases. |
1192 DECL_ACCESSORS(elements, HeapObject) | 1192 DECL_ACCESSORS(elements, HeapObject) |
1193 inline void initialize_elements(); | 1193 inline void initialize_elements(); |
| 1194 inline Object* ResetElements(); |
1194 inline ElementsKind GetElementsKind(); | 1195 inline ElementsKind GetElementsKind(); |
1195 inline bool HasFastElements(); | 1196 inline bool HasFastElements(); |
1196 inline bool HasDictionaryElements(); | 1197 inline bool HasDictionaryElements(); |
1197 inline bool HasPixelElements(); | 1198 inline bool HasPixelElements(); |
1198 inline bool HasExternalArrayElements(); | 1199 inline bool HasExternalArrayElements(); |
1199 inline bool HasExternalByteElements(); | 1200 inline bool HasExternalByteElements(); |
1200 inline bool HasExternalUnsignedByteElements(); | 1201 inline bool HasExternalUnsignedByteElements(); |
1201 inline bool HasExternalShortElements(); | 1202 inline bool HasExternalShortElements(); |
1202 inline bool HasExternalUnsignedShortElements(); | 1203 inline bool HasExternalUnsignedShortElements(); |
1203 inline bool HasExternalIntElements(); | 1204 inline bool HasExternalIntElements(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 Object* SetFastElement(uint32_t index, Object* value); | 1361 Object* SetFastElement(uint32_t index, Object* value); |
1361 | 1362 |
1362 // Set the index'th array element. | 1363 // Set the index'th array element. |
1363 // A Failure object is returned if GC is needed. | 1364 // A Failure object is returned if GC is needed. |
1364 Object* SetElement(uint32_t index, Object* value); | 1365 Object* SetElement(uint32_t index, Object* value); |
1365 | 1366 |
1366 // Returns the index'th element. | 1367 // Returns the index'th element. |
1367 // The undefined object if index is out of bounds. | 1368 // The undefined object if index is out of bounds. |
1368 Object* GetElementWithReceiver(JSObject* receiver, uint32_t index); | 1369 Object* GetElementWithReceiver(JSObject* receiver, uint32_t index); |
1369 | 1370 |
1370 void SetFastElements(FixedArray* elements); | 1371 Object* SetFastElementsCapacityAndLength(int capacity, int length); |
1371 Object* SetSlowElements(Object* length); | 1372 Object* SetSlowElements(Object* length); |
1372 | 1373 |
1373 // Lookup interceptors are used for handling properties controlled by host | 1374 // Lookup interceptors are used for handling properties controlled by host |
1374 // objects. | 1375 // objects. |
1375 inline bool HasNamedInterceptor(); | 1376 inline bool HasNamedInterceptor(); |
1376 inline bool HasIndexedInterceptor(); | 1377 inline bool HasIndexedInterceptor(); |
1377 | 1378 |
1378 // Support functions for v8 api (needed for correct interceptor behavior). | 1379 // Support functions for v8 api (needed for correct interceptor behavior). |
1379 bool HasRealNamedProperty(String* key); | 1380 bool HasRealNamedProperty(String* key); |
1380 bool HasRealElementProperty(uint32_t index); | 1381 bool HasRealElementProperty(uint32_t index); |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 } | 2981 } |
2981 | 2982 |
2982 inline void set_is_extensible() { | 2983 inline void set_is_extensible() { |
2983 set_bit_field2(bit_field2() | (1 << kIsExtensible)); | 2984 set_bit_field2(bit_field2() | (1 << kIsExtensible)); |
2984 } | 2985 } |
2985 | 2986 |
2986 inline bool is_extensible() { | 2987 inline bool is_extensible() { |
2987 return ((1 << kIsExtensible) & bit_field2()) != 0; | 2988 return ((1 << kIsExtensible) & bit_field2()) != 0; |
2988 } | 2989 } |
2989 | 2990 |
| 2991 // Tells whether the instance has fast elements. |
| 2992 void set_has_fast_elements(bool value) { |
| 2993 if (value) { |
| 2994 set_bit_field2(bit_field2() | (1 << kHasFastElements)); |
| 2995 } else { |
| 2996 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); |
| 2997 } |
| 2998 } |
| 2999 |
| 3000 bool has_fast_elements() { |
| 3001 return ((1 << kHasFastElements) & bit_field2()) != 0; |
| 3002 } |
| 3003 |
2990 // Tells whether the instance needs security checks when accessing its | 3004 // Tells whether the instance needs security checks when accessing its |
2991 // properties. | 3005 // properties. |
2992 inline void set_is_access_check_needed(bool access_check_needed); | 3006 inline void set_is_access_check_needed(bool access_check_needed); |
2993 inline bool is_access_check_needed(); | 3007 inline bool is_access_check_needed(); |
2994 | 3008 |
2995 // [prototype]: implicit prototype object. | 3009 // [prototype]: implicit prototype object. |
2996 DECL_ACCESSORS(prototype, Object) | 3010 DECL_ACCESSORS(prototype, Object) |
2997 | 3011 |
2998 // [constructor]: points back to the function responsible for this map. | 3012 // [constructor]: points back to the function responsible for this map. |
2999 DECL_ACCESSORS(constructor, Object) | 3013 DECL_ACCESSORS(constructor, Object) |
3000 | 3014 |
3001 // [instance descriptors]: describes the object. | 3015 // [instance descriptors]: describes the object. |
3002 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 3016 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
3003 | 3017 |
3004 // [stub cache]: contains stubs compiled for this map. | 3018 // [stub cache]: contains stubs compiled for this map. |
3005 DECL_ACCESSORS(code_cache, Object) | 3019 DECL_ACCESSORS(code_cache, Object) |
3006 | 3020 |
3007 Object* CopyDropDescriptors(); | 3021 Object* CopyDropDescriptors(); |
3008 | 3022 |
3009 // Returns a copy of the map, with all transitions dropped from the | 3023 // Returns a copy of the map, with all transitions dropped from the |
3010 // instance descriptors. | 3024 // instance descriptors. |
3011 Object* CopyDropTransitions(); | 3025 Object* CopyDropTransitions(); |
3012 | 3026 |
| 3027 // Returns this map if it has the fast elements bit set, otherwise |
| 3028 // returns a copy of the map, with all transitions dropped from the |
| 3029 // descriptors and the fast elements bit set. |
| 3030 inline Object* GetFastElementsMap(); |
| 3031 |
| 3032 // Returns this map if it has the fast elements bit cleared, |
| 3033 // otherwise returns a copy of the map, with all transitions dropped |
| 3034 // from the descriptors and the fast elements bit cleared. |
| 3035 inline Object* GetSlowElementsMap(); |
| 3036 |
3013 // Returns the property index for name (only valid for FAST MODE). | 3037 // Returns the property index for name (only valid for FAST MODE). |
3014 int PropertyIndexFor(String* name); | 3038 int PropertyIndexFor(String* name); |
3015 | 3039 |
3016 // Returns the next free property index (only valid for FAST MODE). | 3040 // Returns the next free property index (only valid for FAST MODE). |
3017 int NextFreePropertyIndex(); | 3041 int NextFreePropertyIndex(); |
3018 | 3042 |
3019 // Returns the number of properties described in instance_descriptors. | 3043 // Returns the number of properties described in instance_descriptors. |
3020 int NumberOfDescribedProperties(); | 3044 int NumberOfDescribedProperties(); |
3021 | 3045 |
3022 // Casting. | 3046 // Casting. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 static const int kIsHiddenPrototype = 2; | 3128 static const int kIsHiddenPrototype = 2; |
3105 static const int kHasNamedInterceptor = 3; | 3129 static const int kHasNamedInterceptor = 3; |
3106 static const int kHasIndexedInterceptor = 4; | 3130 static const int kHasIndexedInterceptor = 4; |
3107 static const int kIsUndetectable = 5; | 3131 static const int kIsUndetectable = 5; |
3108 static const int kHasInstanceCallHandler = 6; | 3132 static const int kHasInstanceCallHandler = 6; |
3109 static const int kIsAccessCheckNeeded = 7; | 3133 static const int kIsAccessCheckNeeded = 7; |
3110 | 3134 |
3111 // Bit positions for bit field 2 | 3135 // Bit positions for bit field 2 |
3112 static const int kIsExtensible = 0; | 3136 static const int kIsExtensible = 0; |
3113 static const int kFunctionWithPrototype = 1; | 3137 static const int kFunctionWithPrototype = 1; |
| 3138 static const int kHasFastElements = 2; |
3114 | 3139 |
3115 // Layout of the default cache. It holds alternating name and code objects. | 3140 // Layout of the default cache. It holds alternating name and code objects. |
3116 static const int kCodeCacheEntrySize = 2; | 3141 static const int kCodeCacheEntrySize = 2; |
3117 static const int kCodeCacheEntryNameOffset = 0; | 3142 static const int kCodeCacheEntryNameOffset = 0; |
3118 static const int kCodeCacheEntryCodeOffset = 1; | 3143 static const int kCodeCacheEntryCodeOffset = 1; |
3119 | 3144 |
3120 private: | 3145 private: |
3121 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); | 3146 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); |
3122 }; | 3147 }; |
3123 | 3148 |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5309 } else { | 5334 } else { |
5310 value &= ~(1 << bit_position); | 5335 value &= ~(1 << bit_position); |
5311 } | 5336 } |
5312 return value; | 5337 return value; |
5313 } | 5338 } |
5314 }; | 5339 }; |
5315 | 5340 |
5316 } } // namespace v8::internal | 5341 } } // namespace v8::internal |
5317 | 5342 |
5318 #endif // V8_OBJECTS_H_ | 5343 #endif // V8_OBJECTS_H_ |
OLD | NEW |