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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 | 194 |
195 // PropertyNormalizationMode is used to specify whether to keep | 195 // PropertyNormalizationMode is used to specify whether to keep |
196 // inobject properties when normalizing properties of a JSObject. | 196 // inobject properties when normalizing properties of a JSObject. |
197 enum PropertyNormalizationMode { | 197 enum PropertyNormalizationMode { |
198 CLEAR_INOBJECT_PROPERTIES, | 198 CLEAR_INOBJECT_PROPERTIES, |
199 KEEP_INOBJECT_PROPERTIES | 199 KEEP_INOBJECT_PROPERTIES |
200 }; | 200 }; |
201 | 201 |
202 | 202 |
| 203 // NormalizedMapSharingMode is used to specify whether a map may be shared |
| 204 // by different objects with normalized properties. |
| 205 enum NormalizedMapSharingMode { |
| 206 UNIQUE_NORMALIZED_MAP, |
| 207 SHARED_NORMALIZED_MAP |
| 208 }; |
| 209 |
| 210 |
203 // Instance size sentinel for objects of variable size. | 211 // Instance size sentinel for objects of variable size. |
204 static const int kVariableSizeSentinel = 0; | 212 static const int kVariableSizeSentinel = 0; |
205 | 213 |
206 | 214 |
207 // All Maps have a field instance_type containing a InstanceType. | 215 // All Maps have a field instance_type containing a InstanceType. |
208 // It describes the type of the instances. | 216 // It describes the type of the instances. |
209 // | 217 // |
210 // As an example, a JavaScript object is a heap object and its map | 218 // As an example, a JavaScript object is a heap object and its map |
211 // instance_type is JS_OBJECT_TYPE. | 219 // instance_type is JS_OBJECT_TYPE. |
212 // | 220 // |
(...skipping 2289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 }; | 2510 }; |
2503 | 2511 |
2504 | 2512 |
2505 // The cache for maps used by normalized (dictionary mode) objects. | 2513 // The cache for maps used by normalized (dictionary mode) objects. |
2506 // Such maps do not have property descriptors, so a typical program | 2514 // Such maps do not have property descriptors, so a typical program |
2507 // needs very limited number of distinct normalized maps. | 2515 // needs very limited number of distinct normalized maps. |
2508 class NormalizedMapCache: public FixedArray { | 2516 class NormalizedMapCache: public FixedArray { |
2509 public: | 2517 public: |
2510 static const int kEntries = 64; | 2518 static const int kEntries = 64; |
2511 | 2519 |
2512 static bool IsCacheable(JSObject* object); | |
2513 | |
2514 Object* Get(JSObject* object, PropertyNormalizationMode mode); | 2520 Object* Get(JSObject* object, PropertyNormalizationMode mode); |
2515 | 2521 |
2516 bool Contains(Map* map); | |
2517 | |
2518 void Clear(); | 2522 void Clear(); |
2519 | 2523 |
2520 // Casting | 2524 // Casting |
2521 static inline NormalizedMapCache* cast(Object* obj); | 2525 static inline NormalizedMapCache* cast(Object* obj); |
2522 | 2526 |
2523 #ifdef DEBUG | 2527 #ifdef DEBUG |
2524 void NormalizedMapCacheVerify(); | 2528 void NormalizedMapCacheVerify(); |
2525 #endif | 2529 #endif |
2526 | 2530 |
2527 private: | 2531 private: |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3169 inline bool has_fast_elements() { | 3173 inline bool has_fast_elements() { |
3170 return ((1 << kHasFastElements) & bit_field2()) != 0; | 3174 return ((1 << kHasFastElements) & bit_field2()) != 0; |
3171 } | 3175 } |
3172 | 3176 |
3173 // Tells whether the map is attached to SharedFunctionInfo | 3177 // Tells whether the map is attached to SharedFunctionInfo |
3174 // (for inobject slack tracking). | 3178 // (for inobject slack tracking). |
3175 inline void set_attached_to_shared_function_info(bool value); | 3179 inline void set_attached_to_shared_function_info(bool value); |
3176 | 3180 |
3177 inline bool attached_to_shared_function_info(); | 3181 inline bool attached_to_shared_function_info(); |
3178 | 3182 |
| 3183 // Tells whether the map is shared between objects that may have different |
| 3184 // behavior. If true, the map should never be modified, instead a clone |
| 3185 // should be created and modified. |
| 3186 inline void set_is_shared(bool value); |
| 3187 |
| 3188 inline bool is_shared(); |
| 3189 |
3179 // Tells whether the instance needs security checks when accessing its | 3190 // Tells whether the instance needs security checks when accessing its |
3180 // properties. | 3191 // properties. |
3181 inline void set_is_access_check_needed(bool access_check_needed); | 3192 inline void set_is_access_check_needed(bool access_check_needed); |
3182 inline bool is_access_check_needed(); | 3193 inline bool is_access_check_needed(); |
3183 | 3194 |
3184 // [prototype]: implicit prototype object. | 3195 // [prototype]: implicit prototype object. |
3185 DECL_ACCESSORS(prototype, Object) | 3196 DECL_ACCESSORS(prototype, Object) |
3186 | 3197 |
3187 // [constructor]: points back to the function responsible for this map. | 3198 // [constructor]: points back to the function responsible for this map. |
3188 DECL_ACCESSORS(constructor, Object) | 3199 DECL_ACCESSORS(constructor, Object) |
3189 | 3200 |
3190 inline JSFunction* unchecked_constructor(); | 3201 inline JSFunction* unchecked_constructor(); |
3191 | 3202 |
3192 // [instance descriptors]: describes the object. | 3203 // [instance descriptors]: describes the object. |
3193 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 3204 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
3194 | 3205 |
3195 // [stub cache]: contains stubs compiled for this map. | 3206 // [stub cache]: contains stubs compiled for this map. |
3196 DECL_ACCESSORS(code_cache, Object) | 3207 DECL_ACCESSORS(code_cache, Object) |
3197 | 3208 |
3198 MUST_USE_RESULT Object* CopyDropDescriptors(); | 3209 MUST_USE_RESULT Object* CopyDropDescriptors(); |
3199 | 3210 |
3200 MUST_USE_RESULT Object* CopyNormalized(PropertyNormalizationMode mode); | 3211 MUST_USE_RESULT Object* CopyNormalized(PropertyNormalizationMode mode, |
| 3212 NormalizedMapSharingMode sharing); |
3201 | 3213 |
3202 // Returns a copy of the map, with all transitions dropped from the | 3214 // Returns a copy of the map, with all transitions dropped from the |
3203 // instance descriptors. | 3215 // instance descriptors. |
3204 MUST_USE_RESULT Object* CopyDropTransitions(); | 3216 MUST_USE_RESULT Object* CopyDropTransitions(); |
3205 | 3217 |
3206 // Returns this map if it has the fast elements bit set, otherwise | 3218 // Returns this map if it has the fast elements bit set, otherwise |
3207 // returns a copy of the map, with all transitions dropped from the | 3219 // returns a copy of the map, with all transitions dropped from the |
3208 // descriptors and the fast elements bit set. | 3220 // descriptors and the fast elements bit set. |
3209 inline Object* GetFastElementsMap(); | 3221 inline Object* GetFastElementsMap(); |
3210 | 3222 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 // Set all map transitions from this map to dead maps to null. | 3266 // Set all map transitions from this map to dead maps to null. |
3255 // Also, restore the original prototype on the targets of these | 3267 // Also, restore the original prototype on the targets of these |
3256 // transitions, so that we do not process this map again while | 3268 // transitions, so that we do not process this map again while |
3257 // following back pointers. | 3269 // following back pointers. |
3258 void ClearNonLiveTransitions(Object* real_prototype); | 3270 void ClearNonLiveTransitions(Object* real_prototype); |
3259 | 3271 |
3260 // Dispatched behavior. | 3272 // Dispatched behavior. |
3261 #ifdef DEBUG | 3273 #ifdef DEBUG |
3262 void MapPrint(); | 3274 void MapPrint(); |
3263 void MapVerify(); | 3275 void MapVerify(); |
3264 void NormalizedMapVerify(); | 3276 void SharedMapVerify(); |
3265 #endif | 3277 #endif |
3266 | 3278 |
3267 inline int visitor_id(); | 3279 inline int visitor_id(); |
3268 inline void set_visitor_id(int visitor_id); | 3280 inline void set_visitor_id(int visitor_id); |
3269 | 3281 |
3270 typedef void (*TraverseCallback)(Map* map, void* data); | 3282 typedef void (*TraverseCallback)(Map* map, void* data); |
3271 | 3283 |
3272 void TraverseTransitionTree(TraverseCallback callback, void* data); | 3284 void TraverseTransitionTree(TraverseCallback callback, void* data); |
3273 | 3285 |
3274 static const int kMaxPreAllocatedPropertyFields = 255; | 3286 static const int kMaxPreAllocatedPropertyFields = 255; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 static const int kIsUndetectable = 5; | 3330 static const int kIsUndetectable = 5; |
3319 static const int kHasInstanceCallHandler = 6; | 3331 static const int kHasInstanceCallHandler = 6; |
3320 static const int kIsAccessCheckNeeded = 7; | 3332 static const int kIsAccessCheckNeeded = 7; |
3321 | 3333 |
3322 // Bit positions for bit field 2 | 3334 // Bit positions for bit field 2 |
3323 static const int kIsExtensible = 0; | 3335 static const int kIsExtensible = 0; |
3324 static const int kFunctionWithPrototype = 1; | 3336 static const int kFunctionWithPrototype = 1; |
3325 static const int kHasFastElements = 2; | 3337 static const int kHasFastElements = 2; |
3326 static const int kStringWrapperSafeForDefaultValueOf = 3; | 3338 static const int kStringWrapperSafeForDefaultValueOf = 3; |
3327 static const int kAttachedToSharedFunctionInfo = 4; | 3339 static const int kAttachedToSharedFunctionInfo = 4; |
| 3340 static const int kIsShared = 5; |
3328 | 3341 |
3329 // Layout of the default cache. It holds alternating name and code objects. | 3342 // Layout of the default cache. It holds alternating name and code objects. |
3330 static const int kCodeCacheEntrySize = 2; | 3343 static const int kCodeCacheEntrySize = 2; |
3331 static const int kCodeCacheEntryNameOffset = 0; | 3344 static const int kCodeCacheEntryNameOffset = 0; |
3332 static const int kCodeCacheEntryCodeOffset = 1; | 3345 static const int kCodeCacheEntryCodeOffset = 1; |
3333 | 3346 |
3334 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 3347 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
3335 kPointerFieldsEndOffset, | 3348 kPointerFieldsEndOffset, |
3336 kSize> BodyDescriptor; | 3349 kSize> BodyDescriptor; |
3337 | 3350 |
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5712 } else { | 5725 } else { |
5713 value &= ~(1 << bit_position); | 5726 value &= ~(1 << bit_position); |
5714 } | 5727 } |
5715 return value; | 5728 return value; |
5716 } | 5729 } |
5717 }; | 5730 }; |
5718 | 5731 |
5719 } } // namespace v8::internal | 5732 } } // namespace v8::internal |
5720 | 5733 |
5721 #endif // V8_OBJECTS_H_ | 5734 #endif // V8_OBJECTS_H_ |
OLD | NEW |