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, bits 5 and 6 are the string's size (short, medium or long) . |
Mads Ager (chromium)
2008/10/27 09:37:00
This is now bits 4 and 5?
Also, you should add a
| |
399 // long). | 399 const uint32_t kStringSizeMask = 0x18; |
400 const uint32_t kStringSizeMask = 0x60; | 400 const uint32_t kShortStringTag = 0x18; |
401 const uint32_t kShortStringTag = 0x0; | 401 const uint32_t kMediumStringTag = 0x10; |
402 const uint32_t kMediumStringTag = 0x20; | 402 const uint32_t kLongStringTag = 0x00; |
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, bit 4 indicates that the string is a symbol (if set) or |
Mads Ager (chromium)
2008/10/27 09:37:00
And this is now bit 5?
| |
406 // not (if cleared). | 405 // not (if cleared). |
407 const uint32_t kIsSymbolMask = 0x10; | 406 const uint32_t kIsSymbolMask = 0x20; |
408 const uint32_t kNotSymbolTag = 0x0; | 407 const uint32_t kNotSymbolTag = 0x0; |
409 const uint32_t kSymbolTag = 0x10; | 408 const uint32_t kSymbolTag = 0x20; |
410 | 409 |
411 // If bit 7 is clear, and the string representation is a sequential string, | 410 // If bit 7 is clear, and the string representation is a sequential string, |
412 // then bit 3 indicates whether the string consists of two-byte characters or | 411 // then bit 3 indicates whether the string consists of two-byte characters or |
413 // one-byte characters. | 412 // one-byte characters. |
414 const uint32_t kStringEncodingMask = 0x8; | 413 const uint32_t kStringEncodingMask = 0x4; |
415 const uint32_t kTwoByteStringTag = 0x0; | 414 const uint32_t kTwoByteStringTag = 0x0; |
416 const uint32_t kAsciiStringTag = 0x8; | 415 const uint32_t kAsciiStringTag = 0x4; |
417 | 416 |
418 // If bit 7 is clear, the low-order 3 bits indicate the representation | 417 // If bit 7 is clear, the low-order 3 bits indicate the representation |
Mads Ager (chromium)
2008/10/27 09:37:00
3 -> 2 bits.
| |
419 // of the string. | 418 // of the string. |
420 const uint32_t kStringRepresentationMask = 0x07; | 419 const uint32_t kStringRepresentationMask = 0x03; |
421 enum StringRepresentationTag { | 420 enum StringRepresentationTag { |
422 kSeqStringTag = 0x0, | 421 kSeqStringTag = 0x0, |
423 kConsStringTag = 0x1, | 422 kConsStringTag = 0x1, |
424 kSlicedStringTag = 0x2, | 423 kSlicedStringTag = 0x2, |
425 kExternalStringTag = 0x3 | 424 kExternalStringTag = 0x3 |
426 }; | 425 }; |
427 | 426 |
428 enum InstanceType { | 427 enum InstanceType { |
429 SHORT_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSeqStringTag, | 428 SHORT_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSeqStringTag, |
430 MEDIUM_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSeqStringTag, | 429 MEDIUM_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSeqStringTag, |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3147 void StringPrint(); | 3146 void StringPrint(); |
3148 void StringVerify(); | 3147 void StringVerify(); |
3149 #endif | 3148 #endif |
3150 inline bool IsFlat(); | 3149 inline bool IsFlat(); |
3151 | 3150 |
3152 // Layout description. | 3151 // Layout description. |
3153 static const int kLengthOffset = HeapObject::kHeaderSize; | 3152 static const int kLengthOffset = HeapObject::kHeaderSize; |
3154 static const int kSize = kLengthOffset + kIntSize; | 3153 static const int kSize = kLengthOffset + kIntSize; |
3155 | 3154 |
3156 // Limits on sizes of different types of strings. | 3155 // Limits on sizes of different types of strings. |
3157 static const int kMaxShortStringSize = 255; | 3156 static const int kMaxShortStringSize = 63; |
3158 static const int kMaxMediumStringSize = 65535; | 3157 static const int kMaxMediumStringSize = 16383; |
Mads Ager (chromium)
2008/10/27 09:37:00
These reductions in the limits is the only thing t
| |
3159 | 3158 |
3160 static const int kMaxArrayIndexSize = 10; | 3159 static const int kMaxArrayIndexSize = 10; |
3161 | 3160 |
3162 // Max ascii char code. | 3161 // Max ascii char code. |
3163 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 3162 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
3164 | 3163 |
3165 // Minimum length for a cons or sliced string. | 3164 // Minimum length for a cons or sliced string. |
3166 static const int kMinNonFlatLength = 13; | 3165 static const int kMinNonFlatLength = 13; |
3167 | 3166 |
3168 // Mask constant for checking if a string has a computed hash code | 3167 // 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 | 3168 // 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 | 3169 // 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 | 3170 // computed the 2nd bit tells whether the string can be used as an |
3172 // array index. | 3171 // array index. |
3173 static const int kHashComputedMask = 1; | 3172 static const int kHashComputedMask = 1; |
3174 static const int kIsArrayIndexMask = 1 << 1; | 3173 static const int kIsArrayIndexMask = 1 << 1; |
3175 static const int kNofLengthBitFields = 2; | 3174 static const int kNofLengthBitFields = 2; |
3176 | 3175 |
3177 // Array index strings this short can keep their index in the hash | 3176 // Array index strings this short can keep their index in the hash |
3178 // field. | 3177 // field. |
3179 static const int kMaxCachedArrayIndexLength = 6; | 3178 static const int kMaxCachedArrayIndexLength = 7; |
3180 | 3179 |
3181 // Shift constants for retriving length and hash code from | 3180 // Shift constants for retriving length and hash code from |
3182 // length/hash field. | 3181 // length/hash field. |
3183 static const int kHashShift = kNofLengthBitFields; | 3182 static const int kHashShift = kNofLengthBitFields; |
3184 static const int kShortLengthShift = 3 * kBitsPerByte; | 3183 static const int kShortLengthShift = 26; |
Mads Ager (chromium)
2008/10/27 09:37:00
Could we write these as kShortStringTag + kReprese
| |
3185 static const int kMediumLengthShift = 2 * kBitsPerByte; | 3184 static const int kMediumLengthShift = 18; |
3186 static const int kLongLengthShift = kHashShift; | 3185 static const int kLongLengthShift = kHashShift; |
3187 | 3186 |
3188 // Limit for truncation in short printing. | 3187 // Limit for truncation in short printing. |
3189 static const int kMaxShortPrintLength = 1024; | 3188 static const int kMaxShortPrintLength = 1024; |
3190 | 3189 |
3191 // Support for regular expressions. | 3190 // Support for regular expressions. |
3192 const uc16* GetTwoByteData(); | 3191 const uc16* GetTwoByteData(); |
3193 const uc16* GetTwoByteData(unsigned start); | 3192 const uc16* GetTwoByteData(unsigned start); |
3194 | 3193 |
3195 // Support for StringInputBuffer | 3194 // Support for StringInputBuffer |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4119 } else { | 4118 } else { |
4120 value &= ~(1 << bit_position); | 4119 value &= ~(1 << bit_position); |
4121 } | 4120 } |
4122 return value; | 4121 return value; |
4123 } | 4122 } |
4124 }; | 4123 }; |
4125 | 4124 |
4126 } } // namespace v8::internal | 4125 } } // namespace v8::internal |
4127 | 4126 |
4128 #endif // V8_OBJECTS_H_ | 4127 #endif // V8_OBJECTS_H_ |
OLD | NEW |