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