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 2947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 | 2958 |
2959 // Specialization of this function from Object that skips the | 2959 // Specialization of this function from Object that skips the |
2960 // string check. | 2960 // string check. |
2961 inline bool IsSeqAsciiString(); | 2961 inline bool IsSeqAsciiString(); |
2962 | 2962 |
2963 // Fast testing routines that assume the receiver is a string and | 2963 // Fast testing routines that assume the receiver is a string and |
2964 // just check whether it is a certain kind of string. | 2964 // just check whether it is a certain kind of string. |
2965 inline bool StringIsSlicedString(); | 2965 inline bool StringIsSlicedString(); |
2966 inline bool StringIsConsString(); | 2966 inline bool StringIsConsString(); |
2967 | 2967 |
2968 Vector<const char> ToAsciiVector(); | 2968 Vector<const byte> ToAsciiVector(); |
2969 Vector<const uc16> ToUC16Vector(); | 2969 Vector<const uc16> ToUC16Vector(); |
2970 | 2970 |
2971 // Mark the string as an undetectable object. It only applies to | 2971 // Mark the string as an undetectable object. It only applies to |
2972 // ascii and two byte string types. | 2972 // ascii and two byte string types. |
2973 bool MarkAsUndetectable(); | 2973 bool MarkAsUndetectable(); |
2974 | 2974 |
2975 // Slice the string and return a substring. | 2975 // Slice the string and return a substring. |
2976 Object* Slice(int from, int to); | 2976 Object* Slice(int from, int to); |
2977 | 2977 |
2978 // String equality operations. | 2978 // String equality operations. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 // True if the string is a symbol. | 3036 // True if the string is a symbol. |
3037 inline bool is_symbol(); | 3037 inline bool is_symbol(); |
3038 static inline bool is_symbol_map(Map* map); | 3038 static inline bool is_symbol_map(Map* map); |
3039 | 3039 |
3040 // True if the string is ASCII. | 3040 // True if the string is ASCII. |
3041 inline bool is_ascii_representation(); | 3041 inline bool is_ascii_representation(); |
3042 static inline bool is_ascii_representation_map(Map* map); | 3042 static inline bool is_ascii_representation_map(Map* map); |
3043 | 3043 |
3044 // Get the representation tag. | 3044 // Get the representation tag. |
3045 inline StringRepresentationTag representation_tag(); | 3045 inline StringRepresentationTag representation_tag(); |
| 3046 // Get the representation and ASCII tag. |
| 3047 inline int full_representation_tag(); |
3046 static inline StringRepresentationTag map_representation_tag(Map* map); | 3048 static inline StringRepresentationTag map_representation_tag(Map* map); |
3047 | 3049 |
3048 // For use during stack traces. Performs rudimentary sanity check. | 3050 // For use during stack traces. Performs rudimentary sanity check. |
3049 bool LooksValid(); | 3051 bool LooksValid(); |
3050 | 3052 |
3051 // Dispatched behavior. | 3053 // Dispatched behavior. |
3052 void StringShortPrint(StringStream* accumulator); | 3054 void StringShortPrint(StringStream* accumulator); |
3053 #ifdef DEBUG | 3055 #ifdef DEBUG |
3054 void StringPrint(); | 3056 void StringPrint(); |
3055 void StringVerify(); | 3057 void StringVerify(); |
3056 #endif | 3058 #endif |
3057 inline bool IsFlat(); | 3059 inline bool IsFlat(); |
3058 | 3060 |
3059 // Layout description. | 3061 // Layout description. |
3060 static const int kLengthOffset = HeapObject::kHeaderSize; | 3062 static const int kLengthOffset = HeapObject::kHeaderSize; |
3061 static const int kSize = kLengthOffset + kIntSize; | 3063 static const int kSize = kLengthOffset + kIntSize; |
3062 | 3064 |
3063 // Limits on sizes of different types of strings. | 3065 // Limits on sizes of different types of strings. |
3064 static const int kMaxShortStringSize = 255; | 3066 static const int kMaxShortStringSize = 255; |
3065 static const int kMaxMediumStringSize = 65535; | 3067 static const int kMaxMediumStringSize = 65535; |
3066 | 3068 |
3067 static const int kMaxArrayIndexSize = 10; | 3069 static const int kMaxArrayIndexSize = 10; |
3068 | 3070 |
3069 // Max ascii char code. | 3071 // Max ascii char code. |
3070 static const int kMaxAsciiCharCode = 127; | 3072 static const int kMaxAsciiCharCode = 127; |
3071 | 3073 |
| 3074 // Minimum lenth for a cons or sliced string. |
| 3075 static const int kMinNonFlatLength = 13; |
| 3076 |
3072 // Mask constant for checking if a string has a computed hash code | 3077 // Mask constant for checking if a string has a computed hash code |
3073 // and if it is an array index. The least significant bit indicates | 3078 // and if it is an array index. The least significant bit indicates |
3074 // whether a hash code has been computed. If the hash code has been | 3079 // whether a hash code has been computed. If the hash code has been |
3075 // computed the 2nd bit tells whether the string can be used as an | 3080 // computed the 2nd bit tells whether the string can be used as an |
3076 // array index. | 3081 // array index. |
3077 static const int kHashComputedMask = 1; | 3082 static const int kHashComputedMask = 1; |
3078 static const int kIsArrayIndexMask = 1 << 1; | 3083 static const int kIsArrayIndexMask = 1 << 1; |
3079 static const int kNofLengthBitFields = 2; | 3084 static const int kNofLengthBitFields = 2; |
3080 | 3085 |
3081 // Shift constants for retriving length and hash code from | 3086 // Shift constants for retriving length and hash code from |
(...skipping 17 matching lines...) Expand all Loading... |
3099 unsigned capacity, | 3104 unsigned capacity, |
3100 unsigned* remaining, | 3105 unsigned* remaining, |
3101 unsigned* offset); | 3106 unsigned* offset); |
3102 static const unibrow::byte* ReadBlock(String** input, | 3107 static const unibrow::byte* ReadBlock(String** input, |
3103 unibrow::byte* util_buffer, | 3108 unibrow::byte* util_buffer, |
3104 unsigned capacity, | 3109 unsigned capacity, |
3105 unsigned* remaining, | 3110 unsigned* remaining, |
3106 unsigned* offset); | 3111 unsigned* offset); |
3107 | 3112 |
3108 // Helper function for flattening strings. | 3113 // Helper function for flattening strings. |
3109 static void Flatten(String* source, | 3114 template <typename sinkchar> |
3110 String* sink, | 3115 static void WriteToFlat(String* source, |
3111 int from, | 3116 sinkchar* sink, |
3112 int to, | 3117 int from, |
3113 int sink_offset); | 3118 int to); |
3114 | 3119 |
3115 protected: | 3120 protected: |
3116 class ReadBlockBuffer { | 3121 class ReadBlockBuffer { |
3117 public: | 3122 public: |
3118 ReadBlockBuffer(unibrow::byte* util_buffer_, | 3123 ReadBlockBuffer(unibrow::byte* util_buffer_, |
3119 unsigned cursor_, | 3124 unsigned cursor_, |
3120 unsigned capacity_, | 3125 unsigned capacity_, |
3121 unsigned remaining_) : | 3126 unsigned remaining_) : |
3122 util_buffer(util_buffer_), | 3127 util_buffer(util_buffer_), |
3123 cursor(cursor_), | 3128 cursor(cursor_), |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3294 | 3299 |
3295 // Support for StringInputBuffer. | 3300 // Support for StringInputBuffer. |
3296 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer, | 3301 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer, |
3297 unsigned* offset_ptr, | 3302 unsigned* offset_ptr, |
3298 unsigned chars); | 3303 unsigned chars); |
3299 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3304 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
3300 unsigned* offset_ptr, | 3305 unsigned* offset_ptr, |
3301 unsigned chars); | 3306 unsigned chars); |
3302 | 3307 |
3303 | 3308 |
3304 // Minimum lenth for a cons string. | |
3305 static const int kMinLength = 13; | |
3306 | 3309 |
3307 private: | 3310 private: |
3308 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); | 3311 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); |
3309 }; | 3312 }; |
3310 | 3313 |
3311 | 3314 |
3312 // The SlicedString class describes string values that are slices of | 3315 // The SlicedString class describes string values that are slices of |
3313 // some other string. SlicedStrings consist of a reference to an | 3316 // some other string. SlicedStrings consist of a reference to an |
3314 // underlying heap-allocated string value, a start index, and the | 3317 // underlying heap-allocated string value, a start index, and the |
3315 // length field common to all strings. | 3318 // length field common to all strings. |
(...skipping 25 matching lines...) Expand all Loading... |
3341 static const int kSize = kStartOffset + kIntSize; | 3344 static const int kSize = kStartOffset + kIntSize; |
3342 | 3345 |
3343 // Support for StringInputBuffer. | 3346 // Support for StringInputBuffer. |
3344 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, | 3347 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, |
3345 unsigned* offset_ptr, | 3348 unsigned* offset_ptr, |
3346 unsigned chars); | 3349 unsigned chars); |
3347 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3350 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
3348 unsigned* offset_ptr, | 3351 unsigned* offset_ptr, |
3349 unsigned chars); | 3352 unsigned chars); |
3350 | 3353 |
3351 // Minimum lenth for a sliced string. | |
3352 static const int kMinLength = 13; | |
3353 | |
3354 private: | 3354 private: |
3355 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); | 3355 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); |
3356 }; | 3356 }; |
3357 | 3357 |
3358 | 3358 |
3359 // The ExternalString class describes string values that are backed by | 3359 // The ExternalString class describes string values that are backed by |
3360 // a string resource that lies outside the V8 heap. ExternalStrings | 3360 // a string resource that lies outside the V8 heap. ExternalStrings |
3361 // consist of the length field common to all strings, a pointer to the | 3361 // consist of the length field common to all strings, a pointer to the |
3362 // external resource. It is important to ensure (externally) that the | 3362 // external resource. It is important to ensure (externally) that the |
3363 // resource is not deallocated while the ExternalString is live in the | 3363 // resource is not deallocated while the ExternalString is live in the |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4020 } else { | 4020 } else { |
4021 value &= ~(1 << bit_position); | 4021 value &= ~(1 << bit_position); |
4022 } | 4022 } |
4023 return value; | 4023 return value; |
4024 } | 4024 } |
4025 }; | 4025 }; |
4026 | 4026 |
4027 } } // namespace v8::internal | 4027 } } // namespace v8::internal |
4028 | 4028 |
4029 #endif // V8_OBJECTS_H_ | 4029 #endif // V8_OBJECTS_H_ |
OLD | NEW |