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 6112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6123 DISALLOW_IMPLICIT_CONSTRUCTORS(String); | 6123 DISALLOW_IMPLICIT_CONSTRUCTORS(String); |
6124 }; | 6124 }; |
6125 | 6125 |
6126 | 6126 |
6127 // The SeqString abstract class captures sequential string values. | 6127 // The SeqString abstract class captures sequential string values. |
6128 class SeqString: public String { | 6128 class SeqString: public String { |
6129 public: | 6129 public: |
6130 // Casting. | 6130 // Casting. |
6131 static inline SeqString* cast(Object* obj); | 6131 static inline SeqString* cast(Object* obj); |
6132 | 6132 |
| 6133 // Layout description. |
| 6134 static const int kHeaderSize = String::kSize; |
| 6135 |
6133 private: | 6136 private: |
6134 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); | 6137 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); |
6135 }; | 6138 }; |
6136 | 6139 |
6137 | 6140 |
6138 // The AsciiString class captures sequential ascii string objects. | 6141 // The AsciiString class captures sequential ascii string objects. |
6139 // Each character in the AsciiString is an ascii character. | 6142 // Each character in the AsciiString is an ascii character. |
6140 class SeqAsciiString: public SeqString { | 6143 class SeqAsciiString: public SeqString { |
6141 public: | 6144 public: |
6142 static const bool kHasAsciiEncoding = true; | 6145 static const bool kHasAsciiEncoding = true; |
(...skipping 13 matching lines...) Expand all Loading... |
6156 // Garbage collection support. This method is called by the | 6159 // Garbage collection support. This method is called by the |
6157 // garbage collector to compute the actual size of an AsciiString | 6160 // garbage collector to compute the actual size of an AsciiString |
6158 // instance. | 6161 // instance. |
6159 inline int SeqAsciiStringSize(InstanceType instance_type); | 6162 inline int SeqAsciiStringSize(InstanceType instance_type); |
6160 | 6163 |
6161 // Computes the size for an AsciiString instance of a given length. | 6164 // Computes the size for an AsciiString instance of a given length. |
6162 static int SizeFor(int length) { | 6165 static int SizeFor(int length) { |
6163 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); | 6166 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kCharSize); |
6164 } | 6167 } |
6165 | 6168 |
6166 // Layout description. | |
6167 static const int kHeaderSize = String::kSize; | |
6168 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | |
6169 | |
6170 // Maximal memory usage for a single sequential ASCII string. | 6169 // Maximal memory usage for a single sequential ASCII string. |
6171 static const int kMaxSize = 512 * MB - 1; | 6170 static const int kMaxSize = 512 * MB - 1; |
6172 // Maximal length of a single sequential ASCII string. | 6171 // Maximal length of a single sequential ASCII string. |
6173 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 6172 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
6174 static const int kMaxLength = (kMaxSize - kHeaderSize); | 6173 static const int kMaxLength = (kMaxSize - kHeaderSize); |
6175 | 6174 |
6176 // Support for StringInputBuffer. | 6175 // Support for StringInputBuffer. |
6177 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 6176 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
6178 unsigned* offset, | 6177 unsigned* offset, |
6179 unsigned chars); | 6178 unsigned chars); |
(...skipping 30 matching lines...) Expand all Loading... |
6210 // Garbage collection support. This method is called by the | 6209 // Garbage collection support. This method is called by the |
6211 // garbage collector to compute the actual size of a TwoByteString | 6210 // garbage collector to compute the actual size of a TwoByteString |
6212 // instance. | 6211 // instance. |
6213 inline int SeqTwoByteStringSize(InstanceType instance_type); | 6212 inline int SeqTwoByteStringSize(InstanceType instance_type); |
6214 | 6213 |
6215 // Computes the size for a TwoByteString instance of a given length. | 6214 // Computes the size for a TwoByteString instance of a given length. |
6216 static int SizeFor(int length) { | 6215 static int SizeFor(int length) { |
6217 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); | 6216 return OBJECT_POINTER_ALIGN(kHeaderSize + length * kShortSize); |
6218 } | 6217 } |
6219 | 6218 |
6220 // Layout description. | |
6221 static const int kHeaderSize = String::kSize; | |
6222 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); | |
6223 | |
6224 // Maximal memory usage for a single sequential two-byte string. | 6219 // Maximal memory usage for a single sequential two-byte string. |
6225 static const int kMaxSize = 512 * MB - 1; | 6220 static const int kMaxSize = 512 * MB - 1; |
6226 // Maximal length of a single sequential two-byte string. | 6221 // Maximal length of a single sequential two-byte string. |
6227 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. | 6222 // Q.v. String::kMaxLength which is the maximal size of concatenated strings. |
6228 static const int kMaxLength = (kMaxSize - kHeaderSize) / sizeof(uint16_t); | 6223 static const int kMaxLength = (kMaxSize - kHeaderSize) / sizeof(uint16_t); |
6229 | 6224 |
6230 // Support for StringInputBuffer. | 6225 // Support for StringInputBuffer. |
6231 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 6226 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
6232 unsigned* offset_ptr, | 6227 unsigned* offset_ptr, |
6233 unsigned chars); | 6228 unsigned chars); |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7396 } else { | 7391 } else { |
7397 value &= ~(1 << bit_position); | 7392 value &= ~(1 << bit_position); |
7398 } | 7393 } |
7399 return value; | 7394 return value; |
7400 } | 7395 } |
7401 }; | 7396 }; |
7402 | 7397 |
7403 } } // namespace v8::internal | 7398 } } // namespace v8::internal |
7404 | 7399 |
7405 #endif // V8_OBJECTS_H_ | 7400 #endif // V8_OBJECTS_H_ |
OLD | NEW |