OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 V(JS_GLOBAL_PROXY_TYPE) \ | 289 V(JS_GLOBAL_PROXY_TYPE) \ |
290 V(JS_ARRAY_TYPE) \ | 290 V(JS_ARRAY_TYPE) \ |
291 V(JS_REGEXP_TYPE) \ | 291 V(JS_REGEXP_TYPE) \ |
292 \ | 292 \ |
293 V(JS_FUNCTION_TYPE) \ | 293 V(JS_FUNCTION_TYPE) \ |
294 | 294 |
295 | 295 |
296 // Since string types are not consecutive, this macro is used to | 296 // Since string types are not consecutive, this macro is used to |
297 // iterate over them. | 297 // iterate over them. |
298 #define STRING_TYPE_LIST(V) \ | 298 #define STRING_TYPE_LIST(V) \ |
299 V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, short_symbol) \ | 299 V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kAlignedSize, short_symbol)
\ |
300 V(MEDIUM_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, medium_symbol) \ | 300 V(MEDIUM_SYMBOL_TYPE, SeqTwoByteString::kAlignedSize, medium_symbol)
\ |
301 V(LONG_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, long_symbol) \ | 301 V(LONG_SYMBOL_TYPE, SeqTwoByteString::kAlignedSize, long_symbol)
\ |
302 V(SHORT_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, short_ascii_symbol) \ | 302 V(SHORT_ASCII_SYMBOL_TYPE, SeqAsciiString::kAlignedSize, short_ascii_symbol)
\ |
303 V(MEDIUM_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_symbol)\ | 303 V(MEDIUM_ASCII_SYMBOL_TYPE, SeqAsciiString::kAlignedSize, medium_ascii_symbol)
\ |
304 V(LONG_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, long_ascii_symbol) \ | 304 V(LONG_ASCII_SYMBOL_TYPE, SeqAsciiString::kAlignedSize, long_ascii_symbol)
\ |
305 V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol) \ | 305 V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol) \ |
306 V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol) \ | 306 V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol) \ |
307 V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol) \ | 307 V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol) \ |
308 V(SHORT_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, short_cons_ascii_symbol) \ | 308 V(SHORT_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, short_cons_ascii_symbol) \ |
309 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, medium_cons_ascii_symbol)\ | 309 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, medium_cons_ascii_symbol)\ |
310 V(LONG_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, long_cons_ascii_symbol) \ | 310 V(LONG_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, long_cons_ascii_symbol) \ |
311 V(SHORT_SLICED_SYMBOL_TYPE, SlicedString::kSize, short_sliced_symbol) \ | 311 V(SHORT_SLICED_SYMBOL_TYPE, SlicedString::kSize, short_sliced_symbol) \ |
312 V(MEDIUM_SLICED_SYMBOL_TYPE, SlicedString::kSize, medium_sliced_symbol) \ | 312 V(MEDIUM_SLICED_SYMBOL_TYPE, SlicedString::kSize, medium_sliced_symbol) \ |
313 V(LONG_SLICED_SYMBOL_TYPE, SlicedString::kSize, long_sliced_symbol) \ | 313 V(LONG_SLICED_SYMBOL_TYPE, SlicedString::kSize, long_sliced_symbol) \ |
314 V(SHORT_SLICED_ASCII_SYMBOL_TYPE, \ | 314 V(SHORT_SLICED_ASCII_SYMBOL_TYPE, \ |
(...skipping 16 matching lines...) Expand all Loading... |
331 long_external_symbol) \ | 331 long_external_symbol) \ |
332 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \ | 332 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \ |
333 ExternalAsciiString::kSize, \ | 333 ExternalAsciiString::kSize, \ |
334 short_external_ascii_symbol) \ | 334 short_external_ascii_symbol) \ |
335 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE, \ | 335 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE, \ |
336 ExternalAsciiString::kSize, \ | 336 ExternalAsciiString::kSize, \ |
337 medium_external_ascii_symbol) \ | 337 medium_external_ascii_symbol) \ |
338 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \ | 338 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \ |
339 ExternalAsciiString::kSize, \ | 339 ExternalAsciiString::kSize, \ |
340 long_external_ascii_symbol) \ | 340 long_external_ascii_symbol) \ |
341 V(SHORT_STRING_TYPE, SeqTwoByteString::kHeaderSize, short_string) \ | 341 V(SHORT_STRING_TYPE, SeqTwoByteString::kAlignedSize, short_string)
\ |
342 V(MEDIUM_STRING_TYPE, SeqTwoByteString::kHeaderSize, medium_string) \ | 342 V(MEDIUM_STRING_TYPE, SeqTwoByteString::kAlignedSize, medium_string)
\ |
343 V(LONG_STRING_TYPE, SeqTwoByteString::kHeaderSize, long_string) \ | 343 V(LONG_STRING_TYPE, SeqTwoByteString::kAlignedSize, long_string)
\ |
344 V(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, short_ascii_string) \ | 344 V(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize, short_ascii_string)
\ |
345 V(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_string)\ | 345 V(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize, medium_ascii_string)
\ |
346 V(LONG_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, long_ascii_string) \ | 346 V(LONG_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize, long_ascii_string)
\ |
347 V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string) \ | 347 V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string) \ |
348 V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string) \ | 348 V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string) \ |
349 V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string) \ | 349 V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string) \ |
350 V(SHORT_CONS_ASCII_STRING_TYPE, ConsString::kSize, short_cons_ascii_string) \ | 350 V(SHORT_CONS_ASCII_STRING_TYPE, ConsString::kSize, short_cons_ascii_string) \ |
351 V(MEDIUM_CONS_ASCII_STRING_TYPE, ConsString::kSize, medium_cons_ascii_string)\ | 351 V(MEDIUM_CONS_ASCII_STRING_TYPE, ConsString::kSize, medium_cons_ascii_string)\ |
352 V(LONG_CONS_ASCII_STRING_TYPE, ConsString::kSize, long_cons_ascii_string) \ | 352 V(LONG_CONS_ASCII_STRING_TYPE, ConsString::kSize, long_cons_ascii_string) \ |
353 V(SHORT_SLICED_STRING_TYPE, SlicedString::kSize, short_sliced_string) \ | 353 V(SHORT_SLICED_STRING_TYPE, SlicedString::kSize, short_sliced_string) \ |
354 V(MEDIUM_SLICED_STRING_TYPE, SlicedString::kSize, medium_sliced_string) \ | 354 V(MEDIUM_SLICED_STRING_TYPE, SlicedString::kSize, medium_sliced_string) \ |
355 V(LONG_SLICED_STRING_TYPE, SlicedString::kSize, long_sliced_string) \ | 355 V(LONG_SLICED_STRING_TYPE, SlicedString::kSize, long_sliced_string) \ |
356 V(SHORT_SLICED_ASCII_STRING_TYPE, \ | 356 V(SHORT_SLICED_ASCII_STRING_TYPE, \ |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 inline int length(); | 1546 inline int length(); |
1547 inline void set_length(int value); | 1547 inline void set_length(int value); |
1548 | 1548 |
1549 // Convert an object to an array index. | 1549 // Convert an object to an array index. |
1550 // Returns true if the conversion succeeded. | 1550 // Returns true if the conversion succeeded. |
1551 static inline bool IndexFromObject(Object* object, uint32_t* index); | 1551 static inline bool IndexFromObject(Object* object, uint32_t* index); |
1552 | 1552 |
1553 // Layout descriptor. | 1553 // Layout descriptor. |
1554 static const int kLengthOffset = HeapObject::kHeaderSize; | 1554 static const int kLengthOffset = HeapObject::kHeaderSize; |
1555 static const int kHeaderSize = kLengthOffset + kIntSize; | 1555 static const int kHeaderSize = kLengthOffset + kIntSize; |
| 1556 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
1556 | 1557 |
1557 private: | 1558 private: |
1558 DISALLOW_IMPLICIT_CONSTRUCTORS(Array); | 1559 DISALLOW_IMPLICIT_CONSTRUCTORS(Array); |
1559 }; | 1560 }; |
1560 | 1561 |
1561 | 1562 |
1562 // FixedArray describes fixed sized arrays where element | 1563 // FixedArray describes fixed sized arrays where element |
1563 // type is Object*. | 1564 // type is Object*. |
1564 | 1565 |
1565 class FixedArray: public Array { | 1566 class FixedArray: public Array { |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3366 void StringShortPrint(StringStream* accumulator); | 3367 void StringShortPrint(StringStream* accumulator); |
3367 #ifdef DEBUG | 3368 #ifdef DEBUG |
3368 void StringPrint(); | 3369 void StringPrint(); |
3369 void StringVerify(); | 3370 void StringVerify(); |
3370 #endif | 3371 #endif |
3371 inline bool IsFlat(); | 3372 inline bool IsFlat(); |
3372 | 3373 |
3373 // Layout description. | 3374 // Layout description. |
3374 static const int kLengthOffset = HeapObject::kHeaderSize; | 3375 static const int kLengthOffset = HeapObject::kHeaderSize; |
3375 static const int kSize = kLengthOffset + kIntSize; | 3376 static const int kSize = kLengthOffset + kIntSize; |
| 3377 // Notice: kSize is not pointer-size aligned if pointers are 64-bit. |
3376 | 3378 |
3377 // Limits on sizes of different types of strings. | 3379 // Limits on sizes of different types of strings. |
3378 static const int kMaxShortStringSize = 63; | 3380 static const int kMaxShortStringSize = 63; |
3379 static const int kMaxMediumStringSize = 16383; | 3381 static const int kMaxMediumStringSize = 16383; |
3380 | 3382 |
3381 static const int kMaxArrayIndexSize = 10; | 3383 static const int kMaxArrayIndexSize = 10; |
3382 | 3384 |
3383 // Max ascii char code. | 3385 // Max ascii char code. |
3384 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 3386 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
3385 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; | 3387 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3519 // instance. | 3521 // instance. |
3520 inline int SeqAsciiStringSize(InstanceType instance_type); | 3522 inline int SeqAsciiStringSize(InstanceType instance_type); |
3521 | 3523 |
3522 // Computes the size for an AsciiString instance of a given length. | 3524 // Computes the size for an AsciiString instance of a given length. |
3523 static int SizeFor(int length) { | 3525 static int SizeFor(int length) { |
3524 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); | 3526 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); |
3525 } | 3527 } |
3526 | 3528 |
3527 // Layout description. | 3529 // Layout description. |
3528 static const int kHeaderSize = String::kSize; | 3530 static const int kHeaderSize = String::kSize; |
| 3531 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
3529 | 3532 |
3530 // Support for StringInputBuffer. | 3533 // Support for StringInputBuffer. |
3531 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3534 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
3532 unsigned* offset, | 3535 unsigned* offset, |
3533 unsigned chars); | 3536 unsigned chars); |
3534 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, | 3537 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, |
3535 unsigned* offset, | 3538 unsigned* offset, |
3536 unsigned chars); | 3539 unsigned chars); |
3537 | 3540 |
3538 private: | 3541 private: |
(...skipping 25 matching lines...) Expand all Loading... |
3564 // instance. | 3567 // instance. |
3565 inline int SeqTwoByteStringSize(InstanceType instance_type); | 3568 inline int SeqTwoByteStringSize(InstanceType instance_type); |
3566 | 3569 |
3567 // Computes the size for a TwoByteString instance of a given length. | 3570 // Computes the size for a TwoByteString instance of a given length. |
3568 static int SizeFor(int length) { | 3571 static int SizeFor(int length) { |
3569 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); | 3572 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); |
3570 } | 3573 } |
3571 | 3574 |
3572 // Layout description. | 3575 // Layout description. |
3573 static const int kHeaderSize = String::kSize; | 3576 static const int kHeaderSize = String::kSize; |
| 3577 static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); |
3574 | 3578 |
3575 // Support for StringInputBuffer. | 3579 // Support for StringInputBuffer. |
3576 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | 3580 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
3577 unsigned* offset_ptr, | 3581 unsigned* offset_ptr, |
3578 unsigned chars); | 3582 unsigned chars); |
3579 | 3583 |
3580 private: | 3584 private: |
3581 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); | 3585 DISALLOW_IMPLICIT_CONSTRUCTORS(SeqTwoByteString); |
3582 }; | 3586 }; |
3583 | 3587 |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4389 } else { | 4393 } else { |
4390 value &= ~(1 << bit_position); | 4394 value &= ~(1 << bit_position); |
4391 } | 4395 } |
4392 return value; | 4396 return value; |
4393 } | 4397 } |
4394 }; | 4398 }; |
4395 | 4399 |
4396 } } // namespace v8::internal | 4400 } } // namespace v8::internal |
4397 | 4401 |
4398 #endif // V8_OBJECTS_H_ | 4402 #endif // V8_OBJECTS_H_ |
OLD | NEW |