22 if (capture_start_index >= match_info->number_of_capture_registers()) {
23 if (ok !=
nullptr) *ok =
false;
24 return isolate->factory()->empty_string();
28 const int match_start = match_info->capture(capture_start_index);
29 const int match_end = match_info->capture(capture_end_index);
30 if (match_start == -1 || match_end == -1) {
31 if (ok !=
nullptr) *ok =
false;
32 return isolate->factory()->empty_string();
35 if (ok !=
nullptr) *ok =
true;
37 return isolate->factory()->NewSubString(last_subject, match_start, match_end);
44 if (capture == -1)
return false;
47 if (capture_start_index >= match_info->number_of_capture_registers()) {
52 const int match_start = match_info->capture(capture_start_index);
53 const int match_end = match_info->capture(capture_end_index);
54 return match_start != -1 && match_end != -1;
60 return recv->map() == isolate->regexp_function()->initial_map();
68 isolate->factory()->NewNumberFromInt64(value);
69 if (HasInitialRegExpMap(isolate, *recv)) {
75 isolate, recv, isolate->factory()->lastIndex_string(), value_as_object,
82 if (HasInitialRegExpMap(isolate, *recv)) {
86 isolate->factory()->lastIndex_string());
96 if (IsUndefined(*exec, isolate)) {
100 isolate->factory()->exec_string()));
103 if (IsCallable(*exec)) {
104 constexpr int argc = 1;
105 std::array<DirectHandle<Object>, argc>
args = {
string};
115 NewTypeError(MessageTemplate::kInvalidRegExpExecResult));
120 if (!IsJSRegExp(*regexp)) {
122 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
123 isolate->factory()->NewStringFromAsciiChecked(
124 "RegExp.prototype.exec"),
131 constexpr int argc = 1;
132 std::array<DirectHandle<Object>, argc>
args = {
string};
141#ifdef V8_ENABLE_FORCE_SLOW_PATH
142 if (isolate->force_slow_path())
return false;
145 if (!IsJSReceiver(*obj))
return false;
149 if (!HasInitialRegExpMap(isolate, recv))
return false;
153 if (!IsJSReceiver(proto))
return false;
157 if (proto_map != *initial_proto_initial_map) {
165 DCHECK_EQ(*(isolate->factory()->exec_string()),
166 proto_map->instance_descriptors(isolate)->GetKey(kExecIndex));
167 if (proto_map->instance_descriptors(isolate)
168 ->GetDetails(kExecIndex)
179 if (!Protectors::IsRegExpSpeciesLookupChainIntact(isolate))
return false;
190 const uint64_t string_length =
static_cast<uint64_t
>(
string->length());
191 if (unicode && index < string_length) {
192 const uint16_t first =
string->Get(
static_cast<uint32_t
>(index));
193 if (first >= 0xD800 && first <= 0xDBFF && index + 1 < string_length) {
194 DCHECK_LT(index, std::numeric_limits<uint64_t>::max());
195 const uint16_t
second =
string->Get(
static_cast<uint32_t
>(index + 1));
210 isolate, last_index_obj,
212 isolate->factory()->lastIndex_string()));
217 const uint64_t new_last_index =
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > Call(Isolate *isolate, DirectHandle< Object > callable, DirectHandle< Object > receiver, base::Vector< const DirectHandle< Object > > args)
static constexpr int kExecFunctionDescriptorIndex
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > ToLength(Isolate *isolate, DirectHandle< Object > input)
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > SetProperty(LookupIterator *it, DirectHandle< Object > value, StoreOrigin store_origin, Maybe< ShouldThrow > should_throw=Nothing< ShouldThrow >())
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > GetProperty(LookupIterator *it, bool is_global_reference=false)
static constexpr int capture_start_index(int capture_index)
static constexpr int capture_end_index(int capture_index)
static Handle< String > GenericCaptureGetter(Isolate *isolate, DirectHandle< RegExpMatchInfo > match_info, int capture, bool *ok=nullptr)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > GetLastIndex(Isolate *isolate, DirectHandle< JSReceiver > recv)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetAdvancedStringIndex(Isolate *isolate, DirectHandle< JSReceiver > regexp, DirectHandle< String > string, bool unicode)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > SetLastIndex(Isolate *isolate, DirectHandle< JSReceiver > regexp, uint64_t value)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSAny > RegExpExec(Isolate *isolate, DirectHandle< JSReceiver > regexp, DirectHandle< String > string, DirectHandle< Object > exec)
static uint64_t AdvanceStringIndex(Tagged< String > string, uint64_t index, bool unicode)
static bool IsMatchedCapture(Tagged< RegExpMatchInfo > match_info, int capture)
static bool IsUnmodifiedRegExp(Isolate *isolate, DirectHandle< Object > obj)
static constexpr int ToInt(const Tagged< Object > object)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
#define THROW_NEW_ERROR(isolate, call)
base::Vector< const DirectHandle< Object > > args
ZoneVector< RpoNumber > & result
constexpr Vector< T > VectorOf(T *start, size_t size)
constexpr double kMaxSafeInteger
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
uint64_t PositiveNumberToUint64(Tagged< Object > number)
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset IsNull(value)||IsJSProxy(value)||IsWasmObject(value)||(IsJSObject(value) &&(HeapLayout
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Maybe< T > Just(const T &t)
#define DCHECK_LE(v1, v2)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)