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