| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 V(SCRIPT, Script, script) | 388 V(SCRIPT, Script, script) |
| 389 | 389 |
| 390 | 390 |
| 391 // We use the full 8 bits of the instance_type field to encode heap object | 391 // We use the full 8 bits of the instance_type field to encode heap object |
| 392 // instance types. The high-order bit (bit 7) is set if the object is not a | 392 // instance types. The high-order bit (bit 7) is set if the object is not a |
| 393 // string, and cleared if it is a string. | 393 // string, and cleared if it is a string. |
| 394 const uint32_t kIsNotStringMask = 0x80; | 394 const uint32_t kIsNotStringMask = 0x80; |
| 395 const uint32_t kStringTag = 0x0; | 395 const uint32_t kStringTag = 0x0; |
| 396 const uint32_t kNotStringTag = 0x80; | 396 const uint32_t kNotStringTag = 0x80; |
| 397 | 397 |
| 398 // If bit 7 is clear, bits 5 and 6 are the string's size (short, medium, or | 398 // If bit 7 is clear, bit 5 indicates that the string is a symbol (if set) or |
| 399 // long). | 399 // not (if cleared). |
| 400 const uint32_t kStringSizeMask = 0x60; | 400 const uint32_t kIsSymbolMask = 0x20; |
| 401 const uint32_t kShortStringTag = 0x0; | 401 const uint32_t kNotSymbolTag = 0x0; |
| 402 const uint32_t kMediumStringTag = 0x20; | 402 const uint32_t kSymbolTag = 0x20; |
| 403 const uint32_t kLongStringTag = 0x40; | |
| 404 | 403 |
| 405 // If bit 7 is clear, bit 4 indicates that the string is a symbol (if set) or | 404 // If bit 7 is clear, bits 3 and 4 are the string's size (short, medium or |
| 406 // not (if cleared). | 405 // long). These values are very special in that they are also used to shift |
| 407 const uint32_t kIsSymbolMask = 0x10; | 406 // the length field to get the length, removing the hash value. This avoids |
| 408 const uint32_t kNotSymbolTag = 0x0; | 407 // using if or switch when getting the length of a string. |
| 409 const uint32_t kSymbolTag = 0x10; | 408 const uint32_t kStringSizeMask = 0x18; |
| 409 const uint32_t kShortStringTag = 0x18; |
| 410 const uint32_t kMediumStringTag = 0x10; |
| 411 const uint32_t kLongStringTag = 0x00; |
| 410 | 412 |
| 411 // If bit 7 is clear, and the string representation is a sequential string, | 413 // If bit 7 is clear then bit 2 indicates whether the string consists of |
| 412 // then bit 3 indicates whether the string consists of two-byte characters or | 414 // two-byte characters or one-byte characters. |
| 413 // one-byte characters. | 415 const uint32_t kStringEncodingMask = 0x4; |
| 414 const uint32_t kStringEncodingMask = 0x8; | |
| 415 const uint32_t kTwoByteStringTag = 0x0; | 416 const uint32_t kTwoByteStringTag = 0x0; |
| 416 const uint32_t kAsciiStringTag = 0x8; | 417 const uint32_t kAsciiStringTag = 0x4; |
| 417 | 418 |
| 418 // If bit 7 is clear, the low-order 3 bits indicate the representation | 419 // If bit 7 is clear, the low-order 2 bits indicate the representation |
| 419 // of the string. | 420 // of the string. |
| 420 const uint32_t kStringRepresentationMask = 0x07; | 421 const uint32_t kStringRepresentationMask = 0x03; |
| 421 enum StringRepresentationTag { | 422 enum StringRepresentationTag { |
| 422 kSeqStringTag = 0x0, | 423 kSeqStringTag = 0x0, |
| 423 kConsStringTag = 0x1, | 424 kConsStringTag = 0x1, |
| 424 kSlicedStringTag = 0x2, | 425 kSlicedStringTag = 0x2, |
| 425 kExternalStringTag = 0x3 | 426 kExternalStringTag = 0x3 |
| 426 }; | 427 }; |
| 427 | 428 |
| 428 enum InstanceType { | 429 enum InstanceType { |
| 429 SHORT_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSeqStringTag, | 430 SHORT_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSeqStringTag, |
| 430 MEDIUM_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSeqStringTag, | 431 MEDIUM_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSeqStringTag, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 inline bool IsMap(); | 619 inline bool IsMap(); |
| 619 inline bool IsFixedArray(); | 620 inline bool IsFixedArray(); |
| 620 inline bool IsDescriptorArray(); | 621 inline bool IsDescriptorArray(); |
| 621 inline bool IsContext(); | 622 inline bool IsContext(); |
| 622 inline bool IsGlobalContext(); | 623 inline bool IsGlobalContext(); |
| 623 inline bool IsJSFunction(); | 624 inline bool IsJSFunction(); |
| 624 inline bool IsCode(); | 625 inline bool IsCode(); |
| 625 inline bool IsOddball(); | 626 inline bool IsOddball(); |
| 626 inline bool IsSharedFunctionInfo(); | 627 inline bool IsSharedFunctionInfo(); |
| 627 inline bool IsJSValue(); | 628 inline bool IsJSValue(); |
| 629 inline bool IsStringWrapper(); |
| 628 inline bool IsProxy(); | 630 inline bool IsProxy(); |
| 629 inline bool IsBoolean(); | 631 inline bool IsBoolean(); |
| 630 inline bool IsJSArray(); | 632 inline bool IsJSArray(); |
| 631 inline bool IsJSRegExp(); | 633 inline bool IsJSRegExp(); |
| 632 inline bool IsHashTable(); | 634 inline bool IsHashTable(); |
| 633 inline bool IsDictionary(); | 635 inline bool IsDictionary(); |
| 634 inline bool IsSymbolTable(); | 636 inline bool IsSymbolTable(); |
| 635 inline bool IsCompilationCacheTable(); | 637 inline bool IsCompilationCacheTable(); |
| 636 inline bool IsMapCache(); | 638 inline bool IsMapCache(); |
| 637 inline bool IsLookupCache(); | 639 inline bool IsLookupCache(); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 inline bool IsOverflowed(); | 1036 inline bool IsOverflowed(); |
| 1035 | 1037 |
| 1036 // Mutate this object's map pointer to indicate that the object is | 1038 // Mutate this object's map pointer to indicate that the object is |
| 1037 // overflowed. | 1039 // overflowed. |
| 1038 inline void SetOverflow(); | 1040 inline void SetOverflow(); |
| 1039 | 1041 |
| 1040 // Mutate this object's map pointer to remove the indication that the | 1042 // Mutate this object's map pointer to remove the indication that the |
| 1041 // object is overflowed (ie, partially restore the map pointer). | 1043 // object is overflowed (ie, partially restore the map pointer). |
| 1042 inline void ClearOverflow(); | 1044 inline void ClearOverflow(); |
| 1043 | 1045 |
| 1044 static inline Object* GetHeapObjectField(HeapObject* obj, int index); | 1046 // Returns the field at offset in obj, as a read/write Object* reference. |
| 1047 // Does no checking, and is safe to use during GC, while maps are invalid. |
| 1048 // Does not update remembered sets, so should only be assigned to |
| 1049 // during marking GC. |
| 1050 static inline Object** RawField(HeapObject* obj, int offset); |
| 1045 | 1051 |
| 1046 // Casting. | 1052 // Casting. |
| 1047 static inline HeapObject* cast(Object* obj); | 1053 static inline HeapObject* cast(Object* obj); |
| 1048 | 1054 |
| 1049 // Return the write barrier mode for this. | 1055 // Return the write barrier mode for this. |
| 1050 inline WriteBarrierMode GetWriteBarrierMode(); | 1056 inline WriteBarrierMode GetWriteBarrierMode(); |
| 1051 | 1057 |
| 1052 // Dispatched behavior. | 1058 // Dispatched behavior. |
| 1053 void HeapObjectShortPrint(StringStream* accumulator); | 1059 void HeapObjectShortPrint(StringStream* accumulator); |
| 1054 #ifdef DEBUG | 1060 #ifdef DEBUG |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 // Returns the number of enumerable elements in the dictionary. | 1972 // Returns the number of enumerable elements in the dictionary. |
| 1967 int NumberOfEnumElements(); | 1973 int NumberOfEnumElements(); |
| 1968 | 1974 |
| 1969 // Copies keys to preallocated fixed array. | 1975 // Copies keys to preallocated fixed array. |
| 1970 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter); | 1976 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter); |
| 1971 // Copies enumerable keys to preallocated fixed array. | 1977 // Copies enumerable keys to preallocated fixed array. |
| 1972 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); | 1978 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); |
| 1973 // Fill in details for properties into storage. | 1979 // Fill in details for properties into storage. |
| 1974 void CopyKeysTo(FixedArray* storage); | 1980 void CopyKeysTo(FixedArray* storage); |
| 1975 | 1981 |
| 1976 // Returns the value at entry. | |
| 1977 static int ValueIndexFor(int entry) { return EntryToIndex(entry)+1; } | |
| 1978 | |
| 1979 // For transforming properties of a JSObject. | 1982 // For transforming properties of a JSObject. |
| 1980 Object* TransformPropertiesToFastFor(JSObject* obj, | 1983 Object* TransformPropertiesToFastFor(JSObject* obj, |
| 1981 int unused_property_fields); | 1984 int unused_property_fields); |
| 1982 | 1985 |
| 1983 // If slow elements are required we will never go back to fast-case | 1986 // If slow elements are required we will never go back to fast-case |
| 1984 // for the elements kept in this dictionary. We require slow | 1987 // for the elements kept in this dictionary. We require slow |
| 1985 // elements if an element has been added at an index larger than | 1988 // elements if an element has been added at an index larger than |
| 1986 // kRequiresSlowElementsLimit. | 1989 // kRequiresSlowElementsLimit. |
| 1987 inline bool requires_slow_elements(); | 1990 inline bool requires_slow_elements(); |
| 1988 | 1991 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 // Returns the found code or undefined if absent. | 2417 // Returns the found code or undefined if absent. |
| 2415 Object* FindInCodeCache(String* name, Code::Flags flags); | 2418 Object* FindInCodeCache(String* name, Code::Flags flags); |
| 2416 | 2419 |
| 2417 // Returns the non-negative index of the code object if it is in the | 2420 // Returns the non-negative index of the code object if it is in the |
| 2418 // cache and -1 otherwise. | 2421 // cache and -1 otherwise. |
| 2419 int IndexInCodeCache(Code* code); | 2422 int IndexInCodeCache(Code* code); |
| 2420 | 2423 |
| 2421 // Removes a code object from the code cache at the given index. | 2424 // Removes a code object from the code cache at the given index. |
| 2422 void RemoveFromCodeCache(int index); | 2425 void RemoveFromCodeCache(int index); |
| 2423 | 2426 |
| 2427 // For every transition in this map, makes the transition's |
| 2428 // target's prototype pointer point back to this map. |
| 2429 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). |
| 2430 void CreateBackPointers(); |
| 2431 |
| 2432 // Set all map transitions from this map to dead maps to null. |
| 2433 // Also, restore the original prototype on the targets of these |
| 2434 // transitions, so that we do not process this map again while |
| 2435 // following back pointers. |
| 2436 void ClearNonLiveTransitions(Object* real_prototype); |
| 2437 |
| 2424 // Dispatched behavior. | 2438 // Dispatched behavior. |
| 2425 void MapIterateBody(ObjectVisitor* v); | 2439 void MapIterateBody(ObjectVisitor* v); |
| 2426 #ifdef DEBUG | 2440 #ifdef DEBUG |
| 2427 void MapPrint(); | 2441 void MapPrint(); |
| 2428 void MapVerify(); | 2442 void MapVerify(); |
| 2429 #endif | 2443 #endif |
| 2430 | 2444 |
| 2431 // Layout description. | 2445 // Layout description. |
| 2432 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 2446 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
| 2433 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 2447 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2798 // Forward declaration. | 2812 // Forward declaration. |
| 2799 class JSBuiltinsObject; | 2813 class JSBuiltinsObject; |
| 2800 | 2814 |
| 2801 // Common super class for JavaScript global objects and the special | 2815 // Common super class for JavaScript global objects and the special |
| 2802 // builtins global objects. | 2816 // builtins global objects. |
| 2803 class GlobalObject: public JSObject { | 2817 class GlobalObject: public JSObject { |
| 2804 public: | 2818 public: |
| 2805 // [builtins]: the object holding the runtime routines written in JS. | 2819 // [builtins]: the object holding the runtime routines written in JS. |
| 2806 DECL_ACCESSORS(builtins, JSBuiltinsObject) | 2820 DECL_ACCESSORS(builtins, JSBuiltinsObject) |
| 2807 | 2821 |
| 2808 // [global context]: the global context corresponding to this global objet. | 2822 // [global context]: the global context corresponding to this global object. |
| 2809 DECL_ACCESSORS(global_context, Context) | 2823 DECL_ACCESSORS(global_context, Context) |
| 2810 | 2824 |
| 2811 // [global receiver]: the global receiver object of the context | 2825 // [global receiver]: the global receiver object of the context |
| 2812 DECL_ACCESSORS(global_receiver, JSObject) | 2826 DECL_ACCESSORS(global_receiver, JSObject) |
| 2813 | 2827 |
| 2814 // Casting. | 2828 // Casting. |
| 2815 static inline GlobalObject* cast(Object* obj); | 2829 static inline GlobalObject* cast(Object* obj); |
| 2816 | 2830 |
| 2817 // Layout description. | 2831 // Layout description. |
| 2818 static const int kBuiltinsOffset = JSObject::kHeaderSize; | 2832 static const int kBuiltinsOffset = JSObject::kHeaderSize; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 void StringPrint(); | 3161 void StringPrint(); |
| 3148 void StringVerify(); | 3162 void StringVerify(); |
| 3149 #endif | 3163 #endif |
| 3150 inline bool IsFlat(); | 3164 inline bool IsFlat(); |
| 3151 | 3165 |
| 3152 // Layout description. | 3166 // Layout description. |
| 3153 static const int kLengthOffset = HeapObject::kHeaderSize; | 3167 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 3154 static const int kSize = kLengthOffset + kIntSize; | 3168 static const int kSize = kLengthOffset + kIntSize; |
| 3155 | 3169 |
| 3156 // Limits on sizes of different types of strings. | 3170 // Limits on sizes of different types of strings. |
| 3157 static const int kMaxShortStringSize = 255; | 3171 static const int kMaxShortStringSize = 63; |
| 3158 static const int kMaxMediumStringSize = 65535; | 3172 static const int kMaxMediumStringSize = 16383; |
| 3159 | 3173 |
| 3160 static const int kMaxArrayIndexSize = 10; | 3174 static const int kMaxArrayIndexSize = 10; |
| 3161 | 3175 |
| 3162 // Max ascii char code. | 3176 // Max ascii char code. |
| 3163 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 3177 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
| 3164 | 3178 |
| 3165 // Minimum length for a cons or sliced string. | 3179 // Minimum length for a cons or sliced string. |
| 3166 static const int kMinNonFlatLength = 13; | 3180 static const int kMinNonFlatLength = 13; |
| 3167 | 3181 |
| 3168 // Mask constant for checking if a string has a computed hash code | 3182 // Mask constant for checking if a string has a computed hash code |
| 3169 // and if it is an array index. The least significant bit indicates | 3183 // and if it is an array index. The least significant bit indicates |
| 3170 // whether a hash code has been computed. If the hash code has been | 3184 // whether a hash code has been computed. If the hash code has been |
| 3171 // computed the 2nd bit tells whether the string can be used as an | 3185 // computed the 2nd bit tells whether the string can be used as an |
| 3172 // array index. | 3186 // array index. |
| 3173 static const int kHashComputedMask = 1; | 3187 static const int kHashComputedMask = 1; |
| 3174 static const int kIsArrayIndexMask = 1 << 1; | 3188 static const int kIsArrayIndexMask = 1 << 1; |
| 3175 static const int kNofLengthBitFields = 2; | 3189 static const int kNofLengthBitFields = 2; |
| 3176 | 3190 |
| 3177 // Array index strings this short can keep their index in the hash | 3191 // Array index strings this short can keep their index in the hash |
| 3178 // field. | 3192 // field. |
| 3179 static const int kMaxCachedArrayIndexLength = 6; | 3193 static const int kMaxCachedArrayIndexLength = 7; |
| 3180 | 3194 |
| 3181 // Shift constants for retriving length and hash code from | 3195 // Shift constants for retriving length and hash code from |
| 3182 // length/hash field. | 3196 // length/hash field. |
| 3183 static const int kHashShift = kNofLengthBitFields; | 3197 static const int kHashShift = kNofLengthBitFields; |
| 3184 static const int kShortLengthShift = 3 * kBitsPerByte; | 3198 static const int kShortLengthShift = kHashShift + kShortStringTag; |
| 3185 static const int kMediumLengthShift = 2 * kBitsPerByte; | 3199 static const int kMediumLengthShift = kHashShift + kMediumStringTag; |
| 3186 static const int kLongLengthShift = kHashShift; | 3200 static const int kLongLengthShift = kHashShift + kLongStringTag; |
| 3187 | 3201 |
| 3188 // Limit for truncation in short printing. | 3202 // Limit for truncation in short printing. |
| 3189 static const int kMaxShortPrintLength = 1024; | 3203 static const int kMaxShortPrintLength = 1024; |
| 3190 | 3204 |
| 3191 // Support for regular expressions. | 3205 // Support for regular expressions. |
| 3192 const uc16* GetTwoByteData(); | 3206 const uc16* GetTwoByteData(); |
| 3193 const uc16* GetTwoByteData(unsigned start); | 3207 const uc16* GetTwoByteData(unsigned start); |
| 3194 | 3208 |
| 3195 // Support for StringInputBuffer | 3209 // Support for StringInputBuffer |
| 3196 static const unibrow::byte* ReadBlock(String* input, | 3210 static const unibrow::byte* ReadBlock(String* input, |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4119 } else { | 4133 } else { |
| 4120 value &= ~(1 << bit_position); | 4134 value &= ~(1 << bit_position); |
| 4121 } | 4135 } |
| 4122 return value; | 4136 return value; |
| 4123 } | 4137 } |
| 4124 }; | 4138 }; |
| 4125 | 4139 |
| 4126 } } // namespace v8::internal | 4140 } } // namespace v8::internal |
| 4127 | 4141 |
| 4128 #endif // V8_OBJECTS_H_ | 4142 #endif // V8_OBJECTS_H_ |
| OLD | NEW |