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

Unified Diff: src/objects.h

Issue 7477045: Tentative implementation of string slices (hidden under the flag --string-slices). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 months 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 9ef14dbdab6868ed3f2e5461b02be1351dc8f597..20fd36b7b59fba6817d0776ebd7f3249813e472f 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -86,6 +86,7 @@
// - SeqString
// - SeqAsciiString
// - SeqTwoByteString
+// - SlicedString
// - ConsString
// - ExternalString
// - ExternalAsciiString
@@ -280,6 +281,7 @@ static const int kVariableSizeSentinel = 0;
V(ASCII_STRING_TYPE) \
V(CONS_STRING_TYPE) \
V(CONS_ASCII_STRING_TYPE) \
+ V(SLICED_STRING_TYPE) \
V(EXTERNAL_STRING_TYPE) \
V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \
V(EXTERNAL_ASCII_STRING_TYPE) \
@@ -368,6 +370,14 @@ static const int kVariableSizeSentinel = 0;
ConsString::kSize, \
cons_ascii_symbol, \
ConsAsciiSymbol) \
+ V(SLICED_SYMBOL_TYPE, \
+ SlicedString::kSize, \
+ sliced_symbol, \
+ SlicedSymbol) \
+ V(SLICED_ASCII_SYMBOL_TYPE, \
+ SlicedString::kSize, \
+ sliced_ascii_symbol, \
+ SlicedAsciiSymbol) \
V(EXTERNAL_SYMBOL_TYPE, \
ExternalTwoByteString::kSize, \
external_symbol, \
@@ -396,6 +406,14 @@ static const int kVariableSizeSentinel = 0;
ConsString::kSize, \
cons_ascii_string, \
ConsAsciiString) \
+ V(SLICED_STRING_TYPE, \
+ SlicedString::kSize, \
+ sliced_string, \
+ SlicedString) \
+ V(SLICED_ASCII_STRING_TYPE, \
+ SlicedString::kSize, \
+ sliced_ascii_string, \
+ SlicedAsciiString) \
V(EXTERNAL_STRING_TYPE, \
ExternalTwoByteString::kSize, \
external_string, \
@@ -469,9 +487,11 @@ const uint32_t kStringRepresentationMask = 0x03;
enum StringRepresentationTag {
kSeqStringTag = 0x0,
kConsStringTag = 0x1,
- kExternalStringTag = 0x2
+ kExternalStringTag = 0x2,
+ kSlicedStringTag = 0x3
};
-const uint32_t kIsConsStringMask = 0x1;
+const uint32_t kIsIndirectStringMask = 0x1;
+const uint32_t kIsIndirectStringTag = 0x1;
antonm 2011/07/27 12:16:39 maybe worth adding some documentation why it works
// If bit 7 is clear, then bit 3 indicates whether this two-byte
// string actually contains ascii data.
@@ -497,6 +517,8 @@ enum InstanceType {
ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSeqStringTag,
CONS_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kConsStringTag,
CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag,
+ SLICED_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kSlicedStringTag,
+ SLICED_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSlicedStringTag,
EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag,
EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE =
kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag,
@@ -506,6 +528,8 @@ enum InstanceType {
ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag,
CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag,
CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag,
+ SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag,
+ SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag,
EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag,
EXTERNAL_STRING_WITH_ASCII_DATA_TYPE =
kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag,
@@ -709,6 +733,7 @@ class MaybeObject BASE_EMBEDDED {
V(SeqString) \
V(ExternalString) \
V(ConsString) \
+ V(SlicedString) \
V(ExternalTwoByteString) \
V(ExternalAsciiString) \
V(SeqTwoByteString) \
@@ -5709,6 +5734,7 @@ class StringShape BASE_EMBEDDED {
inline bool IsSequential();
inline bool IsExternal();
inline bool IsCons();
+ inline bool IsSliced();
inline bool IsExternalAscii();
inline bool IsExternalTwoByte();
inline bool IsSequentialAscii();
@@ -6228,6 +6254,44 @@ class ConsString: public String {
};
+class SlicedString: public String {
+ public:
+
+ inline String* parent();
+ inline void set_parent(String* parent, WriteBarrierMode mode);
+ inline int offset();
+ inline void set_offset(int offset);
+
+ // Dispatched behavior.
+ uint16_t SlicedStringGet(int index);
+
+ // Casting.
+ static inline SlicedString* cast(Object* obj);
+
+ // Layout description.
+ static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize);
+ static const int kOffsetOffset = kParentOffset + kPointerSize;
+ static const int kSize = kOffsetOffset + kPointerSize;
+
+ // Support for StringInputBuffer
+ inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer,
+ unsigned* offset_ptr,
+ unsigned chars);
+ inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
+ unsigned* offset_ptr,
+ unsigned chars);
+ // Minimum length for a sliced string.
+ static const int kMinLength = 13;
+
+ typedef FixedBodyDescriptor<kParentOffset,
+ kOffsetOffset + kPointerSize, kSize>
+ BodyDescriptor;
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString);
+};
+
+
// The ExternalString class describes string values that are backed by
// a string resource that lies outside the V8 heap. ExternalStrings
// consist of the length field common to all strings, a pointer to the

Powered by Google App Engine
This is Rietveld 408576698