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((kSeqStringTag & kIsIndirectStringMask) == 0); | |
488 STATIC_ASSERT((kExternalStringTag & kIsIndirectStringMask) == 0); | |
489 STATIC_ASSERT( | |
490 (kConsStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); | |
491 STATIC_ASSERT( | |
492 (kSlicedStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); | |
475 | 493 |
476 // If bit 7 is clear, then bit 3 indicates whether this two-byte | 494 // If bit 7 is clear, then bit 3 indicates whether this two-byte |
477 // string actually contains ascii data. | 495 // string actually contains ascii data. |
478 const uint32_t kAsciiDataHintMask = 0x08; | 496 const uint32_t kAsciiDataHintMask = 0x08; |
479 const uint32_t kAsciiDataHintTag = 0x08; | 497 const uint32_t kAsciiDataHintTag = 0x08; |
480 | 498 |
481 | 499 |
482 // A ConsString with an empty string as the right side is a candidate | 500 // 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 | 501 // 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 | 502 // 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, | 517 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, |
500 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, | 518 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, |
501 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = | 519 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
502 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, | 520 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, |
503 EXTERNAL_ASCII_SYMBOL_TYPE = | 521 EXTERNAL_ASCII_SYMBOL_TYPE = |
504 kAsciiStringTag | kSymbolTag | kExternalStringTag, | 522 kAsciiStringTag | kSymbolTag | kExternalStringTag, |
505 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, | 523 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, |
506 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, | 524 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, |
507 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, | 525 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
508 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, | 526 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, |
527 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, | |
528 SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag, | |
509 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, | 529 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
510 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = | 530 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
511 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, | 531 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, |
512 // LAST_STRING_TYPE | 532 // LAST_STRING_TYPE |
513 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, | 533 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, |
514 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, | 534 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, |
515 | 535 |
516 // Objects allocated in their own spaces (never in new space). | 536 // Objects allocated in their own spaces (never in new space). |
517 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 537 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
518 CODE_TYPE, | 538 CODE_TYPE, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 V(HeapObject) \ | 722 V(HeapObject) \ |
703 V(Number) \ | 723 V(Number) \ |
704 | 724 |
705 #define HEAP_OBJECT_TYPE_LIST(V) \ | 725 #define HEAP_OBJECT_TYPE_LIST(V) \ |
706 V(HeapNumber) \ | 726 V(HeapNumber) \ |
707 V(String) \ | 727 V(String) \ |
708 V(Symbol) \ | 728 V(Symbol) \ |
709 V(SeqString) \ | 729 V(SeqString) \ |
710 V(ExternalString) \ | 730 V(ExternalString) \ |
711 V(ConsString) \ | 731 V(ConsString) \ |
732 V(SlicedString) \ | |
712 V(ExternalTwoByteString) \ | 733 V(ExternalTwoByteString) \ |
713 V(ExternalAsciiString) \ | 734 V(ExternalAsciiString) \ |
714 V(SeqTwoByteString) \ | 735 V(SeqTwoByteString) \ |
715 V(SeqAsciiString) \ | 736 V(SeqAsciiString) \ |
716 \ | 737 \ |
717 V(ExternalArray) \ | 738 V(ExternalArray) \ |
718 V(ExternalByteArray) \ | 739 V(ExternalByteArray) \ |
719 V(ExternalUnsignedByteArray) \ | 740 V(ExternalUnsignedByteArray) \ |
720 V(ExternalShortArray) \ | 741 V(ExternalShortArray) \ |
721 V(ExternalUnsignedShortArray) \ | 742 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 | 5723 // 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. | 5724 // concrete performance benefit at that particular point in the code. |
5704 class StringShape BASE_EMBEDDED { | 5725 class StringShape BASE_EMBEDDED { |
5705 public: | 5726 public: |
5706 inline explicit StringShape(String* s); | 5727 inline explicit StringShape(String* s); |
5707 inline explicit StringShape(Map* s); | 5728 inline explicit StringShape(Map* s); |
5708 inline explicit StringShape(InstanceType t); | 5729 inline explicit StringShape(InstanceType t); |
5709 inline bool IsSequential(); | 5730 inline bool IsSequential(); |
5710 inline bool IsExternal(); | 5731 inline bool IsExternal(); |
5711 inline bool IsCons(); | 5732 inline bool IsCons(); |
5733 inline bool IsSliced(); | |
5734 inline bool IsIndirect(); | |
5712 inline bool IsExternalAscii(); | 5735 inline bool IsExternalAscii(); |
5713 inline bool IsExternalTwoByte(); | 5736 inline bool IsExternalTwoByte(); |
5714 inline bool IsSequentialAscii(); | 5737 inline bool IsSequentialAscii(); |
5715 inline bool IsSequentialTwoByte(); | 5738 inline bool IsSequentialTwoByte(); |
5716 inline bool IsSymbol(); | 5739 inline bool IsSymbol(); |
5717 inline StringRepresentationTag representation_tag(); | 5740 inline StringRepresentationTag representation_tag(); |
5718 inline uint32_t full_representation_tag(); | 5741 inline uint32_t full_representation_tag(); |
5719 inline uint32_t size_tag(); | 5742 inline uint32_t size_tag(); |
5720 #ifdef DEBUG | 5743 #ifdef DEBUG |
5721 inline uint32_t type() { return type_; } | 5744 inline uint32_t type() { return type_; } |
(...skipping 28 matching lines...) Expand all Loading... | |
5750 inline int length(); | 5773 inline int length(); |
5751 inline void set_length(int value); | 5774 inline void set_length(int value); |
5752 | 5775 |
5753 // Get and set the hash field of the string. | 5776 // Get and set the hash field of the string. |
5754 inline uint32_t hash_field(); | 5777 inline uint32_t hash_field(); |
5755 inline void set_hash_field(uint32_t value); | 5778 inline void set_hash_field(uint32_t value); |
5756 | 5779 |
5757 inline bool IsAsciiRepresentation(); | 5780 inline bool IsAsciiRepresentation(); |
5758 inline bool IsTwoByteRepresentation(); | 5781 inline bool IsTwoByteRepresentation(); |
5759 | 5782 |
5783 // Cons and slices have an encoding flag that may not represent the actual | |
5784 // encoding of the underlying string. This is taken into account here. | |
Vitaly Repeshko
2011/08/19 16:27:40
Add "Requires: this->IsFlat()".
| |
5785 inline bool IsAsciiRepresentationUnderneath(); | |
5786 inline bool IsTwoByteRepresentationUnderneath(); | |
5787 | |
5760 // Returns whether this string has ascii chars, i.e. all of them can | 5788 // Returns whether this string has ascii chars, i.e. all of them can |
5761 // be ascii encoded. This might be the case even if the string is | 5789 // be ascii encoded. This might be the case even if the string is |
5762 // two-byte. Such strings may appear when the embedder prefers | 5790 // two-byte. Such strings may appear when the embedder prefers |
5763 // two-byte external representations even for ascii data. | 5791 // two-byte external representations even for ascii data. |
5764 // | 5792 // |
5765 // NOTE: this should be considered only a hint. False negatives are | 5793 // NOTE: this should be considered only a hint. False negatives are |
5766 // possible. | 5794 // possible. |
5767 inline bool HasOnlyAsciiChars(); | 5795 inline bool HasOnlyAsciiChars(); |
5768 | 5796 |
5769 // Get and set individual two byte chars in the string. | 5797 // Get and set individual two byte chars in the string. |
(...skipping 17 matching lines...) Expand all Loading... | |
5787 // | 5815 // |
5788 // Use FlattenString from Handles.cc to flatten even in case an | 5816 // Use FlattenString from Handles.cc to flatten even in case an |
5789 // allocation failure happens. | 5817 // allocation failure happens. |
5790 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED); | 5818 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED); |
5791 | 5819 |
5792 // Convenience function. Has exactly the same behavior as | 5820 // Convenience function. Has exactly the same behavior as |
5793 // TryFlatten(), except in the case of failure returns the original | 5821 // TryFlatten(), except in the case of failure returns the original |
5794 // string. | 5822 // string. |
5795 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); | 5823 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); |
5796 | 5824 |
5825 // Returns the parent of a sliced string or first part of a cons string. | |
Vitaly Repeshko
2011/08/19 16:27:40
"... of a *flat* cons ..."
| |
5826 inline String* GetUnderlying(); | |
Vitaly Repeshko
2011/08/19 16:27:40
Add "Requires: StringShape(this).IsIndirect() && t
| |
5827 | |
5797 Vector<const char> ToAsciiVector(); | 5828 Vector<const char> ToAsciiVector(); |
5798 Vector<const uc16> ToUC16Vector(); | 5829 Vector<const uc16> ToUC16Vector(); |
5799 | 5830 |
5800 // Mark the string as an undetectable object. It only applies to | 5831 // Mark the string as an undetectable object. It only applies to |
5801 // ascii and two byte string types. | 5832 // ascii and two byte string types. |
5802 bool MarkAsUndetectable(); | 5833 bool MarkAsUndetectable(); |
5803 | 5834 |
5804 // Return a substring. | 5835 // Return a substring. |
5805 MUST_USE_RESULT MaybeObject* SubString(int from, | 5836 MUST_USE_RESULT MaybeObject* SubString(int from, |
5806 int to, | 5837 int to, |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6036 ReadBlockBuffer* buffer, | 6067 ReadBlockBuffer* buffer, |
6037 unsigned* offset_ptr, | 6068 unsigned* offset_ptr, |
6038 unsigned max_chars); | 6069 unsigned max_chars); |
6039 | 6070 |
6040 private: | 6071 private: |
6041 // Try to flatten the top level ConsString that is hiding behind this | 6072 // 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 | 6073 // string. This is a no-op unless the string is a ConsString. Flatten |
6043 // mutates the ConsString and might return a failure. | 6074 // mutates the ConsString and might return a failure. |
6044 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); | 6075 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure); |
6045 | 6076 |
6077 // Try to create a new sequential string as parent for the slice that is | |
6078 // as short as possible. This is a no-op unless the string is a SlicedString. | |
6079 // Truncating mutates the SlicedString and might return a failure. | |
6080 MUST_USE_RESULT MaybeObject* SlowTryTruncate(PretenureFlag pretenure); | |
Vitaly Repeshko
2011/08/19 16:27:40
Remove?
| |
6081 | |
6046 static inline bool IsHashFieldComputed(uint32_t field); | 6082 static inline bool IsHashFieldComputed(uint32_t field); |
6047 | 6083 |
6048 // Slow case of String::Equals. This implementation works on any strings | 6084 // Slow case of String::Equals. This implementation works on any strings |
6049 // but it is most efficient on strings that are almost flat. | 6085 // but it is most efficient on strings that are almost flat. |
6050 bool SlowEquals(String* other); | 6086 bool SlowEquals(String* other); |
6051 | 6087 |
6052 // Slow case of AsArrayIndex. | 6088 // Slow case of AsArrayIndex. |
6053 bool SlowAsArrayIndex(uint32_t* index); | 6089 bool SlowAsArrayIndex(uint32_t* index); |
6054 | 6090 |
6055 // Compute and set the hash code. | 6091 // 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, | 6252 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
6217 unsigned* offset_ptr, | 6253 unsigned* offset_ptr, |
6218 unsigned chars); | 6254 unsigned chars); |
6219 | 6255 |
6220 // Minimum length for a cons string. | 6256 // Minimum length for a cons string. |
6221 static const int kMinLength = 13; | 6257 static const int kMinLength = 13; |
6222 | 6258 |
6223 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> | 6259 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> |
6224 BodyDescriptor; | 6260 BodyDescriptor; |
6225 | 6261 |
6262 #ifdef DEBUG | |
6263 void ConsStringVerify(); | |
6264 #endif | |
6265 | |
6226 private: | 6266 private: |
6227 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); | 6267 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); |
6228 }; | 6268 }; |
6229 | 6269 |
6230 | 6270 |
6271 // The Sliced String class describes strings that are substrings of another | |
6272 // sequential string. The motivation is to save time and memory when creating | |
6273 // a substring. A Sliced String is described as a pointer to the parent, | |
6274 // the offset from the start of the parent string and the length. Using | |
6275 // a Sliced String therefore requires unpacking of the parent string and | |
6276 // adding the offset to the start address. A substring of a Sliced String | |
6277 // are not nested since the double indirection is simplified when creating | |
6278 // such a substring. | |
6279 // Currently missing features are: | |
6280 // - handling externalized parent strings | |
6281 // - external strings as parent | |
6282 // - truncating sliced string to enable otherwise unneeded parent to be GC'ed. | |
6283 class SlicedString: public String { | |
6284 public: | |
6285 | |
6286 inline String* parent(); | |
6287 inline void set_parent(String* parent); | |
6288 inline int offset(); | |
6289 inline void set_offset(int offset); | |
6290 | |
6291 // Dispatched behavior. | |
6292 uint16_t SlicedStringGet(int index); | |
6293 | |
6294 // Casting. | |
6295 static inline SlicedString* cast(Object* obj); | |
6296 | |
6297 // Layout description. | |
6298 static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize); | |
6299 static const int kOffsetOffset = kParentOffset + kPointerSize; | |
6300 static const int kSize = kOffsetOffset + kPointerSize; | |
6301 | |
6302 // Support for StringInputBuffer | |
6303 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, | |
6304 unsigned* offset_ptr, | |
6305 unsigned chars); | |
6306 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | |
6307 unsigned* offset_ptr, | |
6308 unsigned chars); | |
6309 // Minimum length for a sliced string. | |
6310 static const int kMinLength = 13; | |
6311 | |
6312 typedef FixedBodyDescriptor<kParentOffset, | |
6313 kOffsetOffset + kPointerSize, kSize> | |
6314 BodyDescriptor; | |
6315 | |
6316 #ifdef DEBUG | |
6317 void SlicedStringVerify(); | |
6318 #endif | |
6319 | |
6320 private: | |
6321 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); | |
6322 }; | |
6323 | |
6324 | |
6231 // The ExternalString class describes string values that are backed by | 6325 // The ExternalString class describes string values that are backed by |
6232 // a string resource that lies outside the V8 heap. ExternalStrings | 6326 // a string resource that lies outside the V8 heap. ExternalStrings |
6233 // consist of the length field common to all strings, a pointer to the | 6327 // consist of the length field common to all strings, a pointer to the |
6234 // external resource. It is important to ensure (externally) that the | 6328 // external resource. It is important to ensure (externally) that the |
6235 // resource is not deallocated while the ExternalString is live in the | 6329 // resource is not deallocated while the ExternalString is live in the |
6236 // V8 heap. | 6330 // V8 heap. |
6237 // | 6331 // |
6238 // The API expects that all ExternalStrings are created through the | 6332 // The API expects that all ExternalStrings are created through the |
6239 // API. Therefore, ExternalStrings should not be used internally. | 6333 // API. Therefore, ExternalStrings should not be used internally. |
6240 class ExternalString: public String { | 6334 class ExternalString: public String { |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7203 } else { | 7297 } else { |
7204 value &= ~(1 << bit_position); | 7298 value &= ~(1 << bit_position); |
7205 } | 7299 } |
7206 return value; | 7300 return value; |
7207 } | 7301 } |
7208 }; | 7302 }; |
7209 | 7303 |
7210 } } // namespace v8::internal | 7304 } } // namespace v8::internal |
7211 | 7305 |
7212 #endif // V8_OBJECTS_H_ | 7306 #endif // V8_OBJECTS_H_ |
OLD | NEW |