26 int start_index =
args.smi_value_at(4);
33 :
match_(match), prefix_(prefix), suffix_(suffix) {}
39 int CaptureCount()
override {
return 0; }
40 bool HasNamedCaptures()
override {
return false; }
42 *capture_exists =
false;
46 CaptureState* state)
override {
55 isolate->factory()->NewSubString(subject, 0,
position);
57 subject,
position + matched->length(), subject->length());
58 SimpleMatch match(matched, prefix, suffix);
71 if (stackLimitCheck.
HasOverflowed() || (recursion_limit == 0)) {
75 if (IsConsString(*subject)) {
81 recursion_limit).ToHandle(&new_first)) {
84 if (*found)
return isolate->factory()->NewConsString(new_first,
second);
89 .ToHandle(&new_second)) {
92 if (*found)
return isolate->factory()->NewConsString(first, new_second);
97 if (index == -1)
return subject;
100 isolate->factory()->NewSubString(subject, 0, index);
103 isolate, cons1, isolate->factory()->NewConsString(first, replace));
105 isolate->factory()->NewSubString(subject, index + 1, subject->length());
106 return isolate->factory()->NewConsString(cons1,
second);
119 const int kRecursionLimit = 0x1000;
123 kRecursionLimit).ToHandle(&
result)) {
126 if (isolate->has_exception())
return ReadOnlyRoots(isolate).exception();
130 kRecursionLimit).ToHandle(&
result)) {
133 if (isolate->has_exception())
return ReadOnlyRoots(isolate).exception();
135 return isolate->StackOverflow();
141 isolate->factory()->undefined_value());
149 int end =
args.smi_value_at(2);
153 return *isolate->factory()->NewSubString(
string,
start,
end);
164 isolate->factory()->NewConsString(str1, str2));
172 return *isolate->factory()->InternalizeString(
string);
188 if (
i >=
static_cast<uint32_t
>(subject->length())) {
207 if (
i >=
static_cast<uint32_t
>(subject->length())) {
211 int first_code_point = subject->Get(
i);
212 if ((first_code_point & 0xFC00) != 0xD800) {
216 if (
i + 1 >=
static_cast<uint32_t
>(subject->length())) {
220 int second_code_point = subject->Get(
i + 1);
221 if ((second_code_point & 0xFC00) != 0xDC00) {
225 int surrogate_offset = 0x10000 - (0xD800 << 10) - 0xDC00;
227 (second_code_point + surrogate_offset));
235 int array_length =
args.smi_value_at(1);
242 int special_length = special->length();
245 bool one_byte = special->IsOneByteRepresentation();
251 if (array_length == 0) {
253 }
else if (array_length == 1) {
255 if (IsString(first))
return first;
258 array_length, &one_byte);
262 return isolate->Throw(
ReadOnlyRoots(isolate).illegal_argument_string());
271 isolate, answer, isolate->factory()->NewRawOneByteString(length));
279 isolate, answer, isolate->factory()->NewRawTwoByteString(length));
297 static_cast<int>(std::min(
static_cast<uint32_t
>(s->length()), limit));
300 bool elements_are_initialized =
false;
302 if (s->IsFlat() && s->IsOneByteRepresentation()) {
312 isolate->heap()->single_character_string_table();
321 elements_are_initialized =
true;
325 if (!elements_are_initialized) {
328 isolate->factory()->LookupSingleCharacterStringFromCode(s->Get(
i));
329 elements->set(
i, *str);
339 return *isolate->factory()->NewJSArrayWithElements(elements);
349 return isolate->heap()->ToBoolean(
360 return isolate->heap()->ToBoolean(
371 return isolate->heap()->ToBoolean(
382 return isolate->heap()->ToBoolean(
390#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
443 const int string_length =
string->
length();
445 isolate->factory()->LookupSingleCharacterStringFromCode(
'"');
450 if (quote_index == -1)
return *
string;
453 std::vector<int> indices = {quote_index};
454 while (quote_index + 1 < string_length) {
455 quote_index =
String::IndexOf(isolate,
string, quotes, quote_index + 1);
456 if (quote_index == -1)
break;
457 indices.emplace_back(quote_index);
462 isolate->factory()->NewStringFromAsciiChecked(
""");
463 const int estimated_part_count =
static_cast<int>(indices.size()) * 2 + 1;
465 estimated_part_count);
468 for (
int index : indices) {
469 const int slice_start = prev_index + 1;
470 const int slice_end =
index;
471 if (slice_end > slice_start) {
478 if (prev_index < string_length - 1) {
491 return isolate->heap()->ToBoolean(
502 const int length = source->length();
504 isolate->factory()->NewRawTwoByteString(length).ToHandleChecked();
509 uint16_t* dest_data = dest->GetChars(no_gc);
static void ReplaceUnpairedSurrogates(const uint16_t *source_code_units, uint16_t *dest_code_units, size_t length)
constexpr T * begin() const
static V8_EXPORT_PRIVATE bool Contains(Address address)
static void AddSubjectSlice(FixedArrayBuilder *builder, int from, int to)
MaybeDirectHandle< String > ToString()
void AddString(DirectHandle< String > string)
static constexpr Tagged< Smi > FromInt(int value)
static constexpr int kMaxValue
bool HasOverflowed() const
base::Vector< const uint8_t > ToOneByteVector() const
base::Vector< const base::uc16 > ToUC16Vector() const
static const uint32_t kMaxLength
static V8_INLINE HandleType< String > Flatten(Isolate *isolate, HandleType< T > string, AllocationType allocation=AllocationType::kYoung)
static Tagged< Object > IndexOf(Isolate *isolate, DirectHandle< Object > receiver, DirectHandle< Object > search, DirectHandle< Object > position)
static V8_WARN_UNUSED_RESULT ComparisonResult Compare(Isolate *isolate, DirectHandle< String > x, DirectHandle< String > y)
static bool IsOneByteRepresentationUnderneath(Tagged< String > string)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > GetSubstitution(Isolate *isolate, Match *match, DirectHandle< String > replacement, uint32_t start_index=0)
static bool IsWellFormedUnicode(Isolate *isolate, DirectHandle< String > string)
bool Equals(Tagged< String > other) const
static Tagged< Object > LastIndexOf(Isolate *isolate, DirectHandle< Object > receiver, DirectHandle< Object > search, DirectHandle< Object > position)
#define RUNTIME_FUNCTION(Name)
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
#define RETURN_RESULT_OR_FAILURE(isolate, call)
base::Vector< const DirectHandle< Object > > args
ZoneVector< RpoNumber > & result
InstructionOperand source
bool ComparisonResultToBool(Operation op, ComparisonResult result)
MaybeDirectHandle< String > StringReplaceOneCharWithString(Isolate *isolate, DirectHandle< String > subject, DirectHandle< String > search, DirectHandle< String > replace, bool *found, int recursion_limit)
void StringBuilderConcatHelper(Tagged< String > special, sinkchar *sink, Tagged< FixedArray > fixed_array, int array_length)
int StringBuilderConcatLength(int special_length, Tagged< FixedArray > fixed_array, int array_length, bool *one_byte)
uint32_t NumberToUint32(Tagged< Object > number)
template const char * string
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
DirectHandle< String > match_
#define DCHECK_LE(v1, v2)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)