[objects] Clean up string instance type docs
Moves the string instance type tag definitions around to be in order, makes their definitions slightly clearer (in terms of shifted 1 rather than hex values), and unifies/fixes the descriptions of the bits in the comments. Bug: v8:8834 Change-Id: I632b93053734445264f6c607c541e4171aae8038 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1539583 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#60466}
This commit is contained in:
parent
e6fbf933b8
commit
e1f5da3cff
@ -15,26 +15,14 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// We use the full 16 bits of the instance_type field to encode heap object
|
||||
// instance types. All the high-order bits (bit 7-15) are cleared if the object
|
||||
// instance types. All the high-order bits (bits 7-15) are cleared if the object
|
||||
// is a string, and contain set bits if it is not a string.
|
||||
const uint32_t kIsNotStringMask = 0xff80;
|
||||
const uint32_t kIsNotStringMask = ~((1 << 7) - 1);
|
||||
const uint32_t kStringTag = 0x0;
|
||||
|
||||
// Bit 5 indicates that the object is an internalized string (if not set) or
|
||||
// not (if set). Bit 7 has to be clear as well.
|
||||
const uint32_t kIsNotInternalizedMask = 0x20;
|
||||
const uint32_t kNotInternalizedTag = 0x20;
|
||||
const uint32_t kInternalizedTag = 0x0;
|
||||
|
||||
// If bit 7 is clear then bit 3 indicates whether the string consists of
|
||||
// two-byte characters or one-byte characters.
|
||||
const uint32_t kStringEncodingMask = 0x8;
|
||||
const uint32_t kTwoByteStringTag = 0x0;
|
||||
const uint32_t kOneByteStringTag = 0x8;
|
||||
|
||||
// If bit 7 is clear, the low-order 3 bits indicate the representation
|
||||
// of the string.
|
||||
const uint32_t kStringRepresentationMask = 0x07;
|
||||
// For strings, bits 0-2 indicate the representation of the string. In
|
||||
// particular, bit 0 indicates whether the string is direct or indirect.
|
||||
const uint32_t kStringRepresentationMask = (1 << 3) - 1;
|
||||
enum StringRepresentationTag {
|
||||
kSeqStringTag = 0x0,
|
||||
kConsStringTag = 0x1,
|
||||
@ -42,25 +30,38 @@ enum StringRepresentationTag {
|
||||
kSlicedStringTag = 0x3,
|
||||
kThinStringTag = 0x5
|
||||
};
|
||||
const uint32_t kIsIndirectStringMask = 0x1;
|
||||
const uint32_t kIsIndirectStringTag = 0x1;
|
||||
STATIC_ASSERT((kSeqStringTag & kIsIndirectStringMask) == 0); // NOLINT
|
||||
STATIC_ASSERT((kExternalStringTag & kIsIndirectStringMask) == 0); // NOLINT
|
||||
STATIC_ASSERT((kConsStringTag & kIsIndirectStringMask) ==
|
||||
kIsIndirectStringTag); // NOLINT
|
||||
const uint32_t kIsIndirectStringMask = 1 << 0;
|
||||
const uint32_t kIsIndirectStringTag = 1 << 0;
|
||||
STATIC_ASSERT((kSeqStringTag & kIsIndirectStringMask) == 0);
|
||||
STATIC_ASSERT((kExternalStringTag & kIsIndirectStringMask) == 0);
|
||||
STATIC_ASSERT((kConsStringTag & kIsIndirectStringMask) == kIsIndirectStringTag);
|
||||
STATIC_ASSERT((kSlicedStringTag & kIsIndirectStringMask) ==
|
||||
kIsIndirectStringTag); // NOLINT
|
||||
kIsIndirectStringTag);
|
||||
STATIC_ASSERT((kThinStringTag & kIsIndirectStringMask) == kIsIndirectStringTag);
|
||||
|
||||
// If bit 6 is clear and string representation indicates an external string,
|
||||
// then bit 5 indicates whether the data pointer is cached.
|
||||
const uint32_t kUncachedExternalStringMask = 0x10;
|
||||
const uint32_t kUncachedExternalStringTag = 0x10;
|
||||
// For strings, bit 3 indicates whether the string consists of two-byte
|
||||
// characters or one-byte characters.
|
||||
const uint32_t kStringEncodingMask = 1 << 3;
|
||||
const uint32_t kTwoByteStringTag = 0;
|
||||
const uint32_t kOneByteStringTag = 1 << 3;
|
||||
|
||||
// For strings, bit 4 indicates whether the data pointer of an external string
|
||||
// is cached. Note that the string representation is expected to be
|
||||
// kExternalStringTag.
|
||||
const uint32_t kUncachedExternalStringMask = 1 << 4;
|
||||
const uint32_t kUncachedExternalStringTag = 1 << 4;
|
||||
|
||||
// For strings, bit 5 indicates that the string is internalized (if not set) or
|
||||
// isn't (if set).
|
||||
const uint32_t kIsNotInternalizedMask = 1 << 5;
|
||||
const uint32_t kNotInternalizedTag = 1 << 5;
|
||||
const uint32_t kInternalizedTag = 0;
|
||||
|
||||
// For strings, bit 6 indicates that the string is empty.
|
||||
// TODO(bmeurer)
|
||||
const uint32_t kIsEmptyStringMask = 0x40;
|
||||
const uint32_t kIsEmptyStringTag = 0x40;
|
||||
const uint32_t kIsNotEmptyStringTag = 0x0;
|
||||
const uint32_t kIsEmptyStringMask = 1 << 6;
|
||||
const uint32_t kIsEmptyStringTag = 1 << 6;
|
||||
const uint32_t kIsNotEmptyStringTag = 0;
|
||||
|
||||
// A ConsString with an empty string as the right side is a candidate
|
||||
// for being shortcut by the garbage collector. We don't allocate any
|
||||
|
Loading…
Reference in New Issue
Block a user