Commit 07e24947 authored by dcarney@chromium.org's avatar dcarney@chromium.org

Added back some utf8 optimizations

R=yangguo@chromium.org
BUG=https://code.google.com/p/v8/issues/detail?id=2551

Review URL: https://codereview.chromium.org/12390057

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13842 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 940ed0dc
This diff is collapsed.
......@@ -2648,6 +2648,32 @@ void String::Visit(
}
// TODO(dcarney): Remove this class after conversion to VisitFlat.
class ConsStringCaptureOp {
public:
inline ConsStringCaptureOp() : cons_string_(NULL) {}
inline String* Operate(String* string, unsigned*, int32_t*, unsigned*) {
cons_string_ = ConsString::cast(string);
return NULL;
}
ConsString* cons_string_;
};
template<class Visitor>
ConsString* String::VisitFlat(Visitor* visitor,
String* string,
int offset,
int length,
int32_t type) {
ASSERT(length >= 0 && length == string->length());
ASSERT(offset >= 0 && offset <= length);
ConsStringCaptureOp op;
Visit(string, offset, *visitor, op, type, static_cast<unsigned>(length));
return op.cons_string_;
}
uint16_t SeqOneByteString::SeqOneByteStringGet(int index) {
ASSERT(index >= 0 && index < length());
return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
......
......@@ -7337,6 +7337,8 @@ class Symbol: public Name {
};
class ConsString;
// The String abstract class captures JavaScript string values:
//
// Ecma-262:
......@@ -7615,6 +7617,7 @@ class String: public Name {
return NonOneByteStart(chars, length) >= length;
}
// TODO(dcarney): Replace all instances of this with VisitFlat.
template<class Visitor, class ConsOp>
static inline void Visit(String* string,
unsigned offset,
......@@ -7623,6 +7626,21 @@ class String: public Name {
int32_t type,
unsigned length);
template<class Visitor>
static inline ConsString* VisitFlat(Visitor* visitor,
String* string,
int offset,
int length,
int32_t type);
template<class Visitor>
static inline ConsString* VisitFlat(Visitor* visitor,
String* string,
int offset = 0) {
int32_t type = string->map()->instance_type();
return VisitFlat(visitor, string, offset, string->length(), type);
}
private:
friend class Name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment