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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 inline bool IsJSValue(); | 631 inline bool IsJSValue(); |
632 inline bool IsStringWrapper(); | 632 inline bool IsStringWrapper(); |
633 inline bool IsProxy(); | 633 inline bool IsProxy(); |
634 inline bool IsBoolean(); | 634 inline bool IsBoolean(); |
635 inline bool IsJSArray(); | 635 inline bool IsJSArray(); |
636 inline bool IsJSRegExp(); | 636 inline bool IsJSRegExp(); |
637 inline bool IsHashTable(); | 637 inline bool IsHashTable(); |
638 inline bool IsDictionary(); | 638 inline bool IsDictionary(); |
639 inline bool IsSymbolTable(); | 639 inline bool IsSymbolTable(); |
640 inline bool IsJSFunctionResultCache(); | 640 inline bool IsJSFunctionResultCache(); |
| 641 inline bool IsNormalizedMapCache(); |
641 inline bool IsCompilationCacheTable(); | 642 inline bool IsCompilationCacheTable(); |
642 inline bool IsCodeCacheHashTable(); | 643 inline bool IsCodeCacheHashTable(); |
643 inline bool IsMapCache(); | 644 inline bool IsMapCache(); |
644 inline bool IsPrimitive(); | 645 inline bool IsPrimitive(); |
645 inline bool IsGlobalObject(); | 646 inline bool IsGlobalObject(); |
646 inline bool IsJSGlobalObject(); | 647 inline bool IsJSGlobalObject(); |
647 inline bool IsJSBuiltinsObject(); | 648 inline bool IsJSBuiltinsObject(); |
648 inline bool IsJSGlobalProxy(); | 649 inline bool IsJSGlobalProxy(); |
649 inline bool IsUndetectableObject(); | 650 inline bool IsUndetectableObject(); |
650 inline bool IsAccessCheckNeeded(); | 651 inline bool IsAccessCheckNeeded(); |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 PropertyAttributes attributes); | 1545 PropertyAttributes attributes); |
1545 | 1546 |
1546 // Convert the object to use the canonical dictionary | 1547 // Convert the object to use the canonical dictionary |
1547 // representation. If the object is expected to have additional properties | 1548 // representation. If the object is expected to have additional properties |
1548 // added this number can be indicated to have the backing store allocated to | 1549 // added this number can be indicated to have the backing store allocated to |
1549 // an initial capacity for holding these properties. | 1550 // an initial capacity for holding these properties. |
1550 Object* NormalizeProperties(PropertyNormalizationMode mode, | 1551 Object* NormalizeProperties(PropertyNormalizationMode mode, |
1551 int expected_additional_properties); | 1552 int expected_additional_properties); |
1552 Object* NormalizeElements(); | 1553 Object* NormalizeElements(); |
1553 | 1554 |
| 1555 Object* UpdateMapCodeCache(String* name, Code* code); |
| 1556 |
1554 // Transform slow named properties to fast variants. | 1557 // Transform slow named properties to fast variants. |
1555 // Returns failure if allocation failed. | 1558 // Returns failure if allocation failed. |
1556 Object* TransformToFastProperties(int unused_property_fields); | 1559 Object* TransformToFastProperties(int unused_property_fields); |
1557 | 1560 |
1558 // Access fast-case object properties at index. | 1561 // Access fast-case object properties at index. |
1559 inline Object* FastPropertyAt(int index); | 1562 inline Object* FastPropertyAt(int index); |
1560 inline Object* FastPropertyAtPut(int index, Object* value); | 1563 inline Object* FastPropertyAtPut(int index, Object* value); |
1561 | 1564 |
1562 // Access to in object properties. | 1565 // Access to in object properties. |
1563 inline Object* InObjectPropertyAt(int index); | 1566 inline Object* InObjectPropertyAt(int index); |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2458 | 2461 |
2459 // Casting | 2462 // Casting |
2460 static inline JSFunctionResultCache* cast(Object* obj); | 2463 static inline JSFunctionResultCache* cast(Object* obj); |
2461 | 2464 |
2462 #ifdef DEBUG | 2465 #ifdef DEBUG |
2463 void JSFunctionResultCacheVerify(); | 2466 void JSFunctionResultCacheVerify(); |
2464 #endif | 2467 #endif |
2465 }; | 2468 }; |
2466 | 2469 |
2467 | 2470 |
| 2471 // The cache for maps used by normalized (dictionary mode) objects. |
| 2472 // Such maps do not have property descriptors, so a typical program |
| 2473 // needs very limited number of distinct normalized maps. |
| 2474 class NormalizedMapCache: public FixedArray { |
| 2475 public: |
| 2476 static const int kEntries = 64; |
| 2477 |
| 2478 static bool IsCacheable(JSObject* object); |
| 2479 |
| 2480 Object* Get(JSObject* object, PropertyNormalizationMode mode); |
| 2481 |
| 2482 bool Contains(Map* map); |
| 2483 |
| 2484 void Clear(); |
| 2485 |
| 2486 // Casting |
| 2487 static inline NormalizedMapCache* cast(Object* obj); |
| 2488 |
| 2489 #ifdef DEBUG |
| 2490 void NormalizedMapCacheVerify(); |
| 2491 #endif |
| 2492 |
| 2493 private: |
| 2494 static int Hash(Map* fast); |
| 2495 |
| 2496 static bool CheckHit(Map* slow, Map* fast, PropertyNormalizationMode mode); |
| 2497 }; |
| 2498 |
| 2499 |
2468 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 2500 // ByteArray represents fixed sized byte arrays. Used by the outside world, |
2469 // such as PCRE, and also by the memory allocator and garbage collector to | 2501 // such as PCRE, and also by the memory allocator and garbage collector to |
2470 // fill in free blocks in the heap. | 2502 // fill in free blocks in the heap. |
2471 class ByteArray: public HeapObject { | 2503 class ByteArray: public HeapObject { |
2472 public: | 2504 public: |
2473 // [length]: length of the array. | 2505 // [length]: length of the array. |
2474 inline int length(); | 2506 inline int length(); |
2475 inline void set_length(int value); | 2507 inline void set_length(int value); |
2476 | 2508 |
2477 // Setter and getter. | 2509 // Setter and getter. |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3116 DECL_ACCESSORS(constructor, Object) | 3148 DECL_ACCESSORS(constructor, Object) |
3117 | 3149 |
3118 // [instance descriptors]: describes the object. | 3150 // [instance descriptors]: describes the object. |
3119 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 3151 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
3120 | 3152 |
3121 // [stub cache]: contains stubs compiled for this map. | 3153 // [stub cache]: contains stubs compiled for this map. |
3122 DECL_ACCESSORS(code_cache, Object) | 3154 DECL_ACCESSORS(code_cache, Object) |
3123 | 3155 |
3124 Object* CopyDropDescriptors(); | 3156 Object* CopyDropDescriptors(); |
3125 | 3157 |
| 3158 Object* CopyNormalized(PropertyNormalizationMode mode); |
| 3159 |
3126 // Returns a copy of the map, with all transitions dropped from the | 3160 // Returns a copy of the map, with all transitions dropped from the |
3127 // instance descriptors. | 3161 // instance descriptors. |
3128 Object* CopyDropTransitions(); | 3162 Object* CopyDropTransitions(); |
3129 | 3163 |
3130 // Returns this map if it has the fast elements bit set, otherwise | 3164 // Returns this map if it has the fast elements bit set, otherwise |
3131 // returns a copy of the map, with all transitions dropped from the | 3165 // returns a copy of the map, with all transitions dropped from the |
3132 // descriptors and the fast elements bit set. | 3166 // descriptors and the fast elements bit set. |
3133 inline Object* GetFastElementsMap(); | 3167 inline Object* GetFastElementsMap(); |
3134 | 3168 |
3135 // Returns this map if it has the fast elements bit cleared, | 3169 // Returns this map if it has the fast elements bit cleared, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 // Set all map transitions from this map to dead maps to null. | 3212 // Set all map transitions from this map to dead maps to null. |
3179 // Also, restore the original prototype on the targets of these | 3213 // Also, restore the original prototype on the targets of these |
3180 // transitions, so that we do not process this map again while | 3214 // transitions, so that we do not process this map again while |
3181 // following back pointers. | 3215 // following back pointers. |
3182 void ClearNonLiveTransitions(Object* real_prototype); | 3216 void ClearNonLiveTransitions(Object* real_prototype); |
3183 | 3217 |
3184 // Dispatched behavior. | 3218 // Dispatched behavior. |
3185 #ifdef DEBUG | 3219 #ifdef DEBUG |
3186 void MapPrint(); | 3220 void MapPrint(); |
3187 void MapVerify(); | 3221 void MapVerify(); |
| 3222 void NormalizedMapVerify(); |
3188 #endif | 3223 #endif |
3189 | 3224 |
3190 inline int visitor_id(); | 3225 inline int visitor_id(); |
3191 inline void set_visitor_id(int visitor_id); | 3226 inline void set_visitor_id(int visitor_id); |
3192 | 3227 |
3193 static const int kMaxPreAllocatedPropertyFields = 255; | 3228 static const int kMaxPreAllocatedPropertyFields = 255; |
3194 | 3229 |
3195 // Layout description. | 3230 // Layout description. |
3196 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 3231 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
3197 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 3232 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
(...skipping 14 matching lines...) Expand all Loading... |
3212 | 3247 |
3213 // Byte offsets within kInstanceSizesOffset. | 3248 // Byte offsets within kInstanceSizesOffset. |
3214 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 3249 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
3215 static const int kInObjectPropertiesByte = 1; | 3250 static const int kInObjectPropertiesByte = 1; |
3216 static const int kInObjectPropertiesOffset = | 3251 static const int kInObjectPropertiesOffset = |
3217 kInstanceSizesOffset + kInObjectPropertiesByte; | 3252 kInstanceSizesOffset + kInObjectPropertiesByte; |
3218 static const int kPreAllocatedPropertyFieldsByte = 2; | 3253 static const int kPreAllocatedPropertyFieldsByte = 2; |
3219 static const int kPreAllocatedPropertyFieldsOffset = | 3254 static const int kPreAllocatedPropertyFieldsOffset = |
3220 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 3255 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
3221 // The byte at position 3 is not in use at the moment. | 3256 // The byte at position 3 is not in use at the moment. |
| 3257 static const int kUnusedByte = 3; |
| 3258 static const int kUnusedOffset = kInstanceSizesOffset + kUnusedByte; |
3222 | 3259 |
3223 // Byte offsets within kInstanceAttributesOffset attributes. | 3260 // Byte offsets within kInstanceAttributesOffset attributes. |
3224 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 3261 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
3225 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 3262 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
3226 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 3263 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
3227 static const int kBitField2Offset = kInstanceAttributesOffset + 3; | 3264 static const int kBitField2Offset = kInstanceAttributesOffset + 3; |
3228 | 3265 |
3229 STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); | 3266 STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); |
3230 | 3267 |
3231 // Bit positions for bit field. | 3268 // Bit positions for bit field. |
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5510 } else { | 5547 } else { |
5511 value &= ~(1 << bit_position); | 5548 value &= ~(1 << bit_position); |
5512 } | 5549 } |
5513 return value; | 5550 return value; |
5514 } | 5551 } |
5515 }; | 5552 }; |
5516 | 5553 |
5517 } } // namespace v8::internal | 5554 } } // namespace v8::internal |
5518 | 5555 |
5519 #endif // V8_OBJECTS_H_ | 5556 #endif // V8_OBJECTS_H_ |
OLD | NEW |