• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_RUNTIME_STUBS_H
17 #define ECMASCRIPT_RUNTIME_STUBS_H
18 
19 #include "ecmascript/frames.h"
20 #include "ecmascript/ecma_macros.h"
21 #include "ecmascript/js_tagged_value.h"
22 #include "ecmascript/jspandafile/class_literal.h"
23 #include "ecmascript/method.h"
24 #include "ecmascript/mem/c_containers.h"
25 #include "ecmascript/mem/region.h"
26 #include "ecmascript/stubs/runtime_stub_list.h"
27 
28 namespace panda::ecmascript {
29 class EcmaVM;
30 class GlobalEnv;
31 class JSThread;
32 class JSFunction;
33 class ObjectFactory;
34 class JSBoundFunction;
35 class JSProxy;
36 class JSTypedArray;
37 class AOTLiteralInfo;
38 class GeneratorContext;
39 struct EcmaRuntimeCallInfo;
40 
41 using JSFunctionEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, const JSTaggedType argV[],
42                                               uintptr_t prevFp, bool needPushArgv);
43 using FastCallAotEntryType = JSTaggedValue (*)(uintptr_t glue, uint32_t argc, const JSTaggedType argV[],
44                                               uintptr_t prevFp);
45 
46 class RuntimeStubs {
47 public:
48     static void Initialize(JSThread *thread);
49 
50 #define DECLARE_RUNTIME_STUBS(name) \
51     static JSTaggedType name(uintptr_t argGlue, uint32_t argc, uintptr_t argv);
52     RUNTIME_STUB_WITH_GC_LIST(DECLARE_RUNTIME_STUBS)
TEST_RUNTIME_STUB_GC_LIST(DECLARE_RUNTIME_STUBS)53     TEST_RUNTIME_STUB_GC_LIST(DECLARE_RUNTIME_STUBS)
54 #undef DECLARE_RUNTIME_STUBS
55 
56     inline static JSTaggedType GetTArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index)
57     {
58         ASSERT(index < argc);
59         return *(reinterpret_cast<JSTaggedType *>(argv) + (index));
60     }
61 
GetArg(uintptr_t argv,uint32_t argc,uint32_t index)62     inline static JSTaggedValue GetArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index)
63     {
64         ASSERT(index < argc);
65         return JSTaggedValue(*(reinterpret_cast<JSTaggedType *>(argv) + (index)));
66     }
67 
68     template<typename T>
GetHArg(uintptr_t argv,uint32_t argc,uint32_t index)69     inline static JSHandle<T> GetHArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index)
70     {
71         ASSERT(index < argc);
72         return JSHandle<T>(&(reinterpret_cast<JSTaggedType *>(argv)[index]));
73     }
74 
75     template<typename T>
GetPtrArg(uintptr_t argv,uint32_t argc,uint32_t index)76     inline static T *GetPtrArg(uintptr_t argv, [[maybe_unused]] uint32_t argc, uint32_t index)
77     {
78         ASSERT(index < argc);
79         return reinterpret_cast<T*>(*(reinterpret_cast<JSTaggedType *>(argv) + (index)));
80     }
81 
82     static void Dump(JSTaggedType value);
83     static void DebugDump(JSTaggedType value);
84     static void DumpWithHint(uintptr_t hintStrAddress, JSTaggedType value);
85     static void DebugDumpWithHint(uintptr_t hintStrAddress, JSTaggedType value);
86     static void DebugPrint(int fmtMessageId, ...);
87     static void DebugPrintCustom(uintptr_t fmt, ...);
88     static void DebugPrintInstruction([[maybe_unused]] uintptr_t argGlue, const uint8_t *pc);
89     static void DebugOsrEntry([[maybe_unused]] uintptr_t argGlue, const uint8_t *codeEntry);
90     static void Comment(uintptr_t argStr);
91     static void FatalPrint(int fmtMessageId, ...);
92     static void FatalPrintCustom(uintptr_t fmt, ...);
93     static void MarkingBarrier([[maybe_unused]] uintptr_t argGlue,
94         uintptr_t object, size_t offset, TaggedObject *value);
95     static void MarkingBarrierWithEden([[maybe_unused]] uintptr_t argGlue,
96         uintptr_t object, size_t offset, TaggedObject *value);
97     static void SharedGCMarkingBarrier([[maybe_unused]] uintptr_t argGlue, TaggedObject *value);
98     static void StoreBarrier([[maybe_unused]] uintptr_t argGlue,
99         uintptr_t object, size_t offset, TaggedObject *value);
100     static JSTaggedType CreateArrayFromList([[maybe_unused]] uintptr_t argGlue, int32_t argc, JSTaggedValue *argvPtr);
101     static JSTaggedType GetActualArgvNoGC(uintptr_t argGlue);
102     static void InsertNewToEdenRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset);
103     static void InsertOldToNewRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset);
104     static void InsertLocalToShareRSet([[maybe_unused]] uintptr_t argGlue, uintptr_t object, size_t offset);
105     static void SetBitAtomic(GCBitset::GCBitsetWord *word, GCBitset::GCBitsetWord mask,
106                              GCBitset::GCBitsetWord oldValue);
107     static int32_t DoubleToInt(double x, size_t bits);
108     static JSTaggedType DoubleToLength(double x);
109     static double FloatMod(double x, double y);
110     static double FloatAcos(double x);
111     static double FloatAcosh(double x);
112     static double FloatAsin(double x);
113     static double FloatAsinh(double x);
114     static double FloatAtan(double x);
115     static double FloatAtan2(double y, double x);
116     static double FloatAtanh(double x);
117     static double FloatCos(double x);
118     static double FloatCosh(double x);
119     static double FloatSin(double x);
120     static double FloatSinh(double x);
121     static double FloatTan(double x);
122     static double FloatTanh(double x);
123     static double FloatTrunc(double x);
124     static double FloatFloor(double x);
125     static double FloatLog(double x);
126     static double FloatLog2(double x);
127     static double FloatLog10(double x);
128     static double FloatLog1p(double x);
129     static double FloatExp(double x);
130     static double FloatExpm1(double x);
131     static double FloatPow(double base, double exp);
132     static double FloatCbrt(double x);
133     static double FloatCeil(double x);
134     static bool NumberIsFinite(double x);
135     static double CallDateNow();
136     static int32_t FindElementWithCache(uintptr_t argGlue, JSTaggedType hclass,
137                                         JSTaggedType key, int32_t num);
138     static void UpdateFieldType(JSTaggedType hclass, uint64_t value);
139     static bool StringsAreEquals(EcmaString *str1, EcmaString *str2);
140     static bool BigIntEquals(JSTaggedType left, JSTaggedType right);
141     static bool BigIntSameValueZero(JSTaggedType key, JSTaggedType other);
142     static JSTaggedValue JSHClassFindProtoTransitions(JSHClass *cls, JSTaggedValue key, JSTaggedValue proto);
143     static JSTaggedValue NumberHelperStringToDouble(EcmaString *str);
144     static JSTaggedValue GetStringToListCacheArray(uintptr_t argGlue);
145     static int FastArraySort(JSTaggedType x, JSTaggedType y);
146     static JSTaggedValue StringToNumber(JSTaggedType numberString, int32_t radix);
147     static void ArrayTrim(uintptr_t argGlue, TaggedArray *array, int64_t newLength);
148     static double TimeClip(double time);
149     static double SetDateValues(double year, double month, double day);
150     static void StartCallTimer(uintptr_t argGlue, JSTaggedType func, bool isAot);
151     static void EndCallTimer(uintptr_t argGlue, JSTaggedType func);
152     static JSTaggedValue RuntimeArraySort(JSThread *thread, JSHandle<JSTaggedValue> thisHandle);
153 
154     static JSTaggedValue CallBoundFunction(EcmaRuntimeCallInfo *info);
155 
156     static int32_t StringGetStart(bool isUtf8, EcmaString *srcString, int32_t length, int32_t startIndex);
157     static int32_t StringGetEnd(bool isUtf8, EcmaString *srcString, int32_t start, int32_t length, int32_t startIndex);
158     static void CopyTypedArrayBuffer(uintptr_t argGlue, JSTypedArray *srcArray, JSTypedArray *targetArray,
159                                      int32_t srcStartPos, int32_t tarStartPos, int32_t count);
160 
161     static inline uint32_t RuntimeGetBytecodePcOfstForBaseline(const JSHandle<JSFunction> &func, uintptr_t nativePc);
162 private:
163     static void DumpToStreamWithHint(std::ostream &out, std::string_view prompt, JSTaggedValue value);
164     static void PrintHeapReginInfo(uintptr_t argGlue);
165 
166     static inline JSTaggedValue RuntimeInc(JSThread *thread, const JSHandle<JSTaggedValue> &value);
167     static inline JSTaggedValue RuntimeDec(JSThread *thread, const JSHandle<JSTaggedValue> &value);
168     static inline JSTaggedValue RuntimeExp(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent);
169     static inline JSTaggedValue RuntimeIsIn(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
170                                             const JSHandle<JSTaggedValue> &obj);
171     static inline JSTaggedValue RuntimeInstanceof(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
172                                                   const JSHandle<JSTaggedValue> &target);
173     static inline JSTaggedValue RuntimeInstanceofByHandler(JSThread *thread, JSHandle<JSTaggedValue> target,
174                                                            JSHandle<JSTaggedValue> object,
175                                                            JSHandle<JSTaggedValue> instOfHandler);
176     static inline JSTaggedValue RuntimeCreateGeneratorObj(JSThread *thread, const JSHandle<JSTaggedValue> &genFunc);
177 
178     static inline JSTaggedValue RuntimeCreateAsyncGeneratorObj(JSThread *thread,
179                                                                const JSHandle<JSTaggedValue> &genFunc);
180 
181     static inline JSTaggedValue RuntimeAsyncGeneratorResolve(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj,
182                                                              JSHandle<JSTaggedValue> value, JSTaggedValue flag);
183     static inline JSTaggedValue RuntimeAsyncGeneratorReject(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj,
184                                                             JSHandle<JSTaggedValue> value);
185     static inline JSTaggedValue RuntimeGetTemplateObject(JSThread *thread, const JSHandle<JSTaggedValue> &literal);
186     static inline JSTaggedValue RuntimeGetNextPropName(JSThread *thread, const JSHandle<JSTaggedValue> &iter);
187     static inline JSTaggedValue RuntimeIterNext(JSThread *thread, const JSHandle<JSTaggedValue> &iter);
188     static inline JSTaggedValue RuntimeCloseIterator(JSThread *thread, const JSHandle<JSTaggedValue> &iter);
189     static inline JSTaggedValue RuntimeSuperCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func,
190                                                        const JSHandle<JSTaggedValue> &newTarget,
191                                                        const JSHandle<JSTaggedValue> &array);
192     static inline JSTaggedValue RuntimeOptSuperCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func,
193                                                           const JSHandle<JSTaggedValue> &newTarget,
194                                                           const JSHandle<JSTaggedValue> &taggedArray);
195     static inline JSTaggedValue RuntimeDelObjProp(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
196                                                   const JSHandle<JSTaggedValue> &prop);
197     static inline JSTaggedValue RuntimeNewObjApply(JSThread *thread, const JSHandle<JSTaggedValue> &func,
198                                                    const JSHandle<JSTaggedValue> &array);
199     static inline JSTaggedValue RuntimeCreateIterResultObj(JSThread *thread, const JSHandle<JSTaggedValue> &value,
200                                                            JSTaggedValue flag);
201     static inline JSTaggedValue RuntimeAsyncFunctionAwaitUncaught(JSThread *thread,
202                                                                   const JSHandle<JSTaggedValue> &asyncFuncObj,
203                                                                   const JSHandle<JSTaggedValue> &value);
204     static inline JSTaggedValue RuntimeAsyncFunctionResolveOrReject(JSThread *thread,
205                                                                     const JSHandle<JSTaggedValue> &asyncFuncObj,
206                                                                     const JSHandle<JSTaggedValue> &value,
207                                                                     bool is_resolve);
208     static inline JSTaggedValue RuntimeCopyDataProperties(JSThread *thread, const JSHandle<JSTaggedValue> &dst,
209                                                           const JSHandle<JSTaggedValue> &src);
210     static inline JSTaggedValue RuntimeStArraySpread(JSThread *thread, const JSHandle<JSTaggedValue> &dst,
211                                                      JSTaggedValue index, const JSHandle<JSTaggedValue> &src);
212     static inline JSTaggedValue RuntimeSetObjectWithProto(JSThread *thread, const JSHandle<JSTaggedValue> &proto,
213                                                           const JSHandle<JSObject> &obj);
214     static inline JSTaggedValue RuntimeGetIteratorNext(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
215                                                        const JSHandle<JSTaggedValue> &method);
216     static inline JSTaggedValue RuntimeLdObjByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
217                                                     const JSHandle<JSTaggedValue> &prop, bool callGetter,
218                                                     JSTaggedValue receiver);
219     static inline JSTaggedValue RuntimeStObjByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
220                                                     const JSHandle<JSTaggedValue> &prop,
221                                                     const JSHandle<JSTaggedValue> &value);
222     static inline JSTaggedValue RuntimeStOwnByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
223                                                     const JSHandle<JSTaggedValue> &key,
224                                                     const JSHandle<JSTaggedValue> &value);
225     static inline JSTaggedValue RuntimeLdSuperByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
226                                                       const JSHandle<JSTaggedValue> &key, JSTaggedValue thisFunc);
227     static inline JSTaggedValue RuntimeStSuperByValue(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
228                                                       const JSHandle<JSTaggedValue> &key,
229                                                       const JSHandle<JSTaggedValue> &value, JSTaggedValue thisFunc);
230     static inline JSTaggedValue RuntimeLdObjByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj, uint32_t idx,
231                                                     bool callGetter, JSTaggedValue receiver);
232     static inline JSTaggedValue RuntimeStObjByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj, uint32_t idx,
233                                                     const JSHandle<JSTaggedValue> &value);
234     static inline JSTaggedValue RuntimeStOwnByIndex(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
235                                                     const JSHandle<JSTaggedValue> &idx,
236                                                     const JSHandle<JSTaggedValue> &value);
237     static inline JSTaggedValue RuntimeStGlobalRecord(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
238                                                       const JSHandle<JSTaggedValue> &value, bool isConst);
239     static inline JSTaggedValue RuntimeNeg(JSThread *thread, const JSHandle<JSTaggedValue> &value);
240     static inline JSTaggedValue RuntimeNot(JSThread *thread, const JSHandle<JSTaggedValue> &value);
241     static inline JSTaggedValue RuntimeResolveClass(JSThread *thread, const JSHandle<JSFunction> &ctor,
242                                                     const JSHandle<TaggedArray> &literal,
243                                                     const JSHandle<JSTaggedValue> &base,
244                                                     const JSHandle<JSTaggedValue> &lexenv);
245     static inline JSTaggedValue RuntimeCloneClassFromTemplate(JSThread *thread, const JSHandle<JSFunction> &ctor,
246                                                               const JSHandle<JSTaggedValue> &base,
247                                                               const JSHandle<JSTaggedValue> &lexenv);
248     static inline JSTaggedValue RuntimeCreateClassWithBuffer(JSThread *thread,
249                                                              const JSHandle<JSTaggedValue> &base,
250                                                              const JSHandle<JSTaggedValue> &lexenv,
251                                                              const JSHandle<JSTaggedValue> &constpool,
252                                                              uint16_t methodId, uint16_t literalId,
253                                                              const JSHandle<JSTaggedValue> &module,
254                                                              const JSHandle<JSTaggedValue> &length);
255     static inline void SetProfileTypeInfoCellToFunction(JSThread *thread, const JSHandle<JSFunction> &jsFunc,
256                                                         const JSHandle<JSFunction> &definedFunc, uint16_t slotId);
257     static inline JSTaggedValue RuntimeCreateSharedClass(JSThread *thread,
258                                                          const JSHandle<JSTaggedValue> &base,
259                                                          const JSHandle<JSTaggedValue> &constpool,
260                                                          uint16_t methodId, uint16_t literalId, uint16_t length,
261                                                          const JSHandle<JSTaggedValue> &module);
262     static inline JSTaggedValue RuntimeLdSendableClass(const JSHandle<JSTaggedValue> &env, uint16_t level);
263     static inline JSTaggedValue RuntimeSetClassInheritanceRelationship(JSThread *thread,
264                                                                        const JSHandle<JSTaggedValue> &ctor,
265                                                                        const JSHandle<JSTaggedValue> &base,
266                                                                        ClassKind kind = ClassKind::NON_SENDABLE);
267     static inline JSTaggedValue RuntimeSetClassConstructorLength(JSThread *thread, JSTaggedValue ctor,
268                                                                  JSTaggedValue length);
269     static inline JSTaggedValue RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<JSFunction> &function,
270                                                          uint32_t icSlotSize);
271     static inline JSTaggedValue RuntimeStOwnByValueWithNameSet(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
272                                                                const JSHandle<JSTaggedValue> &key,
273                                                                const JSHandle<JSTaggedValue> &value);
274     static inline JSTaggedValue RuntimeStOwnByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
275                                                    const JSHandle<JSTaggedValue> &prop,
276                                                    const JSHandle<JSTaggedValue> &value);
277     static inline JSTaggedValue RuntimeSuspendGenerator(JSThread *thread, const JSHandle<JSTaggedValue> &genObj,
278                                                         const JSHandle<JSTaggedValue> &value);
279     static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, int32_t index);
280     static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, int32_t index,
281                                                           JSTaggedValue jsFunc);
282     static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName);
283     static inline JSTaggedValue RuntimeGetModuleNamespace(JSThread *thread, JSTaggedValue localName,
284                                                           JSTaggedValue jsFunc);
285     static inline void RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value);
286     static inline void RuntimeStModuleVar(JSThread *thread, int32_t index, JSTaggedValue value,
287                                           JSTaggedValue jsFunc);
288     static inline void RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value);
289     static inline void RuntimeStModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value,
290                                           JSTaggedValue jsFunc);
291     static inline JSTaggedValue RuntimeLdLocalModuleVar(JSThread *thread, int32_t index);
292     static inline JSTaggedValue RuntimeLdLocalModuleVarWithModule(JSThread *thread, int32_t index,
293         JSHandle<JSTaggedValue> moduleHdl);
294     static inline JSTaggedValue RuntimeLdLocalModuleVar(JSThread *thread, int32_t index,
295                                                         JSTaggedValue jsFunc);
296     static inline JSTaggedValue RuntimeLdExternalModuleVar(JSThread *thread, int32_t index);
297     static inline JSTaggedValue RuntimeLdExternalModuleVarWithModule(JSThread *thread, int32_t index,
298         JSHandle<JSTaggedValue> moduleHdl);
299     static inline JSTaggedValue RuntimeLdSendableExternalModuleVar(JSThread *thread, int32_t index,
300                                                                    JSTaggedValue jsFunc);
301     static inline JSTaggedValue RuntimeLdExternalModuleVar(JSThread *thread, int32_t index,
302                                                            JSTaggedValue jsFunc);
303     static inline JSTaggedValue RuntimeLdLazySendableExternalModuleVar(JSThread *thread, int32_t index,
304                                                                        JSTaggedValue jsFunc);
305     static inline JSTaggedValue RuntimeLdLazyExternalModuleVar(JSThread *thread, int32_t index,
306                                                                JSTaggedValue jsFunc);
307     static inline JSTaggedValue RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner);
308     static inline JSTaggedValue RuntimeLdModuleVar(JSThread *thread, JSTaggedValue key, bool inner,
309                                                    JSTaggedValue jsFunc);
310     static inline JSTaggedValue RuntimeGetPropIterator(JSThread *thread, const JSHandle<JSTaggedValue> &value);
311     static inline JSTaggedValue RuntimeAsyncFunctionEnter(JSThread *thread);
312     static inline JSTaggedValue RuntimeGetIterator(JSThread *thread, const JSHandle<JSTaggedValue> &obj);
313     static inline JSTaggedValue RuntimeGetAsyncIterator(JSThread *thread, const JSHandle<JSTaggedValue> &obj);
314     static inline void RuntimeSetGeneratorState(JSThread *thread, const JSHandle<JSTaggedValue> &genObj,
315                                                         const int32_t index);
316     static inline void RuntimeThrow(JSThread *thread, JSTaggedValue value);
317     static inline void RuntimeThrowThrowNotExists(JSThread *thread);
318     static inline void RuntimeThrowPatternNonCoercible(JSThread *thread);
319     static inline void RuntimeThrowDeleteSuperProperty(JSThread *thread);
320     static inline void RuntimeThrowUndefinedIfHole(JSThread *thread, const JSHandle<EcmaString> &obj);
321     static inline void RuntimeThrowIfNotObject(JSThread *thread);
322     static inline void RuntimeThrowConstAssignment(JSThread *thread, const JSHandle<EcmaString> &value);
323     static inline JSTaggedValue RuntimeLdGlobalRecord(JSThread *thread, JSTaggedValue key);
324     static inline JSTaggedValue RuntimeTryLdGlobalByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
325                                                          const JSHandle<JSTaggedValue> &prop);
326     static inline JSTaggedValue RuntimeTryUpdateGlobalRecord(JSThread *thread, JSTaggedValue prop, JSTaggedValue value);
327     static inline JSTaggedValue RuntimeThrowReferenceError(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
328                                                            const char *desc);
329     static inline JSTaggedValue RuntimeLdGlobalVarFromProto(JSThread *thread, const JSHandle<JSTaggedValue> &globalObj,
330                                                             const JSHandle<JSTaggedValue> &prop);
331     static inline JSTaggedValue RuntimeStGlobalVar(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
332                                                    const JSHandle<JSTaggedValue> &value);
333     static inline JSTaggedValue RuntimeToNumber(JSThread *thread, const JSHandle<JSTaggedValue> &value);
334     static inline JSTaggedValue RuntimeDynamicImport(JSThread *thread, const JSHandle<JSTaggedValue> &specifier,
335                                                      const JSHandle<JSTaggedValue> &func);
336     static inline JSTaggedValue RuntimeToNumeric(JSThread *thread, const JSHandle<JSTaggedValue> &value);
337     static inline JSTaggedValue RuntimeEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
338                                           const JSHandle<JSTaggedValue> &right);
339     static inline JSTaggedValue RuntimeLdObjByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop,
340                                                    bool callGetter, JSTaggedValue receiver);
341     static inline JSTaggedValue RuntimeNotEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
342                                              const JSHandle<JSTaggedValue> &right);
343     static inline JSTaggedValue RuntimeLess(JSThread *thread, const JSHandle<JSTaggedValue> &left,
344                                             const JSHandle<JSTaggedValue> &right);
345     static inline JSTaggedValue RuntimeLessEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
346                                               const JSHandle<JSTaggedValue> &right);
347     static inline JSTaggedValue RuntimeGreater(JSThread *thread, const JSHandle<JSTaggedValue> &left,
348                                                const JSHandle<JSTaggedValue> &right);
349     static inline JSTaggedValue RuntimeGreaterEq(JSThread *thread, const JSHandle<JSTaggedValue> &left,
350                                                  const JSHandle<JSTaggedValue> &right);
351     static inline JSTaggedValue RuntimeAdd2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
352                                             const JSHandle<JSTaggedValue> &right);
353     static inline JSTaggedValue RuntimeShl2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
354                                             const JSHandle<JSTaggedValue> &right);
355     static inline JSTaggedValue RuntimeShr2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
356                                             const JSHandle<JSTaggedValue> &right);
357     static inline JSTaggedValue RuntimeSub2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
358                                             const JSHandle<JSTaggedValue> &right);
359     static inline JSTaggedValue RuntimeMul2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
360                                             const JSHandle<JSTaggedValue> &right);
361     static inline JSTaggedValue RuntimeDiv2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
362                                             const JSHandle<JSTaggedValue> &right);
363     static inline JSTaggedValue RuntimeMod2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
364                                             const JSHandle<JSTaggedValue> &right);
365     static inline JSTaggedValue RuntimeAshr2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
366                                              const JSHandle<JSTaggedValue> &right);
367     static inline JSTaggedValue RuntimeAnd2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
368                                             const JSHandle<JSTaggedValue> &right);
369     static inline JSTaggedValue RuntimeOr2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
370                                            const JSHandle<JSTaggedValue> &right);
371     static inline JSTaggedValue RuntimeXor2(JSThread *thread, const JSHandle<JSTaggedValue> &left,
372                                             const JSHandle<JSTaggedValue> &right);
373     static inline JSTaggedValue RuntimeStOwnByNameWithNameSet(JSThread *thread,
374                                                               const JSHandle<JSTaggedValue> &obj,
375                                                               const JSHandle<JSTaggedValue> &prop,
376                                                               const JSHandle<JSTaggedValue> &value);
377     static inline JSTaggedValue RuntimeStObjByName(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
378                                                    const JSHandle<JSTaggedValue> &prop,
379                                                    const JSHandle<JSTaggedValue> &value);
380     static inline JSTaggedValue RuntimeToJSTaggedValueWithInt32(JSThread *thread,
381                                                                 const JSHandle<JSTaggedValue> &value);
382     static inline JSTaggedValue RuntimeToJSTaggedValueWithUint32(JSThread *thread,
383                                                                  const JSHandle<JSTaggedValue> &value);
384     static inline JSTaggedValue RuntimeCreateEmptyObject(JSThread *thread, ObjectFactory *factory,
385                                                          JSHandle<GlobalEnv> globalEnv);
386     static inline JSTaggedValue RuntimeCreateEmptyArray(JSThread *thread, ObjectFactory *factory,
387                                                         JSHandle<GlobalEnv> globalEnv);
388     static inline JSTaggedValue RuntimeGetUnmapedArgs(JSThread *thread, JSTaggedType *sp, uint32_t actualNumArgs,
389                                                       uint32_t startIdx);
390     static inline JSTaggedValue RuntimeCopyRestArgs(JSThread *thread, JSTaggedType *sp, uint32_t restNumArgs,
391                                                     uint32_t startIdx);
392     static inline JSTaggedValue RuntimeCreateArrayWithBuffer(JSThread *thread, ObjectFactory *factory,
393                                                              const JSHandle<JSTaggedValue> &literal);
394     static inline JSTaggedValue RuntimeCreateObjectWithBuffer(JSThread *thread, ObjectFactory *factory,
395                                                               const JSHandle<JSObject> &literal);
396     static inline JSTaggedValue RuntimeNewLexicalEnv(JSThread *thread, uint16_t numVars);
397     static inline JSTaggedValue RuntimeNewSendableEnv(JSThread *thread, uint16_t numVars);
398     static inline JSTaggedValue RuntimeNewObjRange(JSThread *thread, const JSHandle<JSTaggedValue> &func,
399                                                    const JSHandle<JSTaggedValue> &newTarget, uint16_t firstArgIdx,
400                                                    uint16_t length);
401     static inline JSTaggedValue RuntimeDefinefunc(JSThread *thread, const JSHandle<JSTaggedValue> &constpool,
402                                                   uint16_t methodId, const JSHandle<JSTaggedValue> &module,
403                                                   uint16_t length, const JSHandle<JSTaggedValue> &envHandle,
404                                                   const JSHandle<JSTaggedValue> &homeObject);
405     static inline void DefineFuncTryUseAOTHClass(JSThread* thread,
406                                                  const JSHandle<JSFunction>& func,
407                                                  const JSHandle<JSTaggedValue>& ihc,
408                                                  const JSHandle<AOTLiteralInfo>& aotLiteralInfo);
409     static inline JSTaggedValue RuntimeCreateRegExpWithLiteral(JSThread *thread, const JSHandle<JSTaggedValue> &pattern,
410                                                                uint8_t flags);
411     static inline JSTaggedValue RuntimeThrowIfSuperNotCorrectCall(JSThread *thread, uint16_t index,
412                                                                   JSTaggedValue thisValue);
413     static inline JSTaggedValue RuntimeCreateObjectHavingMethod(JSThread *thread, ObjectFactory *factory,
414                                                                 const JSHandle<JSObject> &literal,
415                                                                 const JSHandle<JSTaggedValue> &env);
416     static inline JSTaggedValue RuntimeCreateObjectWithExcludedKeys(JSThread *thread, uint16_t numKeys,
417                                                                     const JSHandle<JSTaggedValue> &objVal,
418                                                                     uint16_t firstArgRegIdx);
419     static inline JSTaggedValue RuntimeDefineMethod(JSThread *thread, const JSHandle<Method> &methodHandle,
420                                                     const JSHandle<JSTaggedValue> &homeObject, uint16_t length,
421                                                     const JSHandle<JSTaggedValue> &env,
422                                                     const JSHandle<JSTaggedValue> &module);
423     static inline JSTaggedValue RuntimeCallSpread(JSThread *thread, const JSHandle<JSTaggedValue> &func,
424                                                      const JSHandle<JSTaggedValue> &obj,
425                                                      const JSHandle<JSTaggedValue> &array);
426     static inline JSTaggedValue RuntimeDefineGetterSetterByValue(JSThread *thread, const JSHandle<JSObject> &obj,
427                                                                  const JSHandle<JSTaggedValue> &prop,
428                                                                  const JSHandle<JSTaggedValue> &getter,
429                                                                  const JSHandle<JSTaggedValue> &setter, bool flag,
430                                                                  const JSHandle<JSTaggedValue> &func,
431                                                                  int32_t pcOffset);
432     static inline JSTaggedValue RuntimeSuperCall(JSThread *thread, const JSHandle<JSTaggedValue> &func,
433                                                  const JSHandle<JSTaggedValue> &newTarget, uint16_t firstVRegIdx,
434                                                  uint16_t length);
435     static inline JSTaggedValue RuntimeOptSuperCall(JSThread *thread, const JSHandle<JSTaggedValue> &func,
436                                                     const JSHandle<JSTaggedValue> &newTarget,
437                                                     const JSHandle<TaggedArray> &argv,
438                                                     uint16_t length);
439     static inline JSTaggedValue RuntimeThrowTypeError(JSThread *thread, const char *message);
440     static inline JSTaggedValue RuntimeGetCallSpreadArgs(JSThread *thread, const JSHandle<JSTaggedValue> &array);
441     static inline JSTaggedValue RuntimeThrowReferenceError(JSThread *thread, JSTaggedValue prop, const char *desc);
442     static inline JSTaggedValue RuntimeThrowSyntaxError(JSThread *thread, const char *message);
443     static inline JSTaggedValue RuntimeLdBigInt(JSThread *thread, const JSHandle<JSTaggedValue> &numberBigInt);
444     static inline JSTaggedValue RuntimeCallBigIntAsIntN(JSThread *thread, JSTaggedValue bits, JSTaggedValue bigint);
445     static inline JSTaggedValue RuntimeCallBigIntAsUintN(JSThread *thread, JSTaggedValue bits, JSTaggedValue bigint);
446     static inline JSTaggedValue RuntimeNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId);
447     static inline JSTaggedValue RuntimeOptGetUnmapedArgs(JSThread *thread, uint32_t actualNumArgs);
448     static inline JSTaggedValue RuntimeGetUnmapedJSArgumentObj(JSThread *thread,
449                                                                const JSHandle<TaggedArray> &argumentsList);
450     static inline JSTaggedValue RuntimeOptNewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId,
451                                                                 JSHandle<JSTaggedValue> &currentLexEnv,
452                                                                 JSHandle<JSTaggedValue> &func);
453     static inline JSTaggedValue RuntimeOptCopyRestArgs(JSThread *thread, uint32_t actualArgc, uint32_t restIndex);
454     static inline JSTaggedValue RuntimeOptSuspendGenerator(JSThread *thread, const JSHandle<JSTaggedValue> &genObj,
455                                                            const JSHandle<JSTaggedValue> &value);
456     static inline JSTaggedValue RuntimeOptAsyncGeneratorResolve(JSThread *thread, JSHandle<JSTaggedValue> asyncFuncObj,
457                                                                 JSHandle<JSTaggedValue> value, JSTaggedValue flag);
458     static inline JSTaggedValue CommonCreateObjectWithExcludedKeys(JSThread *thread,
459                                                                    const JSHandle<JSTaggedValue> &objVal,
460                                                                    uint32_t numExcludedKeys,
461                                                                    JSHandle<TaggedArray> excludedKeys);
462     static inline JSTaggedValue RuntimeOptCreateObjectWithExcludedKeys(JSThread *thread, uintptr_t argv, uint32_t argc);
463     static inline JSTaggedValue RuntimeOptNewObjRange(JSThread *thread, uintptr_t argv, uint32_t argc);
464     static inline JSTaggedValue RuntimeOptConstruct(JSThread *thread, JSHandle<JSTaggedValue> ctor,
465                                                     JSHandle<JSTaggedValue> newTarget, JSHandle<JSTaggedValue> preArgs,
466                                                     JSHandle<TaggedArray> args);
467     static inline JSTaggedValue RuntimeOptConstructProxy(JSThread *thread, JSHandle<JSProxy> ctor,
468                                                          JSHandle<JSTaggedValue> newTgt,
469                                                          JSHandle<JSTaggedValue> preArgs, JSHandle<TaggedArray> args);
470     static inline JSTaggedValue RuntimeOptConstructBoundFunction(JSThread *thread, JSHandle<JSBoundFunction> ctor,
471                                                                  JSHandle<JSTaggedValue> newTgt,
472                                                                  JSHandle<JSTaggedValue> preArgs,
473                                                                  JSHandle<TaggedArray> args);
474     static inline JSTaggedValue RuntimeOptConstructGeneric(JSThread *thread, JSHandle<JSFunction> ctor,
475                                                            JSHandle<JSTaggedValue> newTgt,
476                                                            JSHandle<JSTaggedValue> preArgs, JSHandle<TaggedArray> args);
477     static inline JSTaggedValue GetResultValue(JSThread *thread, bool isAotMethod, JSHandle<JSFunction> ctor,
478         CVector<JSTaggedType> &values, JSHandle<JSTaggedValue> newTgt, uint32_t &size, JSHandle<JSTaggedValue> obj);
479     static inline JSTaggedValue RuntimeOptGenerateScopeInfo(JSThread *thread, uint16_t scopeId, JSTaggedValue func);
480     static inline JSTaggedType *GetActualArgv(JSThread *thread);
481     static inline JSTaggedType *GetActualArgvFromStub(JSThread *thread);
482     static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrame(JSThread *thread);
483     static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrameNoGC(JSThread *thread);
484 
485     static JSTaggedValue NewObject(EcmaRuntimeCallInfo *info);
486     static void SaveFrameToContext(JSThread *thread, JSHandle<GeneratorContext> context);
487 
488     static inline JSTaggedValue RuntimeLdPatchVar(JSThread *thread, uint32_t index);
489     static inline JSTaggedValue RuntimeStPatchVar(JSThread *thread, uint32_t index,
490                                                   const JSHandle<JSTaggedValue> &value);
491     static inline JSTaggedValue RuntimeNotifyConcurrentResult(JSThread *thread, JSTaggedValue result,
492         JSTaggedValue hint);
493     static inline JSTaggedValue RuntimeDefineField(JSThread *thread, JSTaggedValue obj,
494                                                    JSTaggedValue propKey, JSTaggedValue value);
495     static inline JSTaggedValue RuntimeCreatePrivateProperty(JSThread *thread, JSTaggedValue constpool,
496         uint32_t count, JSTaggedValue lexicalEnv, uint32_t literalId, JSTaggedValue module);
497     static inline JSTaggedValue RuntimeDefinePrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
498         uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj, JSTaggedValue value);
499     static inline JSTaggedValue RuntimeLdPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
500         uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj);
501     static inline JSTaggedValue RuntimeStPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
502         uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj, JSTaggedValue value);
503     static inline JSTaggedValue RuntimeTestIn(JSThread *thread, JSTaggedValue lexicalEnv,
504         uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj);
505     static inline JSTaggedValue RuntimeUpdateAOTHClass(JSThread *thread, const JSHandle<JSHClass> &oldhclass,
506         const JSHandle<JSHClass> &newhclass, JSTaggedValue key);
507     static inline JSTaggedValue RuntimeNotifyDebuggerStatement(JSThread *thread);
508     static inline bool CheckElementsNumber(JSHandle<TaggedArray> elements, uint32_t len);
509     static inline JSHandle<JSTaggedValue> GetOrCreateNumberString(JSThread *thread,
510         JSHandle<JSTaggedValue> presentValue, std::map<uint64_t, JSHandle<JSTaggedValue>> &cachedString);
511     static inline JSTaggedValue TryCopyCOWArray(JSThread *thread, JSHandle<JSArray> holderHandler, bool &isCOWArray);
512     static inline JSTaggedValue ArrayNumberSort(JSThread *thread, JSHandle<JSObject> thisObj, uint32_t len);
513     static inline bool ShouldUseAOTHClass(const JSHandle<JSTaggedValue> &ihc,
514                                           const JSHandle<JSTaggedValue> &chc,
515                                           const JSHandle<ClassLiteral> &classLiteral);
516     static inline JSTaggedType RuntimeTryGetInternString(uintptr_t argGlue, const JSHandle<EcmaString> &string);
517     static inline void RuntimeSetPatchModule(JSThread *thread, const JSHandle<JSFunction> &func);
518     friend class SlowRuntimeStub;
519 };
520 }  // namespace panda::ecmascript
521 #endif
522