diff options
Diffstat (limited to 'deps/v8/src/objects/js-regexp.h')
-rw-r--r-- | deps/v8/src/objects/js-regexp.h | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/deps/v8/src/objects/js-regexp.h b/deps/v8/src/objects/js-regexp.h index b3ef06bd5c..03efd4913c 100644 --- a/deps/v8/src/objects/js-regexp.h +++ b/deps/v8/src/objects/js-regexp.h @@ -96,7 +96,8 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> { Handle<String> flags_string); bool MarkedForTierUp(); - void ResetTierUp(); + void ResetLastTierUpTick(); + void TierUpTick(); void MarkTierUpForNextExec(); inline Type TypeTag() const; @@ -176,9 +177,13 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> { // Maps names of named capture groups (at indices 2i) to their corresponding // (1-based) capture group indices (at indices 2i + 1). static const int kIrregexpCaptureNameMapIndex = kDataIndex + 6; - static const int kIrregexpTierUpTicksIndex = kDataIndex + 7; + // Tier-up ticks are set to the value of the tier-up ticks flag. The value is + // decremented on each execution of the bytecode, so that the tier-up + // happens once the ticks reach zero. + // This value is ignored if the regexp-tier-up flag isn't turned on. + static const int kIrregexpTicksUntilTierUpIndex = kDataIndex + 7; - static const int kIrregexpDataSize = kIrregexpTierUpTicksIndex + 1; + static const int kIrregexpDataSize = kIrregexpTicksUntilTierUpIndex + 1; // In-object fields. static const int kLastIndexFieldIndex = 0; @@ -195,6 +200,10 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> { // The uninitialized value for a regexp code object. static const int kUninitializedValue = -1; + // The heuristic value for the length of the subject string for which we + // tier-up to the compiler immediately, instead of using the interpreter. + static constexpr int kTierUpForSubjectLengthValue = 1000; + TQ_OBJECT_CONSTRUCTORS(JSRegExp) }; @@ -208,18 +217,63 @@ DEFINE_OPERATORS_FOR_FLAGS(JSRegExp::Flags) // After creation the result must be treated as a JSArray in all regards. class JSRegExpResult : public JSArray { public: + DECL_CAST(JSRegExpResult) + + // TODO(joshualitt): We would like to add printers and verifiers to + // JSRegExpResult, and maybe JSRegExpResultIndices, but both have the same + // instance type as JSArray. + + // cached_indices_or_match_info and names, are used to construct the + // JSRegExpResultIndices returned from the indices property lazily. + DECL_ACCESSORS(cached_indices_or_match_info, Object) + DECL_ACCESSORS(names, Object) + // Layout description. DEFINE_FIELD_OFFSET_CONSTANTS(JSArray::kSize, - TORQUE_GENERATED_JSREG_EXP_RESULT_FIELDS) + TORQUE_GENERATED_JS_REG_EXP_RESULT_FIELDS) + + static Handle<JSArray> GetAndCacheIndices( + Isolate* isolate, Handle<JSRegExpResult> regexp_result); // Indices of in-object properties. static const int kIndexIndex = 0; static const int kInputIndex = 1; static const int kGroupsIndex = 2; - static const int kInObjectPropertyCount = 3; - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(JSRegExpResult); + // Private internal only fields. + static const int kCachedIndicesOrMatchInfoIndex = 3; + static const int kNamesIndex = 4; + static const int kInObjectPropertyCount = 5; + + OBJECT_CONSTRUCTORS(JSRegExpResult, JSArray); +}; + +// JSRegExpResultIndices is just a JSArray with a specific initial map. +// This initial map adds in-object properties for "group" +// properties, as assigned by RegExp.prototype.exec, which allows +// faster creation of RegExp exec results. +// This class just holds constants used when creating the result. +// After creation the result must be treated as a JSArray in all regards. +class JSRegExpResultIndices : public JSArray { + public: + DECL_CAST(JSRegExpResultIndices) + + // Layout description. + DEFINE_FIELD_OFFSET_CONSTANTS( + JSArray::kSize, TORQUE_GENERATED_JS_REG_EXP_RESULT_INDICES_FIELDS) + + static Handle<JSRegExpResultIndices> BuildIndices( + Isolate* isolate, Handle<RegExpMatchInfo> match_info, + Handle<Object> maybe_names); + + // Indices of in-object properties. + static const int kGroupsIndex = 0; + static const int kInObjectPropertyCount = 1; + + // Descriptor index of groups. + static const int kGroupsDescriptorIndex = 1; + + OBJECT_CONSTRUCTORS(JSRegExpResultIndices, JSArray); }; } // namespace internal |