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

Unified Diff: src/objects.h

Issue 7977001: Added ability to lock strings to prevent their representation or encoding from changing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 9 years, 3 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 ae0ec7a6fb3347ee5d9e3ecaaed4722324d7394a..a9b33e9f10774fb7b0543f9cdf5270cc3a20a6f5 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5755,7 +5755,6 @@ class StringHasher {
uint32_t raw_running_hash_;
uint32_t array_index_;
bool is_array_index_;
- bool is_first_char_;
bool is_valid_;
friend class TwoCharHashTableKey;
};
@@ -6207,15 +6206,25 @@ class SeqString: public String {
// Layout description.
static const int kHeaderSize = String::kSize;
+ // Shortcuts for templates that know their string-type exactly.
+ bool IsExternalAsciiString() {
+ return false;
+ }
+ bool IsExternalTwoByteString() {
+ return false;
+ }
+
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString);
};
-// The AsciiString class captures sequential ascii string objects.
-// Each character in the AsciiString is an ascii character.
+// The SeqAsciiString class captures sequential ASCII string objects.
+// Each character in the AsciiString is an ASCII character.
class SeqAsciiString: public SeqString {
public:
+ typedef char CharType;
static const bool kHasAsciiEncoding = true;
// Dispatched behavior.
@@ -6230,6 +6239,15 @@ class SeqAsciiString: public SeqString {
// Casting
static inline SeqAsciiString* cast(Object* obj);
+ bool IsSeqAsciiString() {
+ ASSERT(this->Object::IsSeqAsciiString());
+ return true;
+ }
+ bool IsSeqTwoByteString() {
+ ASSERT(this->Object::IsSeqAsciiString());
+ return false;
+ }
+
// Garbage collection support. This method is called by the
// garbage collector to compute the actual size of an AsciiString
// instance.
@@ -6259,10 +6277,12 @@ class SeqAsciiString: public SeqString {
};
-// The TwoByteString class captures sequential unicode string objects.
+// The SeqTwoByteString class captures sequential unicode string objects.
// Each character in the TwoByteString is a two-byte uint16_t.
class SeqTwoByteString: public SeqString {
public:
+ typedef uc16 CharType;
+
static const bool kHasAsciiEncoding = false;
// Dispatched behavior.
@@ -6279,6 +6299,14 @@ class SeqTwoByteString: public SeqString {
// Casting
static inline SeqTwoByteString* cast(Object* obj);
+ bool IsSeqTwoByteString() {
+ ASSERT(this->Object::IsSeqTwoByteString());
+ return true;
+ }
+ bool IsSeqAsciiString() {
+ ASSERT(this->Object::IsSeqTwoByteString());
+ return false;
+ }
// Garbage collection support. This method is called by the
// garbage collector to compute the actual size of a TwoByteString
@@ -6439,6 +6467,14 @@ class ExternalString: public String {
STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset);
+ // Shortcuts for templates that know their string type exactly.
+ bool IsSeqAsciiString() {
+ return false;
+ }
+ bool IsSeqTwoByteString() {
+ return false;
+ }
+
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
};
@@ -6448,6 +6484,8 @@ class ExternalString: public String {
// ASCII string.
class ExternalAsciiString: public ExternalString {
public:
+ typedef char CharType;
+
static const bool kHasAsciiEncoding = true;
typedef v8::String::ExternalAsciiStringResource Resource;
@@ -6461,6 +6499,14 @@ class ExternalAsciiString: public ExternalString {
// Casting.
static inline ExternalAsciiString* cast(Object* obj);
+ bool IsExternalAsciiString() {
+ ASSERT(this->Object::IsExternalAsciiString());
+ return true;
+ }
+ bool IsExternalTwoByteString() {
+ ASSERT(this->Object::IsExternalAsciiString());
+ return false;
+ }
// Garbage collection support.
inline void ExternalAsciiStringIterateBody(ObjectVisitor* v);
@@ -6481,10 +6527,11 @@ class ExternalAsciiString: public ExternalString {
};
-// The ExternalTwoByteString class is an external string backed by a UTF-16
-// encoded string.
+// The ExternalTwoByteString class is an external string backed by a 16-bit
+// character sequence.
class ExternalTwoByteString: public ExternalString {
public:
+ typedef uc16 CharType;
static const bool kHasAsciiEncoding = false;
typedef v8::String::ExternalStringResource Resource;
@@ -6501,6 +6548,14 @@ class ExternalTwoByteString: public ExternalString {
// Casting.
static inline ExternalTwoByteString* cast(Object* obj);
+ bool IsExternalTwoByteString() {
+ ASSERT(this->Object::IsExternalTwoByteString());
+ return true;
+ }
+ bool IsExternalAsciiString() {
+ ASSERT(this->Object::IsExternalTwoByteString());
+ return false;
+ }
// Garbage collection support.
inline void ExternalTwoByteStringIterateBody(ObjectVisitor* v);

Powered by Google App Engine
This is Rietveld 408576698