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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 // - ByteArray | 54 // - ByteArray |
| 55 // - FixedArray | 55 // - FixedArray |
| 56 // - DescriptorArray | 56 // - DescriptorArray |
| 57 // - HashTable | 57 // - HashTable |
| 58 // - Dictionary | 58 // - Dictionary |
| 59 // - SymbolTable | 59 // - SymbolTable |
| 60 // - Context | 60 // - Context |
| 61 // - GlobalContext | 61 // - GlobalContext |
| 62 // - String | 62 // - String |
| 63 // - SeqString | 63 // - SeqString |
| 64 // - AsciiString | 64 // - SeqAsciiString |
| 65 // - TwoByteString | 65 // - SeqTwoByteString |
| 66 // - ConsString | 66 // - ConsString |
| 67 // - SlicedString | 67 // - SlicedString |
| 68 // - ExternalString | 68 // - ExternalString |
| 69 // - ExternalAsciiString | 69 // - ExternalAsciiString |
| 70 // - ExternalTwoByteString | 70 // - ExternalTwoByteString |
| 71 // - HeapNumber | 71 // - HeapNumber |
| 72 // - Code | 72 // - Code |
| 73 // - Map | 73 // - Map |
| 74 // - Oddball | 74 // - Oddball |
| 75 // - Proxy | 75 // - Proxy |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 V(JS_BUILTINS_OBJECT_TYPE) \ | 265 V(JS_BUILTINS_OBJECT_TYPE) \ |
| 266 V(JS_ARRAY_TYPE) \ | 266 V(JS_ARRAY_TYPE) \ |
| 267 V(JS_REGEXP_TYPE) \ | 267 V(JS_REGEXP_TYPE) \ |
| 268 \ | 268 \ |
| 269 V(JS_FUNCTION_TYPE) \ | 269 V(JS_FUNCTION_TYPE) \ |
| 270 | 270 |
| 271 | 271 |
| 272 // Since string types are not consecutive, this macro is used to | 272 // Since string types are not consecutive, this macro is used to |
| 273 // iterate over them. | 273 // iterate over them. |
| 274 #define STRING_TYPE_LIST(V) \ | 274 #define STRING_TYPE_LIST(V) \ |
| 275 V(SHORT_SYMBOL_TYPE, TwoByteString::kHeaderSize, short_symbol) \ | 275 V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, short_symbol) \ |
| 276 V(MEDIUM_SYMBOL_TYPE, TwoByteString::kHeaderSize, medium_symbol) \ | 276 V(MEDIUM_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, medium_symbol) \ |
| 277 V(LONG_SYMBOL_TYPE, TwoByteString::kHeaderSize, long_symbol) \ | 277 V(LONG_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, long_symbol) \ |
| 278 V(SHORT_ASCII_SYMBOL_TYPE, AsciiString::kHeaderSize, short_ascii_symbol) \ | 278 V(SHORT_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, short_ascii_symbol) \ |
| 279 V(MEDIUM_ASCII_SYMBOL_TYPE, AsciiString::kHeaderSize, medium_ascii_symbol) \ | 279 V(MEDIUM_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_symbol)\ |
| 280 V(LONG_ASCII_SYMBOL_TYPE, AsciiString::kHeaderSize, long_ascii_symbol) \ | 280 V(LONG_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, long_ascii_symbol) \ |
| 281 V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol) \ | 281 V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol) \ |
| 282 V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol) \ | 282 V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol) \ |
| 283 V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol) \ | 283 V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol) \ |
| 284 V(SHORT_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, short_cons_ascii_symbol) \ | 284 V(SHORT_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, short_cons_ascii_symbol) \ |
| 285 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, medium_cons_ascii_symbol)\ | 285 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, medium_cons_ascii_symbol)\ |
| 286 V(LONG_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, long_cons_ascii_symbol) \ | 286 V(LONG_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, long_cons_ascii_symbol) \ |
| 287 V(SHORT_SLICED_SYMBOL_TYPE, SlicedString::kSize, short_sliced_symbol) \ | 287 V(SHORT_SLICED_SYMBOL_TYPE, SlicedString::kSize, short_sliced_symbol) \ |
| 288 V(MEDIUM_SLICED_SYMBOL_TYPE, SlicedString::kSize, medium_sliced_symbol) \ | 288 V(MEDIUM_SLICED_SYMBOL_TYPE, SlicedString::kSize, medium_sliced_symbol) \ |
| 289 V(LONG_SLICED_SYMBOL_TYPE, SlicedString::kSize, long_sliced_symbol) \ | 289 V(LONG_SLICED_SYMBOL_TYPE, SlicedString::kSize, long_sliced_symbol) \ |
| 290 V(SHORT_SLICED_ASCII_SYMBOL_TYPE, \ | 290 V(SHORT_SLICED_ASCII_SYMBOL_TYPE, \ |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 307 long_external_symbol) \ | 307 long_external_symbol) \ |
| 308 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \ | 308 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \ |
| 309 ExternalAsciiString::kSize, \ | 309 ExternalAsciiString::kSize, \ |
| 310 short_external_ascii_symbol) \ | 310 short_external_ascii_symbol) \ |
| 311 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE, \ | 311 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE, \ |
| 312 ExternalAsciiString::kSize, \ | 312 ExternalAsciiString::kSize, \ |
| 313 medium_external_ascii_symbol) \ | 313 medium_external_ascii_symbol) \ |
| 314 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \ | 314 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \ |
| 315 ExternalAsciiString::kSize, \ | 315 ExternalAsciiString::kSize, \ |
| 316 long_external_ascii_symbol) \ | 316 long_external_ascii_symbol) \ |
| 317 V(SHORT_STRING_TYPE, TwoByteString::kHeaderSize, short_string) \ | 317 V(SHORT_STRING_TYPE, SeqTwoByteString::kHeaderSize, short_string) \ |
| 318 V(MEDIUM_STRING_TYPE, TwoByteString::kHeaderSize, medium_string) \ | 318 V(MEDIUM_STRING_TYPE, SeqTwoByteString::kHeaderSize, medium_string) \ |
| 319 V(LONG_STRING_TYPE, TwoByteString::kHeaderSize, long_string) \ | 319 V(LONG_STRING_TYPE, SeqTwoByteString::kHeaderSize, long_string) \ |
| 320 V(SHORT_ASCII_STRING_TYPE, AsciiString::kHeaderSize, short_ascii_string) \ | 320 V(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, short_ascii_string) \ |
| 321 V(MEDIUM_ASCII_STRING_TYPE, AsciiString::kHeaderSize, medium_ascii_string) \ | 321 V(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_string)\ |
| 322 V(LONG_ASCII_STRING_TYPE, AsciiString::kHeaderSize, long_ascii_string) \ | 322 V(LONG_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, long_ascii_string) \ |
| 323 V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string) \ | 323 V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string) \ |
| 324 V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string) \ | 324 V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string) \ |
| 325 V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string) \ | 325 V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string) \ |
| 326 V(SHORT_CONS_ASCII_STRING_TYPE, ConsString::kSize, short_cons_ascii_string) \ | 326 V(SHORT_CONS_ASCII_STRING_TYPE, ConsString::kSize, short_cons_ascii_string) \ |
| 327 V(MEDIUM_CONS_ASCII_STRING_TYPE, ConsString::kSize, medium_cons_ascii_string)\ | 327 V(MEDIUM_CONS_ASCII_STRING_TYPE, ConsString::kSize, medium_cons_ascii_string)\ |
| 328 V(LONG_CONS_ASCII_STRING_TYPE, ConsString::kSize, long_cons_ascii_string) \ | 328 V(LONG_CONS_ASCII_STRING_TYPE, ConsString::kSize, long_cons_ascii_string) \ |
| 329 V(SHORT_SLICED_STRING_TYPE, SlicedString::kSize, short_sliced_string) \ | 329 V(SHORT_SLICED_STRING_TYPE, SlicedString::kSize, short_sliced_string) \ |
| 330 V(MEDIUM_SLICED_STRING_TYPE, SlicedString::kSize, medium_sliced_string) \ | 330 V(MEDIUM_SLICED_STRING_TYPE, SlicedString::kSize, medium_sliced_string) \ |
| 331 V(LONG_SLICED_STRING_TYPE, SlicedString::kSize, long_sliced_string) \ | 331 V(LONG_SLICED_STRING_TYPE, SlicedString::kSize, long_sliced_string) \ |
| 332 V(SHORT_SLICED_ASCII_STRING_TYPE, \ | 332 V(SHORT_SLICED_ASCII_STRING_TYPE, \ |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 // Since Smi and Failure are subclasses of Object no | 577 // Since Smi and Failure are subclasses of Object no |
| 578 // data members can be present in Object. | 578 // data members can be present in Object. |
| 579 class Object BASE_EMBEDDED { | 579 class Object BASE_EMBEDDED { |
| 580 public: | 580 public: |
| 581 // Type testing. | 581 // Type testing. |
| 582 inline bool IsSmi(); | 582 inline bool IsSmi(); |
| 583 inline bool IsHeapObject(); | 583 inline bool IsHeapObject(); |
| 584 inline bool IsHeapNumber(); | 584 inline bool IsHeapNumber(); |
| 585 inline bool IsString(); | 585 inline bool IsString(); |
| 586 inline bool IsSeqString(); | 586 inline bool IsSeqString(); |
| 587 inline bool IsAsciiString(); | 587 inline bool IsAsciiStringRepresentation(); |
| 588 inline bool IsTwoByteString(); | 588 inline bool IsTwoByteStringRepresentation(); |
| 589 inline bool IsSeqAsciiString(); | |
| 590 inline bool IsSeqTwoByteString(); | |
| 589 inline bool IsConsString(); | 591 inline bool IsConsString(); |
| 590 inline bool IsSlicedString(); | 592 inline bool IsSlicedString(); |
| 591 inline bool IsExternalString(); | 593 inline bool IsExternalString(); |
| 592 inline bool IsExternalAsciiString(); | 594 inline bool IsExternalAsciiString(); |
| 593 inline bool IsExternalTwoByteString(); | 595 inline bool IsExternalTwoByteString(); |
| 594 inline bool IsShortString(); | 596 inline bool IsShortString(); |
| 595 inline bool IsMediumString(); | 597 inline bool IsMediumString(); |
| 596 inline bool IsLongString(); | 598 inline bool IsLongString(); |
| 597 inline bool IsSymbol(); | 599 inline bool IsSymbol(); |
| 598 inline bool IsNumber(); | 600 inline bool IsNumber(); |
| (...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2921 // string. This is a no-op unless the string is a ConsString or a | 2923 // string. This is a no-op unless the string is a ConsString or a |
| 2922 // SlicedString. Flatten mutates the ConsString and might return a | 2924 // SlicedString. Flatten mutates the ConsString and might return a |
| 2923 // failure. | 2925 // failure. |
| 2924 Object* Flatten(); | 2926 Object* Flatten(); |
| 2925 // Try to flatten the string. Do not allow handling of allocation | 2927 // Try to flatten the string. Do not allow handling of allocation |
| 2926 // failures. After calling TryFlatten, the string could still be a | 2928 // failures. After calling TryFlatten, the string could still be a |
| 2927 // ConsString. | 2929 // ConsString. |
| 2928 inline void TryFlatten(); | 2930 inline void TryFlatten(); |
| 2929 | 2931 |
| 2930 // Is this string an ascii string. | 2932 // Is this string an ascii string. |
| 2931 inline bool IsAscii(); | 2933 inline bool IsAsciiRepresentation(); |
| 2932 | 2934 |
| 2933 // Fast testing routines that assume the receiver is a string and | 2935 // Fast testing routines that assume the receiver is a string and |
| 2934 // just check whether it is a certain kind of string. | 2936 // just check whether it is a certain kind of string. |
| 2935 inline bool StringIsSlicedString(); | 2937 inline bool StringIsSlicedString(); |
| 2936 inline bool StringIsConsString(); | 2938 inline bool StringIsConsString(); |
| 2937 | 2939 |
| 2940 Vector<const char> ToAsciiVector(); | |
| 2941 Vector<const uc16> ToUC16Vector(); | |
| 2942 | |
| 2938 // Mark the string as an undetectable object. It only applies to | 2943 // Mark the string as an undetectable object. It only applies to |
| 2939 // ascii and two byte string types. | 2944 // ascii and two byte string types. |
| 2940 bool MarkAsUndetectable(); | 2945 bool MarkAsUndetectable(); |
| 2941 | 2946 |
| 2942 // Slice the string and return a substring. | 2947 // Slice the string and return a substring. |
| 2943 Object* Slice(int from, int to); | 2948 Object* Slice(int from, int to); |
| 2944 | 2949 |
| 2945 // String equality operations. | 2950 // String equality operations. |
| 2946 inline bool Equals(String* other); | 2951 inline bool Equals(String* other); |
| 2947 bool IsEqualTo(Vector<const char> str); | 2952 bool IsEqualTo(Vector<const char> str); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2998 | 3003 |
| 2999 // Get the size tag. | 3004 // Get the size tag. |
| 3000 inline uint32_t size_tag(); | 3005 inline uint32_t size_tag(); |
| 3001 static inline uint32_t map_size_tag(Map* map); | 3006 static inline uint32_t map_size_tag(Map* map); |
| 3002 | 3007 |
| 3003 // True if the string is a symbol. | 3008 // True if the string is a symbol. |
| 3004 inline bool is_symbol(); | 3009 inline bool is_symbol(); |
| 3005 static inline bool is_symbol_map(Map* map); | 3010 static inline bool is_symbol_map(Map* map); |
| 3006 | 3011 |
| 3007 // True if the string is ASCII. | 3012 // True if the string is ASCII. |
| 3008 inline bool is_ascii(); | 3013 inline bool is_ascii_representation(); |
| 3009 static inline bool is_ascii_map(Map* map); | 3014 static inline bool is_ascii_representation_map(Map* map); |
| 3010 | 3015 |
| 3011 // Get the representation tag. | 3016 // Get the representation tag. |
| 3012 inline StringRepresentationTag representation_tag(); | 3017 inline StringRepresentationTag representation_tag(); |
| 3013 static inline StringRepresentationTag map_representation_tag(Map* map); | 3018 static inline StringRepresentationTag map_representation_tag(Map* map); |
| 3014 | 3019 |
| 3015 // For use during stack traces. Performs rudimentary sanity check. | 3020 // For use during stack traces. Performs rudimentary sanity check. |
| 3016 bool LooksValid(); | 3021 bool LooksValid(); |
| 3017 | 3022 |
| 3018 // Dispatched behavior. | 3023 // Dispatched behavior. |
| 3019 void StringShortPrint(StringStream* accumulator); | 3024 void StringShortPrint(StringStream* accumulator); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3138 // For regexp code. | 3143 // For regexp code. |
| 3139 uint16_t* SeqStringGetTwoByteAddress(); | 3144 uint16_t* SeqStringGetTwoByteAddress(); |
| 3140 | 3145 |
| 3141 private: | 3146 private: |
| 3142 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); | 3147 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); |
| 3143 }; | 3148 }; |
| 3144 | 3149 |
| 3145 | 3150 |
| 3146 // The AsciiString class captures sequential ascii string objects. | 3151 // The AsciiString class captures sequential ascii string objects. |
| 3147 // Each character in the AsciiString is an ascii character. | 3152 // Each character in the AsciiString is an ascii character. |
| 3148 class AsciiString: public SeqString { | 3153 class SeqAsciiString: public SeqString { |
| 3149 public: | 3154 public: |
| 3150 // Dispatched behavior. | 3155 // Dispatched behavior. |
| 3151 inline uint16_t AsciiStringGet(int index); | 3156 inline uint16_t AsciiStringGet(int index); |
| 3152 inline void AsciiStringSet(int index, uint16_t value); | 3157 inline void AsciiStringSet(int index, uint16_t value); |
| 3153 | 3158 |
| 3154 // Get the address of the characters in this string. | 3159 // Get the address of the characters in this string. |
| 3155 inline Address GetCharsAddress(); | 3160 inline Address GetCharsAddress(); |
| 3156 | 3161 |
| 3157 // Casting | 3162 // Casting |
| 3158 static inline AsciiString* cast(Object* obj); | 3163 static inline SeqAsciiString* cast(Object* obj); |
| 3159 | 3164 |
| 3160 // Garbage collection support. This method is called by the | 3165 // Garbage collection support. This method is called by the |
| 3161 // garbage collector to compute the actual size of an AsciiString | 3166 // garbage collector to compute the actual size of an AsciiString |
| 3162 // instance. | 3167 // instance. |
| 3163 inline int AsciiStringSize(Map* map); | 3168 inline int AsciiStringSize(Map* map); |
|
Erik Corry
2008/10/08 12:59:53
Needs renaming
| |
| 3164 | 3169 |
| 3165 // Computes the size for an AsciiString instance of a given length. | 3170 // Computes the size for an AsciiString instance of a given length. |
| 3166 static int SizeFor(int length) { | 3171 static int SizeFor(int length) { |
| 3167 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize); | 3172 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize); |
| 3168 } | 3173 } |
| 3169 | 3174 |
| 3170 // Layout description. | 3175 // Layout description. |
| 3171 static const int kHeaderSize = String::kSize; | 3176 static const int kHeaderSize = String::kSize; |
| 3172 | 3177 |
| 3173 // Support for StringInputBuffer. | 3178 // Support for StringInputBuffer. |
| 3174 inline void AsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3179 inline void AsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
|
Erik Corry
2008/10/08 12:59:53
Ditto
| |
| 3175 unsigned* offset, | 3180 unsigned* offset, |
| 3176 unsigned chars); | 3181 unsigned chars); |
| 3177 inline const unibrow::byte* AsciiStringReadBlock(unsigned* remaining, | 3182 inline const unibrow::byte* AsciiStringReadBlock(unsigned* remaining, |
|
Erik Corry
2008/10/08 12:59:53
Ditto
| |
| 3178 unsigned* offset, | 3183 unsigned* offset, |
| 3179 unsigned chars); | 3184 unsigned chars); |
| 3180 | 3185 |
| 3181 private: | 3186 private: |
| 3182 DISALLOW_IMPLICIT_CONSTRUCTORS(AsciiString); | 3187 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqAsciiString); |
| 3183 }; | 3188 }; |
| 3184 | 3189 |
| 3185 | 3190 |
| 3186 // The TwoByteString class captures sequential unicode string objects. | 3191 // The TwoByteString class captures sequential unicode string objects. |
| 3187 // Each character in the TwoByteString is a two-byte uint16_t. | 3192 // Each character in the TwoByteString is a two-byte uint16_t. |
| 3188 class TwoByteString: public SeqString { | 3193 class SeqTwoByteString: public SeqString { |
| 3189 public: | 3194 public: |
| 3190 // Dispatched behavior. | 3195 // Dispatched behavior. |
| 3191 inline uint16_t TwoByteStringGet(int index); | 3196 inline uint16_t TwoByteStringGet(int index); |
| 3192 inline void TwoByteStringSet(int index, uint16_t value); | 3197 inline void TwoByteStringSet(int index, uint16_t value); |
| 3193 | 3198 |
| 3194 // Get the address of the characters in this string. | 3199 // Get the address of the characters in this string. |
| 3195 inline Address GetCharsAddress(); | 3200 inline Address GetCharsAddress(); |
| 3196 | 3201 |
| 3197 // For regexp code. | 3202 // For regexp code. |
| 3198 const uint16_t* TwoByteStringGetData(unsigned start); | 3203 const uint16_t* TwoByteStringGetData(unsigned start); |
|
Erik Corry
2008/10/08 12:59:53
Ditto
| |
| 3199 | 3204 |
| 3200 // Casting | 3205 // Casting |
| 3201 static inline TwoByteString* cast(Object* obj); | 3206 static inline SeqTwoByteString* cast(Object* obj); |
| 3202 | 3207 |
| 3203 // Garbage collection support. This method is called by the | 3208 // Garbage collection support. This method is called by the |
| 3204 // garbage collector to compute the actual size of a TwoByteString | 3209 // garbage collector to compute the actual size of a TwoByteString |
| 3205 // instance. | 3210 // instance. |
| 3206 inline int TwoByteStringSize(Map* map); | 3211 inline int TwoByteStringSize(Map* map); |
|
Erik Corry
2008/10/08 12:59:53
Ditto
| |
| 3207 | 3212 |
| 3208 // Computes the size for a TwoByteString instance of a given length. | 3213 // Computes the size for a TwoByteString instance of a given length. |
| 3209 static int SizeFor(int length) { | 3214 static int SizeFor(int length) { |
| 3210 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize); | 3215 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize); |
| 3211 } | 3216 } |
| 3212 | 3217 |
| 3213 // Layout description. | 3218 // Layout description. |
| 3214 static const int kHeaderSize = String::kSize; | 3219 static const int kHeaderSize = String::kSize; |
| 3215 | 3220 |
| 3216 // Support for StringInputBuffer. | 3221 // Support for StringInputBuffer. |
| 3217 inline void TwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3222 inline void TwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
|
Erik Corry
2008/10/08 12:59:53
Ditto
| |
| 3218 unsigned* offset_ptr, | 3223 unsigned* offset_ptr, |
| 3219 unsigned chars); | 3224 unsigned chars); |
| 3220 | 3225 |
| 3221 private: | 3226 private: |
| 3222 DISALLOW_IMPLICIT_CONSTRUCTORS(TwoByteString); | 3227 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); |
| 3223 }; | 3228 }; |
| 3224 | 3229 |
| 3225 | 3230 |
| 3226 // The ConsString class describes string values built by using the | 3231 // The ConsString class describes string values built by using the |
| 3227 // addition operator on strings. A ConsString is a pair where the | 3232 // addition operator on strings. A ConsString is a pair where the |
| 3228 // first and second components are pointers to other string values. | 3233 // first and second components are pointers to other string values. |
| 3229 // One or both components of a ConsString can be pointers to other | 3234 // One or both components of a ConsString can be pointers to other |
| 3230 // ConsStrings, creating a binary tree of ConsStrings where the leaves | 3235 // ConsStrings, creating a binary tree of ConsStrings where the leaves |
| 3231 // are non-ConsString string values. The string value represented by | 3236 // are non-ConsString string values. The string value represented by |
| 3232 // a ConsString can be obtained by concatenating the leaf string | 3237 // a ConsString can be obtained by concatenating the leaf string |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3424 : public unibrow::InputBuffer<String, String**, 256> { | 3429 : public unibrow::InputBuffer<String, String**, 256> { |
| 3425 public: | 3430 public: |
| 3426 virtual void Seek(unsigned pos); | 3431 virtual void Seek(unsigned pos); |
| 3427 inline SafeStringInputBuffer() | 3432 inline SafeStringInputBuffer() |
| 3428 : unibrow::InputBuffer<String, String**, 256>() {} | 3433 : unibrow::InputBuffer<String, String**, 256>() {} |
| 3429 inline SafeStringInputBuffer(String** backing) | 3434 inline SafeStringInputBuffer(String** backing) |
| 3430 : unibrow::InputBuffer<String, String**, 256>(backing) {} | 3435 : unibrow::InputBuffer<String, String**, 256>(backing) {} |
| 3431 }; | 3436 }; |
| 3432 | 3437 |
| 3433 | 3438 |
| 3439 template <typename T> | |
| 3440 class VectorIterator { | |
| 3441 public: | |
| 3442 VectorIterator(T* d, int l) : data_(Vector<T>(d, l)), index_(0) { } | |
| 3443 explicit VectorIterator(Vector<T> data) : data_(data), index_(0) { } | |
| 3444 T GetNext() { return data_[index_++]; } | |
| 3445 bool has_more() { return index_ < data_.length(); } | |
| 3446 private: | |
| 3447 Vector<T> data_; | |
| 3448 int index_; | |
| 3449 }; | |
| 3450 | |
| 3451 | |
| 3434 // The Oddball describes objects null, undefined, true, and false. | 3452 // The Oddball describes objects null, undefined, true, and false. |
| 3435 class Oddball: public HeapObject { | 3453 class Oddball: public HeapObject { |
| 3436 public: | 3454 public: |
| 3437 // [to_string]: Cached to_string computed at startup. | 3455 // [to_string]: Cached to_string computed at startup. |
| 3438 DECL_ACCESSORS(to_string, String) | 3456 DECL_ACCESSORS(to_string, String) |
| 3439 | 3457 |
| 3440 // [to_number]: Cached to_number computed at startup. | 3458 // [to_number]: Cached to_number computed at startup. |
| 3441 DECL_ACCESSORS(to_number, Object) | 3459 DECL_ACCESSORS(to_number, Object) |
| 3442 | 3460 |
| 3443 // Casting. | 3461 // Casting. |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3972 } else { | 3990 } else { |
| 3973 value &= ~(1 << bit_position); | 3991 value &= ~(1 << bit_position); |
| 3974 } | 3992 } |
| 3975 return value; | 3993 return value; |
| 3976 } | 3994 } |
| 3977 }; | 3995 }; |
| 3978 | 3996 |
| 3979 } } // namespace v8::internal | 3997 } } // namespace v8::internal |
| 3980 | 3998 |
| 3981 #endif // V8_OBJECTS_H_ | 3999 #endif // V8_OBJECTS_H_ |
| OLD | NEW |