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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 572 |
573 // We use the full 8 bits of the instance_type field to encode heap object | 573 // We use the full 8 bits of the instance_type field to encode heap object |
574 // instance types. The high-order bit (bit 7) is set if the object is not a | 574 // instance types. The high-order bit (bit 7) is set if the object is not a |
575 // string, and cleared if it is a string. | 575 // string, and cleared if it is a string. |
576 const uint32_t kIsNotStringMask = 0x80; | 576 const uint32_t kIsNotStringMask = 0x80; |
577 const uint32_t kStringTag = 0x0; | 577 const uint32_t kStringTag = 0x0; |
578 const uint32_t kNotStringTag = 0x80; | 578 const uint32_t kNotStringTag = 0x80; |
579 | 579 |
580 // Bit 6 indicates that the object is an internalized string (if set) or not. | 580 // Bit 6 indicates that the object is an internalized string (if set) or not. |
581 // Bit 7 has to be clear as well. | 581 // Bit 7 has to be clear as well. |
582 const uint32_t kIsInternalizedMask = 0x40; | 582 const uint32_t kIsNotInternalizedMask = 0x40; |
583 const uint32_t kNotInternalizedTag = 0x0; | 583 const uint32_t kNotInternalizedTag = 0x40; |
584 const uint32_t kInternalizedTag = 0x40; | 584 const uint32_t kInternalizedTag = 0x0; |
585 | 585 |
586 // If bit 7 is clear then bit 2 indicates whether the string consists of | 586 // If bit 7 is clear then bit 2 indicates whether the string consists of |
587 // two-byte characters or one-byte characters. | 587 // two-byte characters or one-byte characters. |
588 const uint32_t kStringEncodingMask = 0x4; | 588 const uint32_t kStringEncodingMask = 0x4; |
589 const uint32_t kTwoByteStringTag = 0x0; | 589 const uint32_t kTwoByteStringTag = 0x0; |
590 const uint32_t kOneByteStringTag = 0x4; | 590 const uint32_t kOneByteStringTag = 0x4; |
591 | 591 |
592 // If bit 7 is clear, the low-order 2 bits indicate the representation | 592 // If bit 7 is clear, the low-order 2 bits indicate the representation |
593 // of the string. | 593 // of the string. |
594 const uint32_t kStringRepresentationMask = 0x03; | 594 const uint32_t kStringRepresentationMask = 0x03; |
(...skipping 28 matching lines...) Expand all Loading... |
623 const uint32_t kShortExternalStringTag = 0x10; | 623 const uint32_t kShortExternalStringTag = 0x10; |
624 | 624 |
625 | 625 |
626 // A ConsString with an empty string as the right side is a candidate | 626 // A ConsString with an empty string as the right side is a candidate |
627 // for being shortcut by the garbage collector unless it is internalized. | 627 // for being shortcut by the garbage collector unless it is internalized. |
628 // It's not common to have non-flat internalized strings, so we do not | 628 // It's not common to have non-flat internalized strings, so we do not |
629 // shortcut them thereby avoiding turning internalized strings into strings. | 629 // shortcut them thereby avoiding turning internalized strings into strings. |
630 // See heap.cc and mark-compact.cc. | 630 // See heap.cc and mark-compact.cc. |
631 const uint32_t kShortcutTypeMask = | 631 const uint32_t kShortcutTypeMask = |
632 kIsNotStringMask | | 632 kIsNotStringMask | |
633 kIsInternalizedMask | | 633 kIsNotInternalizedMask | |
634 kStringRepresentationMask; | 634 kStringRepresentationMask; |
635 const uint32_t kShortcutTypeTag = kConsStringTag; | 635 const uint32_t kShortcutTypeTag = kConsStringTag | kNotInternalizedTag; |
636 | 636 |
637 | 637 |
638 enum InstanceType { | 638 enum InstanceType { |
639 // String types. | 639 // String types. |
640 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, | 640 INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kSeqStringTag |
641 ASCII_STRING_TYPE = kOneByteStringTag | kSeqStringTag, | 641 | kInternalizedTag, |
642 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, | 642 ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kSeqStringTag |
643 CONS_ASCII_STRING_TYPE = kOneByteStringTag | kConsStringTag, | 643 | kInternalizedTag, |
644 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, | 644 CONS_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kConsStringTag |
645 SLICED_ASCII_STRING_TYPE = kOneByteStringTag | kSlicedStringTag, | 645 | kInternalizedTag, |
646 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, | 646 CONS_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kConsStringTag |
647 EXTERNAL_ASCII_STRING_TYPE = kOneByteStringTag | kExternalStringTag, | 647 | kInternalizedTag, |
| 648 EXTERNAL_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kExternalStringTag |
| 649 | kInternalizedTag, |
| 650 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag |
| 651 | kExternalStringTag | kInternalizedTag, |
| 652 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = |
| 653 EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag |
| 654 | kInternalizedTag, |
| 655 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = |
| 656 EXTERNAL_INTERNALIZED_STRING_TYPE | kShortExternalStringTag |
| 657 | kInternalizedTag, |
| 658 SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = |
| 659 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kShortExternalStringTag |
| 660 | kInternalizedTag, |
| 661 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = |
| 662 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
| 663 | kShortExternalStringTag | kInternalizedTag, |
| 664 |
| 665 STRING_TYPE = INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
| 666 ASCII_STRING_TYPE = ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
| 667 CONS_STRING_TYPE = CONS_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
| 668 CONS_ASCII_STRING_TYPE = |
| 669 CONS_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
| 670 |
| 671 SLICED_STRING_TYPE = |
| 672 kTwoByteStringTag | kSlicedStringTag | kNotInternalizedTag, |
| 673 SLICED_ASCII_STRING_TYPE = |
| 674 kOneByteStringTag | kSlicedStringTag | kNotInternalizedTag, |
| 675 EXTERNAL_STRING_TYPE = |
| 676 EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
| 677 EXTERNAL_ASCII_STRING_TYPE = |
| 678 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
648 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = | 679 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = |
649 EXTERNAL_STRING_TYPE | kOneByteDataHintTag, | 680 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
650 SHORT_EXTERNAL_STRING_TYPE = EXTERNAL_STRING_TYPE | kShortExternalStringTag, | 681 | kNotInternalizedTag, |
| 682 SHORT_EXTERNAL_STRING_TYPE = |
| 683 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
651 SHORT_EXTERNAL_ASCII_STRING_TYPE = | 684 SHORT_EXTERNAL_ASCII_STRING_TYPE = |
652 EXTERNAL_ASCII_STRING_TYPE | kShortExternalStringTag, | 685 SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
653 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = | 686 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = |
654 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE | kShortExternalStringTag, | 687 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
655 | 688 | kNotInternalizedTag, |
656 INTERNALIZED_STRING_TYPE = STRING_TYPE | kInternalizedTag, | |
657 ASCII_INTERNALIZED_STRING_TYPE = ASCII_STRING_TYPE | kInternalizedTag, | |
658 CONS_INTERNALIZED_STRING_TYPE = CONS_STRING_TYPE | kInternalizedTag, | |
659 CONS_ASCII_INTERNALIZED_STRING_TYPE = | |
660 CONS_ASCII_STRING_TYPE | kInternalizedTag, | |
661 EXTERNAL_INTERNALIZED_STRING_TYPE = EXTERNAL_STRING_TYPE | kInternalizedTag, | |
662 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = | |
663 EXTERNAL_ASCII_STRING_TYPE | kInternalizedTag, | |
664 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = | |
665 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE | kInternalizedTag, | |
666 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = | |
667 SHORT_EXTERNAL_STRING_TYPE | kInternalizedTag, | |
668 SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = | |
669 SHORT_EXTERNAL_ASCII_STRING_TYPE | kInternalizedTag, | |
670 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = | |
671 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE | kInternalizedTag, | |
672 | 689 |
673 // Non-string names | 690 // Non-string names |
674 SYMBOL_TYPE = kNotStringTag, // LAST_NAME_TYPE, FIRST_NONSTRING_TYPE | 691 SYMBOL_TYPE = kNotStringTag, // LAST_NAME_TYPE, FIRST_NONSTRING_TYPE |
675 | 692 |
676 // Objects allocated in their own spaces (never in new space). | 693 // Objects allocated in their own spaces (never in new space). |
677 MAP_TYPE, | 694 MAP_TYPE, |
678 CODE_TYPE, | 695 CODE_TYPE, |
679 ODDBALL_TYPE, | 696 ODDBALL_TYPE, |
680 CELL_TYPE, | 697 CELL_TYPE, |
681 PROPERTY_CELL_TYPE, | 698 PROPERTY_CELL_TYPE, |
(...skipping 9153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9835 } else { | 9852 } else { |
9836 value &= ~(1 << bit_position); | 9853 value &= ~(1 << bit_position); |
9837 } | 9854 } |
9838 return value; | 9855 return value; |
9839 } | 9856 } |
9840 }; | 9857 }; |
9841 | 9858 |
9842 } } // namespace v8::internal | 9859 } } // namespace v8::internal |
9843 | 9860 |
9844 #endif // V8_OBJECTS_H_ | 9861 #endif // V8_OBJECTS_H_ |
OLD | NEW |