Lines Matching refs:thread

54     JSThread *thread = argv->GetThread();
55 [[maybe_unused]] EcmaHandleScope handleScope(thread);
56 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
61 return BuiltinsSymbol::SymbolDescriptiveString(thread, valTagNew.GetTaggedValue());
63 JSHandle<EcmaString> str = JSTaggedValue::ToString(thread, valTagNew);
64 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
69 return JSPrimitiveRef::StringCreate(thread, strTag, newTarget).GetTaggedValue();
76 return JSPrimitiveRef::StringCreate(thread, valTag, newTarget).GetTaggedValue();
84 JSThread *thread = argv->GetThread();
85 [[maybe_unused]] EcmaHandleScope handleScope(thread);
86 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
93 uint16_t codePointValue = JSTaggedValue::ToUint16(thread, codePointTag);
94 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
96 JSHandle<SingleCharTable> singleCharTable(thread, thread->GetSingleCharTable());
106 uint16_t nextCv = JSTaggedValue::ToUint16(thread, nextCp);
108 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
118 JSThread *thread = argv->GetThread();
119 [[maybe_unused]] EcmaHandleScope handleScope(thread);
120 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
129 JSTaggedNumber nextCpVal = JSTaggedValue::ToNumber(thread, nextCpTag);
130 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
132 THROW_RANGE_ERROR_AND_RETURN(thread, "is not integer", JSTaggedValue::Exception());
136 THROW_RANGE_ERROR_AND_RETURN(thread, "CodePoint < 0 or CodePoint > 0x10FFFF", JSTaggedValue::Exception());
165 JSThread *thread = argv->GetThread();
166 [[maybe_unused]] EcmaHandleScope handleScope(thread);
167 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
169 JSHandle<JSObject> cooked = JSTaggedValue::ToObject(thread, BuiltinsString::GetCallArg(argv, 0));
171 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
175 JSObject::GetProperty(thread, JSHandle<JSTaggedValue>::Cast(cooked), rawKey).GetValue();
176 JSHandle<JSObject> rawObj = JSTaggedValue::ToObject(thread, rawTag);
178 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
179 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
181 JSObject::GetProperty(thread, JSHandle<JSTaggedValue>::Cast(rawObj), lengthKey).GetValue();
183 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
184 JSTaggedNumber lengthNumber = JSTaggedValue::ToLength(thread, rawLen);
185 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
197 JSObject::GetProperty(thread, JSHandle<JSTaggedValue>::Cast(rawObj), i).GetValue();
198 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
199 EcmaString *nextSeg = *JSTaggedValue::ToString(thread, elementString);
200 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
209 EcmaString *nextSub = *JSTaggedValue::ToString(thread, GetCallArg(argv, argsI));
210 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
228 JSThread *thread = argv->GetThread();
229 [[maybe_unused]] EcmaHandleScope handleScope(thread);
230 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
231 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
232 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
233 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
234 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
235 JSHandle<EcmaString> thisFlat(thread, EcmaStringAccessor::Flatten(thread->GetEcmaVM(), thisHandle));
244 JSTaggedNumber posVal = JSTaggedValue::ToInteger(thread, posTag);
245 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
257 JSHandle<SingleCharTable> singleCharTable(thread, thread->GetSingleCharTable());
268 JSThread *thread = argv->GetThread();
269 [[maybe_unused]] EcmaHandleScope handleScope(thread);
270 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
271 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
272 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
273 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
274 JSHandle<EcmaString> thisFlat(thread, EcmaStringAccessor::Flatten(thread->GetEcmaVM(), thisHandle));
283 JSTaggedNumber posVal = JSTaggedValue::ToInteger(thread, posTag);
284 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
303 JSThread *thread = argv->GetThread();
304 [[maybe_unused]] EcmaHandleScope handleScope(thread);
305 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
306 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
307 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
308 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
309 JSHandle<EcmaString> thisFlat(thread, EcmaStringAccessor::Flatten(thread->GetEcmaVM(), thisHandle));
312 JSTaggedNumber posVal = JSTaggedValue::ToNumber(thread, posTag);
313 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
336 JSThread *thread = argv->GetThread();
337 [[maybe_unused]] EcmaHandleScope handleScope(thread);
338 auto ecmaVm = thread->GetEcmaVM();
339 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
340 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
341 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
342 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
349 JSHandle<EcmaString> nextHandle = JSTaggedValue::ToString(thread, nextTag);
350 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
352 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
353 thisHandle = JSHandle<EcmaString>(thread, tempStr);
364 JSThread *thread = argv->GetThread();
365 [[maybe_unused]] EcmaHandleScope handleScope(thread);
366 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
367 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
369 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
370 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
371 bool isRegexp = JSObject::IsRegExp(thread, searchTag);
373 THROW_TYPE_ERROR_AND_RETURN(thread, "is regexp", JSTaggedValue::Exception());
375 JSHandle<EcmaString> searchHandle = JSTaggedValue::ToString(thread, searchTag);
376 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
384 JSTaggedNumber posVal = JSTaggedValue::ToInteger(thread, posTag);
385 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
398 int32_t idx = EcmaStringAccessor::IndexOf(thread->GetEcmaVM(), thisHandle, searchHandle, start);
410 JSThread *thread = argv->GetThread();
411 [[maybe_unused]] EcmaHandleScope handleScope(thread);
413 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
414 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
415 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
416 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
417 bool isRegexp = JSObject::IsRegExp(thread, searchTag);
419 THROW_TYPE_ERROR_AND_RETURN(thread, "is regexp", JSTaggedValue::Exception());
421 JSHandle<EcmaString> searchHandle = JSTaggedValue::ToString(thread, searchTag);
422 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
429 JSTaggedNumber posVal = JSTaggedValue::ToNumber(thread, posTag);
430 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
434 int32_t idx = EcmaStringAccessor::IndexOf(thread->GetEcmaVM(), thisHandle, searchHandle, start);
446 JSThread *thread = argv->GetThread();
447 [[maybe_unused]] EcmaHandleScope handleScope(thread);
449 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
450 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
451 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
452 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
454 JSHandle<EcmaString> searchHandle = JSTaggedValue::ToString(thread, searchTag);
455 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
463 JSTaggedNumber posVal = JSTaggedValue::ToInteger(thread, posTag);
464 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
472 int32_t res = EcmaStringAccessor::IndexOf(thread->GetEcmaVM(), thisHandle, searchHandle, pos);
484 JSThread *thread = argv->GetThread();
485 [[maybe_unused]] EcmaHandleScope handleScope(thread);
487 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
488 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
489 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
490 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
492 JSHandle<EcmaString> searchHandle = JSTaggedValue::ToString(thread, searchTag);
493 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
499 JSTaggedNumber posVal = JSTaggedValue::ToInteger(thread, posTag);
500 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
501 if (std::isnan(JSTaggedValue::ToNumber(thread, posTag).GetNumber())) {
506 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
509 int32_t res = EcmaStringAccessor::LastIndexOf(thread->GetEcmaVM(), thisHandle, searchHandle, pos);
522 JSThread *thread = argv->GetThread();
523 [[maybe_unused]] EcmaHandleScope handleScope(thread);
525 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
526 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
527 [[maybe_unused]] JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
528 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
529 [[maybe_unused]] JSHandle<EcmaString> thatHandle = JSTaggedValue::ToString(thread, thatTag);
530 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
534 return DoLocaleCompare(thread, thisHandle, thatHandle, locales, options);
537 JSTaggedValue BuiltinsString::DoLocaleCompare(JSThread *thread,
544 const CompareStringsOption csOption = JSCollator::CompareStringsOptionFor(thread, locales, options);
547 auto collator = JSCollator::GetCachedIcuCollator(thread, locales);
549 JSTaggedValue result = JSCollator::CompareStrings(thread, collator, thisHandle, thatHandle, csOption);
553 return LocaleCompareGC(thread, thisHandle, thatHandle, locales, options, csOption, cacheable);
556 ARK_SUPPORT_INTL_RETURN_JSVALUE(thread, "LocaleCompare");
558 intl::GlobalIntlHelper gh(thread, intl::GlobalFormatterType::Collator);
559 auto collator = gh.GetGlobalObject<intl::GlobalCollator>(thread,
572 JSTaggedValue BuiltinsString::LocaleCompareGC(JSThread *thread,
580 EcmaVM *ecmaVm = thread->GetEcmaVM();
586 JSCollator::InitializeCollator(thread, collator, locales, options, cacheable);
587 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
590 icuCollator = JSCollator::GetCachedIcuCollator(thread, locales);
595 JSTaggedValue result = JSCollator::CompareStrings(thread, icuCollator, thisHandle, thatHandle, csOption);
605 JSThread *thread = argv->GetThread();
606 [[maybe_unused]] EcmaHandleScope handleScope(thread);
607 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
608 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
609 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
612 if (BuiltinsRegExp::IsFastRegExp(thread, regexp, BuiltinsRegExp::RegExpSymbol::MATCH)) {
613 return BuiltinsRegExp::RegExpMatch(thread, regexp, thisTag, true);
617 JSHandle<JSTaggedValue> matchTag = thread->GetEcmaVM()->GetGlobalEnv()->GetMatchSymbol();
620 JSHandle<JSTaggedValue> matcher = JSObject::GetMethod(thread, regexp, matchTag);
621 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
625 EcmaInterpreter::NewRuntimeCallInfo(thread, matcher, regexp, undefined, 1);
626 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
631 JSHandle<EcmaString> thisVal = JSTaggedValue::ToString(thread, thisTag);
632 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
634 JSHandle<JSTaggedValue> rx(thread, BuiltinsRegExp::RegExpCreate(thread, regexp, undifinedHandle));
635 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
636 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, undefined, rx, undefined, 1);
637 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
646 JSThread *thread = argv->GetThread();
647 [[maybe_unused]] EcmaHandleScope handleScope(thread);
648 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
650 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
651 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
653 EcmaVM *ecmaVm = thread->GetEcmaVM();
662 BuiltinsRegExp::IsFastRegExp(thread, regexp, BuiltinsRegExp::RegExpSymbol::MATCH)) {
663 bool isGlobal = BuiltinsRegExp::GetOriginalFlag(thread, regexp, RegExpParser::FLAG_GLOBAL);
665 THROW_TYPE_ERROR_AND_RETURN(thread,
669 } else if (JSObject::IsRegExp(thread, regexp)) {
672 JSHandle<JSTaggedValue> flags = JSObject::GetProperty(thread, regexp, flagsString).GetValue();
673 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
675 JSTaggedValue::RequireObjectCoercible(thread, flags);
676 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
678 JSHandle<EcmaString> flagString = JSTaggedValue::ToString(thread, flags);
679 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
683 THROW_TYPE_ERROR_AND_RETURN(thread,
689 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
692 BuiltinsRegExp::IsFastRegExp(thread, regexp, BuiltinsRegExp::RegExpSymbol::MATCHALL)) {
694 return BuiltinsRegExp::RegExpMatchAll(thread, regexp, string, true);
702 JSHandle<JSTaggedValue> matcher = JSObject::GetMethod(thread, regexp, matchAllTag);
703 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
707 EcmaInterpreter::NewRuntimeCallInfo(thread, matcher, regexp, undefined, 1);
708 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
715 JSHandle<EcmaString> thisVal = JSTaggedValue::ToString(thread, thisTag);
716 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
718 JSHandle<JSTaggedValue> rx(thread, BuiltinsRegExp::RegExpCreate(
719 thread, regexp, JSHandle<JSTaggedValue>(ecmaVm->GetFactory()->NewFromASCII("g"))));
720 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
721 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, undefined, rx, undefined, 1);
722 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
731 JSThread *thread = argv->GetThread();
732 [[maybe_unused]] EcmaHandleScope handleScope(thread);
735 JSHandle<JSTaggedValue> obj(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
736 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
739 JSHandle<EcmaString> string = JSTaggedValue::ToString(thread, obj);
740 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
782 thread->CheckSafepointIfSuspended();
791 JSThread *thread = argv->GetThread();
792 [[maybe_unused]] EcmaHandleScope handleScope(thread);
793 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
796 JSHandle<JSTaggedValue> obj(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
797 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
800 JSHandle<EcmaString> string = JSTaggedValue::ToString(thread, obj);
801 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
854 THROW_RANGE_ERROR_AND_RETURN(thread, "CodePoint < 0 or CodePoint > 0x10FFFF",
873 thread->CheckSafepointIfSuspended();
898 JSThread *thread = argv->GetThread();
899 [[maybe_unused]] EcmaHandleScope handleScope(thread);
900 auto vm = thread->GetEcmaVM();
901 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
902 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
903 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
904 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
907 formValue = JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledNfcString());
911 formValue = JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledNfcString());
913 formValue = JSTaggedValue::ToString(thread, formTag);
914 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
919 JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledNfcString());
923 JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledNfdString());
927 JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledNfkcString());
931 JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledNfkdString());
935 THROW_RANGE_ERROR_AND_RETURN(thread, "compare not equal", JSTaggedValue::Exception());
946 JSHandle<EcmaString> str = intl::LocaleHelper::UStringToString(thread, res);
969 JSThread *thread = argv->GetThread();
970 [[maybe_unused]] EcmaHandleScope handleScope(thread);
971 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
972 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
973 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
974 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
981 JSTaggedNumber num = JSTaggedValue::ToInteger(thread, countTag);
982 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
985 THROW_RANGE_ERROR_AND_RETURN(thread, "is infinity", JSTaggedValue::Exception());
990 THROW_RANGE_ERROR_AND_RETURN(thread, "less than 0", JSTaggedValue::Exception());
993 auto emptyStr = thread->GetEcmaVM()->GetFactory()->GetEmptyString();
1000 THROW_RANGE_ERROR_AND_RETURN(thread, "Invalid string length", JSTaggedValue::Exception());
1003 EcmaString *result = EcmaStringAccessor::CreateLineString(thread->GetEcmaVM(), thisLen * count, isUtf8);
1015 JSThread *thread = argv->GetThread();
1016 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1017 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, BuiltinsString::GetThis(argv));
1018 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1020 auto ecmaVm = thread->GetEcmaVM();
1022 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1029 JSHandle<RegExpExecResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetRegExpCache());
1031 JSHandle<JSTaggedValue> pattern(thread, re->GetOriginalSource());
1032 JSHandle<JSTaggedValue> flags(thread, re->GetOriginalFlags());
1033 bool isFastPath = BuiltinsRegExp::IsFastRegExp(thread, searchTag);
1035 uint32_t lastIndex = static_cast<uint32_t>(BuiltinsRegExp::GetLastIndex(thread, searchTag, true));
1036 JSTaggedValue cacheResult = cacheTable->FindCachedResult(thread, thisTag,
1048 return BuiltinsRegExp::ReplaceInternal(thread, searchTag, thisTag, replaceTag);
1056 JSHandle<JSTaggedValue> replaceMethod = JSObject::GetMethod(thread, searchTag, replaceKey);
1058 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1065 EcmaInterpreter::NewRuntimeCallInfo(thread, replaceMethod, searchTag, undefined, argsLength);
1066 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1073 JSHandle<EcmaString> thisString = JSTaggedValue::ToString(thread, thisTag);
1075 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1077 JSHandle<EcmaString> searchString = JSTaggedValue::ToString(thread, searchTag);
1079 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1085 replaceTag = JSHandle<JSTaggedValue>(JSTaggedValue::ToString(thread, replaceTag));
1086 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1096 JSMutableHandle<JSTaggedValue> replHandle(thread, factory->GetEmptyString().GetTaggedValue());
1102 EcmaInterpreter::NewRuntimeCallInfo(thread, replaceTag, undefined, undefined, argsLength);
1103 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1106 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1112 JSHandle<EcmaString> replacement(thread, replaceTag->GetTaggedObject());
1114 replHandle.Update(GetSubstitution(thread, searchString, thisString, pos, capturesList, undefined, replacement));
1116 JSHandle<EcmaString> realReplaceStr = JSTaggedValue::ToString(thread, replHandle);
1117 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1126 JSHandle<EcmaString> prefixString(thread, EcmaStringAccessor::FastSubString(ecmaVm, thisString, 0, pos));
1128 JSHandle<EcmaString> suffixString(thread,
1131 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1132 JSHandle<EcmaString> tempString(thread, tempStr);
1134 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1141 JSThread *thread = argv->GetThread();
1142 BUILTINS_API_TRACE(thread, String, ReplaceAll);
1143 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1144 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, BuiltinsString::GetThis(argv));
1145 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1147 auto ecmaVm = thread->GetEcmaVM();
1149 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1157 bool isJSRegExp = JSObject::IsRegExp(thread, searchTag);
1158 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1163 JSHandle<JSTaggedValue> flags = JSObject::GetProperty(thread, searchTag, flagsString).GetValue();
1164 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1166 JSTaggedValue::RequireObjectCoercible(thread, flags);
1167 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1169 JSHandle<EcmaString> flagString = JSTaggedValue::ToString(thread, flags);
1170 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1174 THROW_TYPE_ERROR_AND_RETURN(thread,
1181 JSHandle<JSTaggedValue> replaceMethod = JSObject::GetMethod(thread, searchTag, replaceKey);
1182 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1189 EcmaInterpreter::NewRuntimeCallInfo(thread, replaceMethod, searchTag, undefined, argsLength);
1190 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1197 JSHandle<EcmaString> thisString = JSTaggedValue::ToString(thread, thisTag);
1198 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1200 JSHandle<EcmaString> searchString = JSTaggedValue::ToString(thread, searchTag);
1201 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1206 replaceTag = JSHandle<JSTaggedValue>(JSTaggedValue::ToString(thread, replaceTag));
1207 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1215 JSMutableHandle<EcmaString> accumulatedResult(thread, factory->GetEmptyString());
1220 JSMutableHandle<JSTaggedValue> replHandle(thread, factory->GetEmptyString().GetTaggedValue());
1227 EcmaInterpreter::NewRuntimeCallInfo(thread, replaceTag, undefined, undefined, argsLength);
1228 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1231 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1237 JSHandle<EcmaString> replacement(thread, replaceTag->GetTaggedObject());
1239 replHandle.Update(GetSubstitution(thread, searchString, thisString, pos,
1242 JSHandle<EcmaString> realReplaceStr = JSTaggedValue::ToString(thread, replHandle);
1243 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1250 JSHandle<EcmaString> prefixString(thread,
1257 thread->CheckSafepointIfSuspended();
1262 JSHandle<EcmaString> suffixString(thread,
1345 std::pair<int32_t, bool> ProcessNamedCaptures(JSThread *thread, const JSHandle<EcmaString> &replacementFlat,
1354 auto ecmaVm = thread->GetEcmaVM();
1363 thread, EcmaStringAccessor::FastSubString(ecmaVm, replacementFlat, peekIndex + 1, pos - peekIndex - 1));
1365 JSHandle<JSTaggedValue> capture = JSObject::GetProperty(thread, namedCaptures, names).GetValue();
1369 JSHandle<EcmaString> captureName = JSTaggedValue::ToString(thread, capture);
1377 JSTaggedValue BuiltinsString::GetSubstitution(JSThread *thread, const JSHandle<EcmaString> &matched,
1383 BUILTINS_API_TRACE(thread, String, GetSubstitution);
1384 auto ecmaVm = thread->GetEcmaVM();
1386 JSHandle<EcmaString> dollarString = JSHandle<EcmaString>::Cast(thread->GlobalConstants()->GetHandledDollarString());
1387 JSHandle<EcmaString> replacementFlat(thread, EcmaStringAccessor::Flatten(ecmaVm, replacement));
1451 auto result = ProcessNamedCaptures(thread, replacementFlat, peekIndex, namedCaptures, stringBuilder);
1487 thread->CheckSafepointIfSuspended();
1498 JSThread *thread = argv->GetThread();
1499 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1500 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1501 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
1502 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1505 if (BuiltinsRegExp::IsFastRegExp(thread, regexp, BuiltinsRegExp::RegExpSymbol::SEARCH)) {
1506 return BuiltinsRegExp::RegExpSearchFast(thread, regexp, thisTag);
1509 JSHandle<JSTaggedValue> searchTag = thread->GetEcmaVM()->GetGlobalEnv()->GetSearchSymbol();
1512 JSHandle<JSTaggedValue> searcher = JSObject::GetMethod(thread, regexp, searchTag);
1513 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1517 EcmaInterpreter::NewRuntimeCallInfo(thread, searcher, regexp, undefined, 1);
1518 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1523 JSHandle<EcmaString> thisVal = JSTaggedValue::ToString(thread, thisTag);
1524 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1525 JSHandle<JSTaggedValue> rx(thread, BuiltinsRegExp::RegExpCreate(thread, regexp, undefined));
1526 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1528 EcmaInterpreter::NewRuntimeCallInfo(thread, undefined, rx, undefined, 1);
1529 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1539 JSThread *thread = argv->GetThread();
1540 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1542 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
1543 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1544 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
1545 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1548 JSTaggedNumber startVal = JSTaggedValue::ToInteger(thread, startTag);
1549 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1556 JSTaggedNumber endVal = JSTaggedValue::ToInteger(thread, endTag);
1557 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1573 return JSTaggedValue(EcmaStringAccessor::FastSubString(thread->GetEcmaVM(), thisHandle, from, len));
1581 JSThread *thread = argv->GetThread();
1582 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1583 auto ecmaVm = thread->GetEcmaVM();
1587 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv));
1588 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1594 if (BuiltinsRegExp::IsFastRegExp(thread, seperatorTag)) {
1595 return BuiltinsRegExp::RegExpSplit(thread, seperatorTag, thisTag, limitTag, true);
1605 thread, ecmaVm, thisString, seperatorString, thisLength, seperatorLength);
1609 JSTaggedNumber limitIntValue = JSTaggedValue::ToInteger(thread, limitTag);
1610 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1614 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1616 JSHandle<JSObject> resultArray(JSArray::ArrayCreate(thread, JSTaggedNumber(0)));
1617 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1620 return CreateArrayBySplitString(thread, ecmaVm, thisString, seperatorString, thisLength, seperatorLength, lim);
1627 JSHandle<JSTaggedValue> splitter = JSObject::GetMethod(thread, seperatorTag, splitKey);
1628 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1632 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1634 EcmaInterpreter::NewRuntimeCallInfo(thread, splitter, seperatorTag, undefined, argsLength);
1635 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1641 JSHandle<EcmaString> thisString = JSTaggedValue::ToString(thread, thisTag);
1642 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1647 JSTaggedNumber limitIntValue = JSTaggedValue::ToInteger(thread, limitTag);
1648 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1652 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1655 JSHandle<EcmaString> seperatorString = JSTaggedValue::ToString(thread, seperatorTag);
1656 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1659 JSHandle<JSObject> resultArray(JSArray::ArrayCreate(thread, JSTaggedNumber(0)));
1660 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1666 JSHandle<JSObject> resultArray(JSArray::ArrayCreate(thread, JSTaggedNumber(1)));
1667 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1669 JSObject::CreateDataProperty(thread, resultArray, 0, JSHandle<JSTaggedValue>(thisString));
1670 ASSERT_PRINT(!thread->HasPendingException(), "CreateDataProperty(A, \"0\", S) can't throw exception");
1673 return CreateArrayBySplitString(thread, ecmaVm, thisString, seperatorString, thisLength, seperatorLength, lim);
1676 JSTaggedValue BuiltinsString::CreateArrayFromString(JSThread *thread, EcmaVM *ecmaVm,
1685 JSHandle<EcmaString> seperatorString = thread->GetEcmaVM()->GetFactory()->GetEmptyString();
1687 JSHandle<StringSplitResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetStringSplitResultCache());
1688 JSTaggedValue cacheResult = StringSplitResultCache::FindCachedResult(thread, cacheTable, thisString,
1691 JSHandle<JSTaggedValue> resultArray(JSArray::CreateArrayFromList(thread,
1692 JSHandle<TaggedArray>(thread, cacheResult)));
1697 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1703 array->Set<false>(thread, i, JSTaggedValue(elementString));
1705 array->Set(thread, i, JSTaggedValue(elementString));
1707 ASSERT_PRINT(!thread->HasPendingException(), "CreateDataProperty can't throw exception");
1709 JSHandle<JSArray> resultArray = JSArray::CreateArrayFromList(thread, array);
1711 JSHandle<StringSplitResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetStringSplitResultCache());
1712 StringSplitResultCache::SetCachedResult(thread, cacheTable, thisString, seperatorString, array);
1717 JSTaggedValue BuiltinsString::CreateArrayBySplitString(JSThread *thread, EcmaVM *ecmaVm,
1724 thread, ecmaVm, thisString, seperatorString, thisLength, seperatorLength, lim);
1726 return CreateArrayFromString(thread, ecmaVm, thisString, thisLength, lim);
1729 JSHandle<JSObject> resultArray(JSArray::ArrayCreate(thread, JSTaggedNumber(1)));
1730 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1732 JSObject::CreateDataProperty(thread, resultArray, 0, JSHandle<JSTaggedValue>(thisString));
1733 ASSERT_PRINT(!thread->HasPendingException(), "CreateDataProperty(A, \"0\", S) can't throw exception");
1736 JSHandle<JSObject> resultArray(JSArray::ArrayCreate(thread, JSTaggedNumber(0)));
1737 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1742 JSTaggedValue BuiltinsString::CreateArrayThisStringAndSeperatorStringAreNotEmpty(JSThread *thread,
1747 JSHandle<StringSplitResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetStringSplitResultCache());
1748 JSTaggedValue cacheResult = StringSplitResultCache::FindCachedResult(thread, cacheTable, thisString,
1751 JSHandle<JSTaggedValue> resultArray(JSArray::CreateArrayFromList(thread,
1752 JSHandle<TaggedArray>(thread, cacheResult)));
1768 thread->CheckSafepointIfSuspended();
1772 return JSArray::ArrayCreateWithInit(thread, arrayLength,
1773 [thread, ecmaVm, &thisString, &seperatorString, &posArray, thisLength, seperatorLength, lim, posArrLength]
1777 JSMutableHandle<JSTaggedValue> elementTag(thread, JSTaggedValue::Undefined());
1782 newElements->Set(thread, i, elementTag);
1789 newElements->Set(thread, posArrLength, elementTag);
1792 JSHandle<StringSplitResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetStringSplitResultCache());
1793 StringSplitResultCache::SetCachedResult(thread, cacheTable, thisString, seperatorString, newElements);
1803 JSThread *thread = argv->GetThread();
1804 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1807 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
1808 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1809 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
1810 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1811 bool isRegexp = JSObject::IsRegExp(thread, searchTag);
1813 THROW_TYPE_ERROR_AND_RETURN(thread, "is regexp", JSTaggedValue::Exception());
1816 JSHandle<EcmaString> searchHandle = JSTaggedValue::ToString(thread, searchTag);
1817 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1827 JSTaggedNumber posVal = JSTaggedValue::ToInteger(thread, posTag);
1828 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1840 bool result = EcmaStringAccessor::IsSubStringAt(thread->GetEcmaVM(), thisHandle, searchHandle, pos);
1850 JSThread *thread = argv->GetThread();
1851 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1853 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
1854 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1855 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
1856 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1859 JSTaggedNumber startVal = JSTaggedValue::ToInteger(thread, startTag);
1860 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1867 JSTaggedNumber endVal = JSTaggedValue::ToInteger(thread, endTag);
1868 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1876 return JSTaggedValue(EcmaStringAccessor::GetSubString(thread->GetEcmaVM(), thisHandle, from, len));
1884 JSThread *thread = argv->GetThread();
1885 EcmaVM *ecmaVm = thread->GetEcmaVM();
1886 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1889 JSHandle<JSTaggedValue> obj(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
1890 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1892 JSHandle<EcmaString> string = JSTaggedValue::ToString(thread, obj);
1893 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1902 JSHandle<TaggedArray> requestedLocales = intl::LocaleHelper::CanonicalizeLocaleList(thread, locales);
1903 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1907 JSHandle<EcmaString> requestedLocale = intl::LocaleHelper::DefaultLocale(thread);
1909 requestedLocale = JSHandle<EcmaString>(thread, requestedLocales->Get(0));
1915 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1920 std::vector<std::string> availableLocales = intl::LocaleHelper::GetAvailableLocales(thread, nullptr, nullptr);
1921 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1925 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1945 JSThread *thread = argv->GetThread();
1946 EcmaVM *ecmaVm = thread->GetEcmaVM();
1947 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1950 JSHandle<JSTaggedValue> obj(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
1951 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1953 JSHandle<EcmaString> string = JSTaggedValue::ToString(thread, obj);
1954 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1963 JSHandle<TaggedArray> requestedLocales = intl::LocaleHelper::CanonicalizeLocaleList(thread, locales);
1964 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1968 JSHandle<EcmaString> requestedLocale = intl::LocaleHelper::DefaultLocale(thread);
1970 requestedLocale = JSHandle<EcmaString>(thread, requestedLocales->Get(0));
1976 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1981 std::vector<std::string> availableLocales = intl::LocaleHelper::GetAvailableLocales(thread, nullptr, nullptr);
1982 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1986 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2006 JSThread *thread = argv->GetThread();
2007 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2008 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
2009 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2010 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2011 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2012 EcmaString *result = EcmaStringAccessor::ToLower(thread->GetEcmaVM(), thisHandle);
2028 JSThread *thread = argv->GetThread();
2029 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2031 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
2032 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2033 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2034 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2035 EcmaString *result = EcmaStringAccessor::ToUpper(thread->GetEcmaVM(), thisHandle);
2044 JSThread *thread = argv->GetThread();
2045 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2046 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
2047 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2048 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2049 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2050 EcmaString *res = EcmaStringAccessor::Trim(thread, thisHandle, EcmaString::TrimMode::TRIM);
2058 JSThread *thread = argv->GetThread();
2059 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2060 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv));
2061 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2062 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2063 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2064 EcmaString *res = EcmaStringAccessor::Trim(thread, thisHandle, EcmaString::TrimMode::TRIM_START);
2072 JSThread *thread = argv->GetThread();
2073 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2074 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv));
2075 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2076 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2077 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2078 EcmaString *res = EcmaStringAccessor::Trim(thread, thisHandle, EcmaString::TrimMode::TRIM_END);
2086 JSThread *thread = argv->GetThread();
2087 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2088 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv));
2089 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2090 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2091 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2092 EcmaString *res = EcmaStringAccessor::Trim(thread, thisHandle, EcmaString::TrimMode::TRIM_START);
2100 JSThread *thread = argv->GetThread();
2101 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2102 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv));
2103 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2104 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2105 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2106 EcmaString *res = EcmaStringAccessor::Trim(thread, thisHandle, EcmaString::TrimMode::TRIM_END);
2122 JSThread *thread = argv->GetThread();
2123 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2125 JSHandle<JSTaggedValue> current(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
2126 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2129 JSHandle<EcmaString> string = JSTaggedValue::ToString(thread, current);
2132 return JSStringIterator::CreateStringIterator(thread, string).GetTaggedValue();
2140 JSThread *thread = argv->GetThread();
2142 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2147 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
2148 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2149 JSHandle<EcmaString> thisString = JSTaggedValue::ToString(thread, thisTag);
2152 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2155 JSTaggedNumber numStart = JSTaggedValue::ToInteger(thread, intStart);
2157 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2165 JSTaggedNumber lengthNumber = JSTaggedValue::ToInteger(thread, lengthTag);
2167 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2178 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2183 return JSTaggedValue(EcmaStringAccessor::FastSubString(thread->GetEcmaVM(), thisString, start, resultLength));
2191 JSThread *thread = argv->GetThread();
2192 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2196 JSHandle<JSTaggedValue> thisTag(JSTaggedValue::RequireObjectCoercible(thread, GetThis(argv)));
2197 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2198 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2199 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2206 JSTaggedNumber indexVal = JSTaggedValue::ToInteger(thread, indexTag);
2207 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2222 return JSTaggedValue(EcmaStringAccessor::FastSubString(thread->GetEcmaVM(), thisHandle, k, 1));
2228 JSThread *thread = argv->GetThread();
2229 BUILTINS_API_TRACE(thread, String, GetLength);
2230 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2233 JSHandle<EcmaString> thisString = JSTaggedValue::ToString(thread, thisHandle);
2234 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2239 JSTaggedValue BuiltinsString::ThisStringValue(JSThread *thread, JSTaggedValue value)
2241 BUILTINS_API_TRACE(thread, String, ThisStringValue);
2254 THROW_TYPE_ERROR_AND_RETURN(thread, "can not convert to String", JSTaggedValue::Exception());
2259 JSThread *thread = argv->GetThread();
2260 BUILTINS_API_TRACE(thread, String, Pad);
2261 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2263 JSHandle<JSTaggedValue> thisTag = JSTaggedValue::RequireObjectCoercible(thread, BuiltinsString::GetThis(argv));
2264 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2265 JSHandle<EcmaString> thisHandle = JSTaggedValue::ToString(thread, thisTag);
2266 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2268 JSTaggedNumber number = JSTaggedValue::ToNumber(thread, lengthTag);
2269 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2280 JSHandle<EcmaString> filler = JSTaggedValue::ToString(thread, fillString);
2281 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2291 THROW_RANGE_ERROR_AND_RETURN(thread, "Invalid string length", JSTaggedValue::Exception());
2303 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2322 JSTaggedValue BuiltinsString::StringToList(JSThread *thread, JSHandle<EcmaString> &str)
2324 JSHandle<StringToListResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetStringToListResultCache());
2325 JSTaggedValue cacheResult = StringToListResultCache::FindCachedResult(thread, cacheTable, str);
2327 JSHandle<JSTaggedValue> resultArray(JSArray::CreateArrayFromList(thread,
2328 JSHandle<TaggedArray>(thread, cacheResult)));
2332 JSTaggedValue newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue();
2333 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2334 JSHandle<JSObject> newArrayHandle(thread, newArray);
2336 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2337 JSHandle<TaggedArray> oldElements(thread, newArrayHandle->GetElements());
2342 newArrayHandle->SetElements(thread, elements);
2346 ElementAccessor::Set(thread, newArrayHandle, index, newStr, true);
2348 thread->CheckSafepointIfSuspended();
2350 JSHandle<JSArray>(newArrayHandle)->SetArrayLength(thread, totalElements);
2352 StringToListResultCache::SetCachedResult(thread, cacheTable, str, elements);
2357 JSTaggedValue BuiltinsString::StringToSList(JSThread *thread, JSHandle<EcmaString> &str)
2359 JSHandle<StringToListResultCache> cacheTable(thread->GetCurrentEcmaContext()->GetStringToListResultCache());
2360 JSTaggedValue cacheResult = StringToListResultCache::FindCachedResult(thread, cacheTable, str);
2363 JSSharedArray::CreateArrayFromList(thread, JSHandle<TaggedArray>(thread, cacheResult)));
2367 JSTaggedValue newSharedArray = JSSharedArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue();
2368 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2369 JSHandle<JSObject> newSharedArrayHandle(thread, newSharedArray);
2371 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2372 JSHandle<TaggedArray> oldElements(thread, newSharedArrayHandle->GetElements());
2379 newSharedArrayHandle->SetElements(thread, elements);
2383 ElementAccessor::Set(thread, newSharedArrayHandle, index, newStr, true);
2385 thread->CheckSafepointIfSuspended();
2387 JSHandle<JSSharedArray>(newSharedArrayHandle)->SetArrayLength(thread, totalElements);
2389 StringToListResultCache::SetCachedResult(thread, cacheTable, str, elements);
2394 JSTaggedValue StringSplitResultCache::CreateCacheTable(const JSThread *thread)
2398 *thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length, JSTaggedValue::Undefined()));
2402 JSTaggedValue StringSplitResultCache::FindCachedResult(const JSThread *thread,
2414 JSHandle<EcmaString> cacheStringHandle(thread, cacheThis);
2415 JSHandle<EcmaString> cachePatternHandle(thread, cachePattern);
2417 if (EcmaStringAccessor::StringsAreEqual(thread->GetEcmaVM(), thisString, cacheStringHandle) &&
2418 EcmaStringAccessor::StringsAreEqual(thread->GetEcmaVM(), pattern, cachePatternHandle)) {
2419 JSHandle<TaggedArray> cacheArray(thread, cache->Get(index + ARRAY_INDEX));
2421 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2433 void StringSplitResultCache::SetCachedResult(const JSThread *thread, const JSHandle<StringSplitResultCache> &cache,
2439 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2442 newElements->Set(thread, i, resultArray->Get(i));
2448 cache->Set(thread, index + STRING_INDEX, thisString);
2449 cache->Set(thread, index + PATTERN_INDEX, pattern);
2450 cache->Set(thread, index + ARRAY_INDEX, newElements);
2453 JSTaggedValue StringToListResultCache::CreateCacheTable(const JSThread *thread)
2457 *thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length, JSTaggedValue::Undefined()));
2461 JSTaggedValue StringToListResultCache::FindCachedResult(const JSThread *thread,
2470 JSHandle<JSTaggedValue> cacheThis(thread, cache->Get(index + STRING_INDEX));
2475 if (EcmaStringAccessor::StringsAreEqual(thread->GetEcmaVM(), thisString, cacheStr)) {
2481 void StringToListResultCache::SetCachedResult(const JSThread *thread, const JSHandle<StringToListResultCache> &cache,
2493 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2501 newElements->Set(thread, i, resultArray->Get(i));
2506 cache->Set(thread, index + STRING_INDEX, thisString);
2507 cache->Set(thread, index + ARRAY_INDEX, newElements);