OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // - ExternalPixelArray | 90 // - ExternalPixelArray |
91 // - ExternalByteArray | 91 // - ExternalByteArray |
92 // - ExternalUnsignedByteArray | 92 // - ExternalUnsignedByteArray |
93 // - ExternalShortArray | 93 // - ExternalShortArray |
94 // - ExternalUnsignedShortArray | 94 // - ExternalUnsignedShortArray |
95 // - ExternalIntArray | 95 // - ExternalIntArray |
96 // - ExternalUnsignedIntArray | 96 // - ExternalUnsignedIntArray |
97 // - ExternalFloatArray | 97 // - ExternalFloatArray |
98 // - String | 98 // - String |
99 // - SeqString | 99 // - SeqString |
100 // - SeqAsciiString | 100 // - SeqOneByteString |
101 // - SeqTwoByteString | 101 // - SeqTwoByteString |
102 // - SlicedString | 102 // - SlicedString |
103 // - ConsString | 103 // - ConsString |
104 // - ExternalString | 104 // - ExternalString |
105 // - ExternalAsciiString | 105 // - ExternalAsciiString |
106 // - ExternalTwoByteString | 106 // - ExternalTwoByteString |
107 // - HeapNumber | 107 // - HeapNumber |
108 // - Code | 108 // - Code |
109 // - Map | 109 // - Map |
110 // - Oddball | 110 // - Oddball |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 V(HeapNumber) \ | 822 V(HeapNumber) \ |
823 V(String) \ | 823 V(String) \ |
824 V(Symbol) \ | 824 V(Symbol) \ |
825 V(SeqString) \ | 825 V(SeqString) \ |
826 V(ExternalString) \ | 826 V(ExternalString) \ |
827 V(ConsString) \ | 827 V(ConsString) \ |
828 V(SlicedString) \ | 828 V(SlicedString) \ |
829 V(ExternalTwoByteString) \ | 829 V(ExternalTwoByteString) \ |
830 V(ExternalAsciiString) \ | 830 V(ExternalAsciiString) \ |
831 V(SeqTwoByteString) \ | 831 V(SeqTwoByteString) \ |
832 V(SeqAsciiString) \ | 832 V(SeqOneByteString) \ |
833 \ | 833 \ |
834 V(ExternalArray) \ | 834 V(ExternalArray) \ |
835 V(ExternalByteArray) \ | 835 V(ExternalByteArray) \ |
836 V(ExternalUnsignedByteArray) \ | 836 V(ExternalUnsignedByteArray) \ |
837 V(ExternalShortArray) \ | 837 V(ExternalShortArray) \ |
838 V(ExternalUnsignedShortArray) \ | 838 V(ExternalUnsignedShortArray) \ |
839 V(ExternalIntArray) \ | 839 V(ExternalIntArray) \ |
840 V(ExternalUnsignedIntArray) \ | 840 V(ExternalUnsignedIntArray) \ |
841 V(ExternalFloatArray) \ | 841 V(ExternalFloatArray) \ |
842 V(ExternalDoubleArray) \ | 842 V(ExternalDoubleArray) \ |
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 return key->HashForObject(object); | 3030 return key->HashForObject(object); |
3031 } | 3031 } |
3032 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { | 3032 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { |
3033 return key->AsObject(); | 3033 return key->AsObject(); |
3034 } | 3034 } |
3035 | 3035 |
3036 static const int kPrefixSize = 0; | 3036 static const int kPrefixSize = 0; |
3037 static const int kEntrySize = 1; | 3037 static const int kEntrySize = 1; |
3038 }; | 3038 }; |
3039 | 3039 |
3040 class SeqAsciiString; | 3040 class SeqOneByteString; |
3041 | 3041 |
3042 // SymbolTable. | 3042 // SymbolTable. |
3043 // | 3043 // |
3044 // No special elements in the prefix and the element size is 1 | 3044 // No special elements in the prefix and the element size is 1 |
3045 // because only the symbol itself (the key) needs to be stored. | 3045 // because only the symbol itself (the key) needs to be stored. |
3046 class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> { | 3046 class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> { |
3047 public: | 3047 public: |
3048 // Find symbol in the symbol table. If it is not there yet, it is | 3048 // Find symbol in the symbol table. If it is not there yet, it is |
3049 // added. The return value is the symbol table which might have | 3049 // added. The return value is the symbol table which might have |
3050 // been enlarged. If the return value is not a failure, the symbol | 3050 // been enlarged. If the return value is not a failure, the symbol |
3051 // pointer *s is set to the symbol found. | 3051 // pointer *s is set to the symbol found. |
3052 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str, Object** s); | 3052 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str, Object** s); |
3053 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str, | 3053 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str, |
3054 Object** s); | 3054 Object** s); |
3055 MUST_USE_RESULT MaybeObject* LookupSubStringAsciiSymbol( | 3055 MUST_USE_RESULT MaybeObject* LookupSubStringAsciiSymbol( |
3056 Handle<SeqAsciiString> str, | 3056 Handle<SeqOneByteString> str, |
3057 int from, | 3057 int from, |
3058 int length, | 3058 int length, |
3059 Object** s); | 3059 Object** s); |
3060 MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol(Vector<const uc16> str, | 3060 MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol(Vector<const uc16> str, |
3061 Object** s); | 3061 Object** s); |
3062 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s); | 3062 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s); |
3063 | 3063 |
3064 // Looks up a symbol that is equal to the given string and returns | 3064 // Looks up a symbol that is equal to the given string and returns |
3065 // true if it is found, assigning the symbol to the given output | 3065 // true if it is found, assigning the symbol to the given output |
3066 // parameter. | 3066 // parameter. |
(...skipping 4507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7574 // Layout description. | 7574 // Layout description. |
7575 static const int kHeaderSize = String::kSize; | 7575 static const int kHeaderSize = String::kSize; |
7576 | 7576 |
7577 private: | 7577 private: |
7578 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); | 7578 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); |
7579 }; | 7579 }; |
7580 | 7580 |
7581 | 7581 |
7582 // The AsciiString class captures sequential ASCII string objects. | 7582 // The AsciiString class captures sequential ASCII string objects. |
7583 // Each character in the AsciiString is an ASCII character. | 7583 // Each character in the AsciiString is an ASCII character. |
7584 class SeqAsciiString: public SeqString { | 7584 class SeqOneByteString: public SeqString { |
7585 public: | 7585 public: |
7586 static const bool kHasAsciiEncoding = true; | 7586 static const bool kHasAsciiEncoding = true; |
7587 | 7587 |
7588 // Dispatched behavior. | 7588 // Dispatched behavior. |
7589 inline uint16_t SeqAsciiStringGet(int index); | 7589 inline uint16_t SeqOneByteStringGet(int index); |
7590 inline void SeqAsciiStringSet(int index, uint16_t value); | 7590 inline void SeqOneByteStringSet(int index, uint16_t value); |
7591 | 7591 |
7592 // Get the address of the characters in this string. | 7592 // Get the address of the characters in this string. |
7593 inline Address GetCharsAddress(); | 7593 inline Address GetCharsAddress(); |
7594 | 7594 |
7595 inline char* GetChars(); | 7595 inline char* GetChars(); |
7596 | 7596 |
7597 // Casting | 7597 // Casting |
7598 static inline SeqAsciiString* cast(Object* obj); | 7598 static inline SeqOneByteString* cast(Object* obj); |
7599 | 7599 |
7600 // Garbage collection support. This method is called by the | 7600 // Garbage collection support. This method is called by the |
7601 // garbage collector to compute the actual size of an AsciiString | 7601 // garbage collector to compute the actual size of an AsciiString |
7602 // instance. | 7602 // instance. |
7603 inline int SeqAsciiStringSize(InstanceType instance_type); | 7603 inline int SeqOneByteStringSize(InstanceType instance_type); |
7604 | 7604 |
7605 // Computes the size for an AsciiString instance of a given length. | 7605 // Computes the size for an AsciiString instance of a given length. |
7606 static int SizeFor(int length) { | 7606 static int SizeFor(int length) { |
7607 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); | 7607 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); |
7608 } | 7608 } |
7609 | 7609 |
7610 // Maximal memory usage for a single sequential ASCII string. | 7610 // Maximal memory usage for a single sequential ASCII string. |
7611 static const int kMaxSize = 512 * MB - 1; | 7611 static const int kMaxSize = 512 * MB - 1; |
7612 // Maximal length of a single sequential ASCII string. | 7612 // Maximal length of a single sequential ASCII string. |
7613 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 7613 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
7614 static const int kMaxLength = (kMaxSize - kHeaderSize); | 7614 static const int kMaxLength = (kMaxSize - kHeaderSize); |
7615 | 7615 |
7616 // Support for StringInputBuffer. | 7616 // Support for StringInputBuffer. |
7617 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 7617 inline void SeqOneByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
7618 unsigned* offset, | 7618 unsigned* offset, |
7619 unsigned chars); | 7619 unsigned chars); |
7620 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, | 7620 inline const unibrow::byte* SeqOneByteStringReadBlock(unsigned* remaining, |
7621 unsigned* offset, | 7621 unsigned* offset, |
7622 unsigned chars); | 7622 unsigned chars); |
7623 | 7623 |
7624 DECLARE_VERIFIER(SeqAsciiString) | 7624 DECLARE_VERIFIER(SeqOneByteString) |
7625 | 7625 |
7626 private: | 7626 private: |
7627 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqAsciiString); | 7627 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqOneByteString); |
7628 }; | 7628 }; |
7629 | 7629 |
7630 | 7630 |
7631 // The TwoByteString class captures sequential unicode string objects. | 7631 // The TwoByteString class captures sequential unicode string objects. |
7632 // Each character in the TwoByteString is a two-byte uint16_t. | 7632 // Each character in the TwoByteString is a two-byte uint16_t. |
7633 class SeqTwoByteString: public SeqString { | 7633 class SeqTwoByteString: public SeqString { |
7634 public: | 7634 public: |
7635 static const bool kHasAsciiEncoding = false; | 7635 static const bool kHasAsciiEncoding = false; |
7636 | 7636 |
7637 // Dispatched behavior. | 7637 // Dispatched behavior. |
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9018 } else { | 9018 } else { |
9019 value &= ~(1 << bit_position); | 9019 value &= ~(1 << bit_position); |
9020 } | 9020 } |
9021 return value; | 9021 return value; |
9022 } | 9022 } |
9023 }; | 9023 }; |
9024 | 9024 |
9025 } } // namespace v8::internal | 9025 } } // namespace v8::internal |
9026 | 9026 |
9027 #endif // V8_OBJECTS_H_ | 9027 #endif // V8_OBJECTS_H_ |
OLD | NEW |