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

Unified Diff: src/objects-inl.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-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 53a3183694cbfdfc87f16524888036e27d434d14..a589a0626a0aabe6f704d1bac59d2c82acbfa6c5 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -184,6 +184,14 @@ bool Object::IsConsString() {
}
+bool Object::IsSlicedString() {
+ if (!this->IsHeapObject()) return false;
+ uint32_t type = HeapObject::cast(this)->map()->instance_type();
+ return (type & (kIsNotStringMask | kStringRepresentationMask)) ==
antonm 2011/07/27 12:16:39 probably is worth refactoring.
+ (kStringTag | kSlicedStringTag);
+}
+
+
bool Object::IsSeqString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential();
@@ -280,6 +288,11 @@ bool StringShape::IsCons() {
}
+bool StringShape::IsSliced() {
+ return (type_ & kStringRepresentationMask) == kSlicedStringTag;
+}
+
+
bool StringShape::IsExternal() {
return (type_ & kStringRepresentationMask) == kExternalStringTag;
}
@@ -2041,6 +2054,7 @@ CAST_ACCESSOR(String)
CAST_ACCESSOR(SeqString)
CAST_ACCESSOR(SeqAsciiString)
CAST_ACCESSOR(SeqTwoByteString)
+CAST_ACCESSOR(SlicedString)
CAST_ACCESSOR(ConsString)
CAST_ACCESSOR(ExternalString)
CAST_ACCESSOR(ExternalAsciiString)
@@ -2156,6 +2170,9 @@ uint16_t String::Get(int index) {
return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index);
case kExternalStringTag | kTwoByteStringTag:
return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
+ case kSlicedStringTag | kAsciiStringTag:
+ case kSlicedStringTag | kTwoByteStringTag:
+ return SlicedString::cast(this)->SlicedStringGet(index);
default:
break;
}
@@ -2243,6 +2260,20 @@ int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) {
}
+String* SlicedString::parent() {
+ return String::cast(READ_FIELD(this, kParentOffset));
+}
+
+
+void SlicedString::set_parent(String* parent, WriteBarrierMode mode) {
+ WRITE_FIELD(this, kParentOffset, parent);
antonm 2011/07/27 12:16:39 maybe add an assert that parent is never a sliced
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, mode);
+}
+
+
+SMI_ACCESSORS(SlicedString, offset, kOffsetOffset)
+
+
String* ConsString::first() {
return String::cast(READ_FIELD(this, kFirstOffset));
}

Powered by Google App Engine
This is Rietveld 408576698