| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // - ExternalUnsignedByteArray | 83 // - ExternalUnsignedByteArray |
| 84 // - ExternalShortArray | 84 // - ExternalShortArray |
| 85 // - ExternalUnsignedShortArray | 85 // - ExternalUnsignedShortArray |
| 86 // - ExternalIntArray | 86 // - ExternalIntArray |
| 87 // - ExternalUnsignedIntArray | 87 // - ExternalUnsignedIntArray |
| 88 // - ExternalFloatArray | 88 // - ExternalFloatArray |
| 89 // - String | 89 // - String |
| 90 // - SeqString | 90 // - SeqString |
| 91 // - SeqAsciiString | 91 // - SeqAsciiString |
| 92 // - SeqTwoByteString | 92 // - SeqTwoByteString |
| 93 // - SlicedString |
| 93 // - ConsString | 94 // - ConsString |
| 94 // - ExternalString | 95 // - ExternalString |
| 95 // - ExternalAsciiString | 96 // - ExternalAsciiString |
| 96 // - ExternalTwoByteString | 97 // - ExternalTwoByteString |
| 97 // - HeapNumber | 98 // - HeapNumber |
| 98 // - Code | 99 // - Code |
| 99 // - Map | 100 // - Map |
| 100 // - Oddball | 101 // - Oddball |
| 101 // - Foreign | 102 // - Foreign |
| 102 // - SharedFunctionInfo | 103 // - SharedFunctionInfo |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 V(ASCII_SYMBOL_TYPE) \ | 278 V(ASCII_SYMBOL_TYPE) \ |
| 278 V(CONS_SYMBOL_TYPE) \ | 279 V(CONS_SYMBOL_TYPE) \ |
| 279 V(CONS_ASCII_SYMBOL_TYPE) \ | 280 V(CONS_ASCII_SYMBOL_TYPE) \ |
| 280 V(EXTERNAL_SYMBOL_TYPE) \ | 281 V(EXTERNAL_SYMBOL_TYPE) \ |
| 281 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ | 282 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ |
| 282 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ | 283 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ |
| 283 V(STRING_TYPE) \ | 284 V(STRING_TYPE) \ |
| 284 V(ASCII_STRING_TYPE) \ | 285 V(ASCII_STRING_TYPE) \ |
| 285 V(CONS_STRING_TYPE) \ | 286 V(CONS_STRING_TYPE) \ |
| 286 V(CONS_ASCII_STRING_TYPE) \ | 287 V(CONS_ASCII_STRING_TYPE) \ |
| 288 V(SLICED_STRING_TYPE) \ |
| 287 V(EXTERNAL_STRING_TYPE) \ | 289 V(EXTERNAL_STRING_TYPE) \ |
| 288 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ | 290 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ |
| 289 V(EXTERNAL_ASCII_STRING_TYPE) \ | 291 V(EXTERNAL_ASCII_STRING_TYPE) \ |
| 290 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 292 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
| 291 \ | 293 \ |
| 292 V(MAP_TYPE) \ | 294 V(MAP_TYPE) \ |
| 293 V(CODE_TYPE) \ | 295 V(CODE_TYPE) \ |
| 294 V(ODDBALL_TYPE) \ | 296 V(ODDBALL_TYPE) \ |
| 295 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 297 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
| 296 \ | 298 \ |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 ascii_string, \ | 398 ascii_string, \ |
| 397 AsciiString) \ | 399 AsciiString) \ |
| 398 V(CONS_STRING_TYPE, \ | 400 V(CONS_STRING_TYPE, \ |
| 399 ConsString::kSize, \ | 401 ConsString::kSize, \ |
| 400 cons_string, \ | 402 cons_string, \ |
| 401 ConsString) \ | 403 ConsString) \ |
| 402 V(CONS_ASCII_STRING_TYPE, \ | 404 V(CONS_ASCII_STRING_TYPE, \ |
| 403 ConsString::kSize, \ | 405 ConsString::kSize, \ |
| 404 cons_ascii_string, \ | 406 cons_ascii_string, \ |
| 405 ConsAsciiString) \ | 407 ConsAsciiString) \ |
| 408 V(SLICED_STRING_TYPE, \ |
| 409 SlicedString::kSize, \ |
| 410 sliced_string, \ |
| 411 SlicedString) \ |
| 412 V(SLICED_ASCII_STRING_TYPE, \ |
| 413 SlicedString::kSize, \ |
| 414 sliced_ascii_string, \ |
| 415 SlicedAsciiString) \ |
| 406 V(EXTERNAL_STRING_TYPE, \ | 416 V(EXTERNAL_STRING_TYPE, \ |
| 407 ExternalTwoByteString::kSize, \ | 417 ExternalTwoByteString::kSize, \ |
| 408 external_string, \ | 418 external_string, \ |
| 409 ExternalString) \ | 419 ExternalString) \ |
| 410 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ | 420 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ |
| 411 ExternalTwoByteString::kSize, \ | 421 ExternalTwoByteString::kSize, \ |
| 412 external_string_with_ascii_data, \ | 422 external_string_with_ascii_data, \ |
| 413 ExternalStringWithAsciiData) \ | 423 ExternalStringWithAsciiData) \ |
| 414 V(EXTERNAL_ASCII_STRING_TYPE, \ | 424 V(EXTERNAL_ASCII_STRING_TYPE, \ |
| 415 ExternalAsciiString::kSize, \ | 425 ExternalAsciiString::kSize, \ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 const uint32_t kStringEncodingMask = 0x4; | 479 const uint32_t kStringEncodingMask = 0x4; |
| 470 const uint32_t kTwoByteStringTag = 0x0; | 480 const uint32_t kTwoByteStringTag = 0x0; |
| 471 const uint32_t kAsciiStringTag = 0x4; | 481 const uint32_t kAsciiStringTag = 0x4; |
| 472 | 482 |
| 473 // If bit 7 is clear, the low-order 2 bits indicate the representation | 483 // If bit 7 is clear, the low-order 2 bits indicate the representation |
| 474 // of the string. | 484 // of the string. |
| 475 const uint32_t kStringRepresentationMask = 0x03; | 485 const uint32_t kStringRepresentationMask = 0x03; |
| 476 enum StringRepresentationTag { | 486 enum StringRepresentationTag { |
| 477 kSeqStringTag = 0x0, | 487 kSeqStringTag = 0x0, |
| 478 kConsStringTag = 0x1, | 488 kConsStringTag = 0x1, |
| 479 kExternalStringTag = 0x2 | 489 kExternalStringTag = 0x2, |
| 490 kSlicedStringTag = 0x3 |
| 480 }; | 491 }; |
| 481 const uint32_t kIsConsStringMask = 0x1; | 492 const uint32_t kIsIndirectStringMask = 0x1; |
| 493 const uint32_t kIsIndirectStringTag = 0x1; |
| 494 STATIC_ASSERT((kSeqStringTag & kIsIndirectStringMask) == 0); |
| 495 STATIC_ASSERT((kExternalStringTag & kIsIndirectStringMask) == 0); |
| 496 STATIC_ASSERT( |
| 497 (kConsStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); |
| 498 STATIC_ASSERT( |
| 499 (kSlicedStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); |
| 500 |
| 501 // Use this mask to distinguish between cons and slice only after making |
| 502 // sure that the string is one of the two (an indirect string). |
| 503 const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag; |
| 504 STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask) && kSlicedNotConsMask != 0); |
| 482 | 505 |
| 483 // If bit 7 is clear, then bit 3 indicates whether this two-byte | 506 // If bit 7 is clear, then bit 3 indicates whether this two-byte |
| 484 // string actually contains ascii data. | 507 // string actually contains ascii data. |
| 485 const uint32_t kAsciiDataHintMask = 0x08; | 508 const uint32_t kAsciiDataHintMask = 0x08; |
| 486 const uint32_t kAsciiDataHintTag = 0x08; | 509 const uint32_t kAsciiDataHintTag = 0x08; |
| 487 | 510 |
| 488 | 511 |
| 489 // A ConsString with an empty string as the right side is a candidate | 512 // A ConsString with an empty string as the right side is a candidate |
| 490 // for being shortcut by the garbage collector unless it is a | 513 // for being shortcut by the garbage collector unless it is a |
| 491 // symbol. It's not common to have non-flat symbols, so we do not | 514 // symbol. It's not common to have non-flat symbols, so we do not |
| (...skipping 14 matching lines...) Expand all Loading... |
| 506 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, | 529 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, |
| 507 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, | 530 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, |
| 508 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = | 531 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
| 509 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, | 532 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, |
| 510 EXTERNAL_ASCII_SYMBOL_TYPE = | 533 EXTERNAL_ASCII_SYMBOL_TYPE = |
| 511 kAsciiStringTag | kSymbolTag | kExternalStringTag, | 534 kAsciiStringTag | kSymbolTag | kExternalStringTag, |
| 512 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, | 535 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, |
| 513 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, | 536 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, |
| 514 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, | 537 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
| 515 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, | 538 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, |
| 539 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, |
| 540 SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag, |
| 516 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, | 541 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
| 517 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = | 542 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
| 518 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, | 543 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, |
| 519 // LAST_STRING_TYPE | 544 // LAST_STRING_TYPE |
| 520 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, | 545 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, |
| 521 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, | 546 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, |
| 522 | 547 |
| 523 // Objects allocated in their own spaces (never in new space). | 548 // Objects allocated in their own spaces (never in new space). |
| 524 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 549 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
| 525 CODE_TYPE, | 550 CODE_TYPE, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 V(HeapObject) \ | 739 V(HeapObject) \ |
| 715 V(Number) \ | 740 V(Number) \ |
| 716 | 741 |
| 717 #define HEAP_OBJECT_TYPE_LIST(V) \ | 742 #define HEAP_OBJECT_TYPE_LIST(V) \ |
| 718 V(HeapNumber) \ | 743 V(HeapNumber) \ |
| 719 V(String) \ | 744 V(String) \ |
| 720 V(Symbol) \ | 745 V(Symbol) \ |
| 721 V(SeqString) \ | 746 V(SeqString) \ |
| 722 V(ExternalString) \ | 747 V(ExternalString) \ |
| 723 V(ConsString) \ | 748 V(ConsString) \ |
| 749 V(SlicedString) \ |
| 724 V(ExternalTwoByteString) \ | 750 V(ExternalTwoByteString) \ |
| 725 V(ExternalAsciiString) \ | 751 V(ExternalAsciiString) \ |
| 726 V(SeqTwoByteString) \ | 752 V(SeqTwoByteString) \ |
| 727 V(SeqAsciiString) \ | 753 V(SeqAsciiString) \ |
| 728 \ | 754 \ |
| 729 V(ExternalArray) \ | 755 V(ExternalArray) \ |
| 730 V(ExternalByteArray) \ | 756 V(ExternalByteArray) \ |
| 731 V(ExternalUnsignedByteArray) \ | 757 V(ExternalUnsignedByteArray) \ |
| 732 V(ExternalShortArray) \ | 758 V(ExternalShortArray) \ |
| 733 V(ExternalUnsignedShortArray) \ | 759 V(ExternalUnsignedShortArray) \ |
| (...skipping 4965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5699 // prone and so we no longer put StringShapes in variables unless there is a | 5725 // prone and so we no longer put StringShapes in variables unless there is a |
| 5700 // concrete performance benefit at that particular point in the code. | 5726 // concrete performance benefit at that particular point in the code. |
| 5701 class StringShape BASE_EMBEDDED { | 5727 class StringShape BASE_EMBEDDED { |
| 5702 public: | 5728 public: |
| 5703 inline explicit StringShape(String* s); | 5729 inline explicit StringShape(String* s); |
| 5704 inline explicit StringShape(Map* s); | 5730 inline explicit StringShape(Map* s); |
| 5705 inline explicit StringShape(InstanceType t); | 5731 inline explicit StringShape(InstanceType t); |
| 5706 inline bool IsSequential(); | 5732 inline bool IsSequential(); |
| 5707 inline bool IsExternal(); | 5733 inline bool IsExternal(); |
| 5708 inline bool IsCons(); | 5734 inline bool IsCons(); |
| 5735 inline bool IsSliced(); |
| 5736 inline bool IsIndirect(); |
| 5709 inline bool IsExternalAscii(); | 5737 inline bool IsExternalAscii(); |
| 5710 inline bool IsExternalTwoByte(); | 5738 inline bool IsExternalTwoByte(); |
| 5711 inline bool IsSequentialAscii(); | 5739 inline bool IsSequentialAscii(); |
| 5712 inline bool IsSequentialTwoByte(); | 5740 inline bool IsSequentialTwoByte(); |
| 5713 inline bool IsSymbol(); | 5741 inline bool IsSymbol(); |
| 5714 inline StringRepresentationTag representation_tag(); | 5742 inline StringRepresentationTag representation_tag(); |
| 5715 inline uint32_t encoding_tag(); | 5743 inline uint32_t encoding_tag(); |
| 5716 inline uint32_t full_representation_tag(); | 5744 inline uint32_t full_representation_tag(); |
| 5717 inline uint32_t size_tag(); | 5745 inline uint32_t size_tag(); |
| 5718 #ifdef DEBUG | 5746 #ifdef DEBUG |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5790 }; | 5818 }; |
| 5791 | 5819 |
| 5792 // Get and set the length of the string. | 5820 // Get and set the length of the string. |
| 5793 inline int length(); | 5821 inline int length(); |
| 5794 inline void set_length(int value); | 5822 inline void set_length(int value); |
| 5795 | 5823 |
| 5796 // Get and set the hash field of the string. | 5824 // Get and set the hash field of the string. |
| 5797 inline uint32_t hash_field(); | 5825 inline uint32_t hash_field(); |
| 5798 inline void set_hash_field(uint32_t value); | 5826 inline void set_hash_field(uint32_t value); |
| 5799 | 5827 |
| 5800 inline bool IsAsciiRepresentation(); | |
| 5801 inline bool IsTwoByteRepresentation(); | |
| 5802 | |
| 5803 // Returns whether this string has only ASCII chars, i.e. all of them can | 5828 // Returns whether this string has only ASCII chars, i.e. all of them can |
| 5804 // be ASCII encoded. This might be the case even if the string is | 5829 // be ASCII encoded. This might be the case even if the string is |
| 5805 // two-byte. Such strings may appear when the embedder prefers | 5830 // two-byte. Such strings may appear when the embedder prefers |
| 5806 // two-byte external representations even for ASCII data. | 5831 // two-byte external representations even for ASCII data. |
| 5807 // | 5832 inline bool IsAsciiRepresentation(); |
| 5833 inline bool IsTwoByteRepresentation(); |
| 5834 |
| 5835 // Cons and slices have an encoding flag that may not represent the actual |
| 5836 // encoding of the underlying string. This is taken into account here. |
| 5837 // Requires: this->IsFlat() |
| 5838 inline bool IsAsciiRepresentationUnderneath(); |
| 5839 inline bool IsTwoByteRepresentationUnderneath(); |
| 5840 |
| 5808 // NOTE: this should be considered only a hint. False negatives are | 5841 // NOTE: this should be considered only a hint. False negatives are |
| 5809 // possible. | 5842 // possible. |
| 5810 inline bool HasOnlyAsciiChars(); | 5843 inline bool HasOnlyAsciiChars(); |
| 5811 | 5844 |
| 5812 // Get and set individual two byte chars in the string. | 5845 // Get and set individual two byte chars in the string. |
| 5813 inline void Set(int index, uint16_t value); | 5846 inline void Set(int index, uint16_t value); |
| 5814 // Get individual two byte char in the string. Repeated calls | 5847 // Get individual two byte char in the string. Repeated calls |
| 5815 // to this method are not efficient unless the string is flat. | 5848 // to this method are not efficient unless the string is flat. |
| 5816 inline uint16_t Get(int index); | 5849 inline uint16_t Get(int index); |
| 5817 | 5850 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5837 // string. | 5870 // string. |
| 5838 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); | 5871 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); |
| 5839 | 5872 |
| 5840 // Tries to return the content of a flat string as a structure holding either | 5873 // Tries to return the content of a flat string as a structure holding either |
| 5841 // a flat vector of char or of uc16. | 5874 // a flat vector of char or of uc16. |
| 5842 // If the string isn't flat, and therefore doesn't have flat content, the | 5875 // If the string isn't flat, and therefore doesn't have flat content, the |
| 5843 // returned structure will report so, and can't provide a vector of either | 5876 // returned structure will report so, and can't provide a vector of either |
| 5844 // kind. | 5877 // kind. |
| 5845 FlatContent GetFlatContent(); | 5878 FlatContent GetFlatContent(); |
| 5846 | 5879 |
| 5880 // Returns the parent of a sliced string or first part of a flat cons string. |
| 5881 // Requires: StringShape(this).IsIndirect() && this->IsFlat() |
| 5882 inline String* GetUnderlying(); |
| 5883 |
| 5847 // Mark the string as an undetectable object. It only applies to | 5884 // Mark the string as an undetectable object. It only applies to |
| 5848 // ascii and two byte string types. | 5885 // ascii and two byte string types. |
| 5849 bool MarkAsUndetectable(); | 5886 bool MarkAsUndetectable(); |
| 5850 | 5887 |
| 5851 // Return a substring. | 5888 // Return a substring. |
| 5852 MUST_USE_RESULT MaybeObject* SubString(int from, | 5889 MUST_USE_RESULT MaybeObject* SubString(int from, |
| 5853 int to, | 5890 int to, |
| 5854 PretenureFlag pretenure = NOT_TENURED); | 5891 PretenureFlag pretenure = NOT_TENURED); |
| 5855 | 5892 |
| 5856 // String equality operations. | 5893 // String equality operations. |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6265 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 6302 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 6266 unsigned* offset_ptr, | 6303 unsigned* offset_ptr, |
| 6267 unsigned chars); | 6304 unsigned chars); |
| 6268 | 6305 |
| 6269 // Minimum length for a cons string. | 6306 // Minimum length for a cons string. |
| 6270 static const int kMinLength = 13; | 6307 static const int kMinLength = 13; |
| 6271 | 6308 |
| 6272 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> | 6309 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> |
| 6273 BodyDescriptor; | 6310 BodyDescriptor; |
| 6274 | 6311 |
| 6312 #ifdef DEBUG |
| 6313 void ConsStringVerify(); |
| 6314 #endif |
| 6315 |
| 6275 private: | 6316 private: |
| 6276 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); | 6317 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); |
| 6277 }; | 6318 }; |
| 6278 | 6319 |
| 6279 | 6320 |
| 6321 // The Sliced String class describes strings that are substrings of another |
| 6322 // sequential string. The motivation is to save time and memory when creating |
| 6323 // a substring. A Sliced String is described as a pointer to the parent, |
| 6324 // the offset from the start of the parent string and the length. Using |
| 6325 // a Sliced String therefore requires unpacking of the parent string and |
| 6326 // adding the offset to the start address. A substring of a Sliced String |
| 6327 // are not nested since the double indirection is simplified when creating |
| 6328 // such a substring. |
| 6329 // Currently missing features are: |
| 6330 // - handling externalized parent strings |
| 6331 // - external strings as parent |
| 6332 // - truncating sliced string to enable otherwise unneeded parent to be GC'ed. |
| 6333 class SlicedString: public String { |
| 6334 public: |
| 6335 |
| 6336 inline String* parent(); |
| 6337 inline void set_parent(String* parent); |
| 6338 inline int offset(); |
| 6339 inline void set_offset(int offset); |
| 6340 |
| 6341 // Dispatched behavior. |
| 6342 uint16_t SlicedStringGet(int index); |
| 6343 |
| 6344 // Casting. |
| 6345 static inline SlicedString* cast(Object* obj); |
| 6346 |
| 6347 // Layout description. |
| 6348 static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize); |
| 6349 static const int kOffsetOffset = kParentOffset + kPointerSize; |
| 6350 static const int kSize = kOffsetOffset + kPointerSize; |
| 6351 |
| 6352 // Support for StringInputBuffer |
| 6353 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, |
| 6354 unsigned* offset_ptr, |
| 6355 unsigned chars); |
| 6356 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 6357 unsigned* offset_ptr, |
| 6358 unsigned chars); |
| 6359 // Minimum length for a sliced string. |
| 6360 static const int kMinLength = 13; |
| 6361 |
| 6362 typedef FixedBodyDescriptor<kParentOffset, |
| 6363 kOffsetOffset + kPointerSize, kSize> |
| 6364 BodyDescriptor; |
| 6365 |
| 6366 #ifdef DEBUG |
| 6367 void SlicedStringVerify(); |
| 6368 #endif |
| 6369 |
| 6370 private: |
| 6371 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); |
| 6372 }; |
| 6373 |
| 6374 |
| 6280 // The ExternalString class describes string values that are backed by | 6375 // The ExternalString class describes string values that are backed by |
| 6281 // a string resource that lies outside the V8 heap. ExternalStrings | 6376 // a string resource that lies outside the V8 heap. ExternalStrings |
| 6282 // consist of the length field common to all strings, a pointer to the | 6377 // consist of the length field common to all strings, a pointer to the |
| 6283 // external resource. It is important to ensure (externally) that the | 6378 // external resource. It is important to ensure (externally) that the |
| 6284 // resource is not deallocated while the ExternalString is live in the | 6379 // resource is not deallocated while the ExternalString is live in the |
| 6285 // V8 heap. | 6380 // V8 heap. |
| 6286 // | 6381 // |
| 6287 // The API expects that all ExternalStrings are created through the | 6382 // The API expects that all ExternalStrings are created through the |
| 6288 // API. Therefore, ExternalStrings should not be used internally. | 6383 // API. Therefore, ExternalStrings should not be used internally. |
| 6289 class ExternalString: public String { | 6384 class ExternalString: public String { |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7282 } else { | 7377 } else { |
| 7283 value &= ~(1 << bit_position); | 7378 value &= ~(1 << bit_position); |
| 7284 } | 7379 } |
| 7285 return value; | 7380 return value; |
| 7286 } | 7381 } |
| 7287 }; | 7382 }; |
| 7288 | 7383 |
| 7289 } } // namespace v8::internal | 7384 } } // namespace v8::internal |
| 7290 | 7385 |
| 7291 #endif // V8_OBJECTS_H_ | 7386 #endif // V8_OBJECTS_H_ |
| OLD | NEW |