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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 inline bool IsJSValue(); | 624 inline bool IsJSValue(); |
625 inline bool IsStringWrapper(); | 625 inline bool IsStringWrapper(); |
626 inline bool IsProxy(); | 626 inline bool IsProxy(); |
627 inline bool IsBoolean(); | 627 inline bool IsBoolean(); |
628 inline bool IsJSArray(); | 628 inline bool IsJSArray(); |
629 inline bool IsJSRegExp(); | 629 inline bool IsJSRegExp(); |
630 inline bool IsHashTable(); | 630 inline bool IsHashTable(); |
631 inline bool IsDictionary(); | 631 inline bool IsDictionary(); |
632 inline bool IsSymbolTable(); | 632 inline bool IsSymbolTable(); |
633 inline bool IsJSFunctionResultCache(); | 633 inline bool IsJSFunctionResultCache(); |
| 634 inline bool IsNormalizedMapCache(); |
634 inline bool IsCompilationCacheTable(); | 635 inline bool IsCompilationCacheTable(); |
635 inline bool IsCodeCacheHashTable(); | 636 inline bool IsCodeCacheHashTable(); |
636 inline bool IsMapCache(); | 637 inline bool IsMapCache(); |
637 inline bool IsPrimitive(); | 638 inline bool IsPrimitive(); |
638 inline bool IsGlobalObject(); | 639 inline bool IsGlobalObject(); |
639 inline bool IsJSGlobalObject(); | 640 inline bool IsJSGlobalObject(); |
640 inline bool IsJSBuiltinsObject(); | 641 inline bool IsJSBuiltinsObject(); |
641 inline bool IsJSGlobalProxy(); | 642 inline bool IsJSGlobalProxy(); |
642 inline bool IsUndetectableObject(); | 643 inline bool IsUndetectableObject(); |
643 inline bool IsAccessCheckNeeded(); | 644 inline bool IsAccessCheckNeeded(); |
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2380 | 2381 |
2381 // Casting | 2382 // Casting |
2382 static inline JSFunctionResultCache* cast(Object* obj); | 2383 static inline JSFunctionResultCache* cast(Object* obj); |
2383 | 2384 |
2384 #ifdef DEBUG | 2385 #ifdef DEBUG |
2385 void JSFunctionResultCacheVerify(); | 2386 void JSFunctionResultCacheVerify(); |
2386 #endif | 2387 #endif |
2387 }; | 2388 }; |
2388 | 2389 |
2389 | 2390 |
| 2391 // The cache for maps used by normalized (dictionary mode) objects. |
| 2392 // Such maps do not have property descriptors, so a typical program |
| 2393 // needs very limited number of distinct normalized maps. |
| 2394 class NormalizedMapCache: public FixedArray { |
| 2395 public: |
| 2396 static const int kEntries = 256; |
| 2397 |
| 2398 Object* Get(Map* fast, PropertyNormalizationMode mode); |
| 2399 |
| 2400 void Clear(); |
| 2401 |
| 2402 // Casting |
| 2403 static inline NormalizedMapCache* cast(Object* obj); |
| 2404 |
| 2405 #ifdef DEBUG |
| 2406 void NormalizedMapCacheVerify(); |
| 2407 #endif |
| 2408 |
| 2409 private: |
| 2410 static int Hash(Map* fast); |
| 2411 |
| 2412 static bool CheckHit(Map* slow, Map* fast, PropertyNormalizationMode mode); |
| 2413 }; |
| 2414 |
| 2415 |
2390 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 2416 // ByteArray represents fixed sized byte arrays. Used by the outside world, |
2391 // such as PCRE, and also by the memory allocator and garbage collector to | 2417 // such as PCRE, and also by the memory allocator and garbage collector to |
2392 // fill in free blocks in the heap. | 2418 // fill in free blocks in the heap. |
2393 class ByteArray: public HeapObject { | 2419 class ByteArray: public HeapObject { |
2394 public: | 2420 public: |
2395 // [length]: length of the array. | 2421 // [length]: length of the array. |
2396 inline int length(); | 2422 inline int length(); |
2397 inline void set_length(int value); | 2423 inline void set_length(int value); |
2398 | 2424 |
2399 // Setter and getter. | 2425 // Setter and getter. |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 DECL_ACCESSORS(constructor, Object) | 3049 DECL_ACCESSORS(constructor, Object) |
3024 | 3050 |
3025 // [instance descriptors]: describes the object. | 3051 // [instance descriptors]: describes the object. |
3026 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 3052 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
3027 | 3053 |
3028 // [stub cache]: contains stubs compiled for this map. | 3054 // [stub cache]: contains stubs compiled for this map. |
3029 DECL_ACCESSORS(code_cache, Object) | 3055 DECL_ACCESSORS(code_cache, Object) |
3030 | 3056 |
3031 Object* CopyDropDescriptors(); | 3057 Object* CopyDropDescriptors(); |
3032 | 3058 |
| 3059 Object* CopyNormalized(PropertyNormalizationMode mode); |
| 3060 |
3033 // Returns a copy of the map, with all transitions dropped from the | 3061 // Returns a copy of the map, with all transitions dropped from the |
3034 // instance descriptors. | 3062 // instance descriptors. |
3035 Object* CopyDropTransitions(); | 3063 Object* CopyDropTransitions(); |
3036 | 3064 |
3037 // Returns this map if it has the fast elements bit set, otherwise | 3065 // Returns this map if it has the fast elements bit set, otherwise |
3038 // returns a copy of the map, with all transitions dropped from the | 3066 // returns a copy of the map, with all transitions dropped from the |
3039 // descriptors and the fast elements bit set. | 3067 // descriptors and the fast elements bit set. |
3040 inline Object* GetFastElementsMap(); | 3068 inline Object* GetFastElementsMap(); |
3041 | 3069 |
3042 // Returns this map if it has the fast elements bit cleared, | 3070 // Returns this map if it has the fast elements bit cleared, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 // Also, restore the original prototype on the targets of these | 3114 // Also, restore the original prototype on the targets of these |
3087 // transitions, so that we do not process this map again while | 3115 // transitions, so that we do not process this map again while |
3088 // following back pointers. | 3116 // following back pointers. |
3089 void ClearNonLiveTransitions(Object* real_prototype); | 3117 void ClearNonLiveTransitions(Object* real_prototype); |
3090 | 3118 |
3091 // Dispatched behavior. | 3119 // Dispatched behavior. |
3092 void MapIterateBody(ObjectVisitor* v); | 3120 void MapIterateBody(ObjectVisitor* v); |
3093 #ifdef DEBUG | 3121 #ifdef DEBUG |
3094 void MapPrint(); | 3122 void MapPrint(); |
3095 void MapVerify(); | 3123 void MapVerify(); |
| 3124 void NormalizedMapVerify(); |
3096 #endif | 3125 #endif |
3097 | 3126 |
3098 inline Scavenger scavenger(); | 3127 inline Scavenger scavenger(); |
3099 inline void set_scavenger(Scavenger callback); | 3128 inline void set_scavenger(Scavenger callback); |
3100 | 3129 |
3101 inline void Scavenge(HeapObject** slot, HeapObject* obj) { | 3130 inline void Scavenge(HeapObject** slot, HeapObject* obj) { |
3102 scavenger()(this, slot, obj); | 3131 scavenger()(this, slot, obj); |
3103 } | 3132 } |
3104 | 3133 |
3105 static const int kMaxPreAllocatedPropertyFields = 255; | 3134 static const int kMaxPreAllocatedPropertyFields = 255; |
(...skipping 18 matching lines...) Expand all Loading... |
3124 | 3153 |
3125 // Byte offsets within kInstanceSizesOffset. | 3154 // Byte offsets within kInstanceSizesOffset. |
3126 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 3155 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
3127 static const int kInObjectPropertiesByte = 1; | 3156 static const int kInObjectPropertiesByte = 1; |
3128 static const int kInObjectPropertiesOffset = | 3157 static const int kInObjectPropertiesOffset = |
3129 kInstanceSizesOffset + kInObjectPropertiesByte; | 3158 kInstanceSizesOffset + kInObjectPropertiesByte; |
3130 static const int kPreAllocatedPropertyFieldsByte = 2; | 3159 static const int kPreAllocatedPropertyFieldsByte = 2; |
3131 static const int kPreAllocatedPropertyFieldsOffset = | 3160 static const int kPreAllocatedPropertyFieldsOffset = |
3132 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 3161 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
3133 // The byte at position 3 is not in use at the moment. | 3162 // The byte at position 3 is not in use at the moment. |
| 3163 static const int kUnusedByte = 3; |
| 3164 static const int kUnusedOffset = kInstanceSizesOffset + kUnusedByte; |
3134 | 3165 |
3135 // Byte offsets within kInstanceAttributesOffset attributes. | 3166 // Byte offsets within kInstanceAttributesOffset attributes. |
3136 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 3167 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
3137 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 3168 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
3138 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 3169 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
3139 static const int kBitField2Offset = kInstanceAttributesOffset + 3; | 3170 static const int kBitField2Offset = kInstanceAttributesOffset + 3; |
3140 | 3171 |
3141 STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); | 3172 STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); |
3142 | 3173 |
3143 // Bit positions for bit field. | 3174 // Bit positions for bit field. |
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5364 } else { | 5395 } else { |
5365 value &= ~(1 << bit_position); | 5396 value &= ~(1 << bit_position); |
5366 } | 5397 } |
5367 return value; | 5398 return value; |
5368 } | 5399 } |
5369 }; | 5400 }; |
5370 | 5401 |
5371 } } // namespace v8::internal | 5402 } } // namespace v8::internal |
5372 | 5403 |
5373 #endif // V8_OBJECTS_H_ | 5404 #endif // V8_OBJECTS_H_ |
OLD | NEW |