Lines Matching refs:thread

59 JSTaggedValue RuntimeStubs::RuntimeInc(JSThread *thread, const JSHandle<JSTaggedValue> &value)
61 JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
62 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
65 return BigInt::BigintAddOne(thread, bigValue).GetTaggedValue();
71 JSTaggedValue RuntimeStubs::RuntimeDec(JSThread *thread, const JSHandle<JSTaggedValue> &value)
73 JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
74 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
77 return BigInt::BigintSubOne(thread, bigValue).GetTaggedValue();
83 JSTaggedValue RuntimeStubs::RuntimeExp(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent)
85 JSHandle<JSTaggedValue> baseTag(thread, base);
86 JSHandle<JSTaggedValue> exponentTag(thread, exponent);
87 JSHandle<JSTaggedValue> valBase = JSTaggedValue::ToNumeric(thread, baseTag);
88 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
89 JSHandle<JSTaggedValue> valExponent = JSTaggedValue::ToNumeric(thread, exponentTag);
90 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
95 return BigInt::Exponentiate(thread, bigBaseVale, bigExponentValue).GetTaggedValue();
97 THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot mix BigInt and other types, use explicit conversions",
119 JSTaggedValue RuntimeStubs::RuntimeIsIn(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
123 return RuntimeThrowTypeError(thread, "Cannot use 'in' operator in Non-Object");
125 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, prop);
126 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
127 bool ret = JSTaggedValue::HasProperty(thread, obj, propKey);
128 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
132 JSTaggedValue RuntimeStubs::RuntimeInstanceof(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
135 bool ret = JSObject::InstanceOf(thread, obj, target);
136 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
140 JSTaggedValue RuntimeStubs::RuntimeInstanceofByHandler(JSThread *thread, JSHandle<JSTaggedValue> target,
145 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
149 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
154 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
155 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, instOfHandler, target,
157 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
161 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
167 THROW_TYPE_ERROR_AND_RETURN(thread, "InstanceOf error when target is not Callable", JSTaggedValue::Exception());
171 bool res = JSFunction::OrdinaryHasInstance(thread, target, object);
172 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
176 JSTaggedValue RuntimeStubs::RuntimeCreateGeneratorObj(JSThread *thread, const JSHandle<JSTaggedValue> &genFunc)
178 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
181 context->SetGeneratorObject(thread, obj.GetTaggedValue());
185 obj->SetGeneratorContext(thread, context);
187 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
191 JSTaggedValue RuntimeStubs::RuntimeCreateAsyncGeneratorObj(JSThread *thread, const JSHandle<JSTaggedValue> &genFunc)
193 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
196 context->SetGeneratorObject(thread, obj.GetTaggedValue());
200 obj->SetGeneratorContext(thread, context);
202 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
206 JSTaggedValue RuntimeStubs::RuntimeGetTemplateObject(JSThread *thread, const JSHandle<JSTaggedValue> &literal)
208 JSHandle<JSTaggedValue> templateObj = TemplateString::GetTemplateObject(thread, literal);
209 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
213 JSTaggedValue RuntimeStubs::RuntimeGetNextPropName(JSThread *thread, const JSHandle<JSTaggedValue> &iter)
216 JSTaggedValue res = JSForInIterator::NextInternal(thread, JSHandle<JSForInIterator>::Cast(iter));
217 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
221 JSTaggedValue RuntimeStubs::RuntimeIterNext(JSThread *thread, const JSHandle<JSTaggedValue> &iter)
223 JSHandle<JSTaggedValue> resultObj = JSIterator::IteratorNext(thread, iter);
224 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
228 JSTaggedValue RuntimeStubs::RuntimeCloseIterator(JSThread *thread, const JSHandle<JSTaggedValue> &iter)
230 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
231 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
234 if (thread->HasPendingException()) {
236 CompletionRecordType::THROW, JSHandle<JSTaggedValue>(thread, thread->GetException())));
241 JSHandle<JSTaggedValue> result = JSIterator::IteratorClose(thread, iter, record);
242 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
249 JSTaggedValue RuntimeStubs::RuntimeSuperCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func,
253 JSHandle<JSTaggedValue> superFunc(thread, JSTaggedValue::GetPrototype(thread, func));
254 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
256 THROW_TYPE_ERROR_AND_RETURN(thread, "Super constructor is not JSFunction", JSTaggedValue::Exception());
259 JSHandle<TaggedArray> argv(thread, RuntimeGetCallSpreadArgs(thread, array));
260 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
262 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
264 EcmaInterpreter::NewRuntimeCallInfo(thread, superFunc, undefined, newTarget, argsLength);
265 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
268 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
273 JSTaggedValue RuntimeStubs::RuntimeOptSuperCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func,
277 JSHandle<JSTaggedValue> superFunc(thread, JSTaggedValue::GetPrototype(thread, func));
278 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
280 THROW_TYPE_ERROR_AND_RETURN(thread, "Super constructor is not JSFunction", JSTaggedValue::Exception());
283 JSHandle<TaggedArray> argv(thread, taggedArray.GetTaggedValue());
284 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
286 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
288 EcmaInterpreter::NewRuntimeCallInfo(thread, superFunc, undefined, newTarget, argsLength);
289 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
292 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
297 JSTaggedValue RuntimeStubs::RuntimeSuperCallForwardAllArgs(JSThread *thread, JSTaggedType *sp,
303 THROW_TYPE_ERROR_AND_RETURN(thread, "Super constructor is not a constructor", JSTaggedValue::Exception());
307 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
309 EcmaInterpreter::NewRuntimeCallInfo(thread, superFunc, undefined, newTarget, restNumArgs);
310 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
318 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
322 JSTaggedValue RuntimeStubs::RuntimeDelObjProp(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
325 JSHandle<JSTaggedValue> jsObj(JSTaggedValue::ToObject(thread, obj));
326 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
327 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, prop);
328 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
329 bool ret = JSTaggedValue::DeletePropertyOrThrow(thread, jsObj, propKey);
330 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
334 JSTaggedValue RuntimeStubs::RuntimeNewObjApply(JSThread *thread, const JSHandle<JSTaggedValue> &func,
337 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
339 return RuntimeThrowTypeError(thread, "Cannot Newobjspread");
345 auto prop = JSTaggedValue::GetProperty(thread, array, i).GetValue();
346 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
347 argsArray->Set(thread, i, prop);
348 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
350 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
351 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, func, undefined, func, length);
352 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
357 JSTaggedValue RuntimeStubs::RuntimeCreateIterResultObj(JSThread *thread, const JSHandle<JSTaggedValue> &value,
362 JSHandle<JSObject> iter = JSIterator::CreateIterResultObject(thread, value, done);
363 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
367 JSTaggedValue RuntimeStubs::RuntimeAsyncFunctionAwaitUncaught(JSThread *thread,
371 JSAsyncFunction::AsyncFunctionAwait(thread, asyncFuncObj, value);
372 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
374 JSHandle<JSObject> obj = JSTaggedValue::ToObject(thread, asyncFuncObj);
375 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
377 JSHandle<TaggedQueue> queue(thread, generator->GetAsyncGeneratorQueue());
381 JSHandle<AsyncGeneratorRequest> next(thread, queue->Front());
382 JSHandle<PromiseCapability> completion(thread, next->GetCapability());
383 JSHandle<JSPromise> promise(thread, completion->GetPromise());
387 JSHandle<JSPromise> promise(thread, asyncFuncObjHandle->GetPromise());
389 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
393 JSTaggedValue RuntimeStubs::RuntimeAsyncFunctionResolveOrReject(JSThread *thread,
397 JSHandle<JSPromise> promise(thread, asyncFuncObjHandle->GetPromise());
400 JSHandle<ResolvingFunctionsRecord> reactions = JSPromise::CreateResolvingFunctions(thread, promise);
401 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
405 activeFunc = JSHandle<JSTaggedValue>(thread, reactions->GetResolveFunction());
407 activeFunc = JSHandle<JSTaggedValue>(thread, reactions->GetRejectFunction());
409 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
410 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, activeFunc, thisArg, undefined, 1);
411 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
415 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
419 JSTaggedValue RuntimeStubs::RuntimeAsyncGeneratorResolve(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj,
422 [[maybe_unused]] EcmaHandleScope handleScope(thread);
426 JSHandle<GeneratorContext> genContextHandle(thread, asyncGeneratorObjHandle->GetGeneratorContext());
428 SaveFrameToContext(thread, genContextHandle);
433 return JSAsyncGeneratorObject::AsyncGeneratorResolve(thread, asyncGeneratorObjHandle, valueHandle, done);
436 JSTaggedValue RuntimeStubs::RuntimeAsyncGeneratorReject(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj,
439 [[maybe_unused]] EcmaHandleScope handleScope(thread);
444 return JSAsyncGeneratorObject::AsyncGeneratorReject(thread, asyncGeneratorObjHandle, valueHandle);
447 JSTaggedValue RuntimeStubs::RuntimeCopyDataProperties(JSThread *thread, const JSHandle<JSTaggedValue> &dst,
452 JSHandle<JSTaggedValue> from(JSTaggedValue::ToObject(thread, src));
453 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
454 JSHandle<TaggedArray> keys = JSTaggedValue::GetOwnPropertyKeys(thread, from);
455 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
457 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
460 PropertyDescriptor desc(thread);
462 bool success = JSTaggedValue::GetOwnProperty(thread, from, key, desc);
463 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
468 JSTaggedValue::DefineOwnProperty(thread, dst, key, desc);
469 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
476 JSTaggedValue RuntimeStubs::RuntimeStArraySpread(JSThread *thread, const JSHandle<JSTaggedValue> &dst,
479 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
480 JSHandle<JSTaggedValue> undefinedHandle(thread, JSTaggedValue::Undefined());
484 THROW_TYPE_ERROR_AND_RETURN(thread, "src is not iterable", JSTaggedValue::Exception());
487 THROW_TYPE_ERROR_AND_RETURN(thread, "dst is not iterable", JSTaggedValue::Exception());
490 JSHandle<EcmaString> srcString = JSTaggedValue::ToString(thread, src);
491 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
492 JSHandle<EcmaString> srcFlat = JSHandle<EcmaString>(thread,
493 EcmaStringAccessor::Flatten(thread->GetEcmaVM(), srcString));
499 JSTaggedValue::SetProperty(thread, dst, dstLen + i, strValue, true);
500 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
502 JSHandle<JSTaggedValue> length(thread, JSTaggedValue(dstLen + strLen));
504 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
505 JSTaggedValue::SetProperty(thread, dst, lengthKey, length);
510 if (index.GetInt() == 0 && src->IsStableJSArray(thread)) {
511 JSHandle<TaggedArray> srcElements(thread, JSHandle<JSObject>::Cast(src)->GetElements());
515 dstArray->SetElements(thread, dstElements);
516 dstArray->SetArrayLength(thread, length);
519 ElementAccessor::CopyJSArrayObject(thread, srcObj, dstObj, length);
521 JSHandle<JSTaggedValue> reg(thread, ElementAccessor::Get(srcObj, i));
523 JSHandle<JSTaggedValue> reg2(thread, JSArray::FastGetPropertyByValue(thread, src, i).GetTaggedValue());
524 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
526 ElementAccessor::Set(thread, dstObj, i, undefinedHandle, true);
528 ElementAccessor::Set(thread, dstObj, i, reg2, true);
531 ElementAccessor::Set(thread, dstObj, i, reg, true);
538 auto globalConst = thread->GlobalConstants();
544 JSHandle<JSTaggedValue> valuesMethod = JSObject::GetMethod(thread, src, valuesStr);
545 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
546 iter = JSIterator::GetIterator(thread, src, valuesMethod);
547 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
549 iter = JSIterator::GetIterator(thread, src);
550 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
553 JSMutableHandle<JSTaggedValue> indexHandle(thread, index);
555 PropertyDescriptor desc(thread);
559 iterResult = JSIterator::IteratorStep(thread, iter);
560 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
564 bool success = JSTaggedValue::GetOwnProperty(thread, iterResult, valueStr, desc);
565 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
567 JSTaggedValue::DefineOwnProperty(thread, dst, indexHandle, desc);
568 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
575 JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
576 JSTaggedValue::SetProperty(thread, dst, lengthKey, indexHandle);
581 JSTaggedValue RuntimeStubs::RuntimeGetIteratorNext(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
585 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
586 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, method, obj, undefined, 0);
587 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
589 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
591 return RuntimeThrowTypeError(thread, "the Iterator is not an ecmaobject.");
596 JSTaggedValue RuntimeStubs::RuntimeSetObjectWithProto(JSThread *thread, const JSHandle<JSTaggedValue> &proto,
603 THROW_TYPE_ERROR_AND_RETURN(thread, GET_MESSAGE_STRING(SetProtoWithSendable), JSTaggedValue::Exception());
605 JSObject::SetPrototype(thread, obj, proto);
606 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
610 JSTaggedValue RuntimeStubs::RuntimeLdObjByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
618 JSTaggedValue::RequireObjectCoercible(thread, obj, "Cannot load property of null or undefined");
619 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
623 res = JSObject::CallGetter(thread, AccessorData::Cast(receiver.GetTaggedObject()), object);
624 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
626 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, prop);
627 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
628 res = JSTaggedValue::GetProperty(thread, object, propKey).GetValue().GetTaggedValue();
630 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
634 JSTaggedValue RuntimeStubs::RuntimeStObjByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
642 JSTaggedValue::RequireObjectCoercible(thread, obj, "Cannot store property of null or undefined");
643 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
645 JSHandle<JSTaggedValue> propKey(JSTaggedValue::ToPropertyKey(thread, prop));
646 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
648 JSTaggedValue::SetProperty(thread, object, propKey, value, true);
649 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
653 JSTaggedValue RuntimeStubs::RuntimeStOwnByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
657 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
661 return RuntimeThrowTypeError(thread, "In a class, static property named 'prototype' throw a TypeError");
667 PropertyDescriptor desc(thread, value, true, enumerable, true);
668 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, key);
669 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
670 bool ret = JSTaggedValue::DefineOwnProperty(thread, obj, propKey, desc);
671 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
673 return RuntimeThrowTypeError(thread, "StOwnByValue failed");
678 JSTaggedValue RuntimeStubs::RuntimeLdSuperByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
683 JSHandle<JSTaggedValue> homeObject(thread, JSFunction::Cast(thisFunc.GetTaggedObject())->GetHomeObject());
684 JSHandle<JSTaggedValue> superBase(thread, JSTaggedValue::GetSuperBase(thread, homeObject));
685 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
686 JSTaggedValue::RequireObjectCoercible(thread, superBase);
687 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
688 JSHandle<JSTaggedValue> propKey(JSTaggedValue::ToPropertyKey(thread, key));
689 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
691 JSTaggedValue res = JSTaggedValue::GetProperty(thread, superBase, propKey, obj).GetValue().GetTaggedValue();
692 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
696 JSTaggedValue RuntimeStubs::RuntimeStSuperByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
702 JSHandle<JSTaggedValue> homeObject(thread, JSFunction::Cast(thisFunc.GetTaggedObject())->GetHomeObject());
703 JSHandle<JSTaggedValue> superBase(thread, JSTaggedValue::GetSuperBase(thread, homeObject));
704 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
705 JSTaggedValue::RequireObjectCoercible(thread, superBase);
706 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
707 JSHandle<JSTaggedValue> propKey(JSTaggedValue::ToPropertyKey(thread, key));
708 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
711 JSTaggedValue::SetProperty(thread, superBase, propKey, value, obj, true);
712 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
716 JSTaggedValue RuntimeStubs::RuntimeLdObjByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
721 res = JSObject::CallGetter(thread, AccessorData::Cast(receiver.GetTaggedObject()), obj);
723 res = JSTaggedValue::GetProperty(thread, obj, idx).GetValue().GetTaggedValue();
725 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
729 JSTaggedValue RuntimeStubs::RuntimeLdObjByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop,
732 JSHandle<JSTaggedValue> objHandle(thread, obj);
735 res = JSObject::CallGetter(thread, AccessorData::Cast(receiver.GetTaggedObject()), objHandle);
737 JSHandle<JSTaggedValue> propHandle(thread, prop);
738 res = JSTaggedValue::GetProperty(thread, objHandle, propHandle).GetValue().GetTaggedValue();
740 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
744 JSTaggedValue RuntimeStubs::RuntimeStObjByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
748 JSTaggedValue::SetProperty(thread, obj, prop, value, true);
749 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
753 JSTaggedValue RuntimeStubs::RuntimeStObjByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
756 JSTaggedValue::SetProperty(thread, obj, idx, value, true);
757 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
761 JSTaggedValue RuntimeStubs::RuntimeStOwnByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
768 PropertyDescriptor desc(thread, value, true, enumerable, true);
769 bool ret = JSTaggedValue::DefineOwnProperty(thread, obj, idx, desc);
770 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
772 return RuntimeThrowTypeError(thread, "SetOwnByIndex failed");
777 JSTaggedValue RuntimeStubs::RuntimeStGlobalRecord(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
780 ObjectFactory* factory = thread->GetEcmaVM()->GetFactory();
781 if (thread->GetEcmaVM()->GetJSOptions().IsEnableLoweringBuiltin()) {
785 auto box = factory->NewPropertyBox(JSHandle<JSTaggedValue>(thread, JSTaggedValue::Hole()));
786 thread->GetBuiltinEntriesPointer()->ClearByIndex(index, box.GetTaggedValue());
790 EcmaVM *vm = thread->GetEcmaVM();
797 return RuntimeThrowSyntaxError(thread, "Duplicate identifier");
804 JSHandle<GlobalDictionary> dictHandle(thread, dict);
809 dict = *GlobalDictionary::PutIfAbsent(thread, dictHandle, prop, JSHandle<JSTaggedValue>(box), attributes);
810 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
811 env->SetGlobalRecord(thread, JSTaggedValue(dict));
815 JSTaggedValue RuntimeStubs::RuntimeNeg(JSThread *thread, const JSHandle<JSTaggedValue> &value)
817 JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
818 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
821 return BigInt::UnaryMinus(thread, bigValue).GetTaggedValue();
841 JSTaggedValue RuntimeStubs::RuntimeNot(JSThread *thread, const JSHandle<JSTaggedValue> &value)
843 JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
844 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
847 return BigInt::BitwiseNOT(thread, bigValue).GetTaggedValue();
849 int32_t number = JSTaggedValue::ToInt32(thread, inputVal);
853 JSTaggedValue RuntimeStubs::RuntimeResolveClass(JSThread *thread, const JSHandle<JSFunction> &ctor,
860 FrameHandler frameHandler(thread);
862 JSHandle<JSTaggedValue> ecmaModule(thread, JSFunction::Cast(currentFunc.GetTaggedObject())->GetModule());
864 RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(ctor), base);
865 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
875 func->SetLexicalEnv(thread, lexenv.GetTaggedValue());
876 func->SetModule(thread, ecmaModule);
883 JSTaggedValue RuntimeStubs::RuntimeCloneClassFromTemplate(JSThread *thread, const JSHandle<JSFunction> &ctor,
887 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
888 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
891 JSHandle<JSObject> clsPrototype(thread, ctor->GetFunctionPrototype());
895 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
898 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
901 JSFunction::SetFunctionPrototypeOrInstanceHClass(thread, cloneClass, cloneClassPrototype.GetTaggedValue());
902 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
904 PropertyDescriptor ctorDesc(thread, JSHandle<JSTaggedValue>(cloneClass), true, false, true);
905 JSTaggedValue::DefinePropertyOrThrow(thread, JSHandle<JSTaggedValue>(cloneClassPrototype),
907 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
909 cloneClass->SetHomeObject(thread, cloneClassPrototype);
912 RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(cloneClass), base);
913 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
928 JSTaggedValue RuntimeStubs::RuntimeCreateClassWithBuffer(JSThread *thread,
937 THROW_TYPE_ERROR_AND_RETURN(thread, GET_MESSAGE_STRING(NotSendableSubClass), JSTaggedValue::Exception());
939 [[maybe_unused]] EcmaHandleScope handleScope(thread);
940 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
944 auto methodObj = ConstantPool::GetMethodFromCache(thread, constpool.GetTaggedValue(), methodId);
945 JSHandle<JSTaggedValue> method(thread, methodObj);
948 JSMutableHandle<JSTaggedValue> ihc(thread, JSTaggedValue::Undefined());
949 JSMutableHandle<JSTaggedValue> chc(thread, JSTaggedValue::Undefined());
951 JSHandle<ConstantPool> cp(thread,
952 thread->GetCurrentEcmaContext()->FindOrCreateUnsharedConstpool(constpoolHandle.GetTaggedValue()));
955 JSHandle<AOTLiteralInfo> aotLiteralInfo(thread, val);
960 JSHandle<JSTaggedValue> sendableEnv(thread, JSTaggedValue::Undefined());
963 sendableEnv = JSHandle<JSTaggedValue>(thread, moduleRecord->GetSendableEnv());
965 JSTaggedValue literalObj = ConstantPool::GetClassLiteralFromCache(thread, cp, literalId, entry, sendableEnv);
967 JSHandle<ClassLiteral> classLiteral(thread, literalObj);
968 JSHandle<TaggedArray> arrayHandle(thread, classLiteral->GetArray());
971 ClassInfoExtractor::BuildClassInfoExtractorFromLiteral(thread, extractor, arrayHandle, literalLength);
975 cls = ClassHelper::DefineClassWithIHClass(thread, base, extractor, lexenv, ihc, chc);
977 cls = ClassHelper::DefineClassFromExtractor(thread, base, extractor, lexenv);
980 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
981 RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(cls), base);
982 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
984 cls->SetLexicalEnv(thread, lexenv.GetTaggedValue());
985 cls->SetModule(thread, module.GetTaggedValue());
986 RuntimeSetClassConstructorLength(thread, cls.GetTaggedValue(), length.GetTaggedValue());
987 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
992 void RuntimeStubs::SetProfileTypeInfoCellToFunction(JSThread *thread, const JSHandle<JSFunction> &jsFunc,
1006 JSHandle<Method> method(thread, jsFunc->GetMethod());
1008 profileTypeInfo = RuntimeNotifyInlineCache(thread, jsFunc, slotSize);
1013 JSHandle<ProfileTypeInfo> profileTypeArray(thread, profileTypeInfo);
1016 JSHandle<JSTaggedValue> handleUndefined(thread, JSTaggedValue::Undefined());
1018 thread->GetEcmaVM()->GetFactory()->NewProfileTypeInfoCell(handleUndefined);
1019 profileTypeArray->Set(thread, slotId, newProfileTypeInfoCell);
1020 definedFunc->SetRawProfileTypeInfo(thread, newProfileTypeInfoCell);
1023 cellPtr->UpdateProfileTypeInfoCellType(thread);
1024 definedFunc->SetRawProfileTypeInfo(thread, slotValue);
1028 JSTaggedValue RuntimeStubs::RuntimeCreateSharedClass(JSThread *thread,
1035 THROW_TYPE_ERROR_AND_RETURN(thread, GET_MESSAGE_STRING(ClassNotDerivedFromShared), JSTaggedValue::Exception());
1037 [[maybe_unused]] EcmaHandleScope handleScope(thread);
1038 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1041 auto methodObj = ConstantPool::GetMethodFromCache(thread, constpool.GetTaggedValue(), methodId);
1042 JSHandle<JSTaggedValue> method(thread, methodObj);
1046 JSHandle<JSTaggedValue> sendableEnv(thread, JSTaggedValue::Undefined());
1049 sendableEnv = JSHandle<JSTaggedValue>(thread, moduleRecord->GetSendableEnv());
1052 thread, constpoolHandle, literalId, entry, sendableEnv, ClassKind::SENDABLE);
1053 JSHandle<ClassLiteral> classLiteral(thread, literalObj);
1054 JSHandle<TaggedArray> arrayHandle(thread, classLiteral->GetArray());
1061 ClassInfoExtractor::BuildClassInfoExtractorFromLiteral(thread, extractor, arrayHandle,
1064 JSHandle<TaggedArray> fieldTypeArray = ConstantPool::GetFieldLiteral(thread, constpoolHandle, fieldTypeId, entry);
1065 JSHandle<TaggedArray> staticFieldArray = SendableClassDefiner::ExtractStaticFieldTypeArray(thread, fieldTypeArray);
1067 SendableClassDefiner::DefineSendableClassFromExtractor(thread, extractor, staticFieldArray);
1068 ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
1072 sendableClsModuleRecord->SetSendableEnv(thread, sendableEnv);
1074 cls->SetModule(thread, sendableClsModule.GetTaggedValue());
1075 RuntimeSetClassConstructorLength(thread, cls.GetTaggedValue(), JSTaggedValue(length));
1076 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1077 RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(cls), base, ClassKind::SENDABLE);
1078 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1086 SendableClassDefiner::DefineSendableInstanceHClass(thread, fieldTypeArray, instanceLength, cls, base);
1090 JSTaggedValue RuntimeStubs::RuntimeSetClassInheritanceRelationship(JSThread *thread,
1095 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
1096 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1124 parentPrototype = JSHandle<JSTaggedValue>(thread, JSTaggedValue::Null());
1127 return RuntimeThrowTypeError(thread, "parent class is not constructor");
1130 parentPrototype = JSTaggedValue::GetProperty(thread, parent,
1132 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1134 return RuntimeThrowTypeError(thread, "parent class have no valid prototype");
1138 ctor->GetTaggedObject()->GetClass()->SetPrototype(thread, parent); // __proto__
1140 JSHandle<JSObject> clsPrototype(thread, JSHandle<JSFunction>(ctor)->GetFunctionPrototype());
1141 clsPrototype->GetClass()->SetPrototype(thread, parentPrototype);
1146 JSHClass::EnableProtoChangeMarker(thread, JSHandle<JSHClass>(thread, constructor->GetClass()));
1148 JSHClass::EnableProtoChangeMarker(thread,
1149 JSHandle<JSHClass>(thread, constructor->GetFunctionPrototype().GetTaggedObject()->GetClass()));
1159 JSHandle<JSHClass> ihcHandle(thread, ihc);
1160 JSHClass::EnableProtoChangeMarker(thread, ihcHandle);
1163 JSHandle<JSObject> protoHandle(thread, protoOrHClass);
1165 JSHClass::EnablePHCProtoChangeMarker(thread, JSHandle<JSHClass>(thread, protoHandle->GetJSHClass()));
1172 JSTaggedValue RuntimeStubs::RuntimeSetClassConstructorLength(JSThread *thread, JSTaggedValue ctor,
1179 cls->SetPropertyInlinedProps(thread, JSFunction::LENGTH_INLINE_PROPERTY_INDEX, length);
1181 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1182 cls->UpdatePropertyInDictionary(thread, globalConst->GetLengthString(), length);
1187 JSTaggedValue RuntimeStubs::RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<JSFunction> &function,
1192 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1206 JSFunction::SetProfileTypeInfo(thread, function, JSHandle<JSTaggedValue>::Cast(profileTypeInfo));
1210 JSTaggedValue RuntimeStubs::RuntimeStOwnByValueWithNameSet(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
1214 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
1218 return RuntimeThrowTypeError(thread, "In a class, static property named 'prototype' throw a TypeError");
1224 PropertyDescriptor desc(thread, value, true, enumerable, true);
1225 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, key);
1226 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1227 bool ret = JSTaggedValue::DefineOwnProperty(thread, obj, propKey, desc);
1228 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1230 return RuntimeThrowTypeError(thread, "StOwnByValueWithNameSet failed");
1234 propKey = JSHandle<JSTaggedValue>(base::NumberHelper::NumberToString(thread, propKey.GetTaggedValue()));
1236 JSFunctionBase::SetFunctionName(thread, JSHandle<JSFunctionBase>::Cast(value), propKey,
1237 JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()));
1242 JSTaggedValue RuntimeStubs::RuntimeStOwnByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
1251 PropertyDescriptor desc(thread, value, true, enumerable, true);
1252 bool ret = JSTaggedValue::DefineOwnProperty(thread, obj, prop, desc);
1253 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1255 return RuntimeThrowTypeError(thread, "SetOwnByName failed");
1260 JSTaggedValue RuntimeStubs::RuntimeStOwnByNameWithNameSet(JSThread *thread,
1266 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, propHandle);
1267 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1271 PropertyDescriptor desc(thread, valueHandle, true, enumerable, true);
1272 bool ret = JSTaggedValue::DefineOwnProperty(thread, objHandle, propHandle, desc);
1273 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1275 return RuntimeThrowTypeError(thread, "SetOwnByNameWithNameSet failed");
1277 JSFunctionBase::SetFunctionName(thread, JSHandle<JSFunctionBase>::Cast(valueHandle), propKey,
1278 JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()));
1282 JSTaggedValue RuntimeStubs::RuntimeSuspendGenerator(JSThread *thread, const JSHandle<JSTaggedValue> &genObj,
1287 JSHandle<GeneratorContext> genContextHandle(thread, generatorObjectHandle->GetGeneratorContext());
1289 SaveFrameToContext(thread, genContextHandle);
1295 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1301 JSHandle<GeneratorContext> genContextHandle(thread, generatorObjectHandle->GetGeneratorContext());
1303 generatorObjectHandle->SetTaskInfo(thread->GetTaskInfo());
1305 SaveFrameToContext(thread, genContextHandle);
1310 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1313 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1317 return RuntimeThrowTypeError(thread, "RuntimeSuspendGenerator failed");
1320 void RuntimeStubs::RuntimeSetGeneratorState(JSThread *thread, const JSHandle<JSTaggedValue> &genObj,
1324 JSHandle<GeneratorContext> genContextHandle(thread, generatorObjectHandle->GetGeneratorContext());
1349 JSTaggedValue RuntimeStubs::RuntimeGetModuleNamespace(JSThread *thread, int32_t index)
1351 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleNamespace(index);
1354 JSTaggedValue RuntimeStubs::RuntimeGetModuleNamespace(JSThread *thread, int32_t index,
1357 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleNamespace(index, jsFunc);
1360 JSTaggedValue RuntimeStubs::RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName)
1362 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleNamespace(localName);
1365 JSTaggedValue RuntimeStubs::RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName,
1368 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleNamespace(localName, jsFunc);
1371 void RuntimeStubs::RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value)
1373 thread->GetCurrentEcmaContext()->GetModuleManager()->StoreModuleValue(index, value);
1376 void RuntimeStubs::RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value,
1379 thread->GetCurrentEcmaContext()->GetModuleManager()->StoreModuleValue(index, value, jsFunc);
1382 void RuntimeStubs::RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value)
1384 thread->GetCurrentEcmaContext()->GetModuleManager()->StoreModuleValue(key, value);
1387 void RuntimeStubs::RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value,
1390 thread->GetCurrentEcmaContext()->GetModuleManager()->StoreModuleValue(key, value, jsFunc);
1393 JSTaggedValue RuntimeStubs::RuntimeLdLocalModuleVar(JSThread *thread, int32_t index)
1395 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueInner(index);
1398 inline JSTaggedValue RuntimeStubs::RuntimeLdLocalModuleVarWithModule(JSThread* thread, int32_t index,
1402 ModuleManager* mmgr = thread->GetCurrentEcmaContext()->GetModuleManager();
1407 return SourceTextModule::Cast(module)->GetModuleValue(thread, index, false);
1410 JSTaggedValue RuntimeStubs::RuntimeLdLocalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc)
1412 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueInner(index, jsFunc);
1415 JSTaggedValue RuntimeStubs::RuntimeLdExternalModuleVar(JSThread *thread, int32_t index)
1417 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueOutter(index);
1420 inline JSTaggedValue RuntimeStubs::RuntimeLdExternalModuleVarWithModule(JSThread* thread, int32_t index,
1424 ModuleManager* mmgr = thread->GetCurrentEcmaContext()->GetModuleManager();
1428 moduleHdl = JSHandle<JSTaggedValue>(thread, module);
1433 JSTaggedValue RuntimeStubs::RuntimeLdSendableExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc)
1435 return SharedModuleManager::GetInstance()->GetSendableModuleValue(thread, index, jsFunc);
1438 JSTaggedValue RuntimeStubs::RuntimeLdExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc)
1440 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueOutter(index, jsFunc);
1443 JSTaggedValue RuntimeStubs::RuntimeLdLazyExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc)
1445 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetLazyModuleValueOutter(index, jsFunc);
1449 JSThread *thread, int32_t index, JSTaggedValue jsFunc)
1451 return SharedModuleManager::GetInstance()->GetLazySendableModuleValue(thread, index, jsFunc);
1454 JSTaggedValue RuntimeStubs::RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner)
1457 JSTaggedValue moduleValue = thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueInner(key);
1461 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueOutter(key);
1464 JSTaggedValue RuntimeStubs::RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner,
1469 thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueInner(key, jsFunc);
1473 return thread->GetCurrentEcmaContext()->GetModuleManager()->GetModuleValueOutter(key, jsFunc);
1476 JSTaggedValue RuntimeStubs::RuntimeGetPropIterator(JSThread *thread, const JSHandle<JSTaggedValue> &value)
1478 JSHandle<JSForInIterator> iteratorHandle = JSObject::EnumerateObjectProperties(thread, value);
1479 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1483 JSTaggedValue RuntimeStubs::RuntimeAsyncFunctionEnter(JSThread *thread)
1485 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1487 JSHandle<GlobalEnv> globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
1494 asyncFuncObj->SetPromise(thread, promiseObject);
1497 context->SetGeneratorObject(thread, asyncFuncObj);
1501 asyncFuncObj->SetGeneratorContext(thread, context);
1504 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1508 JSTaggedValue RuntimeStubs::RuntimeGetIterator(JSThread *thread, const JSHandle<JSTaggedValue> &obj)
1510 EcmaVM *vm = thread->GetEcmaVM();
1513 JSTaggedValue::GetProperty(thread, obj, env->GetIteratorSymbol()).GetValue();
1514 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1519 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1520 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, valuesFunc, obj, undefined, 0);
1524 JSTaggedValue RuntimeStubs::RuntimeGetAsyncIterator(JSThread *thread, const JSHandle<JSTaggedValue> &obj)
1526 JSHandle<JSTaggedValue> asyncit = JSIterator::GetAsyncIterator(thread, obj);
1527 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1531 JSTaggedValue RuntimeStubs::RuntimeLdPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
1541 JSHandle<JSTaggedValue> handleObj(thread, obj.IsJSProxy() ? JSProxy::Cast(obj)->GetPrivateField() : obj);
1542 JSHandle<JSTaggedValue> handleKey(thread, key);
1544 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1546 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, handleKey, handleObj, undefined, 0);
1547 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1549 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1552 PropertyDescriptor desc(thread);
1554 !JSTaggedValue::GetOwnProperty(thread, handleObj, handleKey, desc)) {
1555 THROW_TYPE_ERROR_AND_RETURN(thread, "invalid or cannot find private key", JSTaggedValue::Exception());
1558 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1562 JSTaggedValue RuntimeStubs::RuntimeStPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
1572 JSHandle<JSTaggedValue> handleObj(thread, obj.IsJSProxy() ? JSProxy::Cast(obj)->GetPrivateField() : obj);
1573 JSHandle<JSTaggedValue> handleKey(thread, key);
1574 JSHandle<JSTaggedValue> handleValue(thread, value);
1576 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
1578 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, handleKey, handleObj, undefined, 1);
1579 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1582 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1585 PropertyDescriptor desc(thread);
1587 !JSTaggedValue::GetOwnProperty(thread, handleObj, handleKey, desc)) {
1588 THROW_TYPE_ERROR_AND_RETURN(thread, "invalid or cannot find private key", JSTaggedValue::Exception());
1591 bool res = JSTaggedValue::DefineOwnProperty(thread, handleObj, handleKey, desc);
1592 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1596 JSTaggedValue RuntimeStubs::RuntimeTestIn(JSThread *thread, JSTaggedValue lexicalEnv,
1600 THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot use 'in' operator in Non-Object", JSTaggedValue::Exception());
1608 JSHandle<JSTaggedValue> handleObj(thread, obj.IsJSProxy() ? JSProxy::Cast(obj)->GetPrivateField() : obj);
1609 JSHandle<JSTaggedValue> handleKey(thread, key);
1610 bool res = JSTaggedValue::IsPropertyKey(handleKey) && JSTaggedValue::HasProperty(thread, handleObj, handleKey);
1611 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1615 void RuntimeStubs::RuntimeThrow(JSThread *thread, JSTaggedValue value)
1617 thread->SetException(value);
1620 void RuntimeStubs::RuntimeThrowThrowNotExists(JSThread *thread)
1622 THROW_TYPE_ERROR(thread, "Throw method is not defined");
1625 void RuntimeStubs::RuntimeThrowPatternNonCoercible(JSThread *thread)
1627 JSHandle<EcmaString> msg(thread->GlobalConstants()->GetHandledObjNotCoercibleString());
1628 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1629 THROW_NEW_ERROR_AND_RETURN(thread,
1633 void RuntimeStubs::RuntimeThrowDeleteSuperProperty(JSThread *thread)
1635 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1638 THROW_NEW_ERROR_AND_RETURN(thread, errorObj.GetTaggedValue());
1641 void RuntimeStubs::RuntimeThrowUndefinedIfHole(JSThread *thread, const JSHandle<EcmaString> &obj)
1643 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1647 THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::REFERENCE_ERROR,
1651 void RuntimeStubs::RuntimeThrowIfNotObject(JSThread *thread)
1653 THROW_TYPE_ERROR(thread, "Inner return result is not object");
1656 void RuntimeStubs::RuntimeThrowConstAssignment(JSThread *thread, const JSHandle<EcmaString> &value)
1658 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1663 THROW_NEW_ERROR_AND_RETURN(thread, factory->NewJSError(base::ErrorType::TYPE_ERROR,
1667 JSTaggedValue RuntimeStubs::RuntimeLdGlobalRecord(JSThread *thread, JSTaggedValue key)
1669 EcmaVM *vm = thread->GetEcmaVM();
1679 JSTaggedValue RuntimeStubs::RuntimeTryLdGlobalByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
1682 OperationResult res = JSTaggedValue::GetProperty(thread, obj, prop);
1683 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1685 return RuntimeThrowReferenceError(thread, prop, " is not defined");
1690 JSTaggedValue RuntimeStubs::RuntimeTryUpdateGlobalRecord(JSThread *thread, JSTaggedValue prop,
1693 EcmaVM *vm = thread->GetEcmaVM();
1700 return RuntimeThrowTypeError(thread, "const variable can not be modified");
1704 box->SetValue(thread, value);
1705 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1709 JSTaggedValue RuntimeStubs::RuntimeThrowReferenceError(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
1712 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
1713 JSHandle<EcmaString> propName = JSTaggedValue::ToString(thread, prop);
1714 ASSERT_NO_ABRUPT_COMPLETION(thread);
1717 THROW_NEW_ERROR_AND_RETURN_VALUE(thread,
1722 JSTaggedValue RuntimeStubs::RuntimeLdGlobalVarFromProto(JSThread *thread, const JSHandle<JSTaggedValue> &globalObj,
1727 JSHandle<JSTaggedValue> obj(thread, JSObject::GetPrototype(global));
1728 OperationResult res = JSTaggedValue::GetProperty(thread, obj, prop);
1729 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1733 JSTaggedValue RuntimeStubs::RuntimeStGlobalVar(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
1736 JSHandle<JSTaggedValue> global(thread, thread->GetEcmaVM()->GetGlobalEnv()->GetGlobalObject());
1738 JSObject::GlobalSetProperty(thread, prop, value, true);
1739 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1743 JSTaggedValue RuntimeStubs::RuntimeToNumber(JSThread *thread, const JSHandle<JSTaggedValue> &value)
1745 return JSTaggedValue::ToNumber(thread, value);
1748 JSTaggedValue RuntimeStubs::RuntimeToNumeric(JSThread *thread, const JSHandle<JSTaggedValue> &value)
1750 return JSTaggedValue::ToNumeric(thread, value).GetTaggedValue();
1753 JSTaggedValue RuntimeStubs::RuntimeDynamicImport(JSThread *thread, const JSHandle<JSTaggedValue> &specifier,
1756 EcmaVM *ecmaVm = thread->GetEcmaVM();
1766 JSMutableHandle<JSTaggedValue> dirPath(thread, thread->GlobalConstants()->GetUndefined());
1767 JSMutableHandle<JSTaggedValue> recordName(thread, thread->GlobalConstants()->GetUndefined());
1777 JSHandle<PromiseCapability> promiseCapability = JSPromise::NewPromiseCapability(thread, promiseFunc);
1778 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1779 JSHandle<job::MicroJobQueue> job = thread->GetCurrentEcmaContext()->GetMicroJobQueue();
1782 argv->Set(thread, 0, promiseCapability->GetResolve());
1783 argv->Set(thread, 1, promiseCapability->GetReject()); // 1 : reject method
1784 argv->Set(thread, 2, dirPath); // 2 : current file path(containing file name)
1785 argv->Set(thread, 3, specifier); // 3 : request module's path
1786 argv->Set(thread, 4, recordName); // 4 : js recordName or undefined
1789 job::MicroJobQueue::EnqueueJob(thread, job, job::QueueType::QUEUE_PROMISE, dynamicImportJob, argv);
1794 JSTaggedValue RuntimeStubs::RuntimeEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1797 bool ret = JSTaggedValue::Equal(thread, left, right);
1798 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1802 JSTaggedValue RuntimeStubs::RuntimeNotEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1805 bool ret = JSTaggedValue::Equal(thread, left, right);
1806 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1810 JSTaggedValue RuntimeStubs::RuntimeLess(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1813 bool ret = JSTaggedValue::Compare(thread, left, right) == ComparisonResult::LESS;
1814 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1818 JSTaggedValue RuntimeStubs::RuntimeLessEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1821 bool ret = JSTaggedValue::Compare(thread, left, right) <= ComparisonResult::EQUAL;
1822 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1826 JSTaggedValue RuntimeStubs::RuntimeGreater(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1829 bool ret = JSTaggedValue::Compare(thread, left, right) == ComparisonResult::GREAT;
1830 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1834 JSTaggedValue RuntimeStubs::RuntimeGreaterEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1837 ComparisonResult comparison = JSTaggedValue::Compare(thread, left, right);
1839 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1843 JSTaggedValue RuntimeStubs::RuntimeAdd2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1848 thread->GetEcmaVM(), JSHandle<EcmaString>(left), JSHandle<EcmaString>(right));
1849 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1852 JSHandle<JSTaggedValue> primitiveA0(thread, JSTaggedValue::ToPrimitive(thread, left));
1853 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1854 JSHandle<JSTaggedValue> primitiveA1(thread, JSTaggedValue::ToPrimitive(thread, right));
1855 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1858 JSHandle<EcmaString> stringA0 = JSTaggedValue::ToString(thread, primitiveA0);
1859 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1860 JSHandle<EcmaString> stringA1 = JSTaggedValue::ToString(thread, primitiveA1);
1861 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1862 EcmaString *resultStr = EcmaStringAccessor::Concat(thread->GetEcmaVM(), stringA0, stringA1);
1863 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1866 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, primitiveA0);
1867 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1868 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, primitiveA1);
1869 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1874 return BigInt::Add(thread, bigLeft, bigRight).GetTaggedValue();
1876 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
1883 JSTaggedValue RuntimeStubs::RuntimeShl2(JSThread *thread,
1887 JSHandle<JSTaggedValue> leftValue = JSTaggedValue::ToNumeric(thread, left);
1888 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1889 JSHandle<JSTaggedValue> rightValue = JSTaggedValue::ToNumeric(thread, right);
1890 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1895 return BigInt::LeftShift(thread, leftBigint, rightBigint).GetTaggedValue();
1897 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
1899 JSTaggedValue taggedNumber0 = RuntimeToJSTaggedValueWithInt32(thread, leftValue);
1900 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1901 JSTaggedValue taggedNumber1 = RuntimeToJSTaggedValueWithInt32(thread, rightValue);
1902 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1913 JSTaggedValue RuntimeStubs::RuntimeShr2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1916 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
1917 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1918 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
1919 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1922 return BigInt::UnsignedRightShift(thread);
1924 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
1926 JSTaggedValue taggedNumber0 = RuntimeToJSTaggedValueWithInt32(thread, valLeft);
1927 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1928 JSTaggedValue taggedNumber1 = RuntimeToJSTaggedValueWithInt32(thread, valRight);
1929 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1939 JSTaggedValue RuntimeStubs::RuntimeSub2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1942 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
1943 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1944 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
1945 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1950 return BigInt::Subtract(thread, bigLeft, bigRight).GetTaggedValue();
1952 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
1959 JSTaggedValue RuntimeStubs::RuntimeMul2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1962 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
1963 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1964 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
1965 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1971 return BigInt::Multiply(thread, bigLeft, bigRight).GetTaggedValue();
1973 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
1981 JSTaggedValue RuntimeStubs::RuntimeDiv2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
1984 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
1985 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1986 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
1987 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
1992 return BigInt::Divide(thread, bigLeft, bigRight).GetTaggedValue();
1994 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
2009 JSTaggedValue RuntimeStubs::RuntimeMod2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
2012 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
2013 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2014 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
2015 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2022 return BigInt::Remainder(thread, leftBigint, rightBigint).GetTaggedValue();
2024 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
2038 JSTaggedValue RuntimeStubs::RuntimeAshr2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
2041 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
2042 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2043 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
2044 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2049 return BigInt::SignedRightShift(thread, bigLeft, bigRight).GetTaggedValue();
2051 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
2053 JSTaggedValue taggedNumber0 = RuntimeToJSTaggedValueWithInt32(thread, valLeft);
2054 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2055 JSTaggedValue taggedNumber1 = RuntimeToJSTaggedValueWithInt32(thread, valRight);
2056 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2064 JSTaggedValue RuntimeStubs::RuntimeAnd2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
2067 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
2068 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2069 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
2070 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2075 return BigInt::BitwiseAND(thread, leftBigint, rightBigint).GetTaggedValue();
2077 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
2079 JSTaggedValue taggedNumber0 = RuntimeToJSTaggedValueWithInt32(thread, valLeft);
2080 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2081 JSTaggedValue taggedNumber1 = RuntimeToJSTaggedValueWithInt32(thread, valRight);
2082 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2090 JSTaggedValue RuntimeStubs::RuntimeOr2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
2093 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
2094 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2095 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
2096 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2101 return BigInt::BitwiseOR(thread, leftBigint, rightBigint).GetTaggedValue();
2103 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
2105 JSTaggedValue taggedNumber0 = RuntimeToJSTaggedValueWithInt32(thread, valLeft);
2106 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2107 JSTaggedValue taggedNumber1 = RuntimeToJSTaggedValueWithInt32(thread, valRight);
2108 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2116 JSTaggedValue RuntimeStubs::RuntimeXor2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
2119 JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
2120 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2121 JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right);
2122 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2127 return BigInt::BitwiseXOR(thread, leftBigint, rightBigint).GetTaggedValue();
2129 return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions");
2131 JSTaggedValue taggedNumber0 = RuntimeToJSTaggedValueWithInt32(thread, valLeft);
2132 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2133 JSTaggedValue taggedNumber1 = RuntimeToJSTaggedValueWithInt32(thread, valRight);
2134 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2142 JSTaggedValue RuntimeStubs::RuntimeToJSTaggedValueWithInt32(JSThread *thread,
2145 int32_t res = JSTaggedValue::ToInt32(thread, value);
2146 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2150 JSTaggedValue RuntimeStubs::RuntimeToJSTaggedValueWithUint32(JSThread *thread, const JSHandle<JSTaggedValue> &value)
2152 uint32_t res = JSTaggedValue::ToUint32(thread, value);
2153 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2157 JSTaggedValue RuntimeStubs::RuntimeCreateEmptyObject([[maybe_unused]] JSThread *thread, ObjectFactory *factory,
2165 JSTaggedValue RuntimeStubs::RuntimeCreateEmptyArray([[maybe_unused]] JSThread *thread, ObjectFactory *factory,
2173 JSTaggedValue RuntimeStubs::RuntimeGetUnmapedArgs(JSThread *thread, JSTaggedType *sp, uint32_t actualNumArgs,
2176 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2179 argumentsList->Set(thread, i,
2182 return RuntimeGetUnmapedJSArgumentObj(thread, argumentsList);
2185 JSTaggedValue RuntimeStubs::RuntimeCopyRestArgs(JSThread *thread, JSTaggedType *sp, uint32_t restNumArgs,
2189 thread, restNumArgs, [thread, sp, startIdx] (const JSHandle<TaggedArray> &newElements, uint32_t length) {
2192 newElements->Set(thread, i, JSTaggedValue(sp[startIdx + i]));
2197 JSTaggedValue RuntimeStubs::RuntimeCreateArrayWithBuffer(JSThread *thread, ObjectFactory *factory,
2202 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2207 JSTaggedValue RuntimeStubs::RuntimeCreateObjectWithBuffer(JSThread *thread, ObjectFactory *factory,
2211 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2216 JSTaggedValue RuntimeStubs::RuntimeNewLexicalEnv(JSThread *thread, uint16_t numVars)
2218 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2221 JSTaggedValue currentLexenv = thread->GetCurrentLexenv();
2222 newEnv->SetParentEnv(thread, currentLexenv);
2223 newEnv->SetScopeInfo(thread, JSTaggedValue::Hole());
2224 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2228 JSTaggedValue RuntimeStubs::RuntimeNewSendableEnv(JSThread *thread, uint16_t numVars)
2230 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2233 JSTaggedValue module = JSFunction::Cast(thread->GetCurrentFunction())->GetModule();
2234 JSHandle<SourceTextModule> moduleHandle(thread, module);
2235 newEnv->SetParentEnv(thread, moduleHandle->GetSendableEnv());
2236 newEnv->SetScopeInfo(thread, JSTaggedValue::Hole());
2237 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2241 JSTaggedValue RuntimeStubs::RuntimeNewObjRange(JSThread *thread, const JSHandle<JSTaggedValue> &func,
2244 JSHandle<JSTaggedValue> preArgs(thread, JSTaggedValue::Undefined());
2245 JSHandle<TaggedArray> args = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length);
2246 FrameHandler frameHandler(thread);
2249 args->Set(thread, i, value);
2251 auto tagged = RuntimeOptConstruct(thread, func, newTarget, preArgs, args);
2252 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2256 void RuntimeStubs::DefineFuncTryUseAOTHClass(JSThread* thread,
2265 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
2266 const GlobalEnvConstants *globalConst = thread->GlobalConstants();
2267 func->SetProtoOrHClass(thread, ihc);
2271 JSHandle<JSObject> clsPrototype(thread, func->GetFunctionPrototype());
2272 clsPrototype->GetClass()->SetPrototype(thread, parentPrototype);
2276 PropertyDescriptor descriptor(thread, JSHandle<JSTaggedValue>::Cast(func), true, false, true);
2277 JSObject::DefineOwnProperty(thread, clsPrototype, constructorKey, descriptor);
2280 JSHClass::EnablePHCProtoChangeMarker(thread,
2281 JSHandle<JSHClass>(thread, parentPrototype->GetTaggedObject()->GetClass()));
2283 JSHClass::EnableProtoChangeMarker(thread, JSHandle<JSHClass>(ihc));
2285 JSHClass::EnablePHCProtoChangeMarker(thread, JSHandle<JSHClass>(thread, clsPrototype->GetClass()));
2287 //avoid one thread uses ihc twice or more times
2292 JSTaggedValue RuntimeStubs::RuntimeDefinefunc(JSThread *thread, const JSHandle<JSTaggedValue> &constpool,
2298 JSMutableHandle<JSTaggedValue> ihc(thread, JSTaggedValue::Undefined());
2299 JSMutableHandle<AOTLiteralInfo> aotLiteralInfo(thread, JSTaggedValue::Hole());
2303 JSTaggedValue unsharedCp = thread->GetCurrentEcmaContext()->FindUnsharedConstpool(constpoolHandle.GetTaggedValue());
2305 JSHandle<ConstantPool> unsharedCpHandle(thread, unsharedCp);
2312 JSTaggedValue method = ConstantPool::GetMethodFromCache(thread, constpoolHandle.GetTaggedValue(), methodId);
2313 const JSHandle<Method> methodHandle(thread, method);
2314 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2318 ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
2323 thread, JSHandle<SourceTextModule>::Cast(module)->GetSendableEnv());
2325 result->SetModule(thread, sendableFuncModule.GetTaggedValue());
2328 result->SetModule(thread, module.GetTaggedValue());
2329 result->SetLexicalEnv(thread, envHandle.GetTaggedValue());
2330 result->SetHomeObject(thread, homeObject.GetTaggedValue());
2332 DefineFuncTryUseAOTHClass(thread, result, ihc, aotLiteralInfo);
2338 JSTaggedValue RuntimeStubs::RuntimeCreateRegExpWithLiteral(JSThread *thread,
2341 JSHandle<JSTaggedValue> flagsHandle(thread, JSTaggedValue(flags));
2342 return builtins::BuiltinsRegExp::RegExpCreate(thread, pattern, flagsHandle);
2345 JSTaggedValue RuntimeStubs::RuntimeThrowIfSuperNotCorrectCall(JSThread *thread, uint16_t index,
2349 return RuntimeThrowReferenceError(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()),
2353 return RuntimeThrowReferenceError(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()),
2359 JSTaggedValue RuntimeStubs::RuntimeCreateObjectHavingMethod(JSThread *thread, ObjectFactory *factory,
2364 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2369 JSTaggedValue RuntimeStubs::CommonCreateObjectWithExcludedKeys(JSThread *thread,
2374 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2379 JSHandle<JSObject> obj(JSTaggedValue::ToObject(thread, objVal));
2380 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2381 JSHandle<TaggedArray> allKeys = JSObject::GetOwnPropertyKeys(thread, obj);
2383 JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
2388 if (JSTaggedValue::Equal(thread, key, JSHandle<JSTaggedValue>(thread, excludedKeys->Get(j)))) {
2394 PropertyDescriptor desc(thread);
2395 bool success = JSObject::GetOwnProperty(thread, obj, key, desc);
2396 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2398 JSHandle<JSTaggedValue> value = JSObject::GetProperty(thread, obj, key).GetValue();
2399 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2400 JSObject::SetProperty(thread, restObj, key, value, true);
2401 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2408 JSTaggedValue RuntimeStubs::RuntimeOptCreateObjectWithExcludedKeys(JSThread *thread, uintptr_t argv, uint32_t argc)
2410 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2419 excludedKeys->Set(thread, 0, excludedKey);
2422 excludedKeys->Set(thread, i, excludedKey);
2425 return CommonCreateObjectWithExcludedKeys(thread, objVal, numExcludedKeys, excludedKeys);
2428 JSTaggedValue RuntimeStubs::RuntimeCreateObjectWithExcludedKeys(JSThread *thread, uint16_t numKeys,
2432 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2435 FrameHandler frameHandler(thread);
2439 excludedKeys->Set(thread, 0, excludedKey);
2442 excludedKeys->Set(thread, i, excludedKey);
2448 JSHandle<JSProxy> proxyVal(thread, finalVal.GetTaggedValue());
2449 finalVal = proxyVal->GetSourceTarget(thread);
2452 return CommonCreateObjectWithExcludedKeys(thread, finalVal, numExcludedKeys, excludedKeys);
2455 JSTaggedValue RuntimeStubs::RuntimeDefineMethod(JSThread *thread, const JSHandle<Method> &methodHandle,
2460 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2463 func->SetLexicalEnv(thread, env);
2464 func->SetModule(thread, module);
2479 JSTaggedValue RuntimeStubs::RuntimeCallSpread(JSThread *thread,
2485 THROW_TYPE_ERROR_AND_RETURN(thread, "cannot Callspread", JSTaggedValue::Exception());
2488 JSHandle<TaggedArray> coretypesArray(thread, RuntimeGetCallSpreadArgs(thread, array));
2489 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2491 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
2492 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, func, obj, undefined, length);
2493 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2498 void RuntimeStubs::RuntimeSetPatchModule(JSThread *thread, const JSHandle<JSFunction> &func)
2500 JSHandle<Method> methodHandle(thread, Method::Cast(func->GetMethod()));
2502 thread->GetCurrentEcmaContext()->FindPatchModule(MethodLiteral::GetRecordName(
2505 func->SetModule(thread, coldReloadRecordName.GetTaggedValue());
2509 JSTaggedValue RuntimeStubs::RuntimeDefineGetterSetterByValue(JSThread *thread, const JSHandle<JSObject> &obj,
2516 JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread, prop);
2517 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2518 auto globalConst = thread->GlobalConstants();
2522 thread,
2532 JSHandle<JSTaggedValue>::Cast(base::NumberHelper::NumberToString(thread, propKey.GetTaggedValue()));
2534 JSFunctionBase::SetFunctionName(thread, JSHandle<JSFunctionBase>::Cast(getter), propKey,
2535 JSHandle<JSTaggedValue>(thread, globalConst->GetGetString()));
2541 JSHandle<JSTaggedValue>::Cast(base::NumberHelper::NumberToString(thread, propKey.GetTaggedValue()));
2543 JSFunctionBase::SetFunctionName(thread, JSHandle<JSFunctionBase>::Cast(setter), propKey,
2544 JSHandle<JSTaggedValue>(thread, globalConst->GetSetString()));
2551 PropertyDescriptor desc(thread, true, enumerable, true);
2563 JSObject::DefineOwnProperty(thread, obj, propKey, desc);
2567 JSHandle<JSHClass> phcHandle(thread, holderTraHClass);
2568 JSHClass::EnablePHCProtoChangeMarker(thread, phcHandle);
2570 if (thread->GetEcmaVM()->IsEnablePGOProfiler()) {
2572 thread->GetEcmaVM()->GetPGOProfiler()->ProfileDefineGetterSetter(
2580 JSTaggedValue RuntimeStubs::RuntimeSuperCall(JSThread *thread, const JSHandle<JSTaggedValue> &func,
2584 JSHandle<JSTaggedValue> superFunc(thread, JSTaggedValue::GetPrototype(thread, func));
2585 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2587 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2589 FrameHandler frameHandler(thread);
2591 argv->Set(thread, i, frameHandler.GetVRegValue(firstVRegIdx + i));
2594 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
2595 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, superFunc, undefined, newTarget, length);
2596 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2599 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2604 JSTaggedValue RuntimeStubs::RuntimeOptSuperCall(JSThread *thread, const JSHandle<JSTaggedValue> &func,
2609 JSHandle<JSTaggedValue> superFunc(thread, JSTaggedValue::GetPrototype(thread, func));
2610 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2611 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
2612 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, superFunc, undefined, newTarget, length);
2613 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2616 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2620 JSTaggedValue RuntimeStubs::RuntimeThrowTypeError(JSThread *thread, const char *message)
2622 ASSERT_NO_ABRUPT_COMPLETION(thread);
2623 THROW_TYPE_ERROR_AND_RETURN(thread, message, JSTaggedValue::Exception());
2626 JSTaggedValue RuntimeStubs::RuntimeGetCallSpreadArgs(JSThread *thread, const JSHandle<JSTaggedValue> &jsArray)
2630 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2632 JSHandle<JSTaggedValue> itor = JSIterator::GetIterator(thread, jsArray);
2633 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2636 if (jsArray->IsStableJSArray(thread) && itor->IsJSArrayIterator()) {
2638 ElementAccessor::CopyJSArrayToTaggedArray(thread, jsArrayObj, argv, argvMayMaxLength);
2642 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2643 JSMutableHandle<JSTaggedValue> next(thread, JSTaggedValue::Undefined());
2644 JSMutableHandle<JSTaggedValue> nextArg(thread, JSTaggedValue::Undefined());
2647 next.Update(JSIterator::IteratorStep(thread, itor).GetTaggedValue());
2648 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2652 nextArg.Update(JSIterator::IteratorValue(thread, next).GetTaggedValue());
2653 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2656 argv = argv->SetCapacity(thread, argv, argvMayMaxLength);
2658 argv->Set(thread, argvIndex++, nextArg);
2664 JSTaggedValue RuntimeStubs::RuntimeThrowSyntaxError(JSThread *thread, const char *message)
2666 ASSERT_NO_ABRUPT_COMPLETION(thread);
2667 THROW_SYNTAX_ERROR_AND_RETURN(thread, message, JSTaggedValue::Exception());
2670 JSTaggedValue RuntimeStubs::RuntimeLdBigInt(JSThread *thread, const JSHandle<JSTaggedValue> &numberBigInt)
2672 return JSTaggedValue::ToBigInt(thread, numberBigInt);
2675 JSTaggedValue RuntimeStubs::RuntimeCallBigIntAsIntN(JSThread *thread, JSTaggedValue bits, JSTaggedValue bigint)
2677 auto biginteger = JSHandle<BigInt>(thread, bigint);
2678 JSTaggedNumber bitness = JSTaggedValue::ToNumber(thread, bits);
2679 return BigInt::AsintN(thread, bitness, biginteger);
2682 JSTaggedValue RuntimeStubs::RuntimeCallBigIntAsUintN(JSThread *thread, JSTaggedValue bits, JSTaggedValue bigint)
2684 auto biginteger = JSHandle<BigInt>(thread, bigint);
2685 JSTaggedNumber bitness = JSTaggedValue::ToNumber(thread, bits);
2686 return BigInt::AsUintN(thread, bitness, biginteger);
2689 JSTaggedValue RuntimeStubs::RuntimeNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId)
2691 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2694 JSTaggedValue currentLexenv = thread->GetCurrentLexenv();
2695 newEnv->SetParentEnv(thread, currentLexenv);
2696 JSTaggedValue scopeInfo = ScopeInfoExtractor::GenerateScopeInfo(thread, scopeId);
2697 newEnv->SetScopeInfo(thread, scopeInfo);
2698 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2702 JSTaggedValue RuntimeStubs::RuntimeOptGetUnmapedArgs(JSThread *thread, uint32_t actualNumArgs)
2704 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2707 auto argv = GetActualArgvFromStub(thread);
2713 argumentsList->Set(thread, idx++, args);
2715 return RuntimeGetUnmapedJSArgumentObj(thread, argumentsList);
2718 JSTaggedValue RuntimeStubs::RuntimeGetUnmapedJSArgumentObj(JSThread *thread, const JSHandle<TaggedArray> &argumentsList)
2720 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2721 JSHandle<GlobalEnv> globalEnv = thread->GetEcmaVM()->GetGlobalEnv();
2730 obj->SetPropertyInlinedProps(thread, JSArguments::LENGTH_INLINE_PROPERTY_INDEX, JSTaggedValue(len));
2736 obj->SetElements(thread, argumentsList.GetTaggedValue());
2740 obj->SetPropertyInlinedProps(thread, JSArguments::ITERATOR_INLINE_PROPERTY_INDEX,
2745 obj->SetPropertyInlinedProps(thread, JSArguments::CALLER_INLINE_PROPERTY_INDEX, accessorCaller.GetTaggedValue());
2749 obj->SetPropertyInlinedProps(thread, JSArguments::CALLEE_INLINE_PROPERTY_INDEX, accessorCallee.GetTaggedValue());
2750 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2755 JSTaggedValue RuntimeStubs::RuntimeOptNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId,
2759 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2762 newEnv->SetParentEnv(thread, currentLexEnv.GetTaggedValue());
2763 JSTaggedValue scopeInfo = RuntimeOptGenerateScopeInfo(thread, scopeId, func.GetTaggedValue());
2764 newEnv->SetScopeInfo(thread, scopeInfo);
2765 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2770 JSTaggedValue RuntimeStubs::RuntimeOptCopyRestArgs(JSThread *thread, uint32_t actualArgc, uint32_t restIndex)
2777 JSHandle<JSTaggedValue> restArray = JSArray::ArrayCreate(thread, JSTaggedNumber(actualRestNum));
2779 auto argv = GetActualArgv(thread);
2781 JSMutableHandle<JSTaggedValue> element(thread, JSTaggedValue::Undefined());
2787 JSObject::SetProperty(thread, restArray, idx++, element, true);
2789 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2793 JSTaggedValue RuntimeStubs::RuntimeOptSuspendGenerator(JSThread *thread, const JSHandle<JSTaggedValue> &genObj,
2802 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2809 generatorObjectHandle->SetTaskInfo(thread->GetTaskInfo());
2813 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2816 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2820 return RuntimeThrowTypeError(thread, "RuntimeSuspendGenerator failed");
2823 JSTaggedValue RuntimeStubs::RuntimeOptAsyncGeneratorResolve(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj,
2826 [[maybe_unused]] EcmaHandleScope handleScope(thread);
2830 JSHandle<GeneratorContext> genContextHandle(thread, asyncGeneratorObjHandle->GetGeneratorContext());
2833 return JSAsyncGeneratorObject::AsyncGeneratorResolve(thread, asyncGeneratorObjHandle, valueHandle, done);
2836 JSTaggedValue RuntimeStubs::RuntimeOptConstruct(JSThread *thread, JSHandle<JSTaggedValue> ctor,
2845 THROW_TYPE_ERROR_AND_RETURN(thread, "Constructor is false", JSTaggedValue::Exception());
2849 return RuntimeOptConstructGeneric(thread, JSHandle<JSFunction>::Cast(ctor), newTarget, preArgs, args);
2853 thread, JSHandle<JSBoundFunction>::Cast(ctor), newTarget, preArgs, args);
2856 return RuntimeOptConstructProxy(thread, JSHandle<JSProxy>::Cast(ctor), newTarget, preArgs, args);
2858 THROW_TYPE_ERROR_AND_RETURN(thread, "Constructor NonConstructor", JSTaggedValue::Exception());
2861 JSTaggedValue RuntimeStubs::RuntimeOptConstructProxy(JSThread *thread, JSHandle<JSProxy> ctor,
2866 JSHandle<JSTaggedValue> handler(thread, ctor->GetHandler());
2868 THROW_TYPE_ERROR_AND_RETURN(thread, "Constructor: handler is null", JSTaggedValue::Exception());
2871 JSHandle<JSTaggedValue> target(thread, ctor->GetTarget());
2874 JSHandle<JSTaggedValue> key(thread->GlobalConstants()->GetHandledProxyConstructString());
2875 JSHandle<JSTaggedValue> method = JSObject::GetMethod(thread, handler, key);
2878 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2884 return RuntimeOptConstruct(thread, target, newTgt, preArgs, args);
2891 JSHandle<TaggedArray> arr = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(size);
2896 arr->Set(thread, i, value);
2902 arr->Set(thread, i + preArgsSize, value);
2904 JSHandle<JSArray> newArr = JSArray::CreateArrayFromList(thread, arr);
2908 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
2909 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, method, handler, undefined, argsLength);
2910 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2914 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2917 THROW_TYPE_ERROR_AND_RETURN(thread, "new object is not object", JSTaggedValue::Exception());
2923 JSTaggedValue RuntimeStubs::RuntimeOptConstructBoundFunction(JSThread *thread, JSHandle<JSBoundFunction> ctor,
2928 JSHandle<JSTaggedValue> target(thread, ctor->GetBoundTarget());
2930 THROW_TYPE_ERROR_AND_RETURN(thread, "Constructor is false", JSTaggedValue::Exception());
2933 JSHandle<TaggedArray> boundArgs(thread, ctor->GetBoundArguments());
2934 JSMutableHandle<JSTaggedValue> newPreArgs(thread, preArgs.GetTaggedValue());
2939 TaggedArray::Append(thread, boundArgs, JSHandle<TaggedArray>::Cast(preArgs)).GetTaggedValue());
2941 JSMutableHandle<JSTaggedValue> newTargetMutable(thread, newTgt.GetTaggedValue());
2945 return RuntimeOptConstruct(thread, target, newTargetMutable, newPreArgs, args);
2948 JSTaggedValue RuntimeStubs::GetResultValue(JSThread *thread, bool isAotMethod, JSHandle<JSFunction> ctor,
2955 const JSTaggedType *prevFp = thread->GetLastLeaveFrame();
2964 resultValue = thread->GetEcmaVM()->FastCallAot(size, values.data(), prevFp);
2966 resultValue = thread->GetCurrentEcmaContext()->ExecuteAot(size, values.data(), prevFp, needPushArgv);
2970 EcmaInterpreter::NewRuntimeCallInfo(thread, JSHandle<JSTaggedValue>(ctor), obj, newTgt, size);
2971 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
2978 JSTaggedValue RuntimeStubs::RuntimeOptConstructGeneric(JSThread *thread, JSHandle<JSFunction> ctor,
2983 THROW_TYPE_ERROR_AND_RETURN(thread, "Constructor is false", JSTaggedValue::Exception());
2986 JSHandle<JSTaggedValue> obj(thread, JSTaggedValue::Undefined());
2988 ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
2990 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3027 JSTaggedValue resultValue = RuntimeStubs::GetResultValue(thread, isCompiledCode, ctor, values, newTgt, size, obj);
3028 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3041 THROW_TYPE_ERROR_AND_RETURN(thread, "function is non-constructor", JSTaggedValue::Exception());
3046 JSTaggedValue RuntimeStubs::RuntimeOptNewObjRange(JSThread *thread, uintptr_t argv, uint32_t argc)
3049 JSHandle<JSTaggedValue> undefined = thread->GlobalConstants()->GetHandledUndefined();
3053 JSHandle<TaggedArray> args = thread->GetEcmaVM()->GetFactory()->NewTaggedArray(arrLength);
3055 args->Set(thread, i, GetArg(argv, argc, i + firstArgOffset));
3057 JSTaggedValue object = RuntimeOptConstruct(thread, ctor, ctor, undefined, args);
3058 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3060 THROW_TYPE_ERROR_AND_RETURN(thread, "Derived constructor must return object or undefined",
3066 JSTaggedValue RuntimeStubs::RuntimeOptGenerateScopeInfo(JSThread *thread, uint16_t scopeId, JSTaggedValue func)
3068 EcmaVM *ecmaVm = thread->GetEcmaVM();
3072 JSHandle<ConstantPool> constpool(thread, method->GetConstantPool());
3075 LiteralDataExtractor::GetDatasIgnoreType(thread, jsPandaFile, id, constpool);
3098 JSTaggedType *RuntimeStubs::GetActualArgv(JSThread *thread)
3100 JSTaggedType *current = const_cast<JSTaggedType *>(thread->GetLastLeaveFrame());
3101 FrameIterator it(current, thread);
3114 JSTaggedType *RuntimeStubs::GetActualArgvFromStub(JSThread *thread)
3116 JSTaggedType *current = const_cast<JSTaggedType *>(thread->GetLastLeaveFrame());
3117 FrameIterator it(current, thread);
3131 OptimizedJSFunctionFrame *RuntimeStubs::GetOptimizedJSFunctionFrame(JSThread *thread)
3133 JSTaggedType *current = const_cast<JSTaggedType *>(thread->GetLastLeaveFrame());
3134 FrameIterator it(current, thread);
3141 OptimizedJSFunctionFrame *RuntimeStubs::GetOptimizedJSFunctionFrameNoGC(JSThread *thread)
3143 JSTaggedType *current = const_cast<JSTaggedType *>(thread->GetLastLeaveFrame());
3144 FrameIterator it(current, thread);
3151 JSTaggedValue RuntimeStubs::RuntimeLdPatchVar(JSThread *thread, uint32_t index)
3154 JSHandle<TaggedArray>::Cast(thread->GetEcmaVM()->GetGlobalEnv()->GetGlobalPatch());
3156 return globalPatch->Get(thread, index);
3159 JSTaggedValue RuntimeStubs::RuntimeStPatchVar(JSThread *thread, uint32_t index, const JSHandle<JSTaggedValue> &value)
3161 JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
3165 globalPatch = TaggedArray::SetCapacity(thread, globalPatch, index + 1);
3167 globalPatch->Set(thread, index, value);
3168 env->SetGlobalPatch(thread, globalPatch.GetTaggedValue());
3172 JSTaggedValue RuntimeStubs::RuntimeNotifyConcurrentResult(JSThread *thread, JSTaggedValue result, JSTaggedValue hint)
3174 thread->GetEcmaVM()->TriggerConcurrentCallback(result, hint);
3178 JSTaggedValue RuntimeStubs::RuntimeUpdateAOTHClass(JSThread *thread,
3182 if (JSHClass::IsNeedNotifyHclassChangedForAotTransition(thread, oldhclass, key)) {
3183 JSHClass::NotifyHclassChanged(thread, oldhclass, newhclass, key);
3185 JSHClass::RefreshUsers(thread, oldhclass, newhclass);
3187 JSHClass::EnablePHCProtoChangeMarker(thread, newhclass);
3192 JSTaggedValue RuntimeStubs::RuntimeDefineField(JSThread *thread, JSTaggedValue obj,
3198 THROW_TYPE_ERROR_AND_RETURN(thread, "DefineField: obj is not Object", JSTaggedValue::Exception());
3200 JSHandle<JSObject> handleObj(thread, obj);
3201 JSHandle<JSTaggedValue> handleValue(thread, value);
3202 JSHandle<JSTaggedValue> handleKey = JSTaggedValue::ToPropertyKey(thread, JSHandle<JSTaggedValue>(thread, propKey));
3203 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3205 JSObject::CreateDataPropertyOrThrow(thread, handleObj, handleKey, handleValue, SCheckMode::CHECK);
3206 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3211 JSTaggedValue RuntimeStubs::RuntimeCreatePrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
3214 ObjectFactory* factory = thread->GetEcmaVM()->GetFactory();
3215 JSHandle<LexicalEnv> handleLexicalEnv(thread, lexicalEnv);
3216 JSHandle<ConstantPool> handleConstpool(thread, constpool);
3217 JSHandle<JSTaggedValue> handleModule(thread, module);
3219 thread, thread->GetCurrentEcmaContext()->FindOrCreateUnsharedConstpool(constpool));
3228 JSHandle<TaggedArray> aotSymbolInfoHandle(thread, aotSymbolInfo);
3229 FrameHandler frameHandler(thread);
3238 symbolHandle = JSHandle<JSSymbol>(thread, symbol);
3244 handleLexicalEnv->SetProperties(thread, index, symbolHandle.GetTaggedValue());
3248 ConstantPool::GetClassLiteralFromCache(thread, unsharedConstpoolHandle, literalId, entry);
3249 JSHandle<ClassLiteral> classLiteral(thread, literalObj);
3250 JSHandle<TaggedArray> literalBuffer(thread, classLiteral->GetArray());
3259 JSMutableHandle<JSTaggedValue> literalValue(thread, JSTaggedValue::Undefined());
3265 func->SetLexicalEnv(thread, handleLexicalEnv.GetTaggedValue());
3266 func->SetModule(thread, handleModule.GetTaggedValue());
3269 handleLexicalEnv->SetProperties(thread, startIndex + count + i, literalValue.GetTaggedValue());
3277 symbolHandle = JSHandle<JSSymbol>(thread, symbol);
3283 handleLexicalEnv->SetProperties(thread, index, symbolHandle.GetTaggedValue());
3288 JSTaggedValue RuntimeStubs::RuntimeDefinePrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
3298 JSHandle<JSTaggedValue> handleObj(thread, obj.IsJSProxy() ? JSProxy::Cast(obj)->GetPrivateField() : obj);
3299 JSHandle<JSTaggedValue> handleKey(thread, key);
3300 JSHandle<JSTaggedValue> handleValue(thread, value);
3301 PropertyDescriptor desc(thread);
3303 JSTaggedValue::GetOwnProperty(thread, handleObj, handleKey, desc)) {
3304 THROW_TYPE_ERROR_AND_RETURN(thread, "invalid private key or already exists", JSTaggedValue::Exception());
3306 bool extensible = handleObj->IsExtensible(thread);
3308 THROW_TYPE_ERROR_AND_RETURN(thread, "DefinePrivateProperty obj is undefined", JSTaggedValue::Exception());
3311 THROW_TYPE_ERROR_AND_RETURN(thread, "shared obj cannot use # to define private property",
3318 bool result = JSObject::CreateDataPropertyOrThrow(thread, JSHandle<JSObject>::Cast(handleObj),
3320 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3324 RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
3328 JSTaggedValue RuntimeStubs::RuntimeNotifyDebuggerStatement(JSThread *thread)
3330 FrameHandler frameHandler(thread);
3340 auto *debuggerMgr = thread->GetEcmaVM()->GetJsDebuggerManager();
3341 debuggerMgr->GetNotificationManager()->DebuggerStmtEvent(thread, method, bcOffset);
3358 JSHandle<JSTaggedValue> RuntimeStubs::GetOrCreateNumberString(JSThread *thread, JSHandle<JSTaggedValue> presentValue,
3361 JSMutableHandle<JSTaggedValue> presentString(thread, JSTaggedValue::Undefined());
3366 presentString.Update(JSTaggedValue::ToString(thread, presentValue).GetTaggedValue());
3372 JSTaggedValue RuntimeStubs::TryCopyCOWArray(JSThread *thread, JSHandle<JSArray> holderHandler, bool &isCOWArray)
3375 JSArray::CheckAndCopyArray(thread, holderHandler);
3381 JSTaggedValue RuntimeStubs::ArrayNumberSort(JSThread *thread, JSHandle<JSObject> thisObj, uint32_t len)
3383 JSMutableHandle<JSTaggedValue> presentValue(thread, JSTaggedValue::Undefined());
3384 JSMutableHandle<JSTaggedValue> middleValue(thread, JSTaggedValue::Undefined());
3385 JSMutableHandle<JSTaggedValue> previousValue(thread, JSTaggedValue::Undefined());
3387 JSMutableHandle<TaggedArray> elements(thread, thisObj->GetElements());
3393 JSHandle<JSTaggedValue> presentString = GetOrCreateNumberString(thread, presentValue, cachedString);
3397 JSHandle<JSTaggedValue> middleString = GetOrCreateNumberString(thread, middleValue, cachedString);
3398 double compareResult = ArrayHelper::StringSortCompare(thread, middleString, presentString);
3399 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
3409 elements.Update(TryCopyCOWArray(thread, JSHandle<JSArray>(thisObj), isCOWArray));
3410 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
3411 elements->Set(thread, j, previousValue);
3413 elements.Update(TryCopyCOWArray(thread, JSHandle<JSArray>(thisObj), isCOWArray));
3414 RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
3415 elements->Set(thread, endIndex, presentValue);
3423 auto thread = JSThread::GlueToJSThread(argGlue);
3425 thread->GetEcmaVM()->GetEcmaStringTable()->TryGetInternString(thread, string);