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

Unified Diff: src/objects.h

Issue 28311: Flattened the representation of compiled RegExp data. (Closed)
Patch Set: ... and it lints. Created 11 years, 10 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
« src/jsregexp.cc ('K') | « src/jsregexp.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »
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 555871a1694f3a29eae9016360089c16e9d42072..bd81103604c75283fded64e633ef31fa96504976 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2939,6 +2939,19 @@ class JSValue: public JSObject {
};
// Regular expressions
+// The regular expression holds a single reference to a FixedArray in
+// the kDataOffset field.
+// The FixedArray contains the following data:
+// - tag : type of regexp implementation (not compiled yet, atom or irregexp)
+// - reference to the original source string
+// - reference to the original flag string
+// If it is an atom regexp
+// - a reference to a literal string to search for
+// If it is an irregexp regexp:
+// - a reference to code for ASCII inputs (bytecode or compiled).
+// - a reference to code for UC16 inputs (bytecode or compiled).
+// - max number of registers used by irregexp implementations.
+// - number of capture registers (output values) of the regexp.
class JSRegExp: public JSObject {
public:
// Meaning of Type:
@@ -2966,6 +2979,8 @@ class JSRegExp: public JSObject {
inline Flags GetFlags();
inline String* Pattern();
inline Object* DataAt(int index);
+ // Set implementation data after the object has been prepared.
+ inline void SetDataAt(int index, Object* value);
static inline JSRegExp* cast(Object* obj);
@@ -2977,14 +2992,29 @@ class JSRegExp: public JSObject {
static const int kDataOffset = JSObject::kHeaderSize;
static const int kSize = kDataOffset + kIntSize;
+ // Indices in the data array.
static const int kTagIndex = 0;
static const int kSourceIndex = kTagIndex + 1;
static const int kFlagsIndex = kSourceIndex + 1;
- // These two are the same since the same entry is shared for
- // different purposes in different types of regexps.
- static const int kAtomPatternIndex = kFlagsIndex + 1;
- static const int kIrregexpDataIndex = kFlagsIndex + 1;
- static const int kDataSize = kAtomPatternIndex + 1;
+ static const int kDataIndex = kFlagsIndex + 1;
+ // The data fields are used in different ways depending on the
+ // value of the tag.
+ // Atom regexps (literal strings).
+ static const int kAtomPatternIndex = kDataIndex;
+
+ static const int kAtomDataSize = kAtomPatternIndex + 1;
+
+ // Irregexp compiled code or bytecode for ASCII.
+ static const int kIrregexpASCIICodeIndex = kDataIndex;
+ // Irregexp compiled code or bytecode for UC16.
+ static const int kIrregexpUC16CodeIndex = kDataIndex + 1;
+ // Maximal number of registers used by either ASCII or UC16.
+ // Only used to check that there is enough stack space
+ static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 2;
+ // Number of captures in the compiled regexp.
+ static const int kIrregexpCaptureCountIndex = kDataIndex + 3;
+
+ static const int kIrregexpDataSize = kIrregexpCaptureCountIndex + 1;
};
« src/jsregexp.cc ('K') | « src/jsregexp.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698