Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 // - CompilationCacheTable | 79 // - CompilationCacheTable |
| 80 // - CodeCacheHashTable | 80 // - CodeCacheHashTable |
| 81 // - MapCache | 81 // - MapCache |
| 82 // - Context | 82 // - Context |
| 83 // - JSFunctionResultCache | 83 // - JSFunctionResultCache |
| 84 // - SerializedScopeInfo | 84 // - SerializedScopeInfo |
| 85 // - String | 85 // - String |
| 86 // - SeqString | 86 // - SeqString |
| 87 // - SeqAsciiString | 87 // - SeqAsciiString |
| 88 // - SeqTwoByteString | 88 // - SeqTwoByteString |
| 89 // - SlicedString | |
| 89 // - ConsString | 90 // - ConsString |
| 90 // - ExternalString | 91 // - ExternalString |
| 91 // - ExternalAsciiString | 92 // - ExternalAsciiString |
| 92 // - ExternalTwoByteString | 93 // - ExternalTwoByteString |
| 93 // - HeapNumber | 94 // - HeapNumber |
| 94 // - Code | 95 // - Code |
| 95 // - Map | 96 // - Map |
| 96 // - Oddball | 97 // - Oddball |
| 97 // - Foreign | 98 // - Foreign |
| 98 // - SharedFunctionInfo | 99 // - SharedFunctionInfo |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 V(ASCII_SYMBOL_TYPE) \ | 274 V(ASCII_SYMBOL_TYPE) \ |
| 274 V(CONS_SYMBOL_TYPE) \ | 275 V(CONS_SYMBOL_TYPE) \ |
| 275 V(CONS_ASCII_SYMBOL_TYPE) \ | 276 V(CONS_ASCII_SYMBOL_TYPE) \ |
| 276 V(EXTERNAL_SYMBOL_TYPE) \ | 277 V(EXTERNAL_SYMBOL_TYPE) \ |
| 277 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ | 278 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ |
| 278 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ | 279 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ |
| 279 V(STRING_TYPE) \ | 280 V(STRING_TYPE) \ |
| 280 V(ASCII_STRING_TYPE) \ | 281 V(ASCII_STRING_TYPE) \ |
| 281 V(CONS_STRING_TYPE) \ | 282 V(CONS_STRING_TYPE) \ |
| 282 V(CONS_ASCII_STRING_TYPE) \ | 283 V(CONS_ASCII_STRING_TYPE) \ |
| 284 V(SLICED_STRING_TYPE) \ | |
| 283 V(EXTERNAL_STRING_TYPE) \ | 285 V(EXTERNAL_STRING_TYPE) \ |
| 284 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ | 286 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ |
| 285 V(EXTERNAL_ASCII_STRING_TYPE) \ | 287 V(EXTERNAL_ASCII_STRING_TYPE) \ |
| 286 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 288 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
| 287 \ | 289 \ |
| 288 V(MAP_TYPE) \ | 290 V(MAP_TYPE) \ |
| 289 V(CODE_TYPE) \ | 291 V(CODE_TYPE) \ |
| 290 V(ODDBALL_TYPE) \ | 292 V(ODDBALL_TYPE) \ |
| 291 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 293 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
| 292 \ | 294 \ |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 ascii_string, \ | 391 ascii_string, \ |
| 390 AsciiString) \ | 392 AsciiString) \ |
| 391 V(CONS_STRING_TYPE, \ | 393 V(CONS_STRING_TYPE, \ |
| 392 ConsString::kSize, \ | 394 ConsString::kSize, \ |
| 393 cons_string, \ | 395 cons_string, \ |
| 394 ConsString) \ | 396 ConsString) \ |
| 395 V(CONS_ASCII_STRING_TYPE, \ | 397 V(CONS_ASCII_STRING_TYPE, \ |
| 396 ConsString::kSize, \ | 398 ConsString::kSize, \ |
| 397 cons_ascii_string, \ | 399 cons_ascii_string, \ |
| 398 ConsAsciiString) \ | 400 ConsAsciiString) \ |
| 401 V(SLICED_STRING_TYPE, \ | |
| 402 SlicedString::kSize, \ | |
| 403 sliced_string, \ | |
| 404 SlicedString) \ | |
| 405 V(SLICED_ASCII_STRING_TYPE, \ | |
| 406 SlicedString::kSize, \ | |
| 407 sliced_ascii_string, \ | |
| 408 SlicedAsciiString) \ | |
| 399 V(EXTERNAL_STRING_TYPE, \ | 409 V(EXTERNAL_STRING_TYPE, \ |
| 400 ExternalTwoByteString::kSize, \ | 410 ExternalTwoByteString::kSize, \ |
| 401 external_string, \ | 411 external_string, \ |
| 402 ExternalString) \ | 412 ExternalString) \ |
| 403 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ | 413 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ |
| 404 ExternalTwoByteString::kSize, \ | 414 ExternalTwoByteString::kSize, \ |
| 405 external_string_with_ascii_data, \ | 415 external_string_with_ascii_data, \ |
| 406 ExternalStringWithAsciiData) \ | 416 ExternalStringWithAsciiData) \ |
| 407 V(EXTERNAL_ASCII_STRING_TYPE, \ | 417 V(EXTERNAL_ASCII_STRING_TYPE, \ |
| 408 ExternalAsciiString::kSize, \ | 418 ExternalAsciiString::kSize, \ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 const uint32_t kStringEncodingMask = 0x4; | 472 const uint32_t kStringEncodingMask = 0x4; |
| 463 const uint32_t kTwoByteStringTag = 0x0; | 473 const uint32_t kTwoByteStringTag = 0x0; |
| 464 const uint32_t kAsciiStringTag = 0x4; | 474 const uint32_t kAsciiStringTag = 0x4; |
| 465 | 475 |
| 466 // If bit 7 is clear, the low-order 2 bits indicate the representation | 476 // If bit 7 is clear, the low-order 2 bits indicate the representation |
| 467 // of the string. | 477 // of the string. |
| 468 const uint32_t kStringRepresentationMask = 0x03; | 478 const uint32_t kStringRepresentationMask = 0x03; |
| 469 enum StringRepresentationTag { | 479 enum StringRepresentationTag { |
| 470 kSeqStringTag = 0x0, | 480 kSeqStringTag = 0x0, |
| 471 kConsStringTag = 0x1, | 481 kConsStringTag = 0x1, |
| 472 kExternalStringTag = 0x2 | 482 kExternalStringTag = 0x2, |
| 483 kSlicedStringTag = 0x3 | |
| 473 }; | 484 }; |
| 474 const uint32_t kIsConsStringMask = 0x1; | 485 const uint32_t kIsIndirectStringMask = 0x1; |
| 486 const uint32_t kIsIndirectStringTag = 0x1; | |
| 487 STATIC_ASSERT( | |
| 488 (kConsStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); | |
| 489 STATIC_ASSERT( | |
| 490 (kSlicedStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); | |
| 475 | 491 |
| 476 // If bit 7 is clear, then bit 3 indicates whether this two-byte | 492 // If bit 7 is clear, then bit 3 indicates whether this two-byte |
| 477 // string actually contains ascii data. | 493 // string actually contains ascii data. |
| 478 const uint32_t kAsciiDataHintMask = 0x08; | 494 const uint32_t kAsciiDataHintMask = 0x08; |
| 479 const uint32_t kAsciiDataHintTag = 0x08; | 495 const uint32_t kAsciiDataHintTag = 0x08; |
| 480 | 496 |
| 481 | 497 |
| 482 // A ConsString with an empty string as the right side is a candidate | 498 // A ConsString with an empty string as the right side is a candidate |
| 483 // for being shortcut by the garbage collector unless it is a | 499 // for being shortcut by the garbage collector unless it is a |
| 484 // symbol. It's not common to have non-flat symbols, so we do not | 500 // symbol. It's not common to have non-flat symbols, so we do not |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 499 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, | 515 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, |
| 500 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, | 516 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, |
| 501 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = | 517 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
| 502 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, | 518 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, |
| 503 EXTERNAL_ASCII_SYMBOL_TYPE = | 519 EXTERNAL_ASCII_SYMBOL_TYPE = |
| 504 kAsciiStringTag | kSymbolTag | kExternalStringTag, | 520 kAsciiStringTag | kSymbolTag | kExternalStringTag, |
| 505 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, | 521 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, |
| 506 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, | 522 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, |
| 507 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, | 523 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
| 508 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, | 524 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, |
| 525 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, | |
| 526 SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag, | |
| 509 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, | 527 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
| 510 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = | 528 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
| 511 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, | 529 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, |
| 512 // LAST_STRING_TYPE | 530 // LAST_STRING_TYPE |
| 513 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, | 531 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, |
| 514 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, | 532 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, |
| 515 | 533 |
| 516 // Objects allocated in their own spaces (never in new space). | 534 // Objects allocated in their own spaces (never in new space). |
| 517 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 535 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
| 518 CODE_TYPE, | 536 CODE_TYPE, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 V(HeapObject) \ | 720 V(HeapObject) \ |
| 703 V(Number) \ | 721 V(Number) \ |
| 704 | 722 |
| 705 #define HEAP_OBJECT_TYPE_LIST(V) \ | 723 #define HEAP_OBJECT_TYPE_LIST(V) \ |
| 706 V(HeapNumber) \ | 724 V(HeapNumber) \ |
| 707 V(String) \ | 725 V(String) \ |
| 708 V(Symbol) \ | 726 V(Symbol) \ |
| 709 V(SeqString) \ | 727 V(SeqString) \ |
| 710 V(ExternalString) \ | 728 V(ExternalString) \ |
| 711 V(ConsString) \ | 729 V(ConsString) \ |
| 730 V(SlicedString) \ | |
| 712 V(ExternalTwoByteString) \ | 731 V(ExternalTwoByteString) \ |
| 713 V(ExternalAsciiString) \ | 732 V(ExternalAsciiString) \ |
| 714 V(SeqTwoByteString) \ | 733 V(SeqTwoByteString) \ |
| 715 V(SeqAsciiString) \ | 734 V(SeqAsciiString) \ |
| 716 \ | 735 \ |
| 717 V(ExternalArray) \ | 736 V(ExternalArray) \ |
| 718 V(ExternalByteArray) \ | 737 V(ExternalByteArray) \ |
| 719 V(ExternalUnsignedByteArray) \ | 738 V(ExternalUnsignedByteArray) \ |
| 720 V(ExternalShortArray) \ | 739 V(ExternalShortArray) \ |
| 721 V(ExternalUnsignedShortArray) \ | 740 V(ExternalUnsignedShortArray) \ |
| (...skipping 4980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5702 // prone and so we no longer put StringShapes in variables unless there is a | 5721 // prone and so we no longer put StringShapes in variables unless there is a |
| 5703 // concrete performance benefit at that particular point in the code. | 5722 // concrete performance benefit at that particular point in the code. |
| 5704 class StringShape BASE_EMBEDDED { | 5723 class StringShape BASE_EMBEDDED { |
| 5705 public: | 5724 public: |
| 5706 inline explicit StringShape(String* s); | 5725 inline explicit StringShape(String* s); |
| 5707 inline explicit StringShape(Map* s); | 5726 inline explicit StringShape(Map* s); |
| 5708 inline explicit StringShape(InstanceType t); | 5727 inline explicit StringShape(InstanceType t); |
| 5709 inline bool IsSequential(); | 5728 inline bool IsSequential(); |
| 5710 inline bool IsExternal(); | 5729 inline bool IsExternal(); |
| 5711 inline bool IsCons(); | 5730 inline bool IsCons(); |
| 5731 inline bool IsSliced(); | |
| 5732 inline bool IsIndirect(); | |
| 5712 inline bool IsExternalAscii(); | 5733 inline bool IsExternalAscii(); |
| 5713 inline bool IsExternalTwoByte(); | 5734 inline bool IsExternalTwoByte(); |
| 5714 inline bool IsSequentialAscii(); | 5735 inline bool IsSequentialAscii(); |
| 5715 inline bool IsSequentialTwoByte(); | 5736 inline bool IsSequentialTwoByte(); |
| 5716 inline bool IsSymbol(); | 5737 inline bool IsSymbol(); |
| 5717 inline StringRepresentationTag representation_tag(); | 5738 inline StringRepresentationTag representation_tag(); |
| 5718 inline uint32_t full_representation_tag(); | 5739 inline uint32_t full_representation_tag(); |
| 5719 inline uint32_t size_tag(); | 5740 inline uint32_t size_tag(); |
| 5720 #ifdef DEBUG | 5741 #ifdef DEBUG |
| 5721 inline uint32_t type() { return type_; } | 5742 inline uint32_t type() { return type_; } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5786 // collector (see IsShortcutCandidate). | 5807 // collector (see IsShortcutCandidate). |
| 5787 // | 5808 // |
| 5788 // Use FlattenString from Handles.cc to flatten even in case an | 5809 // Use FlattenString from Handles.cc to flatten even in case an |
| 5789 // allocation failure happens. | 5810 // allocation failure happens. |
| 5790 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED); | 5811 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED); |
| 5791 | 5812 |
| 5792 // Convenience function. Has exactly the same behavior as | 5813 // Convenience function. Has exactly the same behavior as |
| 5793 // TryFlatten(), except in the case of failure returns the original | 5814 // TryFlatten(), except in the case of failure returns the original |
| 5794 // string. | 5815 // string. |
| 5795 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); | 5816 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); |
| 5796 | 5817 |
|
Vitaly Repeshko
2011/08/17 19:20:23
nit: Remove one blank line.
| |
| 5818 | |
| 5819 // Returns the parent of a sliced string or first part of a cons string. | |
| 5820 inline String* GetIndirect(); | |
|
Vitaly Repeshko
2011/08/17 19:20:23
GetUnderlying? GetIndirect sounds as if it should
| |
| 5821 | |
| 5797 Vector<const char> ToAsciiVector(); | 5822 Vector<const char> ToAsciiVector(); |
| 5798 Vector<const uc16> ToUC16Vector(); | 5823 Vector<const uc16> ToUC16Vector(); |
| 5799 | 5824 |
| 5800 // Mark the string as an undetectable object. It only applies to | 5825 // Mark the string as an undetectable object. It only applies to |
| 5801 // ascii and two byte string types. | 5826 // ascii and two byte string types. |
| 5802 bool MarkAsUndetectable(); | 5827 bool MarkAsUndetectable(); |
| 5803 | 5828 |
| 5804 // Return a substring. | 5829 // Return a substring. |
| 5805 MUST_USE_RESULT MaybeObject* SubString(int from, | 5830 MUST_USE_RESULT MaybeObject* SubString(int from, |
| 5806 int to, | 5831 int to, |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6036 ReadBlockBuffer* buffer, | 6061 ReadBlockBuffer* buffer, |
| 6037 unsigned* offset_ptr, | 6062 unsigned* offset_ptr, |
| 6038 unsigned max_chars); | 6063 unsigned max_chars); |
| 6039 | 6064 |
| 6040 private: | 6065 private: |
| 6041 // Try to flatten the top level ConsString that is hiding behind this | 6066 // Try to flatten the top level ConsString that is hiding behind this |
| 6042 // string. This is a no-op unless the string is a ConsString. Flatten | 6067 // string. This is a no-op unless the string is a ConsString. Flatten |
| 6043 // mutates the ConsString and might return a failure. | 6068 // mutates the ConsString and might return a failure. |
| 6044 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); | 6069 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); |
| 6045 | 6070 |
| 6071 // Try to create a new sequential string as parent for the slice that is | |
| 6072 // as short as possible. This is a no-op unless the string is a SlicedString. | |
| 6073 // Truncating mutates the SlicedString and might return a failure. | |
| 6074 MUST_USE_RESULT MaybeObject* SlowTryTruncate(PretenureFlag pretenure); | |
| 6075 | |
| 6046 static inline bool IsHashFieldComputed(uint32_t field); | 6076 static inline bool IsHashFieldComputed(uint32_t field); |
| 6047 | 6077 |
| 6048 // Slow case of String::Equals. This implementation works on any strings | 6078 // Slow case of String::Equals. This implementation works on any strings |
| 6049 // but it is most efficient on strings that are almost flat. | 6079 // but it is most efficient on strings that are almost flat. |
| 6050 bool SlowEquals(String* other); | 6080 bool SlowEquals(String* other); |
| 6051 | 6081 |
| 6052 // Slow case of AsArrayIndex. | 6082 // Slow case of AsArrayIndex. |
| 6053 bool SlowAsArrayIndex(uint32_t* index); | 6083 bool SlowAsArrayIndex(uint32_t* index); |
| 6054 | 6084 |
| 6055 // Compute and set the hash code. | 6085 // Compute and set the hash code. |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6216 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 6246 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 6217 unsigned* offset_ptr, | 6247 unsigned* offset_ptr, |
| 6218 unsigned chars); | 6248 unsigned chars); |
| 6219 | 6249 |
| 6220 // Minimum length for a cons string. | 6250 // Minimum length for a cons string. |
| 6221 static const int kMinLength = 13; | 6251 static const int kMinLength = 13; |
| 6222 | 6252 |
| 6223 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> | 6253 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> |
| 6224 BodyDescriptor; | 6254 BodyDescriptor; |
| 6225 | 6255 |
| 6256 #ifdef DEBUG | |
| 6257 void ConsStringVerify(); | |
| 6258 #endif | |
| 6259 | |
| 6226 private: | 6260 private: |
| 6227 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); | 6261 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); |
| 6228 }; | 6262 }; |
| 6229 | 6263 |
| 6230 | 6264 |
| 6265 // The Sliced String class describes strings that are substrings of another | |
| 6266 // sequential string. The motivation is to save time and memory when creating | |
| 6267 // a substring. A Sliced String is described as a pointer to the parent, | |
| 6268 // the offset from the start of the parent string and the length. Using | |
| 6269 // a Sliced String therefore requires unpacking of the parent string and | |
| 6270 // adding the offset to the start address. A substring of a Sliced String | |
| 6271 // are not nested since the double indirection is simplified when creating | |
| 6272 // such a substring. | |
| 6273 // Currently missing features are: | |
| 6274 // - handling externalized parent strings | |
| 6275 // - external strings as parent | |
| 6276 // - truncating sliced string to enable otherwise unneeded parent to be GC'ed. | |
| 6277 class SlicedString: public String { | |
| 6278 public: | |
| 6279 | |
| 6280 inline String* parent(); | |
| 6281 inline void set_parent(String* parent); | |
| 6282 inline int offset(); | |
| 6283 inline void set_offset(int offset); | |
| 6284 | |
| 6285 // Dispatched behavior. | |
| 6286 uint16_t SlicedStringGet(int index); | |
| 6287 | |
| 6288 // Casting. | |
| 6289 static inline SlicedString* cast(Object* obj); | |
| 6290 | |
| 6291 // Layout description. | |
| 6292 static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize); | |
| 6293 static const int kOffsetOffset = kParentOffset + kPointerSize; | |
| 6294 static const int kSize = kOffsetOffset + kPointerSize; | |
| 6295 | |
| 6296 // Support for StringInputBuffer | |
| 6297 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, | |
| 6298 unsigned* offset_ptr, | |
| 6299 unsigned chars); | |
| 6300 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | |
| 6301 unsigned* offset_ptr, | |
| 6302 unsigned chars); | |
| 6303 // Minimum length for a sliced string. | |
| 6304 static const int kMinLength = 13; | |
| 6305 | |
| 6306 typedef FixedBodyDescriptor<kParentOffset, | |
| 6307 kOffsetOffset + kPointerSize, kSize> | |
| 6308 BodyDescriptor; | |
| 6309 | |
| 6310 #ifdef DEBUG | |
| 6311 void SlicedStringVerify(); | |
| 6312 #endif | |
| 6313 | |
| 6314 private: | |
| 6315 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); | |
| 6316 }; | |
| 6317 | |
| 6318 | |
| 6231 // The ExternalString class describes string values that are backed by | 6319 // The ExternalString class describes string values that are backed by |
| 6232 // a string resource that lies outside the V8 heap. ExternalStrings | 6320 // a string resource that lies outside the V8 heap. ExternalStrings |
| 6233 // consist of the length field common to all strings, a pointer to the | 6321 // consist of the length field common to all strings, a pointer to the |
| 6234 // external resource. It is important to ensure (externally) that the | 6322 // external resource. It is important to ensure (externally) that the |
| 6235 // resource is not deallocated while the ExternalString is live in the | 6323 // resource is not deallocated while the ExternalString is live in the |
| 6236 // V8 heap. | 6324 // V8 heap. |
| 6237 // | 6325 // |
| 6238 // The API expects that all ExternalStrings are created through the | 6326 // The API expects that all ExternalStrings are created through the |
| 6239 // API. Therefore, ExternalStrings should not be used internally. | 6327 // API. Therefore, ExternalStrings should not be used internally. |
| 6240 class ExternalString: public String { | 6328 class ExternalString: public String { |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7203 } else { | 7291 } else { |
| 7204 value &= ~(1 << bit_position); | 7292 value &= ~(1 << bit_position); |
| 7205 } | 7293 } |
| 7206 return value; | 7294 return value; |
| 7207 } | 7295 } |
| 7208 }; | 7296 }; |
| 7209 | 7297 |
| 7210 } } // namespace v8::internal | 7298 } } // namespace v8::internal |
| 7211 | 7299 |
| 7212 #endif // V8_OBJECTS_H_ | 7300 #endif // V8_OBJECTS_H_ |
| OLD | NEW |