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, |
Yang
2013/07/19 09:45:06
I would prefer to have the kInternalizedTag added
mvstanton
2013/07/19 11:07:42
Done.
| |
641 ASCII_STRING_TYPE = kOneByteStringTag | kSeqStringTag, | 641 ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kSeqStringTag, |
642 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, | 642 CONS_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
643 CONS_ASCII_STRING_TYPE = kOneByteStringTag | kConsStringTag, | 643 CONS_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kConsStringTag, |
644 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, | 644 EXTERNAL_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
645 SLICED_ASCII_STRING_TYPE = kOneByteStringTag | kSlicedStringTag, | 645 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag |
646 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, | 646 | kExternalStringTag, |
647 EXTERNAL_ASCII_STRING_TYPE = kOneByteStringTag | kExternalStringTag, | 647 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = |
648 EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag, | |
649 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = | |
650 EXTERNAL_INTERNALIZED_STRING_TYPE | kShortExternalStringTag, | |
651 SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = | |
652 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kShortExternalStringTag, | |
653 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = | |
654 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE | |
655 | kShortExternalStringTag, | |
656 | |
657 STRING_TYPE = INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
658 ASCII_STRING_TYPE = ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
659 CONS_STRING_TYPE = CONS_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
660 CONS_ASCII_STRING_TYPE = | |
661 CONS_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
662 | |
663 SLICED_STRING_TYPE = | |
664 kTwoByteStringTag | kSlicedStringTag | kNotInternalizedTag, | |
665 SLICED_ASCII_STRING_TYPE = | |
666 kOneByteStringTag | kSlicedStringTag | kNotInternalizedTag, | |
667 EXTERNAL_STRING_TYPE = | |
668 EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
669 EXTERNAL_ASCII_STRING_TYPE = | |
670 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
648 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = | 671 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = |
649 EXTERNAL_STRING_TYPE | kOneByteDataHintTag, | 672 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
650 SHORT_EXTERNAL_STRING_TYPE = EXTERNAL_STRING_TYPE | kShortExternalStringTag, | 673 | kNotInternalizedTag, |
674 SHORT_EXTERNAL_STRING_TYPE = | |
675 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, | |
651 SHORT_EXTERNAL_ASCII_STRING_TYPE = | 676 SHORT_EXTERNAL_ASCII_STRING_TYPE = |
652 EXTERNAL_ASCII_STRING_TYPE | kShortExternalStringTag, | 677 SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, |
653 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = | 678 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = |
654 EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE | kShortExternalStringTag, | 679 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
655 | 680 | 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 | 681 |
673 // Non-string names | 682 // Non-string names |
674 SYMBOL_TYPE = kNotStringTag, // LAST_NAME_TYPE, FIRST_NONSTRING_TYPE | 683 SYMBOL_TYPE = kNotStringTag, // LAST_NAME_TYPE, FIRST_NONSTRING_TYPE |
675 | 684 |
676 // Objects allocated in their own spaces (never in new space). | 685 // Objects allocated in their own spaces (never in new space). |
677 MAP_TYPE, | 686 MAP_TYPE, |
678 CODE_TYPE, | 687 CODE_TYPE, |
679 ODDBALL_TYPE, | 688 ODDBALL_TYPE, |
680 CELL_TYPE, | 689 CELL_TYPE, |
681 PROPERTY_CELL_TYPE, | 690 PROPERTY_CELL_TYPE, |
(...skipping 9153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9835 } else { | 9844 } else { |
9836 value &= ~(1 << bit_position); | 9845 value &= ~(1 << bit_position); |
9837 } | 9846 } |
9838 return value; | 9847 return value; |
9839 } | 9848 } |
9840 }; | 9849 }; |
9841 | 9850 |
9842 } } // namespace v8::internal | 9851 } } // namespace v8::internal |
9843 | 9852 |
9844 #endif // V8_OBJECTS_H_ | 9853 #endif // V8_OBJECTS_H_ |
OLD | NEW |