Lines Matching refs:thread

38     JSThread *thread = argv->GetThread();
39 [[maybe_unused]] EcmaHandleScope handleScope(thread);
58 return JSArray::ArrayCreate(thread, JSTaggedNumber(0), newTarget).GetTaggedValue();
64 JSHandle<JSObject> newArrayHandle(JSArray::ArrayCreate(thread, JSTaggedNumber(0), newTarget));
65 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
78 JSHandle<JSTaggedValue> key0 = thread->GlobalConstants()->GetHandledZeroString();
79 JSObject::CreateDataProperty(thread, newArrayHandle, key0, len);
82 newLen = JSTaggedValue::ToUint32(thread, len);
83 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
85 THROW_RANGE_ERROR_AND_RETURN(thread, "Invalid array length", JSTaggedValue::Exception());
88 JSArray::SetCapacity(thread, newArrayHandle, 0, newLen, true);
100 auto arrayFunc = thread->GetEcmaVM()->GetGlobalEnv()->GetArrayFunction();
104 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
112 elements->Set(thread, k, value);
115 auto newArray = JSArray::CreateArrayFromList(thread, newTarget, elements);
116 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
117 if (thread->GetEcmaVM()->IsEnableElementsKind()) {
118 JSHClass::TransitToElementsKind(thread, newArray, newKind);
125 JSTaggedValue newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(argc), newTarget).GetTaggedValue();
126 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
127 if (!newArray.IsArray(thread)) {
128 THROW_TYPE_ERROR_AND_RETURN(thread, "Failed to create array.", JSTaggedValue::Exception());
130 JSHandle<JSObject> newArrayHandle(thread, newArray);
139 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
140 JSMutableHandle<JSTaggedValue> itemK(thread, JSTaggedValue::Undefined());
147 JSObject::CreateDataProperty(thread, newArrayHandle, key, itemK);
151 JSArray::Cast(*newArrayHandle)->SetArrayLength(thread, argc);
161 JSThread *thread = argv->GetThread();
162 [[maybe_unused]] EcmaHandleScope handleScope(thread);
163 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
176 THROW_TYPE_ERROR_AND_RETURN(thread, "the mapfn is not callable.", JSTaggedValue::Exception());
183 THROW_TYPE_ERROR_AND_RETURN(thread, "The items is null.", JSTaggedValue::Exception());
187 return BuiltinsString::StringToList(thread, strItems);
192 return BuiltinsArrayBuffer::TypedArrayToList(thread, arrayItems);
195 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
197 JSHandle<JSTaggedValue> usingIterator = JSObject::GetMethod(thread, items, iteratorSymbol);
199 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
201 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
204 JSHandle<JSTaggedValue> iterator(thread, JSTaggedValue::Hole());
206 iterator = JSIterator::GetIterator(thread, items, usingIterator);
208 return JSMapIterator::MapIteratorToList(thread, iterator);
220 EcmaInterpreter::NewRuntimeCallInfo(thread, thisHandle, undefined, undefined, 0);
222 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
224 newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(0)).GetTaggedValue();
225 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
228 THROW_TYPE_ERROR_AND_RETURN(thread, "Failed to construct the array.", JSTaggedValue::Exception());
230 JSHandle<JSObject> newArrayHandle(thread, newArray);
233 iterator = JSIterator::GetIterator(thread, items, usingIterator);
235 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
240 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
241 JSMutableHandle<JSTaggedValue> mapValue(thread, JSTaggedValue::Undefined());
244 JSHandle<JSObject> arrayLikeObj = JSTaggedValue::ToObject(thread, items);
246 int64_t len = ArrayHelper::GetArrayLength(thread, arrayLike);
248 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, arrayLike, k);
249 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
254 EcmaInterpreter::NewRuntimeCallInfo(thread, mapfn, thisArgHandle, undefined, argsLength);
255 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
258 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
263 JSArray::TryFastCreateDataProperty(thread, newArrayHandle, k, mapValue);
264 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
266 len = ArrayHelper::GetArrayLength(thread, arrayLike);
267 thread->CheckSafepointIfSuspended();
275 JSHandle<JSTaggedValue> next = JSIterator::IteratorStep(thread, iterator);
277 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
283 JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(newArrayHandle), lengthKey, key, true);
284 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
288 JSHandle<JSTaggedValue> nextValue = JSIterator::IteratorValue(thread, next);
290 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
299 EcmaInterpreter::NewRuntimeCallInfo(thread, mapfn, thisArgHandle, undefined, argsLength);
300 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
303 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread,
304 JSIterator::IteratorClose(thread, iterator, mapValue).GetTaggedValue());
313 JSArray::TryFastCreateDataProperty(thread, newArrayHandle, k, mapValue) :
314 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, key, mapValue);
316 JSHandle<JSTaggedValue> defineStatus(thread, JSTaggedValue(createRes));
317 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread,
318 JSIterator::IteratorClose(thread, iterator, defineStatus).GetTaggedValue());
324 JSHandle<JSObject> arrayLikeObj = JSTaggedValue::ToObject(thread, items);
326 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
329 int64_t len = ArrayHelper::GetArrayLength(thread, arrayLike);
331 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
340 EcmaInterpreter::NewRuntimeCallInfo(thread, thisHandle, undefined, undefined, 1);
341 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
344 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
346 newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(len))).GetTaggedValue();
347 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
350 THROW_TYPE_ERROR_AND_RETURN(thread, "Failed to construct the array.", JSTaggedValue::Exception());
352 JSHandle<JSObject> newArrayHandle(thread, newArray);
361 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
362 JSMutableHandle<JSTaggedValue> mapValue(thread, JSTaggedValue::Undefined());
365 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, arrayLike, k);
366 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
371 EcmaInterpreter::NewRuntimeCallInfo(thread, mapfn, thisArgHandle, undefined, argsLength);
372 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
375 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
380 JSArray::TryFastCreateDataProperty(thread, newArrayHandle, k, mapValue);
381 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
383 thread->CheckSafepointIfSuspended();
386 JSHandle<JSTaggedValue> lenHandle(thread, JSTaggedValue(len));
387 JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(newArrayHandle), lengthKey, lenHandle, true);
389 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
411 JSThread *thread = argv->GetThread();
412 [[maybe_unused]] EcmaHandleScope handleScope(thread);
413 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
430 EcmaInterpreter::NewRuntimeCallInfo(thread, thisHandle, undefined, undefined, 1);
431 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
434 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
435 newArray = JSHandle<JSTaggedValue>(thread, taggedArray);
437 newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(argc));
438 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
441 THROW_TYPE_ERROR_AND_RETURN(thread, "Failed to create Object.", JSTaggedValue::Exception());
452 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
456 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, key, kValue);
457 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
460 JSHandle<JSTaggedValue> lenHandle(thread, JSTaggedValue(argc));
461 JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(newArrayHandle), lengthKey, lenHandle, true);
462 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
481 JSThread *thread = argv->GetThread();
482 [[maybe_unused]] EcmaHandleScope handleScope(thread);
487 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
488 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
493 JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(arrayLen));
494 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
496 THROW_TYPE_ERROR_AND_RETURN(thread, "array must be object or undefined.", JSTaggedValue::Exception());
498 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
499 JSHandle<JSObject> newArrayHandle(thread, newArray);
501 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
505 JSMutableHandle<JSTaggedValue> ele(thread, JSTaggedValue::Undefined());
506 JSMutableHandle<JSTaggedValue> fromKey(thread, JSTaggedValue::Undefined());
507 JSMutableHandle<JSTaggedValue> toKey(thread, JSTaggedValue::Undefined());
517 bool isSpreadable = ArrayHelper::IsConcatSpreadable(thread, ele);
518 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
524 int64_t len = ArrayHelper::GetArrayLength(thread, ele);
526 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
528 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
531 if (ele->IsStableJSArray(thread)) {
532 JSStableArray::Concat(thread, newArrayHandle, JSHandle<JSObject>::Cast(ele), k, n);
533 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
540 fromKey.Update(JSTaggedValue::ToString(thread, JSTaggedValue(k)));
542 bool exists = JSTaggedValue::HasProperty(thread, ele, fromKey);
543 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
547 JSArray::FastGetPropertyByValue(thread, ele, fromKey);
548 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
550 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, toKey, fromValHandle);
551 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
557 thread->CheckSafepointIfSuspended();
563 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
568 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, toKey, ele);
569 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
574 JSHandle<JSTaggedValue> lenHandle(thread, JSTaggedValue(n));
575 JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(newArrayHandle), lengthKey, lenHandle, true);
576 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
587 JSThread *thread = argv->GetThread();
588 [[maybe_unused]] EcmaHandleScope handleScope(thread);
591 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, GetThis(argv));
593 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
597 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
599 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
606 JSTaggedNumber targetTemp = JSTaggedValue::ToInteger(thread, GetCallArg(argv, 0));
608 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
618 JSTaggedNumber start_t = JSTaggedValue::ToInteger(thread, GetCallArg(argv, 1));
620 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
633 JSTaggedNumber temp = JSTaggedValue::ToInteger(thread, msg3);
635 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
678 JSMutableHandle<JSTaggedValue> fromKey(thread, JSTaggedValue::Undefined());
679 JSMutableHandle<JSTaggedValue> toKey(thread, JSTaggedValue::Undefined());
684 JSTaggedValue::HasProperty(thread, thisObjVal, fromKey));
685 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
687 JSHandle<JSTaggedValue> fromValHandle = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
688 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
689 JSArray::FastSetPropertyByValue(thread, thisObjVal, toKey, fromValHandle);
690 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
693 toKey.Update(JSTaggedValue::ToString(thread, toKey).GetTaggedValue());
694 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
696 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, toKey);
697 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
713 JSThread *thread = argv->GetThread();
714 [[maybe_unused]] EcmaHandleScope handleScope(thread);
715 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
718 JSHandle<JSObject> self = JSTaggedValue::ToObject(thread, GetThis(argv));
719 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
729 JSThread *thread = argv->GetThread();
730 BUILTINS_API_TRACE(thread, Array, Every);
731 [[maybe_unused]] EcmaHandleScope handleScope(thread);
735 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
737 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
741 uint64_t len = static_cast<uint64_t>(ArrayHelper::GetArrayLength(thread, thisObjVal));
743 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
748 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
766 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
769 if (thisObjVal->IsStableJSArray(thread)) {
770 callResult = JSStableArray::HandleEveryOfStable(thread, thisObjHandle, callbackFnHandle, thisArgHandle, k);
771 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
776 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
779 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, k);
780 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
782 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
783 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
786 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
787 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
790 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
796 thread->CheckSafepointIfSuspended();
808 JSThread *thread = argv->GetThread();
809 [[maybe_unused]] EcmaHandleScope handleScope(thread);
813 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
815 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
824 JSObject::TryOptimizeAsFastElements(thread, thisObjHandle);
830 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
835 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
837 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
841 JSTaggedNumber argStartTemp = JSTaggedValue::ToInteger(thread, startArg);
843 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
858 JSTaggedNumber argEndTemp = JSTaggedValue::ToInteger(thread, endArg);
860 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
878 if (thisObjVal->IsStableJSArray(thread) && !startArg->IsJSObject() && !endArg->IsJSObject()) {
879 return JSStableArray::Fill(thread, thisObjHandle, value, start, end, len);
883 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
886 JSArray::FastSetPropertyByValue(thread, thisObjVal, key, value);
887 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
895 JSTaggedValue BuiltinsArray::FilterUnStableJSArray(JSThread *thread, JSHandle<JSTaggedValue> &thisArgHandle,
899 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
902 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
903 JSMutableHandle<JSTaggedValue> toIndexHandle(thread, JSTaggedValue::Undefined());
905 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, k);
906 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
908 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
909 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
912 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
913 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
916 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
919 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, toIndexHandle, kValue);
920 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
925 thread->CheckSafepointIfSuspended();
934 JSThread *thread = argv->GetThread();
935 BUILTINS_API_TRACE(thread, Array, Filter);
936 [[maybe_unused]] EcmaHandleScope handleScope(thread);
940 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
942 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
946 uint64_t len = static_cast<uint64_t>(ArrayHelper::GetArrayLength(thread, thisObjVal));
948 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
953 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
961 JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(arrayLen));
963 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
964 JSHandle<JSObject> newArrayHandle(thread, newArray);
983 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
984 JSMutableHandle<JSTaggedValue> toIndexHandle(thread, JSTaggedValue::Undefined());
986 if (thisObjVal->IsStableJSArray(thread)) {
988 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
990 return FilterUnStableJSArray(thread, thisArgHandle, thisObjVal, k, len, toIndex, newArrayHandle, callbackFnHandle);
998 JSThread *thread = argv->GetThread();
999 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1003 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1005 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1009 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
1011 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1016 THROW_TYPE_ERROR_AND_RETURN(thread, "the predicate is not callable.", JSTaggedValue::Exception());
1031 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1034 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
1035 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1038 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1040 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
1041 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1044 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1060 JSThread *thread = argv->GetThread();
1061 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1065 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1067 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1071 uint64_t len = static_cast<uint64_t>(ArrayHelper::GetLength(thread, thisObjVal));
1073 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1078 THROW_TYPE_ERROR_AND_RETURN(thread, "the predicate is not callable.", JSTaggedValue::Exception());
1095 if (thisObjVal->IsStableJSArray(thread)) {
1096 callResult = JSStableArray::HandleFindIndexOfStable(thread, thisObjHandle, callbackFnHandle, thisArgHandle, k);
1097 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1102 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1103 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1106 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
1107 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1110 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
1111 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1114 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1119 thread->CheckSafepointIfSuspended();
1130 JSThread *thread = argv->GetThread();
1131 BUILTINS_API_TRACE(thread, Array, ForEach);
1132 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1136 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1138 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1142 uint64_t len = static_cast<uint64_t>(ArrayHelper::GetArrayLength(thread, thisObjVal));
1144 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1149 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
1166 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1168 if (thisObjVal->IsStableJSArray(thread)) {
1169 JSStableArray::HandleforEachOfStable(thread, thisObjHandle, callbackFnHandle, thisArgHandle, len, k);
1170 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1173 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1175 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, k);
1176 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1178 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
1179 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1182 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
1183 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1186 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, funcResult);
1189 thread->CheckSafepointIfSuspended();
1197 EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisHandle)
1208 fromIndex = ArrayHelper::GetStartIndex(thread, fromIndexHandle, length);
1209 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1213 return IndexOfSlowPath(argv, thread, thisHandle, length, fromIndex);
1220 return IndexOfSlowPath(argv, thread, thisHandle, length, fromIndex);
1224 thread, thisHandle, target, static_cast<uint32_t>(fromIndex), static_cast<uint32_t>(length));
1228 EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisHandle)
1231 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1233 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1236 int64_t length = ArrayHelper::GetLength(thread, thisObjVal);
1238 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1244 int64_t fromIndex = ArrayHelper::GetStartIndexFromArgs(thread, argv, 1, length);
1245 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1246 return IndexOfSlowPath(argv, thread, thisObjVal, length, fromIndex);
1250 EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisObjVal,
1256 JSMutableHandle<JSTaggedValue> keyHandle(thread, JSTaggedValue::Undefined());
1261 bool found = ArrayHelper::ElementIsStrictEqualTo(thread, thisObjVal, keyHandle, target);
1262 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1266 thread->CheckSafepointIfSuspended();
1276 JSThread *thread = argv->GetThread();
1277 BUILTINS_API_TRACE(thread, Array, IndexOf);
1278 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1281 if (thisHandle->IsStableJSArray(thread)) {
1282 return IndexOfStable(argv, thread, thisHandle);
1284 return IndexOfSlowPath(argv, thread, thisHandle);
1292 JSThread *thread = argv->GetThread();
1293 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1295 auto factory = thread->GetEcmaVM()->GetFactory();
1296 auto context = thread->GetCurrentEcmaContext();
1301 if (thisHandle->IsStableJSArray(thread)) {
1306 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1308 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
1312 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
1314 THROW_TYPE_ERROR_AND_RETURN(thread, "Invalid array length", JSTaggedValue::Exception());
1317 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
1323 sepHandle = thread->GlobalConstants()->GetHandledCommaString();
1328 JSHandle<EcmaString> sepStringHandle = JSTaggedValue::ToString(thread, sepHandle);
1337 THROW_RANGE_ERROR_AND_RETURN(thread, "Invalid string length", JSTaggedValue::Exception());
1340 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
1346 return GetTaggedString(thread, "");
1363 JSHandle<JSTaggedValue> element = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
1364 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
1366 JSHandle<EcmaString> nextStringHandle = JSTaggedValue::ToString(thread, element);
1367 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
1376 THROW_RANGE_ERROR_AND_RETURN(thread, "Invalid string length", JSTaggedValue::Exception());
1378 thread->CheckSafepointIfSuspended();
1395 JSThread *thread = argv->GetThread();
1396 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1397 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1400 JSHandle<JSObject> self = JSTaggedValue::ToObject(thread, GetThis(argv));
1401 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1408 EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisHandle)
1419 fromIndex = ArrayHelper::GetLastStartIndex(thread, fromIndexHandle, length);
1420 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1424 return LastIndexOfSlowPath(argv, thread, thisHandle, fromIndex);
1432 thread, thisHandle, target, static_cast<uint32_t>(fromIndex), static_cast<uint32_t>(length));
1436 EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisHandle)
1439 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1441 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1444 int64_t length = ArrayHelper::GetLength(thread, thisObjVal);
1446 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1452 int64_t fromIndex = ArrayHelper::GetLastStartIndexFromArgs(thread, argv, 1, length);
1453 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1454 return LastIndexOfSlowPath(argv, thread, thisObjVal, fromIndex);
1458 EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisObjVal, int64_t fromIndex)
1463 JSMutableHandle<JSTaggedValue> keyHandle(thread, JSTaggedValue::Undefined());
1468 bool found = ArrayHelper::ElementIsStrictEqualTo(thread, thisObjVal, keyHandle, target);
1469 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1483 JSThread *thread = argv->GetThread();
1484 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1487 if (thisHandle->IsStableJSArray(thread)) {
1488 return LastIndexOfStable(argv, thread, thisHandle);
1490 return LastIndexOfSlowPath(argv, thread, thisHandle);
1498 JSThread *thread = argv->GetThread();
1499 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1503 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1505 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1509 int64_t rawLen = ArrayHelper::GetArrayLength(thread, thisObjVal);
1511 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1516 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
1524 JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(static_cast<double>(rawLen)));
1526 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1528 THROW_TYPE_ERROR_AND_RETURN(thread, "Failed to create Object.", JSTaggedValue::Exception());
1530 JSHandle<JSObject> newArrayHandle(thread, newArray);
1547 if (thisObjVal->IsStableJSArray(thread)) {
1549 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1551 return MapUnStableJSArray(thread, thisArgHandle, thisObjVal, k, len, newArrayHandle, callbackFnHandle);
1554 JSTaggedValue BuiltinsArray::MapUnStableJSArray(JSThread *thread, JSHandle<JSTaggedValue> &thisArgHandle,
1558 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1559 JSMutableHandle<JSTaggedValue> mapResultHandle(thread, JSTaggedValue::Undefined());
1560 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1563 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, k);
1564 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1566 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
1567 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1570 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
1571 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1574 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1576 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, k, mapResultHandle);
1577 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1580 thread->CheckSafepointIfSuspended();
1592 JSThread *thread = argv->GetThread();
1593 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1597 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1598 if (thisHandle->IsStableJSArray(thread) && JSObject::IsArrayLengthWritable(thread, thisObjHandle)) {
1603 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1607 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
1609 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1614 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
1616 JSHandle<JSTaggedValue> lengthValue(thread, JSTaggedValue(0));
1617 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, lengthValue, true);
1618 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1633 JSHandle<JSTaggedValue> indexHandle(thread, JSTaggedValue(newLen));
1634 JSHandle<JSTaggedValue> element = JSTaggedValue::GetProperty(thread, thisObjVal, indexHandle).GetValue();
1635 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1636 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, indexHandle);
1637 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1638 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, indexHandle, true);
1639 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1649 JSThread *thread = argv->GetThread();
1650 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1653 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1654 if (thisHandle->IsStableJSArray(thread) && JSObject::IsArrayLengthWritable(thread, thisObjHandle)) {
1661 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1665 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
1667 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1670 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
1679 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1683 JSArray::FastSetPropertyByValue(thread, thisObjVal, key, kValue);
1684 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1690 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
1692 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, key, true);
1694 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1700 JSTaggedValue BuiltinsArray::ReduceUnStableJSArray(JSThread *thread, JSHandle<JSTaggedValue> &thisHandle,
1704 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1706 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1708 bool exists = (thisHandle->IsTypedArray() || JSTaggedValue::HasProperty(thread, thisObjVal, k));
1709 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1711 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
1712 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1718 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
1719 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1723 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1727 thread->CheckSafepointIfSuspended();
1737 JSThread *thread = argv->GetThread();
1738 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1742 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1744 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1748 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
1750 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1757 JSThread *thread = argv->GetThread();
1761 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1763 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1769 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
1774 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
1792 JSMutableHandle<JSTaggedValue> accumulator(thread, JSTaggedValue::Undefined());
1799 JSTaggedValue::HasProperty(thread, thisObjVal, k));
1800 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1802 accumulator.Update(JSArray::FastGetPropertyByValue(thread, thisObjVal, k).GetTaggedValue());
1803 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1808 THROW_TYPE_ERROR_AND_RETURN(thread, "accumulator can't be initialized.", JSTaggedValue::Exception());
1812 if (thisObjVal->IsStableJSArray(thread)) {
1813 JSStableArray::Reduce(thread, thisObjHandle, callbackFnHandle, accumulator, k, len);
1814 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1816 return ReduceUnStableJSArray(thread, thisHandle, thisObjVal, k, len, accumulator, callbackFnHandle);
1824 JSThread *thread = argv->GetThread();
1825 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1829 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1831 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1835 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
1837 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1844 JSThread *thread = argv->GetThread();
1845 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1851 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1853 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1859 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
1864 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
1882 JSMutableHandle<JSTaggedValue> accumulator(thread, JSTaggedValue::Undefined());
1888 kPresent = (thisHandle->IsTypedArray() || JSTaggedValue::HasProperty(thread, thisObjVal, k));
1889 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1891 accumulator.Update(JSArray::FastGetPropertyByValue(thread, thisObjVal, k).GetTaggedValue());
1892 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1897 THROW_TYPE_ERROR_AND_RETURN(thread, "accumulator can't be initialized.", JSTaggedValue::Exception());
1911 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
1915 if (thisObjVal->IsStableJSArray(thread)) {
1916 JSTaggedValue ret = JSStableArray::HandleReduceRightOfStable(thread, thisObjHandle,
1918 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1926 bool exists = (thisHandle->IsTypedArray() || JSTaggedValue::HasProperty(thread, thisObjVal, key));
1927 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1929 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, key);
1930 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1934 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
1935 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1939 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1954 JSThread *thread = argv->GetThread();
1955 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1959 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
1961 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1969 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
1970 JSHandle<JSTaggedValue> lenResult = JSTaggedValue::GetProperty(thread, thisHandle, lengthKey).GetValue();
1971 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
1972 JSTaggedNumber lenNumber = JSTaggedValue::ToLength(thread, lenResult);
1973 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
1977 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2017 JSMutableHandle<JSTaggedValue> lowerP(thread, JSTaggedValue::Undefined());
2018 JSMutableHandle<JSTaggedValue> upperP(thread, JSTaggedValue::Undefined());
2019 JSHandle<JSTaggedValue> lowerValueHandle(thread, JSTaggedValue::Undefined());
2020 JSHandle<JSTaggedValue> upperValueHandle(thread, JSTaggedValue::Undefined());
2022 if (thisObjVal->IsStableJSArray(thread)) {
2023 JSStableArray::Reverse(thread, thisObjHandle, lower, len);
2029 bool lowerExists = (JSTaggedValue::HasProperty(thread, thisObjVal, lowerP));
2030 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2032 lowerValueHandle = JSArray::FastGetPropertyByValue(thread, thisObjVal, lowerP);
2033 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2035 bool upperExists = (JSTaggedValue::HasProperty(thread, thisObjVal, upperP));
2036 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2038 upperValueHandle = JSArray::FastGetPropertyByValue(thread, thisObjVal, upperP);
2039 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2042 JSArray::FastSetPropertyByValue(thread, thisObjVal, lowerP, upperValueHandle);
2043 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2044 JSArray::FastSetPropertyByValue(thread, thisObjVal, upperP, lowerValueHandle);
2045 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2047 JSArray::FastSetPropertyByValue(thread, thisObjVal, lowerP, upperValueHandle);
2048 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2049 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, upperP);
2050 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2052 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, lowerP);
2053 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2054 JSArray::FastSetPropertyByValue(thread, thisObjVal, upperP, lowerValueHandle);
2055 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2070 JSThread *thread = argv->GetThread();
2071 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2075 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2077 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2078 if (thisHandle->IsStableJSArray(thread) && JSObject::IsArrayLengthWritable(thread, thisObjHandle)) {
2084 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
2086 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2091 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
2093 JSHandle<JSTaggedValue> zeroLenHandle(thread, JSTaggedValue(len));
2094 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, zeroLenHandle, true);
2095 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2100 JSHandle<JSTaggedValue> firstKey(thread, JSTaggedValue(0));
2101 JSHandle<JSTaggedValue> firstValue = JSTaggedValue::GetProperty(thread, thisObjVal, firstKey).GetValue();
2103 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2120 JSMutableHandle<JSTaggedValue> toKey(thread, JSTaggedValue::Undefined());
2123 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, k);
2124 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2126 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
2127 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2128 JSArray::FastSetPropertyByValue(thread, thisObjVal, k - 1, fromValue);
2129 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2132 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, toKey);
2133 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2136 thread->CheckSafepointIfSuspended();
2139 JSHandle<JSTaggedValue> deleteKey(thread, JSTaggedValue(len - 1));
2140 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, deleteKey);
2142 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2145 JSHandle<JSTaggedValue> newLenHandle(thread, JSTaggedValue(len - 1));
2146 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, newLenHandle, true);
2148 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2159 JSThread *thread = argv->GetThread();
2160 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2164 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2166 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2170 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
2172 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2180 JSTaggedNumber argStartTemp = JSTaggedValue::ToInteger(thread, msg0);
2182 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2204 JSTaggedNumber argEndTemp = JSTaggedValue::ToInteger(thread, msg1);
2205 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2216 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2221 if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()
2223 return JSStableArray::Slice(thread, thisObjHandle, k, count);
2228 JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(static_cast<double>(count)));
2230 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2234 JSHandle<JSObject> newArrayHandle(thread, newArray);
2249 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
2250 JSMutableHandle<JSTaggedValue> nKey(thread, JSTaggedValue::Undefined());
2253 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, key);
2254 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2257 JSHandle<JSTaggedValue> kValueHandle = JSArray::FastGetPropertyByValue(thread, thisObjVal, key);
2258 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2259 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, nKey, kValueHandle);
2260 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2267 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
2268 JSHandle<JSTaggedValue> newLenHandle(thread, JSTaggedValue(n));
2269 JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(newArrayHandle), lengthKey, newLenHandle, true);
2271 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2282 JSThread *thread = argv->GetThread();
2283 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2287 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2289 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2293 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
2295 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2300 THROW_TYPE_ERROR_AND_RETURN(thread, "the callbackfun is not callable.", JSTaggedValue::Exception());
2318 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
2319 JSMutableHandle<JSTaggedValue> kValue(thread, JSTaggedValue::Undefined());
2322 if (thisObjVal->IsStableJSArray(thread)) {
2323 callResult = JSStableArray::HandleSomeOfStable(thread, thisObjHandle, callbackFnHandle, thisArgHandle, k);
2324 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2331 JSTaggedValue::HasProperty(thread, thisObjVal, k));
2332 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2335 kValue.Update(JSArray::FastGetPropertyByValue(thread, thisObjVal, key));
2336 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2338 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
2340 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
2341 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2344 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2350 thread->CheckSafepointIfSuspended();
2361 JSThread *thread = argv->GetThread();
2362 BUILTINS_API_TRACE(thread, Array, Sort);
2363 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2368 THROW_TYPE_ERROR_AND_RETURN(thread, "Callable is false", JSTaggedValue::Exception());
2373 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2374 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2377 if (thisHandle->IsStableJSArray(thread) && callbackFnHandle->IsUndefined()) {
2378 JSStableArray::Sort(thread, thisObjHandle, callbackFnHandle);
2380 JSArray::Sort(thread, JSHandle<JSTaggedValue>::Cast(thisObjHandle), callbackFnHandle);
2381 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2392 JSThread *thread = argv->GetThread();
2393 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2397 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2399 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2402 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
2404 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2413 JSTaggedNumber argStartTemp = JSTaggedValue::ToInteger(thread, msg0);
2415 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2441 JSTaggedNumber argDeleteCount = JSTaggedValue::ToInteger(thread, msg1);
2442 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2449 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
2452 JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
2454 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2455 JSHandle<JSObject> newArrayHandle(thread, newArray);
2456 if (thisHandle->IsStableJSArray(thread) && JSObject::IsArrayLengthWritable(thread, thisObjHandle)) {
2468 JSMutableHandle<JSTaggedValue> fromKey(thread, JSTaggedValue::Undefined());
2469 JSMutableHandle<JSTaggedValue> toKey(thread, JSTaggedValue::Undefined());
2474 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, fromKey);
2475 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2477 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
2478 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2481 toKey.Update(JSTaggedValue::ToString(thread, toKey).GetTaggedValue());
2482 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2484 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, toKey, fromValue);
2485 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2490 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
2491 JSHandle<JSTaggedValue> deleteCountHandle(thread, JSTaggedValue(actualDeleteCount));
2492 JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(newArrayHandle), lengthKey, deleteCountHandle,
2494 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2517 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, fromKey);
2518 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2520 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
2521 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2522 JSArray::FastSetPropertyByValue(thread, thisObjVal, toKey, fromValue);
2523 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2525 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, toKey);
2526 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2531 JSMutableHandle<JSTaggedValue> deleteKey(thread, JSTaggedValue::Undefined());
2534 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, deleteKey);
2535 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2559 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, fromKey);
2560 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2562 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
2563 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2564 JSArray::FastSetPropertyByValue(thread, thisObjVal, toKey, fromValue);
2565 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2567 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, toKey);
2568 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2576 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
2580 JSArray::FastSetPropertyByValue(thread, thisObjVal, key, itemValue);
2581 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2586 JSHandle<JSTaggedValue> newLenHandle(thread, JSTaggedValue(newLen));
2587 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, newLenHandle, true);
2589 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2599 JSThread *thread = argv->GetThread();
2600 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2601 auto ecmaVm = thread->GetEcmaVM();
2606 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2608 auto context = thread->GetCurrentEcmaContext();
2614 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
2618 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
2620 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
2626 return GetTaggedString(thread, "");
2653 auto globalConst = thread->GlobalConstants();
2656 thread->CheckSafepointIfSuspended();
2658 JSHandle<JSTaggedValue> nextElement = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
2659 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
2664 EcmaInterpreter::NewRuntimeCallInfo(thread, undefined, nextValueHandle, undefined, 2); // 2: two args
2665 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
2668 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
2671 JSHandle<JSTaggedValue> nextHandle(thread, next);
2672 JSHandle<EcmaString> nextStringHandle = JSTaggedValue::ToString(thread, nextHandle);
2673 RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, thisHandle);
2694 JSThread *thread = argv->GetThread();
2695 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2696 auto ecmaVm = thread->GetEcmaVM();
2700 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2702 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2706 JSHandle<JSTaggedValue> joinKey = thread->GlobalConstants()->GetHandledJoinString();
2707 JSHandle<JSTaggedValue> callbackFnHandle = JSTaggedValue::GetProperty(thread, thisObjVal, joinKey).GetValue();
2710 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2716 JSHandle<JSTaggedValue> toStringKey = thread->GlobalConstants()->GetHandledToStringString();
2717 callbackFnHandle = JSTaggedValue::GetProperty(thread, objectPrototype, toStringKey).GetValue();
2718 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2720 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
2722 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisObjVal, undefined, 0);
2723 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2732 JSThread *thread = argv->GetThread();
2733 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2740 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2742 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2746 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
2748 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2769 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
2771 JSMutableHandle<JSTaggedValue> fromKey(thread, JSTaggedValue::Undefined());
2772 JSMutableHandle<JSTaggedValue> toKey(thread, JSTaggedValue::Undefined());
2777 bool exists = JSTaggedValue::HasProperty(thread, thisObjVal, fromKey);
2778 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2780 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
2781 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2782 JSArray::FastSetPropertyByValue(thread, thisObjVal, toKey, fromValue);
2783 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2785 JSTaggedValue::DeletePropertyOrThrow(thread, thisObjVal, toKey);
2786 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2802 JSArray::FastSetPropertyByValue(thread, thisObjVal, toKey, toValue);
2803 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2809 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
2811 JSHandle<JSTaggedValue> newLenHandle(thread, JSTaggedValue(newLen));
2812 JSTaggedValue::SetProperty(thread, thisObjVal, lengthKey, newLenHandle, true);
2814 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2825 JSThread *thread = argv->GetThread();
2826 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2827 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2830 JSHandle<JSObject> self = JSTaggedValue::ToObject(thread, GetThis(argv));
2831 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2842 JSThread *thread = argv->GetThread();
2843 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2847 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2848 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2854 int64_t sourceLen = ArrayHelper::GetLength(thread, thisObjVal);
2855 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2866 JSTaggedNumber fromIndexTemp = JSTaggedValue::ToNumber(thread, msg1);
2867 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2874 JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(arrayLen));
2875 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2878 JSHandle<JSObject> newArrayHandle(thread, newArray);
2880 ArrayHelper::FlattenIntoArray(thread, newArrayHandle, thisObjVal, args,
2881 thread->GlobalConstants()->GetHandledUndefined(),
2882 thread->GlobalConstants()->GetHandledUndefined());
2883 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2894 JSThread *thread = argv->GetThread();
2895 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2899 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2900 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2904 int64_t sourceLen = ArrayHelper::GetLength(thread, thisObjVal);
2905 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2910 THROW_TYPE_ERROR_AND_RETURN(thread, "the mapperFunction is not callable.", JSTaggedValue::Exception());
2914 JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle, JSTaggedNumber(arrayLen));
2915 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2918 JSHandle<JSObject> newArrayHandle(thread, newArray);
2920 ArrayHelper::FlattenIntoArray(thread, newArrayHandle, thisObjVal, args,
2922 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2932 JSThread *thread = argv->GetThread();
2933 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2936 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
2937 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2944 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
2945 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2955 JSTaggedNumber fromIndexTemp = JSTaggedValue::ToNumber(thread, msg1);
2956 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2978 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
2979 JSMutableHandle<JSTaggedValue> kValueHandle(thread, JSTaggedValue::Undefined());
2982 JSHandle<JSTaggedValue> handledFrom(thread, JSTaggedValue(from));
2983 fromStr = JSTaggedValue::ToString(thread, handledFrom);
2984 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2986 kValueHandle.Update(JSArray::FastGetPropertyByValue(thread, thisObjVal, key).GetTaggedValue());
2987 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3002 JSThread *thread = argv->GetThread();
3003 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3007 if (thisHandle->IsStableJSArray(thread)) {
3010 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3012 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3016 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
3018 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3021 JSTaggedNumber index = JSTaggedValue::ToInteger(thread, GetCallArg(argv, 0));
3023 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3043 JSHandle<JSTaggedValue> element = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
3044 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3053 JSThread *thread = argv->GetThread();
3054 BUILTINS_API_TRACE(thread, Array, With);
3055 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3059 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3060 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3063 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
3065 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3067 JSTaggedNumber index = JSTaggedValue::ToInteger(thread, GetCallArg(argv, 0));
3069 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3082 THROW_RANGE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
3086 JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(len))).GetTaggedValue();
3088 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3089 JSHandle<JSObject> newArrayHandle(thread, newArray);
3090 if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()) {
3091 return JSStableArray::With(thread, JSHandle<JSArray>::Cast(thisHandle), len, actualIndex, value);
3101 JSMutableHandle<JSTaggedValue> fromKey(thread, JSTaggedValue::Undefined());
3108 fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
3109 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3111 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, fromKey, fromValue);
3112 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3114 thread->CheckSafepointIfSuspended();
3124 JSThread *thread = argv->GetThread();
3125 BUILTINS_API_TRACE(thread, Array, ToSorted);
3126 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3131 THROW_TYPE_ERROR_AND_RETURN(thread, "Callable is false", JSTaggedValue::Exception());
3136 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3137 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3140 int64_t len = ArrayHelper::GetArrayLength(thread, JSHandle<JSTaggedValue>(thisObjHandle));
3142 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3145 JSTaggedValue newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(len))).GetTaggedValue();
3146 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3147 JSHandle<JSObject> newArrayHandle(thread, newArray);
3154 ArrayHelper::SortIndexedProperties(thread, JSHandle<JSTaggedValue>::Cast(thisObjHandle), len, callbackFnHandle,
3156 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3163 JSMutableHandle<JSTaggedValue> itemValue(thread, JSTaggedValue::Undefined());
3166 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, j, itemValue);
3167 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3178 JSThread *thread = argv->GetThread();
3179 BUILTINS_API_TRACE(thread, Array, ToSpliced);
3180 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3184 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3186 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3189 int64_t len = ArrayHelper::GetArrayLength(thread, thisObjVal);
3191 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3198 JSTaggedNumber argStart = JSTaggedValue::ToInteger(thread, GetCallArg(argv, 0));
3200 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3223 JSTaggedNumber argSkipCount = JSTaggedValue::ToInteger(thread, GetCallArg(argv, 1));
3225 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3234 THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
3236 if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()) {
3242 JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(newLen)));
3244 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3245 JSHandle<JSObject> newArrayHandle(thread, newJsTaggedArray.GetTaggedValue());
3256 JSHandle<JSTaggedValue> iValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, i);
3258 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3259 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, i, iValue);
3260 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3267 JSMutableHandle<JSTaggedValue> pi(thread, JSTaggedValue::Undefined());
3271 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, pi, element);
3272 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3282 JSMutableHandle<JSTaggedValue> from(thread, JSTaggedValue::Undefined());
3286 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, from);
3287 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3288 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, pi, fromValue);
3289 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3293 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
3294 JSHandle<JSTaggedValue> newLenHandle(thread, JSTaggedValue(newLen));
3295 JSTaggedValue::SetProperty(thread, newJsTaggedArray, lengthKey, newLenHandle, true);
3297 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3306 JSThread *thread = argv->GetThread();
3307 BUILTINS_API_TRACE(thread, Array, FindLast);
3308 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3312 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3314 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3318 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
3320 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3325 THROW_TYPE_ERROR_AND_RETURN(thread, "the predicate is not callable.", JSTaggedValue::Exception());
3340 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
3342 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
3345 if (thisObjVal->IsStableJSArray(thread)) {
3346 JSMutableHandle<JSTaggedValue> kValue(thread, JSTaggedValue::Undefined());
3347 callResult = JSStableArray::HandleFindLastOfStable(thread, thisObjHandle,
3349 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3356 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
3357 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3360 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
3361 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3364 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3379 JSThread *thread = argv->GetThread();
3380 BUILTINS_API_TRACE(thread, Array, FindLastIndex);
3381 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3385 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3387 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3391 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
3393 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3398 THROW_TYPE_ERROR_AND_RETURN(thread, "the predicate is not callable.", JSTaggedValue::Exception());
3415 if (thisObjVal->IsStableJSArray(thread)) {
3417 JSStableArray::HandleFindLastIndexOfStable(thread, thisObjHandle, callbackFnHandle, thisArgHandle, k);
3418 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3423 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
3424 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
3427 JSHandle<JSTaggedValue> kValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, k);
3428 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3431 EcmaInterpreter::NewRuntimeCallInfo(thread, callbackFnHandle, thisArgHandle, undefined, argsLength);
3432 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3435 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3450 JSThread *thread = argv->GetThread();
3451 BUILTINS_API_TRACE(thread, Array, ToReversed);
3452 [[maybe_unused]] EcmaHandleScope handleScope(thread);
3456 JSHandle<JSObject> thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle);
3458 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3462 int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
3464 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3465 if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()) {
3466 return JSStableArray::ToReversed(thread, JSHandle<JSArray>::Cast(thisHandle), len);
3469 JSTaggedValue newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(len))).GetTaggedValue();
3471 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3472 JSHandle<JSObject> newArrayHandle(thread, newArray);
3481 JSMutableHandle<JSTaggedValue> fromKey(thread, JSTaggedValue::Undefined());
3482 JSMutableHandle<JSTaggedValue> toKey(thread, JSTaggedValue::Undefined());
3488 JSHandle<JSTaggedValue> fromValue = JSArray::FastGetPropertyByValue(thread, thisObjVal, fromKey);
3489 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3490 JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, toKey, fromValue);
3491 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3493 thread->CheckSafepointIfSuspended();