| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // - HashTable | 72 // - HashTable |
| 73 // - Dictionary | 73 // - Dictionary |
| 74 // - SymbolTable | 74 // - SymbolTable |
| 75 // - CompilationCacheTable | 75 // - CompilationCacheTable |
| 76 // - CodeCacheHashTable | 76 // - CodeCacheHashTable |
| 77 // - MapCache | 77 // - MapCache |
| 78 // - Context | 78 // - Context |
| 79 // - JSFunctionResultCache | 79 // - JSFunctionResultCache |
| 80 // - SerializedScopeInfo | 80 // - SerializedScopeInfo |
| 81 // - String | 81 // - String |
| 82 // - SeqString | |
| 83 // - SeqAsciiString | |
| 84 // - SeqTwoByteString | |
| 85 // - ConsString | 82 // - ConsString |
| 86 // - ExternalString | 83 // - FlatString |
| 87 // - ExternalAsciiString | 84 // - SeqString |
| 88 // - ExternalTwoByteString | 85 // - SeqAsciiString |
| 86 // - SeqTwoByteString |
| 87 // - ExternalString |
| 88 // - ExternalAsciiString |
| 89 // - ExternalTwoByteString |
| 89 // - HeapNumber | 90 // - HeapNumber |
| 90 // - Code | 91 // - Code |
| 91 // - Map | 92 // - Map |
| 92 // - Oddball | 93 // - Oddball |
| 93 // - Proxy | 94 // - Proxy |
| 94 // - SharedFunctionInfo | 95 // - SharedFunctionInfo |
| 95 // - Struct | 96 // - Struct |
| 96 // - AccessorInfo | 97 // - AccessorInfo |
| 97 // - AccessCheckInfo | 98 // - AccessCheckInfo |
| 98 // - InterceptorInfo | 99 // - InterceptorInfo |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 675 |
| 675 #define OBJECT_TYPE_LIST(V) \ | 676 #define OBJECT_TYPE_LIST(V) \ |
| 676 V(Smi) \ | 677 V(Smi) \ |
| 677 V(HeapObject) \ | 678 V(HeapObject) \ |
| 678 V(Number) \ | 679 V(Number) \ |
| 679 | 680 |
| 680 #define HEAP_OBJECT_TYPE_LIST(V) \ | 681 #define HEAP_OBJECT_TYPE_LIST(V) \ |
| 681 V(HeapNumber) \ | 682 V(HeapNumber) \ |
| 682 V(String) \ | 683 V(String) \ |
| 683 V(Symbol) \ | 684 V(Symbol) \ |
| 685 V(FlatString) \ |
| 684 V(SeqString) \ | 686 V(SeqString) \ |
| 685 V(ExternalString) \ | 687 V(ExternalString) \ |
| 686 V(ConsString) \ | 688 V(ConsString) \ |
| 687 V(ExternalTwoByteString) \ | 689 V(ExternalTwoByteString) \ |
| 688 V(ExternalAsciiString) \ | 690 V(ExternalAsciiString) \ |
| 689 V(SeqTwoByteString) \ | 691 V(SeqTwoByteString) \ |
| 690 V(SeqAsciiString) \ | 692 V(SeqAsciiString) \ |
| 691 \ | 693 \ |
| 692 V(ExternalArray) \ | 694 V(ExternalArray) \ |
| 693 V(ExternalByteArray) \ | 695 V(ExternalByteArray) \ |
| (...skipping 4652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5346 // NOTE: this should be considered only a hint. False negatives are | 5348 // NOTE: this should be considered only a hint. False negatives are |
| 5347 // possible. | 5349 // possible. |
| 5348 inline bool HasOnlyAsciiChars(); | 5350 inline bool HasOnlyAsciiChars(); |
| 5349 | 5351 |
| 5350 // Get and set individual two byte chars in the string. | 5352 // Get and set individual two byte chars in the string. |
| 5351 inline void Set(int index, uint16_t value); | 5353 inline void Set(int index, uint16_t value); |
| 5352 // Get individual two byte char in the string. Repeated calls | 5354 // Get individual two byte char in the string. Repeated calls |
| 5353 // to this method are not efficient unless the string is flat. | 5355 // to this method are not efficient unless the string is flat. |
| 5354 inline uint16_t Get(int index); | 5356 inline uint16_t Get(int index); |
| 5355 | 5357 |
| 5358 // Try to get a character (smi encoded) from the string. |
| 5359 // The method may try to flatten the string, or part of the string. |
| 5360 inline MaybeObject* GetMayFlatten(int index); |
| 5361 |
| 5356 // Try to flatten the string. Checks first inline to see if it is | 5362 // Try to flatten the string. Checks first inline to see if it is |
| 5357 // necessary. Does nothing if the string is not a cons string. | 5363 // necessary. Does nothing if the string is not a cons string. |
| 5358 // Flattening allocates a sequential string with the same data as | 5364 // Flattening allocates a sequential string with the same data as |
| 5359 // the given string and mutates the cons string to a degenerate | 5365 // the given string and mutates the cons string to a degenerate |
| 5360 // form, where the first component is the new sequential string and | 5366 // form, where the first component is the new sequential string and |
| 5361 // the second component is the empty string. If allocation fails, | 5367 // the second component is the empty string. If allocation fails, |
| 5362 // this function returns a failure. If flattening succeeds, this | 5368 // this function returns a failure. If flattening succeeds, this |
| 5363 // function returns the sequential string that is now the first | 5369 // function returns the sequential string that is now the first |
| 5364 // component of the cons string. | 5370 // component of the cons string. |
| 5365 // | 5371 // |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5633 // Slow case of AsArrayIndex. | 5639 // Slow case of AsArrayIndex. |
| 5634 bool SlowAsArrayIndex(uint32_t* index); | 5640 bool SlowAsArrayIndex(uint32_t* index); |
| 5635 | 5641 |
| 5636 // Compute and set the hash code. | 5642 // Compute and set the hash code. |
| 5637 uint32_t ComputeAndSetHash(); | 5643 uint32_t ComputeAndSetHash(); |
| 5638 | 5644 |
| 5639 DISALLOW_IMPLICIT_CONSTRUCTORS(String); | 5645 DISALLOW_IMPLICIT_CONSTRUCTORS(String); |
| 5640 }; | 5646 }; |
| 5641 | 5647 |
| 5642 | 5648 |
| 5649 class FlatString: public String { |
| 5650 public: |
| 5651 // Casting. |
| 5652 static inline FlatString* cast(Object* obj); |
| 5653 |
| 5654 // Get a character from a flat string. |
| 5655 inline uint16_t FlatStringGet(int index); |
| 5656 |
| 5657 private: |
| 5658 DISALLOW_IMPLICIT_CONSTRUCTORS(FlatString); |
| 5659 }; |
| 5660 |
| 5661 |
| 5643 // The SeqString abstract class captures sequential string values. | 5662 // The SeqString abstract class captures sequential string values. |
| 5644 class SeqString: public String { | 5663 class SeqString: public FlatString { |
| 5645 public: | 5664 public: |
| 5646 | |
| 5647 // Casting. | 5665 // Casting. |
| 5648 static inline SeqString* cast(Object* obj); | 5666 static inline SeqString* cast(Object* obj); |
| 5649 | 5667 |
| 5650 private: | 5668 private: |
| 5651 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); | 5669 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); |
| 5652 }; | 5670 }; |
| 5653 | 5671 |
| 5654 | 5672 |
| 5655 // The AsciiString class captures sequential ascii string objects. | 5673 // The AsciiString class captures sequential ascii string objects. |
| 5656 // Each character in the AsciiString is an ascii character. | 5674 // Each character in the AsciiString is an ascii character. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5775 // Second string of the cons cell. | 5793 // Second string of the cons cell. |
| 5776 inline String* second(); | 5794 inline String* second(); |
| 5777 // Doesn't check that the result is a string, even in debug mode. This is | 5795 // Doesn't check that the result is a string, even in debug mode. This is |
| 5778 // useful during GC where the mark bits confuse the checks. | 5796 // useful during GC where the mark bits confuse the checks. |
| 5779 inline Object* unchecked_second(); | 5797 inline Object* unchecked_second(); |
| 5780 inline void set_second(String* second, | 5798 inline void set_second(String* second, |
| 5781 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 5799 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 5782 | 5800 |
| 5783 // Dispatched behavior. | 5801 // Dispatched behavior. |
| 5784 uint16_t ConsStringGet(int index); | 5802 uint16_t ConsStringGet(int index); |
| 5803 MaybeObject* ConsStringGetMayFlatten(int index); |
| 5785 | 5804 |
| 5786 // Casting. | 5805 // Casting. |
| 5787 static inline ConsString* cast(Object* obj); | 5806 static inline ConsString* cast(Object* obj); |
| 5788 | 5807 |
| 5789 // Layout description. | 5808 // Layout description. |
| 5790 static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize); | 5809 static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize); |
| 5791 static const int kSecondOffset = kFirstOffset + kPointerSize; | 5810 static const int kSecondOffset = kFirstOffset + kPointerSize; |
| 5792 static const int kSize = kSecondOffset + kPointerSize; | 5811 static const int kSize = kSecondOffset + kPointerSize; |
| 5793 | 5812 |
| 5794 // Support for StringInputBuffer. | 5813 // Support for StringInputBuffer. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5812 | 5831 |
| 5813 // The ExternalString class describes string values that are backed by | 5832 // The ExternalString class describes string values that are backed by |
| 5814 // a string resource that lies outside the V8 heap. ExternalStrings | 5833 // a string resource that lies outside the V8 heap. ExternalStrings |
| 5815 // consist of the length field common to all strings, a pointer to the | 5834 // consist of the length field common to all strings, a pointer to the |
| 5816 // external resource. It is important to ensure (externally) that the | 5835 // external resource. It is important to ensure (externally) that the |
| 5817 // resource is not deallocated while the ExternalString is live in the | 5836 // resource is not deallocated while the ExternalString is live in the |
| 5818 // V8 heap. | 5837 // V8 heap. |
| 5819 // | 5838 // |
| 5820 // The API expects that all ExternalStrings are created through the | 5839 // The API expects that all ExternalStrings are created through the |
| 5821 // API. Therefore, ExternalStrings should not be used internally. | 5840 // API. Therefore, ExternalStrings should not be used internally. |
| 5822 class ExternalString: public String { | 5841 class ExternalString: public FlatString { |
| 5823 public: | 5842 public: |
| 5824 // Casting | 5843 // Casting |
| 5825 static inline ExternalString* cast(Object* obj); | 5844 static inline ExternalString* cast(Object* obj); |
| 5826 | 5845 |
| 5827 // Layout description. | 5846 // Layout description. |
| 5828 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); | 5847 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); |
| 5829 static const int kSize = kResourceOffset + kPointerSize; | 5848 static const int kSize = kResourceOffset + kPointerSize; |
| 5830 | 5849 |
| 5831 STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset); | 5850 STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset); |
| 5832 | 5851 |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6712 } else { | 6731 } else { |
| 6713 value &= ~(1 << bit_position); | 6732 value &= ~(1 << bit_position); |
| 6714 } | 6733 } |
| 6715 return value; | 6734 return value; |
| 6716 } | 6735 } |
| 6717 }; | 6736 }; |
| 6718 | 6737 |
| 6719 } } // namespace v8::internal | 6738 } } // namespace v8::internal |
| 6720 | 6739 |
| 6721 #endif // V8_OBJECTS_H_ | 6740 #endif // V8_OBJECTS_H_ |
| OLD | NEW |