summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/js-regexp.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/js-regexp.h')
-rw-r--r--deps/v8/src/objects/js-regexp.h93
1 files changed, 72 insertions, 21 deletions
diff --git a/deps/v8/src/objects/js-regexp.h b/deps/v8/src/objects/js-regexp.h
index 7c8841ee79..5380b79c6c 100644
--- a/deps/v8/src/objects/js-regexp.h
+++ b/deps/v8/src/objects/js-regexp.h
@@ -36,20 +36,49 @@ class JSRegExp : public JSObject {
// ATOM: A simple string to match against using an indexOf operation.
// IRREGEXP: Compiled with Irregexp.
enum Type { NOT_COMPILED, ATOM, IRREGEXP };
- enum Flag {
+ struct FlagShiftBit {
+ static const int kGlobal = 0;
+ static const int kIgnoreCase = 1;
+ static const int kMultiline = 2;
+ static const int kSticky = 3;
+ static const int kUnicode = 4;
+ static const int kDotAll = 5;
+ static const int kInvalid = 7;
+ };
+ enum Flag : uint8_t {
kNone = 0,
- kGlobal = 1 << 0,
- kIgnoreCase = 1 << 1,
- kMultiline = 1 << 2,
- kSticky = 1 << 3,
- kUnicode = 1 << 4,
- kDotAll = 1 << 5,
+ kGlobal = 1 << FlagShiftBit::kGlobal,
+ kIgnoreCase = 1 << FlagShiftBit::kIgnoreCase,
+ kMultiline = 1 << FlagShiftBit::kMultiline,
+ kSticky = 1 << FlagShiftBit::kSticky,
+ kUnicode = 1 << FlagShiftBit::kUnicode,
+ kDotAll = 1 << FlagShiftBit::kDotAll,
// Update FlagCount when adding new flags.
+ kInvalid = 1 << FlagShiftBit::kInvalid, // Not included in FlagCount.
};
typedef base::Flags<Flag> Flags;
-
static constexpr int FlagCount() { return 6; }
+ static int FlagShiftBits(Flag flag) {
+ switch (flag) {
+ case kGlobal:
+ return FlagShiftBit::kGlobal;
+ case kIgnoreCase:
+ return FlagShiftBit::kIgnoreCase;
+ case kMultiline:
+ return FlagShiftBit::kMultiline;
+ case kSticky:
+ return FlagShiftBit::kSticky;
+ case kUnicode:
+ return FlagShiftBit::kUnicode;
+ case kDotAll:
+ return FlagShiftBit::kDotAll;
+ default:
+ STATIC_ASSERT(FlagCount() == 6);
+ UNREACHABLE();
+ }
+ }
+
DECL_ACCESSORS(data, Object)
DECL_ACCESSORS(flags, Object)
DECL_ACCESSORS(last_index, Object)
@@ -66,15 +95,15 @@ class JSRegExp : public JSObject {
Handle<String> source,
Handle<String> flags_string);
- inline Type TypeTag();
+ inline Type TypeTag() const;
// Number of captures (without the match itself).
inline int CaptureCount();
inline Flags GetFlags();
- inline String* Pattern();
- inline Object* CaptureNameMap();
- inline Object* DataAt(int index);
+ inline String Pattern();
+ inline Object CaptureNameMap();
+ inline Object DataAt(int index) const;
// Set implementation data after the object has been prepared.
- inline void SetDataAt(int index, Object* value);
+ inline void SetDataAt(int index, Object value);
static int code_index(bool is_latin1) {
if (is_latin1) {
@@ -84,17 +113,27 @@ class JSRegExp : public JSObject {
}
}
+ inline bool HasCompiledCode() const;
+ inline void DiscardCompiledCodeForSerialization();
+
DECL_CAST(JSRegExp)
// Dispatched behavior.
DECL_PRINTER(JSRegExp)
DECL_VERIFIER(JSRegExp)
- static const int kDataOffset = JSObject::kHeaderSize;
- static const int kSourceOffset = kDataOffset + kPointerSize;
- static const int kFlagsOffset = kSourceOffset + kPointerSize;
- static const int kSize = kFlagsOffset + kPointerSize;
- static const int kLastIndexOffset = kSize; // In-object field.
+// Layout description.
+#define JS_REGEXP_FIELDS(V) \
+ V(kDataOffset, kTaggedSize) \
+ V(kSourceOffset, kTaggedSize) \
+ V(kFlagsOffset, kTaggedSize) \
+ /* Total size. */ \
+ V(kSize, 0) \
+ /* This is already an in-object field. */ \
+ V(kLastIndexOffset, 0)
+
+ DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_REGEXP_FIELDS)
+#undef JS_REGEXP_FIELDS
// Indices in the data array.
static const int kTagIndex = 0;
@@ -131,8 +170,18 @@ class JSRegExp : public JSObject {
static const int kLastIndexFieldIndex = 0;
static const int kInObjectFieldCount = 1;
+ // Descriptor array index to important methods in the prototype.
+ static const int kExecFunctionDescriptorIndex = 1;
+ static const int kSymbolMatchFunctionDescriptorIndex = 13;
+ static const int kSymbolReplaceFunctionDescriptorIndex = 14;
+ static const int kSymbolSearchFunctionDescriptorIndex = 15;
+ static const int kSymbolSplitFunctionDescriptorIndex = 16;
+ static const int kSymbolMatchAllFunctionDescriptorIndex = 17;
+
// The uninitialized value for a regexp code object.
static const int kUninitializedValue = -1;
+
+ OBJECT_CONSTRUCTORS(JSRegExp, JSObject)
};
DEFINE_OPERATORS_FOR_FLAGS(JSRegExp::Flags)
@@ -145,10 +194,12 @@ DEFINE_OPERATORS_FOR_FLAGS(JSRegExp::Flags)
// After creation the result must be treated as a JSArray in all regards.
class JSRegExpResult : public JSArray {
public:
+// Layout description.
#define REG_EXP_RESULT_FIELDS(V) \
- V(kIndexOffset, kPointerSize) \
- V(kInputOffset, kPointerSize) \
- V(kGroupsOffset, kPointerSize) \
+ V(kIndexOffset, kTaggedSize) \
+ V(kInputOffset, kTaggedSize) \
+ V(kGroupsOffset, kTaggedSize) \
+ /* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSArray::kSize, REG_EXP_RESULT_FIELDS)