| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // allocation of the C++ vtable. | 588 // allocation of the C++ vtable. |
| 589 // Since Smi and Failure are subclasses of Object no | 589 // Since Smi and Failure are subclasses of Object no |
| 590 // data members can be present in Object. | 590 // data members can be present in Object. |
| 591 class Object BASE_EMBEDDED { | 591 class Object BASE_EMBEDDED { |
| 592 public: | 592 public: |
| 593 // Type testing. | 593 // Type testing. |
| 594 inline bool IsSmi(); | 594 inline bool IsSmi(); |
| 595 inline bool IsHeapObject(); | 595 inline bool IsHeapObject(); |
| 596 inline bool IsHeapNumber(); | 596 inline bool IsHeapNumber(); |
| 597 inline bool IsString(); | 597 inline bool IsString(); |
| 598 inline bool IsSymbol(); |
| 598 inline bool IsSeqString(); | 599 inline bool IsSeqString(); |
| 599 inline bool IsAsciiStringRepresentation(); | |
| 600 inline bool IsTwoByteStringRepresentation(); | |
| 601 inline bool IsSeqAsciiString(); | |
| 602 inline bool IsSeqTwoByteString(); | |
| 603 inline bool IsConsString(); | |
| 604 inline bool IsSlicedString(); | 600 inline bool IsSlicedString(); |
| 605 inline bool IsExternalString(); | 601 inline bool IsExternalString(); |
| 602 inline bool IsConsString(); |
| 603 inline bool IsExternalTwoByteString(); |
| 606 inline bool IsExternalAsciiString(); | 604 inline bool IsExternalAsciiString(); |
| 607 inline bool IsExternalTwoByteString(); | 605 inline bool IsSeqTwoByteString(); |
| 608 inline bool IsShortString(); | 606 inline bool IsSeqAsciiString(); |
| 609 inline bool IsMediumString(); | 607 |
| 610 inline bool IsLongString(); | |
| 611 inline bool IsSymbol(); | |
| 612 inline bool IsNumber(); | 608 inline bool IsNumber(); |
| 613 inline bool IsByteArray(); | 609 inline bool IsByteArray(); |
| 614 inline bool IsFailure(); | 610 inline bool IsFailure(); |
| 615 inline bool IsRetryAfterGC(); | 611 inline bool IsRetryAfterGC(); |
| 616 inline bool IsOutOfMemoryFailure(); | 612 inline bool IsOutOfMemoryFailure(); |
| 617 inline bool IsException(); | 613 inline bool IsException(); |
| 618 inline bool IsJSObject(); | 614 inline bool IsJSObject(); |
| 619 inline bool IsMap(); | 615 inline bool IsMap(); |
| 620 inline bool IsFixedArray(); | 616 inline bool IsFixedArray(); |
| 621 inline bool IsDescriptorArray(); | 617 inline bool IsDescriptorArray(); |
| (...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3010 | 3006 |
| 3011 int length_; | 3007 int length_; |
| 3012 uint32_t raw_running_hash_; | 3008 uint32_t raw_running_hash_; |
| 3013 uint32_t array_index_; | 3009 uint32_t array_index_; |
| 3014 bool is_array_index_; | 3010 bool is_array_index_; |
| 3015 bool is_first_char_; | 3011 bool is_first_char_; |
| 3016 bool is_valid_; | 3012 bool is_valid_; |
| 3017 }; | 3013 }; |
| 3018 | 3014 |
| 3019 | 3015 |
| 3016 // The characteristics of a string are stored in its map. Retrieving these |
| 3017 // few bits of information is moderately expensive, involving two memory |
| 3018 // loads where the second is dependent on the first. To improve efficiency |
| 3019 // the shape of the string is given its own class so that it can be retrieved |
| 3020 // once and used for several string operations. A StringShape is small enough |
| 3021 // to be passed by value and is immutable, but be aware that flattening a |
| 3022 // string can potentially alter its shape. |
| 3023 // |
| 3024 // Most of the methods designed to interrogate a string as to its exact nature |
| 3025 // have been made into methods on StringShape in order to encourage the use of |
| 3026 // StringShape. The String class has both a length() and a length(StringShape) |
| 3027 // operation. The former is simpler to type, but the latter is faster if you |
| 3028 // need the StringShape for some other operation immediately before or after. |
| 3029 class StringShape BASE_EMBEDDED { |
| 3030 public: |
| 3031 inline explicit StringShape(String* s); |
| 3032 inline explicit StringShape(Map* s); |
| 3033 inline explicit StringShape(InstanceType t); |
| 3034 inline bool IsAsciiRepresentation(); |
| 3035 inline bool IsTwoByteRepresentation(); |
| 3036 inline bool IsSequential(); |
| 3037 inline bool IsExternal(); |
| 3038 inline bool IsCons(); |
| 3039 inline bool IsSliced(); |
| 3040 inline bool IsExternalAscii(); |
| 3041 inline bool IsExternalTwoByte(); |
| 3042 inline bool IsSequentialAscii(); |
| 3043 inline bool IsSequentialTwoByte(); |
| 3044 inline bool IsSymbol(); |
| 3045 inline StringRepresentationTag representation_tag(); |
| 3046 inline uint32_t full_representation_tag(); |
| 3047 inline uint32_t size_tag(); |
| 3048 #ifdef DEBUG |
| 3049 inline uint32_t type() { return type_; } |
| 3050 inline void invalidate() { valid_ = false; } |
| 3051 inline bool valid() { return valid_; } |
| 3052 #else |
| 3053 inline void invalidate() { } |
| 3054 #endif |
| 3055 private: |
| 3056 uint32_t type_; |
| 3057 #ifdef DEBUG |
| 3058 inline void set_valid() { valid_ = true; } |
| 3059 bool valid_; |
| 3060 #else |
| 3061 inline void set_valid() { } |
| 3062 #endif |
| 3063 }; |
| 3064 |
| 3065 |
| 3020 // The String abstract class captures JavaScript string values: | 3066 // The String abstract class captures JavaScript string values: |
| 3021 // | 3067 // |
| 3022 // Ecma-262: | 3068 // Ecma-262: |
| 3023 // 4.3.16 String Value | 3069 // 4.3.16 String Value |
| 3024 // A string value is a member of the type String and is a finite | 3070 // A string value is a member of the type String and is a finite |
| 3025 // ordered sequence of zero or more 16-bit unsigned integer values. | 3071 // ordered sequence of zero or more 16-bit unsigned integer values. |
| 3026 // | 3072 // |
| 3027 // All string values have a length field. | 3073 // All string values have a length field. |
| 3028 class String: public HeapObject { | 3074 class String: public HeapObject { |
| 3029 public: | 3075 public: |
| 3030 // Get and set the length of the string. | 3076 // Get and set the length of the string. |
| 3077 // Fast version. |
| 3078 inline int length(StringShape shape); |
| 3079 // Easy version. |
| 3031 inline int length(); | 3080 inline int length(); |
| 3032 inline void set_length(int value); | 3081 inline void set_length(int value); |
| 3033 | 3082 |
| 3034 // Get and set the uninterpreted length field of the string. Notice | 3083 // Get and set the uninterpreted length field of the string. Notice |
| 3035 // that the length field is also used to cache the hash value of | 3084 // that the length field is also used to cache the hash value of |
| 3036 // strings. In order to get or set the actual length of the string | 3085 // strings. In order to get or set the actual length of the string |
| 3037 // use the length() and set_length methods. | 3086 // use the length() and set_length methods. |
| 3038 inline uint32_t length_field(); | 3087 inline uint32_t length_field(); |
| 3039 inline void set_length_field(uint32_t value); | 3088 inline void set_length_field(uint32_t value); |
| 3040 | 3089 |
| 3041 // Get and set individual two byte chars in the string. | 3090 // Get and set individual two byte chars in the string. |
| 3042 inline void Set(int index, uint16_t value); | 3091 inline void Set(StringShape shape, int index, uint16_t value); |
| 3043 // Get individual two byte char in the string. Repeated calls | 3092 // Get individual two byte char in the string. Repeated calls |
| 3044 // to this method are not efficient unless the string is flat. | 3093 // to this method are not efficient unless the string is flat. |
| 3045 inline uint16_t Get(int index); | 3094 inline uint16_t Get(StringShape shape, int index); |
| 3046 | 3095 |
| 3047 // Flatten the top level ConsString that is hiding behind this | 3096 // Flatten the top level ConsString that is hiding behind this |
| 3048 // string. This is a no-op unless the string is a ConsString or a | 3097 // string. This is a no-op unless the string is a ConsString or a |
| 3049 // SlicedString. Flatten mutates the ConsString and might return a | 3098 // SlicedString. Flatten mutates the ConsString and might return a |
| 3050 // failure. | 3099 // failure. |
| 3051 Object* Flatten(); | 3100 Object* Flatten(StringShape shape); |
| 3052 // Try to flatten the string. Do not allow handling of allocation | 3101 // Try to flatten the string. Do not allow handling of allocation |
| 3053 // failures. After calling TryFlatten, the string could still be a | 3102 // failures. After calling TryFlatten, the string could still be a |
| 3054 // ConsString. | 3103 // ConsString. |
| 3055 inline void TryFlatten(); | 3104 inline void TryFlatten(StringShape shape); |
| 3056 | |
| 3057 // Is this string an ascii string. | |
| 3058 inline bool IsAsciiRepresentation(); | |
| 3059 | |
| 3060 // Specialization of this function from Object that skips the | |
| 3061 // string check. | |
| 3062 inline bool IsSeqAsciiString(); | |
| 3063 | |
| 3064 // Fast testing routines that assume the receiver is a string and | |
| 3065 // just check whether it is a certain kind of string. | |
| 3066 inline bool StringIsSlicedString(); | |
| 3067 inline bool StringIsConsString(); | |
| 3068 | 3105 |
| 3069 Vector<const char> ToAsciiVector(); | 3106 Vector<const char> ToAsciiVector(); |
| 3070 Vector<const uc16> ToUC16Vector(); | 3107 Vector<const uc16> ToUC16Vector(); |
| 3071 | 3108 |
| 3072 // Mark the string as an undetectable object. It only applies to | 3109 // Mark the string as an undetectable object. It only applies to |
| 3073 // ascii and two byte string types. | 3110 // ascii and two byte string types. |
| 3074 bool MarkAsUndetectable(); | 3111 bool MarkAsUndetectable(); |
| 3075 | 3112 |
| 3076 // Slice the string and return a substring. | 3113 // Slice the string and return a substring. |
| 3077 Object* Slice(int from, int to); | 3114 Object* Slice(StringShape shape, int from, int to); |
| 3078 | 3115 |
| 3079 // String equality operations. | 3116 // String equality operations. |
| 3080 inline bool Equals(String* other); | 3117 inline bool Equals(String* other); |
| 3081 bool IsEqualTo(Vector<const char> str); | 3118 bool IsEqualTo(Vector<const char> str); |
| 3082 | 3119 |
| 3083 // Return a UTF8 representation of the string. The string is null | 3120 // Return a UTF8 representation of the string. The string is null |
| 3084 // terminated but may optionally contain nulls. Length is returned | 3121 // terminated but may optionally contain nulls. Length is returned |
| 3085 // in length_output if length_output is not a null pointer The string | 3122 // in length_output if length_output is not a null pointer The string |
| 3086 // should be nearly flat, otherwise the performance of this method may | 3123 // should be nearly flat, otherwise the performance of this method may |
| 3087 // be very slow (quadratic in the length). Setting robustness_flag to | 3124 // be very slow (quadratic in the length). Setting robustness_flag to |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3123 int length); | 3160 int length); |
| 3124 | 3161 |
| 3125 // Conversion. | 3162 // Conversion. |
| 3126 inline bool AsArrayIndex(uint32_t* index); | 3163 inline bool AsArrayIndex(uint32_t* index); |
| 3127 | 3164 |
| 3128 // Casting. | 3165 // Casting. |
| 3129 static inline String* cast(Object* obj); | 3166 static inline String* cast(Object* obj); |
| 3130 | 3167 |
| 3131 void PrintOn(FILE* out); | 3168 void PrintOn(FILE* out); |
| 3132 | 3169 |
| 3133 // Get the size tag. | |
| 3134 inline uint32_t size_tag(); | |
| 3135 static inline uint32_t map_size_tag(Map* map); | |
| 3136 | |
| 3137 // True if the string is a symbol. | |
| 3138 inline bool is_symbol(); | |
| 3139 static inline bool is_symbol_map(Map* map); | |
| 3140 | |
| 3141 // True if the string is ASCII. | |
| 3142 inline bool is_ascii_representation(); | |
| 3143 static inline bool is_ascii_representation_map(Map* map); | |
| 3144 | |
| 3145 // Get the representation tag. | |
| 3146 inline StringRepresentationTag representation_tag(); | |
| 3147 // Get the representation and ASCII tag. | |
| 3148 inline int full_representation_tag(); | |
| 3149 static inline StringRepresentationTag map_representation_tag(Map* map); | |
| 3150 | |
| 3151 // For use during stack traces. Performs rudimentary sanity check. | 3170 // For use during stack traces. Performs rudimentary sanity check. |
| 3152 bool LooksValid(); | 3171 bool LooksValid(); |
| 3153 | 3172 |
| 3154 // Dispatched behavior. | 3173 // Dispatched behavior. |
| 3155 void StringShortPrint(StringStream* accumulator); | 3174 void StringShortPrint(StringStream* accumulator); |
| 3156 #ifdef DEBUG | 3175 #ifdef DEBUG |
| 3157 void StringPrint(); | 3176 void StringPrint(); |
| 3158 void StringVerify(); | 3177 void StringVerify(); |
| 3159 #endif | 3178 #endif |
| 3160 inline bool IsFlat(); | 3179 inline bool IsFlat(StringShape shape); |
| 3161 | 3180 |
| 3162 // Layout description. | 3181 // Layout description. |
| 3163 static const int kLengthOffset = HeapObject::kHeaderSize; | 3182 static const int kLengthOffset = HeapObject::kHeaderSize; |
| 3164 static const int kSize = kLengthOffset + kIntSize; | 3183 static const int kSize = kLengthOffset + kIntSize; |
| 3165 | 3184 |
| 3166 // Limits on sizes of different types of strings. | 3185 // Limits on sizes of different types of strings. |
| 3167 static const int kMaxShortStringSize = 63; | 3186 static const int kMaxShortStringSize = 63; |
| 3168 static const int kMaxMediumStringSize = 16383; | 3187 static const int kMaxMediumStringSize = 16383; |
| 3169 | 3188 |
| 3170 static const int kMaxArrayIndexSize = 10; | 3189 static const int kMaxArrayIndexSize = 10; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3210 unsigned* offset); | 3229 unsigned* offset); |
| 3211 static const unibrow::byte* ReadBlock(String** input, | 3230 static const unibrow::byte* ReadBlock(String** input, |
| 3212 unibrow::byte* util_buffer, | 3231 unibrow::byte* util_buffer, |
| 3213 unsigned capacity, | 3232 unsigned capacity, |
| 3214 unsigned* remaining, | 3233 unsigned* remaining, |
| 3215 unsigned* offset); | 3234 unsigned* offset); |
| 3216 | 3235 |
| 3217 // Helper function for flattening strings. | 3236 // Helper function for flattening strings. |
| 3218 template <typename sinkchar> | 3237 template <typename sinkchar> |
| 3219 static void WriteToFlat(String* source, | 3238 static void WriteToFlat(String* source, |
| 3239 StringShape shape, |
| 3220 sinkchar* sink, | 3240 sinkchar* sink, |
| 3221 int from, | 3241 int from, |
| 3222 int to); | 3242 int to); |
| 3223 | 3243 |
| 3224 protected: | 3244 protected: |
| 3225 class ReadBlockBuffer { | 3245 class ReadBlockBuffer { |
| 3226 public: | 3246 public: |
| 3227 ReadBlockBuffer(unibrow::byte* util_buffer_, | 3247 ReadBlockBuffer(unibrow::byte* util_buffer_, |
| 3228 unsigned cursor_, | 3248 unsigned cursor_, |
| 3229 unsigned capacity_, | 3249 unsigned capacity_, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3250 unsigned* offset, | 3270 unsigned* offset, |
| 3251 unsigned max_chars); | 3271 unsigned max_chars); |
| 3252 static void ReadBlockIntoBuffer(String* input, | 3272 static void ReadBlockIntoBuffer(String* input, |
| 3253 ReadBlockBuffer* buffer, | 3273 ReadBlockBuffer* buffer, |
| 3254 unsigned* offset_ptr, | 3274 unsigned* offset_ptr, |
| 3255 unsigned max_chars); | 3275 unsigned max_chars); |
| 3256 | 3276 |
| 3257 private: | 3277 private: |
| 3258 // Slow case of String::Equals. This implementation works on any strings | 3278 // Slow case of String::Equals. This implementation works on any strings |
| 3259 // but it is most efficient on strings that are almost flat. | 3279 // but it is most efficient on strings that are almost flat. |
| 3260 bool SlowEquals(String* other); | 3280 bool SlowEquals(StringShape this_shape, |
| 3281 String* other, |
| 3282 StringShape other_shape); |
| 3261 | 3283 |
| 3262 // Slow case of AsArrayIndex. | 3284 // Slow case of AsArrayIndex. |
| 3263 bool SlowAsArrayIndex(uint32_t* index); | 3285 bool SlowAsArrayIndex(uint32_t* index); |
| 3264 | 3286 |
| 3265 // Compute and set the hash code. | 3287 // Compute and set the hash code. |
| 3266 uint32_t ComputeAndSetHash(); | 3288 uint32_t ComputeAndSetHash(); |
| 3267 | 3289 |
| 3268 DISALLOW_IMPLICIT_CONSTRUCTORS(String); | 3290 DISALLOW_IMPLICIT_CONSTRUCTORS(String); |
| 3269 }; | 3291 }; |
| 3270 | 3292 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3297 inline Address GetCharsAddress(); | 3319 inline Address GetCharsAddress(); |
| 3298 | 3320 |
| 3299 inline char* GetChars(); | 3321 inline char* GetChars(); |
| 3300 | 3322 |
| 3301 // Casting | 3323 // Casting |
| 3302 static inline SeqAsciiString* cast(Object* obj); | 3324 static inline SeqAsciiString* cast(Object* obj); |
| 3303 | 3325 |
| 3304 // Garbage collection support. This method is called by the | 3326 // Garbage collection support. This method is called by the |
| 3305 // garbage collector to compute the actual size of an AsciiString | 3327 // garbage collector to compute the actual size of an AsciiString |
| 3306 // instance. | 3328 // instance. |
| 3307 inline int SeqAsciiStringSize(Map* map); | 3329 inline int SeqAsciiStringSize(StringShape shape); |
| 3308 | 3330 |
| 3309 // Computes the size for an AsciiString instance of a given length. | 3331 // Computes the size for an AsciiString instance of a given length. |
| 3310 static int SizeFor(int length) { | 3332 static int SizeFor(int length) { |
| 3311 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize); | 3333 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize); |
| 3312 } | 3334 } |
| 3313 | 3335 |
| 3314 // Layout description. | 3336 // Layout description. |
| 3315 static const int kHeaderSize = String::kSize; | 3337 static const int kHeaderSize = String::kSize; |
| 3316 | 3338 |
| 3317 // Support for StringInputBuffer. | 3339 // Support for StringInputBuffer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3342 | 3364 |
| 3343 // For regexp code. | 3365 // For regexp code. |
| 3344 const uint16_t* SeqTwoByteStringGetData(unsigned start); | 3366 const uint16_t* SeqTwoByteStringGetData(unsigned start); |
| 3345 | 3367 |
| 3346 // Casting | 3368 // Casting |
| 3347 static inline SeqTwoByteString* cast(Object* obj); | 3369 static inline SeqTwoByteString* cast(Object* obj); |
| 3348 | 3370 |
| 3349 // Garbage collection support. This method is called by the | 3371 // Garbage collection support. This method is called by the |
| 3350 // garbage collector to compute the actual size of a TwoByteString | 3372 // garbage collector to compute the actual size of a TwoByteString |
| 3351 // instance. | 3373 // instance. |
| 3352 inline int SeqTwoByteStringSize(Map* map); | 3374 inline int SeqTwoByteStringSize(StringShape shape); |
| 3353 | 3375 |
| 3354 // Computes the size for a TwoByteString instance of a given length. | 3376 // Computes the size for a TwoByteString instance of a given length. |
| 3355 static int SizeFor(int length) { | 3377 static int SizeFor(int length) { |
| 3356 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize); | 3378 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize); |
| 3357 } | 3379 } |
| 3358 | 3380 |
| 3359 // Layout description. | 3381 // Layout description. |
| 3360 static const int kHeaderSize = String::kSize; | 3382 static const int kHeaderSize = String::kSize; |
| 3361 | 3383 |
| 3362 // Support for StringInputBuffer. | 3384 // Support for StringInputBuffer. |
| 3363 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3385 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 3364 unsigned* offset_ptr, | 3386 unsigned* offset_ptr, |
| 3365 unsigned chars); | 3387 unsigned chars); |
| 3366 | 3388 |
| 3367 private: | 3389 private: |
| 3368 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); | 3390 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); |
| 3369 }; | 3391 }; |
| 3370 | 3392 |
| 3371 | 3393 |
| 3372 // The ConsString class describes string values built by using the | 3394 // The ConsString class describes string values built by using the |
| 3373 // addition operator on strings. A ConsString is a pair where the | 3395 // addition operator on strings. A ConsString is a pair where the |
| 3374 // first and second components are pointers to other string values. | 3396 // first and second components are pointers to other string values. |
| 3375 // One or both components of a ConsString can be pointers to other | 3397 // One or both components of a ConsString can be pointers to other |
| 3376 // ConsStrings, creating a binary tree of ConsStrings where the leaves | 3398 // ConsStrings, creating a binary tree of ConsStrings where the leaves |
| 3377 // are non-ConsString string values. The string value represented by | 3399 // are non-ConsString string values. The string value represented by |
| 3378 // a ConsString can be obtained by concatenating the leaf string | 3400 // a ConsString can be obtained by concatenating the leaf string |
| 3379 // values in a left-to-right depth-first traversal of the tree. | 3401 // values in a left-to-right depth-first traversal of the tree. |
| 3380 class ConsString: public String { | 3402 class ConsString: public String { |
| 3381 public: | 3403 public: |
| 3382 // First object of the cons cell. | 3404 // First string of the cons cell. |
| 3383 inline Object* first(); | 3405 inline String* first(); |
| 3384 inline void set_first(Object* first, | 3406 // Doesn't check that the result is a string, even in debug mode. This is |
| 3407 // useful during GC where the mark bits confuse the checks. |
| 3408 inline Object* unchecked_first(); |
| 3409 inline void set_first(String* first, |
| 3385 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 3410 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 3386 | 3411 |
| 3387 // Second object of the cons cell. | 3412 // Second string of the cons cell. |
| 3388 inline Object* second(); | 3413 inline String* second(); |
| 3389 inline void set_second(Object* second, | 3414 // Doesn't check that the result is a string, even in debug mode. This is |
| 3415 // useful during GC where the mark bits confuse the checks. |
| 3416 inline Object* unchecked_second(); |
| 3417 inline void set_second(String* second, |
| 3390 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 3418 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 3391 | 3419 |
| 3392 // Dispatched behavior. | 3420 // Dispatched behavior. |
| 3393 uint16_t ConsStringGet(int index); | 3421 uint16_t ConsStringGet(int index); |
| 3394 | 3422 |
| 3395 // Casting. | 3423 // Casting. |
| 3396 static inline ConsString* cast(Object* obj); | 3424 static inline ConsString* cast(Object* obj); |
| 3397 | 3425 |
| 3398 // Garbage collection support. This method is called during garbage | 3426 // Garbage collection support. This method is called during garbage |
| 3399 // collection to iterate through the heap pointers in the body of | 3427 // collection to iterate through the heap pointers in the body of |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3421 }; | 3449 }; |
| 3422 | 3450 |
| 3423 | 3451 |
| 3424 // The SlicedString class describes string values that are slices of | 3452 // The SlicedString class describes string values that are slices of |
| 3425 // some other string. SlicedStrings consist of a reference to an | 3453 // some other string. SlicedStrings consist of a reference to an |
| 3426 // underlying heap-allocated string value, a start index, and the | 3454 // underlying heap-allocated string value, a start index, and the |
| 3427 // length field common to all strings. | 3455 // length field common to all strings. |
| 3428 class SlicedString: public String { | 3456 class SlicedString: public String { |
| 3429 public: | 3457 public: |
| 3430 // The underlying string buffer. | 3458 // The underlying string buffer. |
| 3431 inline Object* buffer(); | 3459 inline String* buffer(); |
| 3432 inline void set_buffer(Object* buffer); | 3460 inline void set_buffer(String* buffer); |
| 3433 | 3461 |
| 3434 // The start index of the slice. | 3462 // The start index of the slice. |
| 3435 inline int start(); | 3463 inline int start(); |
| 3436 inline void set_start(int start); | 3464 inline void set_start(int start); |
| 3437 | 3465 |
| 3438 // Dispatched behavior. | 3466 // Dispatched behavior. |
| 3439 uint16_t SlicedStringGet(int index); | 3467 uint16_t SlicedStringGet(int index); |
| 3440 | 3468 |
| 3441 // Flatten any ConsString hiding behind this SlicedString. | 3469 // Flatten any ConsString hiding behind this SlicedString. |
| 3442 Object* SlicedStringFlatten(); | 3470 Object* SlicedStringFlatten(); |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 } else { | 4161 } else { |
| 4134 value &= ~(1 << bit_position); | 4162 value &= ~(1 << bit_position); |
| 4135 } | 4163 } |
| 4136 return value; | 4164 return value; |
| 4137 } | 4165 } |
| 4138 }; | 4166 }; |
| 4139 | 4167 |
| 4140 } } // namespace v8::internal | 4168 } } // namespace v8::internal |
| 4141 | 4169 |
| 4142 #endif // V8_OBJECTS_H_ | 4170 #endif // V8_OBJECTS_H_ |
| OLD | NEW |