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

Unified Diff: src/objects.h

Issue 6991007: Don't flatten every time we call CharCodeAt Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Handle flat cons string. Flatten entire string. Created 9 years, 7 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
« no previous file with comments | « src/isolate.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index be4652bed5894264ca48baea2205f8ecf8209078..cc0faaac1b35c05ef41b100a4d8f09b14649f3e6 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -79,13 +79,14 @@
// - JSFunctionResultCache
// - SerializedScopeInfo
// - String
-// - SeqString
-// - SeqAsciiString
-// - SeqTwoByteString
// - ConsString
-// - ExternalString
-// - ExternalAsciiString
-// - ExternalTwoByteString
+// - FlatString
+// - SeqString
+// - SeqAsciiString
+// - SeqTwoByteString
+// - ExternalString
+// - ExternalAsciiString
+// - ExternalTwoByteString
// - HeapNumber
// - Code
// - Map
@@ -681,6 +682,7 @@ class MaybeObject BASE_EMBEDDED {
V(HeapNumber) \
V(String) \
V(Symbol) \
+ V(FlatString) \
V(SeqString) \
V(ExternalString) \
V(ConsString) \
@@ -5353,6 +5355,10 @@ class String: public HeapObject {
// to this method are not efficient unless the string is flat.
inline uint16_t Get(int index);
+ // Try to get a character (smi encoded) from the string.
+ // The method may try to flatten the string, or part of the string.
+ inline MaybeObject* GetMayFlatten(int index);
+
// Try to flatten the string. Checks first inline to see if it is
// necessary. Does nothing if the string is not a cons string.
// Flattening allocates a sequential string with the same data as
@@ -5640,10 +5646,22 @@ class String: public HeapObject {
};
-// The SeqString abstract class captures sequential string values.
-class SeqString: public String {
+class FlatString: public String {
public:
+ // Casting.
+ static inline FlatString* cast(Object* obj);
+
+ // Get a character from a flat string.
+ inline uint16_t FlatStringGet(int index);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(FlatString);
+};
+
+// The SeqString abstract class captures sequential string values.
+class SeqString: public FlatString {
+ public:
// Casting.
static inline SeqString* cast(Object* obj);
@@ -5782,6 +5800,7 @@ class ConsString: public String {
// Dispatched behavior.
uint16_t ConsStringGet(int index);
+ MaybeObject* ConsStringGetMayFlatten(int index);
// Casting.
static inline ConsString* cast(Object* obj);
@@ -5819,7 +5838,7 @@ class ConsString: public String {
//
// The API expects that all ExternalStrings are created through the
// API. Therefore, ExternalStrings should not be used internally.
-class ExternalString: public String {
+class ExternalString: public FlatString {
public:
// Casting
static inline ExternalString* cast(Object* obj);
« no previous file with comments | « src/isolate.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698