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

Unified Diff: src/objects-inl.h

Issue 8568013: Introduce read buffer for external strings when using charAt (ia32). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years, 1 month 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
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 11819eaa09d13db19bf029f07c9b92a960c72c31..9946c88c13a99f5c0741ab44106a6ba46e15c687 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -256,11 +256,13 @@ bool Object::IsExternalTwoByteString() {
String::cast(this)->IsTwoByteRepresentation();
}
+
bool Object::HasValidElements() {
// Dictionary is covered under FixedArray.
return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray();
}
+
StringShape::StringShape(String* str)
: type_(str->map()->instance_type()) {
set_valid();
@@ -2143,7 +2145,7 @@ String* String::TryFlattenGetString(PretenureFlag pretenure) {
}
-uint16_t String::Get(int index) {
+uint16_t String::Get(int index, ExternalStringBufferFlag flag) {
ASSERT(index >= 0 && index < length());
switch (StringShape(this).full_representation_tag()) {
case kSeqStringTag | kAsciiStringTag:
@@ -2152,14 +2154,16 @@ uint16_t String::Get(int index) {
return SeqTwoByteString::cast(this)->SeqTwoByteStringGet(index);
case kConsStringTag | kAsciiStringTag:
case kConsStringTag | kTwoByteStringTag:
- return ConsString::cast(this)->ConsStringGet(index);
+ return ConsString::cast(this)->ConsStringGet(index, flag);
case kExternalStringTag | kAsciiStringTag:
- return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index);
+ return ExternalAsciiString::cast(this)->ExternalAsciiStringGet(index,
+ flag);
case kExternalStringTag | kTwoByteStringTag:
- return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index);
+ return ExternalTwoByteString::cast(this)->ExternalTwoByteStringGet(index,
+ flag);
case kSlicedStringTag | kAsciiStringTag:
case kSlicedStringTag | kTwoByteStringTag:
- return SlicedString::cast(this)->SlicedStringGet(index);
+ return SlicedString::cast(this)->SlicedStringGet(index, flag);
default:
break;
}
@@ -2297,6 +2301,32 @@ void ConsString::set_second(String* value, WriteBarrierMode mode) {
}
+bool ExternalString::IsBuffered() {
+ uint32_t type = map()->instance_type();
+ ASSERT(StringShape(this).IsExternal());
+ return (type & kBufferedStringMask) == kBufferedStringTag;
+}
+
+
+int ExternalString::buffer_index() {
+ ASSERT(IsBuffered());
+ Object* value = READ_FIELD(this, kBufferIndexOffset);
+ return Smi::cast(value)->value();
+}
+
+
+void ExternalString::set_buffer_index(int value) {
+ ASSERT(IsBuffered());
+ WRITE_FIELD(this, kBufferIndexOffset, Smi::FromInt(value));
+}
+
+
+Address ExternalString::buffer() {
+ return reinterpret_cast<Address>(
+ HeapObject::RawField(this, kBufferContentOffset));
+}
+
+
const ExternalAsciiString::Resource* ExternalAsciiString::resource() {
return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
}
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698