OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 const uint32_t kOneByteDataHintMask = 0x08; | 612 const uint32_t kOneByteDataHintMask = 0x08; |
613 const uint32_t kOneByteDataHintTag = 0x08; | 613 const uint32_t kOneByteDataHintTag = 0x08; |
614 | 614 |
615 // If bit 7 is clear and string representation indicates an external string, | 615 // If bit 7 is clear and string representation indicates an external string, |
616 // then bit 4 indicates whether the data pointer is cached. | 616 // then bit 4 indicates whether the data pointer is cached. |
617 const uint32_t kShortExternalStringMask = 0x10; | 617 const uint32_t kShortExternalStringMask = 0x10; |
618 const uint32_t kShortExternalStringTag = 0x10; | 618 const uint32_t kShortExternalStringTag = 0x10; |
619 | 619 |
620 | 620 |
621 // A ConsString with an empty string as the right side is a candidate | 621 // A ConsString with an empty string as the right side is a candidate |
622 // for being shortcut by the garbage collector unless it is internalized. | 622 // for being shortcut by the garbage collector. We don't allocate any |
623 // It's not common to have non-flat internalized strings, so we do not | 623 // non-flat internalized strings, so we do not shortcut them thereby |
624 // shortcut them thereby avoiding turning internalized strings into strings. | 624 // avoiding turning internalized strings into strings. The bit-masks |
625 // See heap.cc and mark-compact.cc. | 625 // below contain the internalized bit as additional safety. |
| 626 // See heap.cc, mark-compact.cc and objects-visiting.cc. |
626 const uint32_t kShortcutTypeMask = | 627 const uint32_t kShortcutTypeMask = |
627 kIsNotStringMask | | 628 kIsNotStringMask | |
628 kIsNotInternalizedMask | | 629 kIsNotInternalizedMask | |
629 kStringRepresentationMask; | 630 kStringRepresentationMask; |
630 const uint32_t kShortcutTypeTag = kConsStringTag | kNotInternalizedTag; | 631 const uint32_t kShortcutTypeTag = kConsStringTag | kNotInternalizedTag; |
631 | 632 |
| 633 static inline bool IsShortcutCandidate(int type) { |
| 634 return ((type & kShortcutTypeMask) == kShortcutTypeTag); |
| 635 } |
| 636 |
632 | 637 |
633 enum InstanceType { | 638 enum InstanceType { |
634 // String types. | 639 // String types. |
635 INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kSeqStringTag | 640 INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kSeqStringTag |
636 | kInternalizedTag, | 641 | kInternalizedTag, |
637 ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kSeqStringTag | 642 ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | kSeqStringTag |
638 | kInternalizedTag, | 643 | kInternalizedTag, |
639 EXTERNAL_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kExternalStringTag | 644 EXTERNAL_INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kExternalStringTag |
640 | kInternalizedTag, | 645 | kInternalizedTag, |
641 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag | 646 EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE = kOneByteStringTag |
(...skipping 10587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11229 } else { | 11234 } else { |
11230 value &= ~(1 << bit_position); | 11235 value &= ~(1 << bit_position); |
11231 } | 11236 } |
11232 return value; | 11237 return value; |
11233 } | 11238 } |
11234 }; | 11239 }; |
11235 | 11240 |
11236 } } // namespace v8::internal | 11241 } } // namespace v8::internal |
11237 | 11242 |
11238 #endif // V8_OBJECTS_H_ | 11243 #endif // V8_OBJECTS_H_ |
OLD | NEW |