/* * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ECMASCRIPT_RUNTIME_STUBS_H #define ECMASCRIPT_RUNTIME_STUBS_H #include "ecmascript/frames.h" #include "ecmascript/ecma_macros.h" #include "ecmascript/js_tagged_value.h" #include "ecmascript/jspandafile/class_literal.h" #include "ecmascript/method.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/region.h" #include "ecmascript/stubs/runtime_stub_list.h" namespace panda::ecmascript { class EcmaVM; class GlobalEnv; class JSThread; class JSFunction; class ObjectFactory; class JSBoundFunction; class JSProxy; class JSTypedArray; class AOTLiteralInfo; class GeneratorContext; struct EcmaRuntimeCallInfo; using JSFunctionEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, const JSTaggedType argV[], uintptr_t prevFp, bool needPushArgv); using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, const JSTaggedType argV[], uintptr_t prevFp); class RuntimeStubs { public: static void Initialize(JSThread *thread); #define DECLARE_RUNTIME_STUBS(name) \ static JSTaggedType name(uintptr_t argGlue, uint32_t argc, uintptr_t argv); RUNTIME_STUB_WITH_GC_LIST(DECLARE_RUNTIME_STUBS) TEST_RUNTIME_STUB_GC_LIST(DECLARE_RUNTIME_STUBS) #undef DECLARE_RUNTIME_STUBS inline static JSTaggedType GetTArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) { ASSERT(index < argc); return *(reinterpret_cast(argv) + (index)); } inline static JSTaggedValue GetArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) { ASSERT(index < argc); return JSTaggedValue(*(reinterpret_cast(argv) + (index))); } template inline static JSHandle GetHArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) { ASSERT(index < argc); return JSHandle(&(reinterpret_cast(argv)[index])); } template inline static T *GetPtrArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index) { ASSERT(index < argc); return reinterpret_cast(*(reinterpret_cast(argv) + (index))); } static void Dump(JSTaggedType value); static void DebugDump(JSTaggedType value); static void DumpWithHint(uintptr_t hintStrAddress, JSTaggedType value); static void DebugDumpWithHint(uintptr_t hintStrAddress, JSTaggedType value); static void DebugPrint(int fmtMessageId, ...); static void DebugPrintCustom(uintptr_t fmt, ...); static void DebugPrintInstruction([[maybe_unused]] uintptr_t argGlue, const uint8_t *pc); static void DebugOsrEntry([[maybe_unused]] uintptr_t argGlue, const uint8_t *codeEntry); static void Comment(uintptr_t argStr); static void FatalPrint(int fmtMessageId, ...); static void FatalPrintCustom(uintptr_t fmt, ...); static void MarkingBarrier([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset, TaggedObject *value); static void MarkingBarrierWithEden([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset, TaggedObject *value); static void SharedGCMarkingBarrier([[maybe_unused]] uintptr_t argGlue, TaggedObject *value); static void StoreBarrier([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset, TaggedObject *value); static JSTaggedType CreateArrayFromList([[maybe_unused]] uintptr_t argGlue, int32_t argc, JSTaggedValue *argvPtr); static JSTaggedType GetActualArgvNoGC(uintptr_t argGlue); static void InsertNewToEdenRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset); static void InsertOldToNewRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset); static void InsertLocalToShareRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset); static void SetBitAtomic(GCBitset::GCBitsetWord *word, GCBitset::GCBitsetWord mask, GCBitset::GCBitsetWord oldValue); static int32_t DoubleToInt(double x, size_t bits); static JSTaggedType DoubleToLength(double x); static double FloatMod(double x, double y); static double FloatAcos(double x); static double FloatAcosh(double x); static double FloatAsin(double x); static double FloatAsinh(double x); static double FloatAtan(double x); static double FloatAtan2(double y, double x); static double FloatAtanh(double x); static double FloatCos(double x); static double FloatCosh(double x); static double FloatSin(double x); static double FloatSinh(double x); static double FloatTan(double x); static double FloatTanh(double x); static double FloatTrunc(double x); static double FloatFloor(double x); static double FloatLog(double x); static double FloatLog2(double x); static double FloatLog10(double x); static double FloatLog1p(double x); static double FloatExp(double x); static double FloatExpm1(double x); static double FloatPow(double base, double exp); static double FloatCbrt(double x); static double FloatCeil(double x); static bool NumberIsFinite(double x); static double CallDateNow(); static int32_t FindElementWithCache(uintptr_t argGlue, JSTaggedType hclass, JSTaggedType key, int32_t num); static void UpdateFieldType(JSTaggedType hclass, uint64_t value); static bool StringsAreEquals(EcmaString *str1, EcmaString *str2); static bool BigIntEquals(JSTaggedType left, JSTaggedType right); static bool BigIntSameValueZero(JSTaggedType key, JSTaggedType other); static JSTaggedValue JSHClassFindProtoTransitions(JSHClass *cls, JSTaggedValue key, JSTaggedValue proto); static JSTaggedValue NumberHelperStringToDouble(EcmaString *str); static JSTaggedValue GetStringToListCacheArray(uintptr_t argGlue); static int FastArraySort(JSTaggedType x, JSTaggedType y); static int FastArraySortString(uintptr_t argGlue, JSTaggedValue x, JSTaggedValue y); static JSTaggedValue StringToNumber(JSTaggedType numberString, int32_t radix); static void ArrayTrim(uintptr_t argGlue, TaggedArray *array, int64_t newLength); static double TimeClip(double time); static double SetDateValues(double year, double month, double day); static void StartCallTimer(uintptr_t argGlue, JSTaggedType func, bool isAot); static void EndCallTimer(uintptr_t argGlue, JSTaggedType func); static JSTaggedValue RuntimeArraySort(JSThread *thread, JSHandle thisHandle); static JSTaggedValue CallBoundFunction(EcmaRuntimeCallInfo *info); static int32_t StringGetStart(bool isUtf8, EcmaString *srcString, int32_t length, int32_t startIndex); static int32_t StringGetEnd(bool isUtf8, EcmaString *srcString, int32_t start, int32_t length, int32_t startIndex); static void CopyTypedArrayBuffer(JSTypedArray *srcArray, JSTypedArray *targetArray, int32_t srcStartPos, int32_t tarStartPos, int32_t count, int32_t elementSize); static inline uint32_t RuntimeGetBytecodePcOfstForBaseline(const JSHandle &func, uintptr_t nativePc); private: static void DumpToStreamWithHint(std::ostream &out, std::string_view prompt, JSTaggedValue value); static inline JSTaggedValue RuntimeInc(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeDec(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeExp(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent); static inline JSTaggedValue RuntimeIsIn(JSThread *thread, const JSHandle &prop, const JSHandle &obj); static inline JSTaggedValue RuntimeInstanceof(JSThread *thread, const JSHandle &obj, const JSHandle &target); static inline JSTaggedValue RuntimeInstanceofByHandler(JSThread *thread, JSHandle target, JSHandle object, JSHandle instOfHandler); static inline JSTaggedValue RuntimeCreateGeneratorObj(JSThread *thread, const JSHandle &genFunc); static inline JSTaggedValue RuntimeCreateAsyncGeneratorObj(JSThread *thread, const JSHandle &genFunc); static inline JSTaggedValue RuntimeAsyncGeneratorResolve(JSThread *thread, JSHandle asyncFuncObj, JSHandle value, JSTaggedValue flag); static inline JSTaggedValue RuntimeAsyncGeneratorReject(JSThread *thread, JSHandle asyncFuncObj, JSHandle value); static inline JSTaggedValue RuntimeGetTemplateObject(JSThread *thread, const JSHandle &literal); static inline JSTaggedValue RuntimeGetNextPropName(JSThread *thread, const JSHandle &iter); static inline JSTaggedValue RuntimeIterNext(JSThread *thread, const JSHandle &iter); static inline JSTaggedValue RuntimeCloseIterator(JSThread *thread, const JSHandle &iter); static inline JSTaggedValue RuntimeSuperCallSpread(JSThread *thread, const JSHandle &func, const JSHandle &newTarget, const JSHandle &array); static inline JSTaggedValue RuntimeOptSuperCallSpread(JSThread *thread, const JSHandle &func, const JSHandle &newTarget, const JSHandle &taggedArray); static inline JSTaggedValue RuntimeSuperCallForwardAllArgs(JSThread *thread, JSTaggedType *sp, const JSHandle &superFunc, const JSHandle &newTarget, uint32_t restNumArgs, uint32_t startIdx); static inline JSTaggedValue RuntimeDelObjProp(JSThread *thread, const JSHandle &obj, const JSHandle &prop); static inline JSTaggedValue RuntimeNewObjApply(JSThread *thread, const JSHandle &func, const JSHandle &array); static inline JSTaggedValue RuntimeCreateIterResultObj(JSThread *thread, const JSHandle &value, JSTaggedValue flag); static inline JSTaggedValue RuntimeAsyncFunctionAwaitUncaught(JSThread *thread, const JSHandle &asyncFuncObj, const JSHandle &value); static inline JSTaggedValue RuntimeAsyncFunctionResolveOrReject(JSThread *thread, const JSHandle &asyncFuncObj, const JSHandle &value, bool is_resolve); static inline JSTaggedValue RuntimeCopyDataProperties(JSThread *thread, const JSHandle &dst, const JSHandle &src); static inline JSTaggedValue RuntimeStArraySpread(JSThread *thread, const JSHandle &dst, JSTaggedValue index, const JSHandle &src); static inline JSTaggedValue RuntimeSetObjectWithProto(JSThread *thread, const JSHandle &proto, const JSHandle &obj); static inline JSTaggedValue RuntimeGetIteratorNext(JSThread *thread, const JSHandle &obj, const JSHandle &method); static inline JSTaggedValue RuntimeLdObjByValue(JSThread *thread, const JSHandle &obj, const JSHandle &prop, bool callGetter, JSTaggedValue receiver); static inline JSTaggedValue RuntimeStObjByValue(JSThread *thread, const JSHandle &obj, const JSHandle &prop, const JSHandle &value); static inline JSTaggedValue RuntimeStOwnByValue(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &value); static inline JSTaggedValue RuntimeLdSuperByValue(JSThread *thread, const JSHandle &obj, const JSHandle &key, JSTaggedValue thisFunc); static inline JSTaggedValue RuntimeStSuperByValue(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &value, JSTaggedValue thisFunc); static inline JSTaggedValue RuntimeLdObjByIndex(JSThread *thread, const JSHandle &obj, uint32_t idx, bool callGetter, JSTaggedValue receiver); static inline JSTaggedValue RuntimeStObjByIndex(JSThread *thread, const JSHandle &obj, uint32_t idx, const JSHandle &value); static inline JSTaggedValue RuntimeStOwnByIndex(JSThread *thread, const JSHandle &obj, const JSHandle &idx, const JSHandle &value); static inline JSTaggedValue RuntimeStGlobalRecord(JSThread *thread, const JSHandle &prop, const JSHandle &value, bool isConst); static inline JSTaggedValue RuntimeNeg(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeNot(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeResolveClass(JSThread *thread, const JSHandle &ctor, const JSHandle &literal, const JSHandle &base, const JSHandle &lexenv); static inline JSTaggedValue RuntimeCloneClassFromTemplate(JSThread *thread, const JSHandle &ctor, const JSHandle &base, const JSHandle &lexenv); static inline JSTaggedValue RuntimeCreateClassWithBuffer(JSThread *thread, const JSHandle &base, const JSHandle &lexenv, const JSHandle &constpool, uint16_t methodId, uint16_t literalId, const JSHandle &module, const JSHandle &length); static inline void SetProfileTypeInfoCellToFunction(JSThread *thread, const JSHandle &jsFunc, const JSHandle &definedFunc, uint16_t slotId); static inline JSTaggedValue RuntimeCreateSharedClass(JSThread *thread, const JSHandle &base, const JSHandle &constpool, uint16_t methodId, uint16_t literalId, uint16_t length, const JSHandle &module); static inline JSTaggedValue RuntimeLdSendableClass(const JSHandle &env, uint16_t level); static inline JSTaggedValue RuntimeSetClassInheritanceRelationship(JSThread *thread, const JSHandle &ctor, const JSHandle &base, ClassKind kind = ClassKind::NON_SENDABLE); static inline JSTaggedValue RuntimeSetClassConstructorLength(JSThread *thread, JSTaggedValue ctor, JSTaggedValue length); static inline JSTaggedValue RuntimeNotifyInlineCache(JSThread *thread, const JSHandle &function, uint32_t icSlotSize); static inline JSTaggedValue RuntimeStOwnByValueWithNameSet(JSThread *thread, const JSHandle &obj, const JSHandle &key, const JSHandle &value); static inline JSTaggedValue RuntimeStOwnByName(JSThread *thread, const JSHandle &obj, const JSHandle &prop, const JSHandle &value); static inline JSTaggedValue RuntimeSuspendGenerator(JSThread *thread, const JSHandle &genObj, const JSHandle &value); static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, int32_t index); static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, int32_t index, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName); static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName, JSTaggedValue jsFunc); static inline void RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value); static inline void RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value, JSTaggedValue jsFunc); static inline void RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value); static inline void RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeLdLocalModuleVar(JSThread *thread, int32_t index); static inline JSTaggedValue RuntimeLdLocalModuleVarWithModule(JSThread *thread, int32_t index, JSHandle moduleHdl); static inline JSTaggedValue RuntimeLdLocalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeLdExternalModuleVar(JSThread *thread, int32_t index); static inline JSTaggedValue RuntimeLdExternalModuleVarWithModule(JSThread *thread, int32_t index, JSHandle moduleHdl); static inline JSTaggedValue RuntimeLdSendableExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeLdExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeLdLazySendableExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeLdLazyExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner); static inline JSTaggedValue RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner, JSTaggedValue jsFunc); static inline JSTaggedValue RuntimeGetPropIterator(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeAsyncFunctionEnter(JSThread *thread); static inline JSTaggedValue RuntimeGetIterator(JSThread *thread, const JSHandle &obj); static inline JSTaggedValue RuntimeGetAsyncIterator(JSThread *thread, const JSHandle &obj); static inline void RuntimeSetGeneratorState(JSThread *thread, const JSHandle &genObj, const int32_t index); static inline void RuntimeThrow(JSThread *thread, JSTaggedValue value); static inline void RuntimeThrowThrowNotExists(JSThread *thread); static inline void RuntimeThrowPatternNonCoercible(JSThread *thread); static inline void RuntimeThrowDeleteSuperProperty(JSThread *thread); static inline void RuntimeThrowUndefinedIfHole(JSThread *thread, const JSHandle &obj); static inline void RuntimeThrowIfNotObject(JSThread *thread); static inline void RuntimeThrowConstAssignment(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeLdGlobalRecord(JSThread *thread, JSTaggedValue key); static inline JSTaggedValue RuntimeTryLdGlobalByName(JSThread *thread, const JSHandle &obj, const JSHandle &prop); static inline JSTaggedValue RuntimeTryUpdateGlobalRecord(JSThread *thread, JSTaggedValue prop, JSTaggedValue value); static inline JSTaggedValue RuntimeThrowReferenceError(JSThread *thread, const JSHandle &prop, const char *desc); static inline JSTaggedValue RuntimeLdGlobalVarFromProto(JSThread *thread, const JSHandle &globalObj, const JSHandle &prop); static inline JSTaggedValue RuntimeStGlobalVar(JSThread *thread, const JSHandle &prop, const JSHandle &value); static inline JSTaggedValue RuntimeToNumber(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeDynamicImport(JSThread *thread, const JSHandle &specifier, const JSHandle &func); static inline JSTaggedValue RuntimeToNumeric(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeEq(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeLdObjByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop, bool callGetter, JSTaggedValue receiver); static inline JSTaggedValue RuntimeNotEq(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeLess(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeLessEq(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeGreater(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeGreaterEq(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeAdd2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeShl2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeShr2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeSub2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeMul2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeDiv2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeMod2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeAshr2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeAnd2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeOr2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeXor2(JSThread *thread, const JSHandle &left, const JSHandle &right); static inline JSTaggedValue RuntimeStOwnByNameWithNameSet(JSThread *thread, const JSHandle &obj, const JSHandle &prop, const JSHandle &value); static inline JSTaggedValue RuntimeStObjByName(JSThread *thread, const JSHandle &obj, const JSHandle &prop, const JSHandle &value); static inline JSTaggedValue RuntimeToJSTaggedValueWithInt32(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeToJSTaggedValueWithUint32(JSThread *thread, const JSHandle &value); static inline JSTaggedValue RuntimeCreateEmptyObject(JSThread *thread, ObjectFactory *factory, JSHandle globalEnv); static inline JSTaggedValue RuntimeCreateEmptyArray(JSThread *thread, ObjectFactory *factory, JSHandle globalEnv); static inline JSTaggedValue RuntimeGetUnmapedArgs(JSThread *thread, JSTaggedType *sp, uint32_t actualNumArgs, uint32_t startIdx); static inline JSTaggedValue RuntimeCopyRestArgs(JSThread *thread, JSTaggedType *sp, uint32_t restNumArgs, uint32_t startIdx); static inline JSTaggedValue RuntimeCreateArrayWithBuffer(JSThread *thread, ObjectFactory *factory, const JSHandle &literal); static inline JSTaggedValue RuntimeCreateObjectWithBuffer(JSThread *thread, ObjectFactory *factory, const JSHandle &literal); static inline JSTaggedValue RuntimeNewLexicalEnv(JSThread *thread, uint16_t numVars); static inline JSTaggedValue RuntimeNewSendableEnv(JSThread *thread, uint16_t numVars); static inline JSTaggedValue RuntimeNewObjRange(JSThread *thread, const JSHandle &func, const JSHandle &newTarget, uint16_t firstArgIdx, uint16_t length); static inline JSTaggedValue RuntimeDefinefunc(JSThread *thread, const JSHandle &constpool, uint16_t methodId, const JSHandle &module, uint16_t length, const JSHandle &envHandle, const JSHandle &homeObject); static inline void DefineFuncTryUseAOTHClass(JSThread* thread, const JSHandle& func, const JSHandle& ihc, const JSHandle& aotLiteralInfo); static inline JSTaggedValue RuntimeCreateRegExpWithLiteral(JSThread *thread, const JSHandle &pattern, uint8_t flags); static inline JSTaggedValue RuntimeThrowIfSuperNotCorrectCall(JSThread *thread, uint16_t index, JSTaggedValue thisValue); static inline JSTaggedValue RuntimeCreateObjectHavingMethod(JSThread *thread, ObjectFactory *factory, const JSHandle &literal, const JSHandle &env); static inline JSTaggedValue RuntimeCreateObjectWithExcludedKeys(JSThread *thread, uint16_t numKeys, const JSHandle &objVal, uint16_t firstArgRegIdx); static inline JSTaggedValue RuntimeDefineMethod(JSThread *thread, const JSHandle &methodHandle, const JSHandle &homeObject, uint16_t length, const JSHandle &env, const JSHandle &module); static inline JSTaggedValue RuntimeCallSpread(JSThread *thread, const JSHandle &func, const JSHandle &obj, const JSHandle &array); static inline JSTaggedValue RuntimeDefineGetterSetterByValue(JSThread *thread, const JSHandle &obj, const JSHandle &prop, const JSHandle &getter, const JSHandle &setter, bool flag, const JSHandle &func, int32_t pcOffset); static inline JSTaggedValue RuntimeSuperCall(JSThread *thread, const JSHandle &func, const JSHandle &newTarget, uint16_t firstVRegIdx, uint16_t length); static inline JSTaggedValue RuntimeOptSuperCall(JSThread *thread, const JSHandle &func, const JSHandle &newTarget, const JSHandle &argv, uint16_t length); static inline JSTaggedValue RuntimeThrowTypeError(JSThread *thread, const char *message); static inline JSTaggedValue RuntimeGetCallSpreadArgs(JSThread *thread, const JSHandle &array); static inline JSTaggedValue RuntimeThrowReferenceError(JSThread *thread, JSTaggedValue prop, const char *desc); static inline JSTaggedValue RuntimeThrowSyntaxError(JSThread *thread, const char *message); static inline JSTaggedValue RuntimeLdBigInt(JSThread *thread, const JSHandle &numberBigInt); static inline JSTaggedValue RuntimeCallBigIntAsIntN(JSThread *thread, JSTaggedValue bits, JSTaggedValue bigint); static inline JSTaggedValue RuntimeCallBigIntAsUintN(JSThread *thread, JSTaggedValue bits, JSTaggedValue bigint); static inline JSTaggedValue RuntimeNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId); static inline JSTaggedValue RuntimeOptGetUnmapedArgs(JSThread *thread, uint32_t actualNumArgs); static inline JSTaggedValue RuntimeGetUnmapedJSArgumentObj(JSThread *thread, const JSHandle &argumentsList); static inline JSTaggedValue RuntimeOptNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId, JSHandle ¤tLexEnv, JSHandle &func); static inline JSTaggedValue RuntimeOptCopyRestArgs(JSThread *thread, uint32_t actualArgc, uint32_t restIndex); static inline JSTaggedValue RuntimeOptSuspendGenerator(JSThread *thread, const JSHandle &genObj, const JSHandle &value); static inline JSTaggedValue RuntimeOptAsyncGeneratorResolve(JSThread *thread, JSHandle asyncFuncObj, JSHandle value, JSTaggedValue flag); static inline JSTaggedValue CommonCreateObjectWithExcludedKeys(JSThread *thread, const JSHandle &objVal, uint32_t numExcludedKeys, JSHandle excludedKeys); static inline JSTaggedValue RuntimeOptCreateObjectWithExcludedKeys(JSThread *thread, uintptr_t argv, uint32_t argc); static inline JSTaggedValue RuntimeOptNewObjRange(JSThread *thread, uintptr_t argv, uint32_t argc); static inline JSTaggedValue RuntimeOptConstruct(JSThread *thread, JSHandle ctor, JSHandle newTarget, JSHandle preArgs, JSHandle args); static inline JSTaggedValue RuntimeOptConstructProxy(JSThread *thread, JSHandle ctor, JSHandle newTgt, JSHandle preArgs, JSHandle args); static inline JSTaggedValue RuntimeOptConstructBoundFunction(JSThread *thread, JSHandle ctor, JSHandle newTgt, JSHandle preArgs, JSHandle args); static inline JSTaggedValue RuntimeOptConstructGeneric(JSThread *thread, JSHandle ctor, JSHandle newTgt, JSHandle preArgs, JSHandle args); static inline JSTaggedValue GetResultValue(JSThread *thread, bool isAotMethod, JSHandle ctor, CVector &values, JSHandle newTgt, uint32_t &size, JSHandle obj); static inline JSTaggedValue RuntimeOptGenerateScopeInfo(JSThread *thread, uint16_t scopeId, JSTaggedValue func); static inline JSTaggedType *GetActualArgv(JSThread *thread); static inline JSTaggedType *GetActualArgvFromStub(JSThread *thread); static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrame(JSThread *thread); static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrameNoGC(JSThread *thread); static JSTaggedValue NewObject(EcmaRuntimeCallInfo *info); static void SaveFrameToContext(JSThread *thread, JSHandle context); static inline JSTaggedValue RuntimeLdPatchVar(JSThread *thread, uint32_t index); static inline JSTaggedValue RuntimeStPatchVar(JSThread *thread, uint32_t index, const JSHandle &value); static inline JSTaggedValue RuntimeNotifyConcurrentResult(JSThread *thread, JSTaggedValue result, JSTaggedValue hint); static inline JSTaggedValue RuntimeDefineField(JSThread *thread, JSTaggedValue obj, JSTaggedValue propKey, JSTaggedValue value); static inline JSTaggedValue RuntimeCreatePrivateProperty(JSThread *thread, JSTaggedValue constpool, uint32_t count, JSTaggedValue lexicalEnv, uint32_t literalId, JSTaggedValue module); static inline JSTaggedValue RuntimeDefinePrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv, uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj, JSTaggedValue value); static inline JSTaggedValue RuntimeLdPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv, uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj); static inline JSTaggedValue RuntimeStPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv, uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj, JSTaggedValue value); static inline JSTaggedValue RuntimeTestIn(JSThread *thread, JSTaggedValue lexicalEnv, uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj); static inline JSTaggedValue RuntimeUpdateAOTHClass(JSThread *thread, const JSHandle &oldhclass, const JSHandle &newhclass, JSTaggedValue key); static inline JSTaggedValue RuntimeNotifyDebuggerStatement(JSThread *thread); static inline bool CheckElementsNumber(JSHandle elements, uint32_t len); static inline JSHandle GetOrCreateNumberString(JSThread *thread, JSHandle presentValue, std::map> &cachedString); static inline JSTaggedValue TryCopyCOWArray(JSThread *thread, JSHandle holderHandler, bool &isCOWArray); static inline JSTaggedValue ArrayNumberSort(JSThread *thread, JSHandle thisObj, uint32_t len); static inline bool ShouldUseAOTHClass(const JSHandle &ihc, const JSHandle &chc, const JSHandle &classLiteral); static inline JSTaggedType RuntimeTryGetInternString(uintptr_t argGlue, const JSHandle &string); static inline void RuntimeSetPatchModule(JSThread *thread, const JSHandle &func); template static inline JSTaggedValue RuntimeDecodeURIComponent(JSThread *thread, const JSHandle &str, const T *data); template static inline uint16_t GetCodeUnit(Span &sp, int32_t index, int32_t length); template static inline JSTaggedValue DecodePercentEncoding(JSThread *thread, const JSHandle &str, int32_t &k, int32_t strLen, std::u16string &sStr, Span &sp); template static inline JSTaggedValue DecodePercentEncoding(JSThread *thread, int32_t &n, int32_t &k, const JSHandle &str, uint8_t &bb, std::vector &oct, Span &sp, int32_t strLen); static inline JSTaggedValue UTF16EncodeCodePoint(JSThread *thread, const std::vector &oct, const JSHandle &str, std::u16string &sStr); static inline bool IsFastRegExp(uintptr_t argGlue, JSTaggedValue thisValue); static inline uint8_t GetValueFromTwoHex(uint8_t front, uint8_t behind); friend class SlowRuntimeStub; }; } // namespace panda::ecmascript #endif