Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: src/objects.h

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: forgot one Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index ff67447f31a9e3db0d64ea872574fc6c06349ac9..19800c454cc8ca638fd4aa168f15a2410a3b4476 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -107,6 +107,7 @@
// - SeqTwoByteString
// - SlicedString
// - ConsString
+// - ThinString
// - ExternalString
// - ExternalOneByteString
// - ExternalTwoByteString
@@ -324,6 +325,8 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(ONE_BYTE_STRING_TYPE) \
V(CONS_STRING_TYPE) \
V(CONS_ONE_BYTE_STRING_TYPE) \
+ V(THIN_STRING_TYPE) \
+ V(THIN_ONE_BYTE_STRING_TYPE) \
V(SLICED_STRING_TYPE) \
V(SLICED_ONE_BYTE_STRING_TYPE) \
V(EXTERNAL_STRING_TYPE) \
@@ -524,7 +527,10 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE, \
ExternalTwoByteString::kShortSize, \
short_external_internalized_string_with_one_byte_data, \
- ShortExternalInternalizedStringWithOneByteData)
+ ShortExternalInternalizedStringWithOneByteData) \
+ V(THIN_STRING_TYPE, ThinString::kSize, thin_string, ThinString) \
+ V(THIN_ONE_BYTE_STRING_TYPE, ThinString::kSize, thin_one_byte_string, \
+ ThinOneByteString)
// A struct is a simple object a set of object-valued fields. Including an
// object type in this causes the compiler to generate most of the boilerplate
@@ -576,20 +582,21 @@ const uint32_t kIsNotInternalizedMask = 0x40;
const uint32_t kNotInternalizedTag = 0x40;
const uint32_t kInternalizedTag = 0x0;
-// If bit 7 is clear then bit 2 indicates whether the string consists of
+// 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 = 0x4;
+const uint32_t kStringEncodingMask = 0x8;
const uint32_t kTwoByteStringTag = 0x0;
-const uint32_t kOneByteStringTag = 0x4;
+const uint32_t kOneByteStringTag = 0x8;
-// If bit 7 is clear, the low-order 2 bits indicate the representation
+// If bit 7 is clear, the low-order 3 bits indicate the representation
// of the string.
-const uint32_t kStringRepresentationMask = 0x03;
+const uint32_t kStringRepresentationMask = 0x07;
enum StringRepresentationTag {
kSeqStringTag = 0x0,
kConsStringTag = 0x1,
kExternalStringTag = 0x2,
- kSlicedStringTag = 0x3
+ kSlicedStringTag = 0x3,
+ kThinStringTag = 0x5
};
const uint32_t kIsIndirectStringMask = 0x1;
const uint32_t kIsIndirectStringTag = 0x1;
@@ -599,22 +606,17 @@ STATIC_ASSERT((kConsStringTag &
kIsIndirectStringMask) == kIsIndirectStringTag); // NOLINT
STATIC_ASSERT((kSlicedStringTag &
kIsIndirectStringMask) == kIsIndirectStringTag); // NOLINT
+STATIC_ASSERT((kThinStringTag & kIsIndirectStringMask) == kIsIndirectStringTag);
-// Use this mask to distinguish between cons and slice only after making
-// sure that the string is one of the two (an indirect string).
-const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag;
-STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask));
-
-// If bit 7 is clear, then bit 3 indicates whether this two-byte
+// If bit 7 is clear, then bit 4 indicates whether this two-byte
// string actually contains one byte data.
-const uint32_t kOneByteDataHintMask = 0x08;
-const uint32_t kOneByteDataHintTag = 0x08;
+const uint32_t kOneByteDataHintMask = 0x10;
+const uint32_t kOneByteDataHintTag = 0x10;
// If bit 7 is clear and string representation indicates an external string,
-// then bit 4 indicates whether the data pointer is cached.
-const uint32_t kShortExternalStringMask = 0x10;
-const uint32_t kShortExternalStringTag = 0x10;
-
+// then bit 5 indicates whether the data pointer is cached.
+const uint32_t kShortExternalStringMask = 0x20;
+const uint32_t kShortExternalStringTag = 0x20;
// 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
@@ -678,6 +680,9 @@ enum InstanceType {
SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE =
SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
kNotInternalizedTag,
+ THIN_STRING_TYPE = kTwoByteStringTag | kThinStringTag | kNotInternalizedTag,
+ THIN_ONE_BYTE_STRING_TYPE =
+ kOneByteStringTag | kThinStringTag | kNotInternalizedTag,
// Non-string names
SYMBOL_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE, LAST_NAME_TYPE
@@ -1052,6 +1057,7 @@ template <class C> inline bool Is(Object* obj);
V(SeqTwoByteString) \
V(SeqOneByteString) \
V(InternalizedString) \
+ V(ThinString) \
V(Symbol) \
\
V(FixedTypedArrayBase) \
@@ -9595,6 +9601,7 @@ class StringShape BASE_EMBEDDED {
inline bool IsExternal();
inline bool IsCons();
inline bool IsSliced();
+ inline bool IsThin();
inline bool IsIndirect();
inline bool IsExternalOneByte();
inline bool IsExternalTwoByte();
@@ -10307,6 +10314,27 @@ class ConsString: public String {
DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString);
};
+class ThinString : public String {
Hannes Payer (out of office) 2016/12/21 09:53:14 Please add a description what a ThinString is.
Jakob Kummerow 2017/01/04 12:45:06 Done.
+ public:
+ // Actual string that this ThinString refers to.
+ inline String* actual() const;
+ inline void set_actual(String* s,
+ WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
+
+ V8_EXPORT_PRIVATE uint16_t ThinStringGet(int index);
+
+ DECLARE_CAST(ThinString)
+ DECLARE_VERIFIER(ThinString)
+
+ // Layout description.
+ static const int kActualOffset = String::kSize;
+ static const int kSize = kActualOffset + kPointerSize;
+
+ typedef FixedBodyDescriptor<kActualOffset, kSize, kSize> BodyDescriptor;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ThinString);
+};
// The Sliced String class describes strings that are substrings of another
// sequential string. The motivation is to save time and memory when creating

Powered by Google App Engine
This is Rietveld 408576698