1/*
2 * Copyright (c) 2021 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#include "ecmascript/interpreter/slow_runtime_stub.h"
17
18#include "ecmascript/interpreter/interpreter-inl.h"
19#include "ecmascript/stubs/runtime_stubs-inl.h"
20
21namespace panda::ecmascript {
22JSTaggedValue SlowRuntimeStub::CallSpread(JSThread *thread, JSTaggedValue func, JSTaggedValue obj,
23                                          JSTaggedValue array)
24{
25    INTERPRETER_TRACE(thread, CallSpread);
26    [[maybe_unused]] EcmaHandleScope handleScope(thread);
27
28    JSHandle<JSTaggedValue> jsFunc(thread, func);
29    JSHandle<JSTaggedValue> jsArray(thread, array);
30    JSHandle<JSTaggedValue> taggedObj(thread, obj);
31    return RuntimeStubs::RuntimeCallSpread(thread, jsFunc, taggedObj, jsArray);
32}
33
34JSTaggedValue SlowRuntimeStub::Neg(JSThread *thread, JSTaggedValue value)
35{
36    INTERPRETER_TRACE(thread, Neg);
37    [[maybe_unused]] EcmaHandleScope handleScope(thread);
38
39    JSHandle<JSTaggedValue> inputTag(thread, value);
40    return RuntimeStubs::RuntimeNeg(thread, inputTag);
41}
42
43JSTaggedValue SlowRuntimeStub::AsyncFunctionEnter(JSThread *thread)
44{
45    INTERPRETER_TRACE(thread, AsyncFunctionEnter);
46    [[maybe_unused]] EcmaHandleScope handleScope(thread);
47
48    return RuntimeStubs::RuntimeAsyncFunctionEnter(thread);
49}
50
51JSTaggedValue SlowRuntimeStub::ToNumber(JSThread *thread, JSTaggedValue value)
52{
53    INTERPRETER_TRACE(thread, Tonumber);
54    [[maybe_unused]] EcmaHandleScope handleScope(thread);
55
56    JSHandle<JSTaggedValue> number(thread, value);
57    // may return exception
58    return RuntimeStubs::RuntimeToNumber(thread, number);
59}
60
61JSTaggedValue SlowRuntimeStub::ToNumeric(JSThread *thread, JSTaggedValue value)
62{
63    INTERPRETER_TRACE(thread, Tonumeric);
64    [[maybe_unused]] EcmaHandleScope handleScope(thread);
65
66    JSHandle<JSTaggedValue> numeric(thread, value);
67    // may return exception
68    return RuntimeStubs::RuntimeToNumeric(thread, numeric);
69}
70
71JSTaggedValue SlowRuntimeStub::Not(JSThread *thread, JSTaggedValue value)
72{
73    INTERPRETER_TRACE(thread, Not);
74    [[maybe_unused]] EcmaHandleScope handleScope(thread);
75
76    JSHandle<JSTaggedValue> inputTag(thread, value);
77    return RuntimeStubs::RuntimeNot(thread, inputTag);
78}
79
80JSTaggedValue SlowRuntimeStub::Inc(JSThread *thread, JSTaggedValue value)
81{
82    INTERPRETER_TRACE(thread, Inc);
83    [[maybe_unused]] EcmaHandleScope handleScope(thread);
84
85    JSHandle<JSTaggedValue> inputTag(thread, value);
86    return RuntimeStubs::RuntimeInc(thread, inputTag);
87}
88
89JSTaggedValue SlowRuntimeStub::Dec(JSThread *thread, JSTaggedValue value)
90{
91    INTERPRETER_TRACE(thread, Dec);
92    [[maybe_unused]] EcmaHandleScope handleScope(thread);
93
94    JSHandle<JSTaggedValue> inputTag(thread, value);
95    return RuntimeStubs::RuntimeDec(thread, inputTag);
96}
97
98void SlowRuntimeStub::Throw(JSThread *thread, JSTaggedValue value)
99{
100    INTERPRETER_TRACE(thread, Throw);
101    RuntimeStubs::RuntimeThrow(thread, value);
102}
103
104JSTaggedValue SlowRuntimeStub::GetPropIterator(JSThread *thread, JSTaggedValue value)
105{
106    INTERPRETER_TRACE(thread, GetPropIterator);
107    [[maybe_unused]] EcmaHandleScope handleScope(thread);
108
109    JSHandle<JSTaggedValue> objHandle(thread, value);
110    return RuntimeStubs::RuntimeGetPropIterator(thread, objHandle);
111}
112
113void SlowRuntimeStub::ThrowConstAssignment(JSThread *thread, JSTaggedValue value)
114{
115    INTERPRETER_TRACE(thread, ThrowConstAssignment);
116    [[maybe_unused]] EcmaHandleScope handleScope(thread);
117
118    JSHandle<EcmaString> name(thread, value.GetTaggedObject());
119    return RuntimeStubs::RuntimeThrowConstAssignment(thread, name);
120}
121
122JSTaggedValue SlowRuntimeStub::Add2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
123{
124    INTERPRETER_TRACE(thread, Add2);
125    [[maybe_unused]] EcmaHandleScope handleScope(thread);
126
127    JSHandle<JSTaggedValue> leftValue(thread, left);
128    JSHandle<JSTaggedValue> rightValue(thread, right);
129    return RuntimeStubs::RuntimeAdd2(thread, leftValue, rightValue);
130}
131
132JSTaggedValue SlowRuntimeStub::Sub2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
133{
134    INTERPRETER_TRACE(thread, Sub2);
135    [[maybe_unused]] EcmaHandleScope handleScope(thread);
136
137    JSHandle<JSTaggedValue> leftTag(thread, left);
138    JSHandle<JSTaggedValue> rightTag(thread, right);
139    return RuntimeStubs::RuntimeSub2(thread, leftTag, rightTag);
140}
141
142JSTaggedValue SlowRuntimeStub::Mul2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
143{
144    INTERPRETER_TRACE(thread, Mul2);
145    [[maybe_unused]] EcmaHandleScope handleScope(thread);
146
147    JSHandle<JSTaggedValue> leftTag(thread, left);
148    JSHandle<JSTaggedValue> rightTag(thread, right);
149    return RuntimeStubs::RuntimeMul2(thread, leftTag, rightTag);
150}
151
152JSTaggedValue SlowRuntimeStub::Div2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
153{
154    INTERPRETER_TRACE(thread, Div2);
155    [[maybe_unused]] EcmaHandleScope handleScope(thread);
156
157    JSHandle<JSTaggedValue> leftTag(thread, left);
158    JSHandle<JSTaggedValue> rightTag(thread, right);
159    return RuntimeStubs::RuntimeDiv2(thread, leftTag, rightTag);
160}
161
162JSTaggedValue SlowRuntimeStub::Mod2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
163{
164    INTERPRETER_TRACE(thread, Mod2);
165    [[maybe_unused]] EcmaHandleScope handleScope(thread);
166
167    JSHandle<JSTaggedValue> leftTag(thread, left);
168    JSHandle<JSTaggedValue> rightTag(thread, right);
169    return RuntimeStubs::RuntimeMod2(thread, leftTag, rightTag);
170}
171
172JSTaggedValue SlowRuntimeStub::Eq(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
173{
174    INTERPRETER_TRACE(thread, Eq);
175    [[maybe_unused]] EcmaHandleScope handleScope(thread);
176
177    JSHandle<JSTaggedValue> leftValue(thread, left);
178    JSHandle<JSTaggedValue> rightValue(thread, right);
179    return RuntimeStubs::RuntimeEq(thread, leftValue, rightValue);
180}
181
182JSTaggedValue SlowRuntimeStub::NotEq(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
183{
184    INTERPRETER_TRACE(thread, NotEq);
185    [[maybe_unused]] EcmaHandleScope handleScope(thread);
186
187    JSHandle<JSTaggedValue> leftValue(thread, left);
188    JSHandle<JSTaggedValue> rightValue(thread, right);
189    return RuntimeStubs::RuntimeNotEq(thread, leftValue, rightValue);
190}
191
192JSTaggedValue SlowRuntimeStub::Less(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
193{
194    INTERPRETER_TRACE(thread, Less);
195    [[maybe_unused]] EcmaHandleScope handleScope(thread);
196
197    JSHandle<JSTaggedValue> leftValue(thread, left);
198    JSHandle<JSTaggedValue> rightValue(thread, right);
199    return RuntimeStubs::RuntimeLess(thread, leftValue, rightValue);
200}
201
202JSTaggedValue SlowRuntimeStub::LessEq(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
203{
204    INTERPRETER_TRACE(thread, LessEq);
205    [[maybe_unused]] EcmaHandleScope handleScope(thread);
206
207    JSHandle<JSTaggedValue> leftValue(thread, left);
208    JSHandle<JSTaggedValue> rightValue(thread, right);
209    return RuntimeStubs::RuntimeLessEq(thread, leftValue, rightValue);
210}
211
212JSTaggedValue SlowRuntimeStub::Greater(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
213{
214    INTERPRETER_TRACE(thread, Greater);
215    [[maybe_unused]] EcmaHandleScope handleScope(thread);
216
217    JSHandle<JSTaggedValue> leftValue(thread, left);
218    JSHandle<JSTaggedValue> rightValue(thread, right);
219    return RuntimeStubs::RuntimeGreater(thread, leftValue, rightValue);
220}
221
222JSTaggedValue SlowRuntimeStub::GreaterEq(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
223{
224    INTERPRETER_TRACE(thread, GreaterEq);
225    [[maybe_unused]] EcmaHandleScope handleScope(thread);
226
227    JSHandle<JSTaggedValue> leftValue(thread, left);
228    JSHandle<JSTaggedValue> rightValue(thread, right);
229    return RuntimeStubs::RuntimeGreaterEq(thread, leftValue, rightValue);
230}
231
232JSTaggedValue SlowRuntimeStub::Shl2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
233{
234    INTERPRETER_TRACE(thread, Shl2);
235    [[maybe_unused]] EcmaHandleScope handleScope(thread);
236
237    JSHandle<JSTaggedValue> leftTag(thread, left);
238    JSHandle<JSTaggedValue> rightTag(thread, right);
239    return RuntimeStubs::RuntimeShl2(thread, leftTag, rightTag);
240}
241
242JSTaggedValue SlowRuntimeStub::Shr2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
243{
244    INTERPRETER_TRACE(thread, Shr2);
245    [[maybe_unused]] EcmaHandleScope handleScope(thread);
246
247    JSHandle<JSTaggedValue> leftTag(thread, left);
248    JSHandle<JSTaggedValue> rightTag(thread, right);
249    return RuntimeStubs::RuntimeShr2(thread, leftTag, rightTag);
250}
251
252JSTaggedValue SlowRuntimeStub::Ashr2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
253{
254    INTERPRETER_TRACE(thread, Ashr2);
255    [[maybe_unused]] EcmaHandleScope handleScope(thread);
256
257    JSHandle<JSTaggedValue> leftTag(thread, left);
258    JSHandle<JSTaggedValue> rightTag(thread, right);
259    return RuntimeStubs::RuntimeAshr2(thread, leftTag, rightTag);
260}
261
262JSTaggedValue SlowRuntimeStub::And2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
263{
264    INTERPRETER_TRACE(thread, And2);
265    [[maybe_unused]] EcmaHandleScope handleScope(thread);
266    JSHandle<JSTaggedValue> leftTag(thread, left);
267    JSHandle<JSTaggedValue> rightTag(thread, right);
268    return RuntimeStubs::RuntimeAnd2(thread, leftTag, rightTag);
269}
270
271JSTaggedValue SlowRuntimeStub::Or2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
272{
273    INTERPRETER_TRACE(thread, Or2);
274    [[maybe_unused]] EcmaHandleScope handleScope(thread);
275
276    JSHandle<JSTaggedValue> leftTag(thread, left);
277    JSHandle<JSTaggedValue> rightTag(thread, right);
278    return RuntimeStubs::RuntimeOr2(thread, leftTag, rightTag);
279}
280
281JSTaggedValue SlowRuntimeStub::Xor2(JSThread *thread, JSTaggedValue left, JSTaggedValue right)
282{
283    INTERPRETER_TRACE(thread, Xor2);
284    [[maybe_unused]] EcmaHandleScope handleScope(thread);
285
286    JSHandle<JSTaggedValue> leftTag(thread, left);
287    JSHandle<JSTaggedValue> rightTag(thread, right);
288    return RuntimeStubs::RuntimeXor2(thread, leftTag, rightTag);
289}
290
291JSTaggedValue SlowRuntimeStub::ToJSTaggedValueWithInt32(JSThread *thread, JSTaggedValue value)
292{
293    INTERPRETER_TRACE(thread, ToJSTaggedValueWithInt32);
294    [[maybe_unused]] EcmaHandleScope handleScope(thread);
295    JSHandle<JSTaggedValue> valueHandle(thread, value);
296    return RuntimeStubs::RuntimeToJSTaggedValueWithInt32(thread, valueHandle);
297}
298
299JSTaggedValue SlowRuntimeStub::ToJSTaggedValueWithUint32(JSThread *thread, JSTaggedValue value)
300{
301    INTERPRETER_TRACE(thread, ToJSTaggedValueWithUint32);
302    [[maybe_unused]] EcmaHandleScope handleScope(thread);
303    JSHandle<JSTaggedValue> valueHandle(thread, value);
304    return RuntimeStubs::RuntimeToJSTaggedValueWithUint32(thread, valueHandle);
305}
306
307JSTaggedValue SlowRuntimeStub::DelObjProp(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop)
308{
309    INTERPRETER_TRACE(thread, Delobjprop);
310    [[maybe_unused]] EcmaHandleScope handleScope(thread);
311
312    JSHandle<JSTaggedValue> objHandle(thread, obj);
313    JSHandle<JSTaggedValue> propHandle(thread, prop);
314    return RuntimeStubs::RuntimeDelObjProp(thread, objHandle, propHandle);
315}
316
317JSTaggedValue SlowRuntimeStub::NewObjRange(JSThread *thread, JSTaggedValue func, JSTaggedValue newTarget,
318                                           uint16_t firstArgIdx, uint16_t length)
319{
320    INTERPRETER_TRACE(thread, NewobjRange);
321    [[maybe_unused]] EcmaHandleScope handleScope(thread);
322
323    JSHandle<JSTaggedValue> funcHandle(thread, func);
324    JSHandle<JSTaggedValue> newTargetHandle(thread, newTarget);
325    return RuntimeStubs::RuntimeNewObjRange(thread, funcHandle, newTargetHandle, firstArgIdx, length);
326}
327
328JSTaggedValue SlowRuntimeStub::CreateObjectWithExcludedKeys(JSThread *thread, uint16_t numKeys, JSTaggedValue objVal,
329                                                            uint16_t firstArgRegIdx)
330{
331    INTERPRETER_TRACE(thread, CreateObjectWithExcludedKeys);
332    [[maybe_unused]] EcmaHandleScope handleScope(thread);
333
334    JSHandle<JSTaggedValue> obj(thread, objVal);
335    return RuntimeStubs::RuntimeCreateObjectWithExcludedKeys(thread, numKeys, obj, firstArgRegIdx);
336}
337
338JSTaggedValue SlowRuntimeStub::Exp(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent)
339{
340    INTERPRETER_TRACE(thread, Exp);
341    [[maybe_unused]] EcmaHandleScope handleScope(thread);
342
343    return RuntimeStubs::RuntimeExp(thread, base, exponent);
344}
345
346JSTaggedValue SlowRuntimeStub::IsIn(JSThread *thread, JSTaggedValue prop, JSTaggedValue obj)
347{
348    INTERPRETER_TRACE(thread, IsIn);
349    [[maybe_unused]] EcmaHandleScope handleScope(thread);
350
351    JSHandle<JSTaggedValue> propHandle(thread, prop);
352    JSHandle<JSTaggedValue> objHandle(thread, obj);
353    return RuntimeStubs::RuntimeIsIn(thread, propHandle, objHandle);
354}
355
356JSTaggedValue SlowRuntimeStub::Instanceof(JSThread *thread, JSTaggedValue obj, JSTaggedValue target)
357{
358    INTERPRETER_TRACE(thread, Instanceof);
359    [[maybe_unused]] EcmaHandleScope handleScope(thread);
360
361    JSHandle<JSTaggedValue> objHandle(thread, obj);
362    JSHandle<JSTaggedValue> targetHandle(thread, target);
363    return RuntimeStubs::RuntimeInstanceof(thread, objHandle, targetHandle);
364}
365
366JSTaggedValue SlowRuntimeStub::InstanceofByHandler(JSThread *thread, JSTaggedValue target, JSTaggedValue object,
367                                                   JSTaggedValue instOfHandler)
368{
369    INTERPRETER_TRACE(thread, InstanceofByHandler);
370    [[maybe_unused]] EcmaHandleScope handleScope(thread);
371
372    JSHandle<JSTaggedValue> objectHandle(thread, object);
373    JSHandle<JSTaggedValue> targetHandle(thread, target);
374    JSHandle<JSTaggedValue> instOfHandle(thread, instOfHandler);
375
376    return RuntimeStubs::RuntimeInstanceofByHandler(thread, targetHandle, objectHandle, instOfHandle);
377}
378
379JSTaggedValue SlowRuntimeStub::NewLexicalEnv(JSThread *thread, uint16_t numVars)
380{
381    INTERPRETER_TRACE(thread, Newlexenv);
382    [[maybe_unused]] EcmaHandleScope handleScope(thread);
383
384    return RuntimeStubs::RuntimeNewLexicalEnv(thread, numVars);
385}
386
387JSTaggedValue SlowRuntimeStub::NewSendableEnv(JSThread *thread, uint16_t numVars)
388{
389    INTERPRETER_TRACE(thread, NewSendableEnv);
390    [[maybe_unused]] EcmaHandleScope handleScope(thread);
391
392    return RuntimeStubs::RuntimeNewSendableEnv(thread, numVars);
393}
394
395JSTaggedValue SlowRuntimeStub::NewLexicalEnvWithName(JSThread *thread, uint16_t numVars, uint16_t scopeId)
396{
397    INTERPRETER_TRACE(thread, NewlexenvwithName);
398    [[maybe_unused]] EcmaHandleScope handleScope(thread);
399
400    return RuntimeStubs::RuntimeNewLexicalEnvWithName(thread, numVars, scopeId);
401}
402
403JSTaggedValue SlowRuntimeStub::CreateIterResultObj(JSThread *thread, JSTaggedValue value, JSTaggedValue flag)
404{
405    INTERPRETER_TRACE(thread, CreateIterResultObj);
406    [[maybe_unused]] EcmaHandleScope handleScope(thread);
407
408    JSHandle<JSTaggedValue> valueHandle(thread, value);
409    return RuntimeStubs::RuntimeCreateIterResultObj(thread, valueHandle, flag);
410}
411
412JSTaggedValue SlowRuntimeStub::CreateGeneratorObj(JSThread *thread, JSTaggedValue genFunc)
413{
414    INTERPRETER_TRACE(thread, CreateGeneratorObj);
415    [[maybe_unused]] EcmaHandleScope handleScope(thread);
416
417    JSHandle<JSTaggedValue> generatorFunction(thread, genFunc);
418    return RuntimeStubs::RuntimeCreateGeneratorObj(thread, generatorFunction);
419}
420
421JSTaggedValue SlowRuntimeStub::CreateAsyncGeneratorObj(JSThread *thread, JSTaggedValue genFunc)
422{
423    INTERPRETER_TRACE(thread, CreateAsyncGeneratorObj);
424    [[maybe_unused]] EcmaHandleScope handleScope(thread);
425
426    JSHandle<JSTaggedValue> asyncGeneratorFunction(thread, genFunc);
427    return RuntimeStubs::RuntimeCreateAsyncGeneratorObj(thread, asyncGeneratorFunction);
428}
429
430JSTaggedValue SlowRuntimeStub::SuspendGenerator(JSThread *thread, JSTaggedValue genObj, JSTaggedValue value)
431{
432    INTERPRETER_TRACE(thread, SuspendGenerator);
433    [[maybe_unused]] EcmaHandleScope handleScope(thread);
434
435    JSHandle<JSTaggedValue> genObjHandle(thread, genObj);
436    JSHandle<JSTaggedValue> valueHandle(thread, value);
437    return RuntimeStubs::RuntimeSuspendGenerator(thread, genObjHandle, valueHandle);
438}
439
440void SlowRuntimeStub::SetGeneratorState(JSThread *thread, JSTaggedValue genObj, int32_t index)
441{
442    INTERPRETER_TRACE(thread, SetGeneratorState);
443    [[maybe_unused]] EcmaHandleScope handleScope(thread);
444
445    JSHandle<JSTaggedValue> genObjHandle(thread, genObj);
446    return RuntimeStubs::RuntimeSetGeneratorState(thread, genObjHandle, index);
447}
448
449JSTaggedValue SlowRuntimeStub::AsyncFunctionAwaitUncaught(JSThread *thread, JSTaggedValue asyncFuncObj,
450                                                          JSTaggedValue value)
451{
452    INTERPRETER_TRACE(thread, AsyncFunctionAwaitUncaught);
453    [[maybe_unused]] EcmaHandleScope handleScope(thread);
454    JSHandle<JSTaggedValue> asyncFuncObjHandle(thread, asyncFuncObj);
455    JSHandle<JSTaggedValue> valueHandle(thread, value);
456
457    return RuntimeStubs::RuntimeAsyncFunctionAwaitUncaught(thread, asyncFuncObjHandle, valueHandle);
458}
459
460JSTaggedValue SlowRuntimeStub::AsyncFunctionResolveOrReject(JSThread *thread, JSTaggedValue asyncFuncObj,
461                                                            JSTaggedValue value, bool is_resolve)
462{
463    INTERPRETER_TRACE(thread, AsyncFunctionResolveOrReject);
464    [[maybe_unused]] EcmaHandleScope handleScope(thread);
465
466    JSHandle<JSTaggedValue> asyncFuncObjHandle(thread, asyncFuncObj);
467    JSHandle<JSTaggedValue> valueHandle(thread, value);
468    return RuntimeStubs::RuntimeAsyncFunctionResolveOrReject(thread, asyncFuncObjHandle, valueHandle, is_resolve);
469}
470
471JSTaggedValue SlowRuntimeStub::NewObjApply(JSThread *thread, JSTaggedValue func, JSTaggedValue array)
472{
473    INTERPRETER_TRACE(thread, NewObjApply);
474    [[maybe_unused]] EcmaHandleScope handleScope(thread);
475
476    JSHandle<JSTaggedValue> funcHandle(thread, func);
477    JSHandle<JSTaggedValue> jsArray(thread, array);
478    return RuntimeStubs::RuntimeNewObjApply(thread, funcHandle, jsArray);
479}
480
481void SlowRuntimeStub::ThrowUndefinedIfHole(JSThread *thread, JSTaggedValue obj)
482{
483    INTERPRETER_TRACE(thread, ThrowUndefinedIfHole);
484    [[maybe_unused]] EcmaHandleScope handleScope(thread);
485
486    JSHandle<EcmaString> name(thread, obj);
487    return RuntimeStubs::RuntimeThrowUndefinedIfHole(thread, name);
488}
489
490JSTaggedValue SlowRuntimeStub::ThrowIfSuperNotCorrectCall(JSThread *thread, uint16_t index, JSTaggedValue thisValue)
491{
492    INTERPRETER_TRACE(thread, ThrowIfSuperNotCorrectCall);
493    [[maybe_unused]] EcmaHandleScope handleScope(thread);
494
495    return RuntimeStubs::RuntimeThrowIfSuperNotCorrectCall(thread, index, thisValue);
496}
497
498void SlowRuntimeStub::ThrowIfNotObject(JSThread *thread)
499{
500    INTERPRETER_TRACE(thread, ThrowIfNotObject);
501    [[maybe_unused]] EcmaHandleScope handleScope(thread);
502
503    THROW_TYPE_ERROR(thread, "Inner return result is not object");
504}
505
506void SlowRuntimeStub::ThrowThrowNotExists(JSThread *thread)
507{
508    INTERPRETER_TRACE(thread, ThrowThrowNotExists);
509    [[maybe_unused]] EcmaHandleScope handleScope(thread);
510
511    return RuntimeStubs::RuntimeThrowIfNotObject(thread);
512}
513
514void SlowRuntimeStub::ThrowPatternNonCoercible(JSThread *thread)
515{
516    INTERPRETER_TRACE(thread, ThrowPatternNonCoercible);
517    [[maybe_unused]] EcmaHandleScope handleScope(thread);
518
519    return RuntimeStubs::RuntimeThrowPatternNonCoercible(thread);
520}
521
522JSTaggedValue SlowRuntimeStub::StOwnByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop, JSTaggedValue value)
523{
524    INTERPRETER_TRACE(thread, StOwnByName);
525    [[maybe_unused]] EcmaHandleScope handleScope(thread);
526
527    JSHandle<JSTaggedValue> objHandle(thread, obj);
528    JSHandle<JSTaggedValue> propHandle(thread, prop);
529    JSHandle<JSTaggedValue> valueHandle(thread, value);
530    return RuntimeStubs::RuntimeStOwnByName(thread, objHandle, propHandle, valueHandle);
531}
532
533JSTaggedValue SlowRuntimeStub::StOwnByNameWithNameSet(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop,
534                                                      JSTaggedValue value)
535{
536    INTERPRETER_TRACE(thread, StOwnByName);
537    [[maybe_unused]] EcmaHandleScope handleScope(thread);
538
539    JSHandle<JSTaggedValue> objHandle(thread, obj);
540    JSHandle<JSTaggedValue> propHandle(thread, prop);
541    JSHandle<JSTaggedValue> valueHandle(thread, value);
542    return RuntimeStubs::RuntimeStOwnByNameWithNameSet(thread, objHandle, propHandle, valueHandle);
543}
544
545JSTaggedValue SlowRuntimeStub::StOwnByIndex(JSThread *thread, JSTaggedValue obj, uint32_t idx, JSTaggedValue value)
546{
547    INTERPRETER_TRACE(thread, StOwnById);
548    [[maybe_unused]] EcmaHandleScope handleScope(thread);
549
550    JSHandle<JSTaggedValue> objHandle(thread, obj);
551    JSHandle<JSTaggedValue> idxHandle(thread, JSTaggedValue(idx));
552    JSHandle<JSTaggedValue> valueHandle(thread, value);
553    return RuntimeStubs::RuntimeStOwnByIndex(thread, objHandle, idxHandle, valueHandle);
554}
555
556JSTaggedValue SlowRuntimeStub::StOwnByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue key, JSTaggedValue value)
557{
558    INTERPRETER_TRACE(thread, StOwnByValue);
559    [[maybe_unused]] EcmaHandleScope handleScope(thread);
560
561    JSHandle<JSTaggedValue> objHandle(thread, obj);
562    JSHandle<JSTaggedValue> keyHandle(thread, key);
563    JSHandle<JSTaggedValue> valueHandle(thread, value);
564    return RuntimeStubs::RuntimeStOwnByValue(thread, objHandle, keyHandle, valueHandle);
565}
566
567JSTaggedValue SlowRuntimeStub::StOwnByValueWithNameSet(JSThread *thread, JSTaggedValue obj, JSTaggedValue key,
568                                                       JSTaggedValue value)
569{
570    INTERPRETER_TRACE(thread, StOwnByValue);
571    [[maybe_unused]] EcmaHandleScope handleScope(thread);
572
573    JSHandle<JSTaggedValue> objHandle(thread, obj);
574    JSHandle<JSTaggedValue> keyHandle(thread, key);
575    JSHandle<JSTaggedValue> valueHandle(thread, value);
576    return RuntimeStubs::RuntimeStOwnByValueWithNameSet(thread, objHandle, keyHandle, valueHandle);
577}
578
579JSTaggedValue SlowRuntimeStub::CreateEmptyArray(JSThread *thread, ObjectFactory *factory, JSHandle<GlobalEnv> globalEnv)
580{
581    INTERPRETER_TRACE(thread, CreateEmptyArray);
582    [[maybe_unused]] EcmaHandleScope handleScope(thread);
583    return RuntimeStubs::RuntimeCreateEmptyArray(thread, factory, globalEnv);
584}
585
586JSTaggedValue SlowRuntimeStub::CreateEmptyObject(JSThread *thread, ObjectFactory *factory,
587                                                 JSHandle<GlobalEnv> globalEnv)
588{
589    INTERPRETER_TRACE(thread, CreateEmptyObject);
590    [[maybe_unused]] EcmaHandleScope handleScope(thread);
591
592    return RuntimeStubs::RuntimeCreateEmptyObject(thread, factory, globalEnv);
593}
594
595JSTaggedValue SlowRuntimeStub::CreateObjectWithBuffer(JSThread *thread, ObjectFactory *factory, JSObject *literal)
596{
597    INTERPRETER_TRACE(thread, CreateObjectWithBuffer);
598    [[maybe_unused]] EcmaHandleScope handleScope(thread);
599
600    JSHandle<JSObject> obj(thread, literal);
601    return RuntimeStubs::RuntimeCreateObjectWithBuffer(thread, factory, obj);
602}
603
604JSTaggedValue SlowRuntimeStub::CreateObjectHavingMethod(JSThread *thread, ObjectFactory *factory, JSObject *literal,
605                                                        JSTaggedValue env)
606{
607    INTERPRETER_TRACE(thread, CreateObjectHavingMethod);
608    [[maybe_unused]] EcmaHandleScope handleScope(thread);
609
610    JSHandle<JSObject> obj(thread, literal);
611    JSHandle<JSTaggedValue> envi(thread, env);
612    return RuntimeStubs::RuntimeCreateObjectHavingMethod(thread, factory, obj, envi);
613}
614
615JSTaggedValue SlowRuntimeStub::SetObjectWithProto(JSThread *thread, JSTaggedValue proto, JSTaggedValue obj)
616{
617    INTERPRETER_TRACE(thread, SetObjectWithProto);
618    [[maybe_unused]] EcmaHandleScope handleScope(thread);
619
620    JSHandle<JSTaggedValue> protoHandle(thread, proto);
621    JSHandle<JSObject> objHandle(thread, obj);
622    return RuntimeStubs::RuntimeSetObjectWithProto(thread, protoHandle, objHandle);
623}
624
625JSTaggedValue SlowRuntimeStub::IterNext(JSThread *thread, JSTaggedValue iter)
626{
627    INTERPRETER_TRACE(thread, IterNext);
628    [[maybe_unused]] EcmaHandleScope handleScope(thread);
629
630    JSHandle<JSTaggedValue> iterHandle(thread, iter);
631    return RuntimeStubs::RuntimeIterNext(thread, iterHandle);
632}
633
634JSTaggedValue SlowRuntimeStub::CloseIterator(JSThread *thread, JSTaggedValue iter)
635{
636    INTERPRETER_TRACE(thread, CloseIterator);
637    [[maybe_unused]] EcmaHandleScope handleScope(thread);
638
639    JSHandle<JSTaggedValue> iterHandle(thread, iter);
640    return RuntimeStubs::RuntimeCloseIterator(thread, iterHandle);
641}
642
643void SlowRuntimeStub::StModuleVar(JSThread *thread, int32_t index, JSTaggedValue value)
644{
645    INTERPRETER_TRACE(thread, StModuleVar);
646    [[maybe_unused]] EcmaHandleScope scope(thread);
647
648    return RuntimeStubs::RuntimeStModuleVar(thread, index, value);
649}
650
651void SlowRuntimeStub::StModuleVar(JSThread *thread, JSTaggedValue key, JSTaggedValue value)
652{
653    INTERPRETER_TRACE(thread, StModuleVar);
654    [[maybe_unused]] EcmaHandleScope scope(thread);
655
656    return RuntimeStubs::RuntimeStModuleVar(thread, key, value);
657}
658
659JSTaggedValue SlowRuntimeStub::LdLocalModuleVar(JSThread *thread, int32_t index)
660{
661    RUNTIME_TRACE(thread, LdLocalModuleVarByIndex);
662    [[maybe_unused]] EcmaHandleScope scope(thread);
663
664    return RuntimeStubs::RuntimeLdLocalModuleVar(thread, index);
665}
666
667JSTaggedValue SlowRuntimeStub::LdExternalModuleVar(JSThread *thread, int32_t index)
668{
669    RUNTIME_TRACE(thread, LdExternalModuleVarByIndex);
670    [[maybe_unused]] EcmaHandleScope scope(thread);
671
672    return RuntimeStubs::RuntimeLdExternalModuleVar(thread, index);
673}
674
675JSTaggedValue SlowRuntimeStub::LdModuleVar(JSThread *thread, JSTaggedValue key, bool inner)
676{
677    INTERPRETER_TRACE(thread, LdModuleVar);
678    [[maybe_unused]] EcmaHandleScope scope(thread);
679
680    return RuntimeStubs::RuntimeLdModuleVar(thread, key, inner);
681}
682
683JSTaggedValue SlowRuntimeStub::CreateRegExpWithLiteral(JSThread *thread, JSTaggedValue pattern, uint8_t flags)
684{
685    INTERPRETER_TRACE(thread, CreateRegExpWithLiteral);
686    [[maybe_unused]] EcmaHandleScope handleScope(thread);
687
688    JSHandle<JSTaggedValue> patternHandle(thread, pattern);
689    return RuntimeStubs::RuntimeCreateRegExpWithLiteral(thread, patternHandle, flags);
690}
691
692JSTaggedValue SlowRuntimeStub::CreateArrayWithBuffer(JSThread *thread, ObjectFactory *factory, JSArray *literal)
693{
694    INTERPRETER_TRACE(thread, CreateArrayWithBuffer);
695    [[maybe_unused]] EcmaHandleScope handleScope(thread);
696
697    JSHandle<JSTaggedValue> array(thread, literal);
698    return RuntimeStubs::RuntimeCreateArrayWithBuffer(thread, factory, array);
699}
700
701JSTaggedValue SlowRuntimeStub::GetTemplateObject(JSThread *thread, JSTaggedValue literal)
702{
703    INTERPRETER_TRACE(thread, GetTemplateObject);
704    [[maybe_unused]] EcmaHandleScope handleScope(thread);
705
706    JSHandle<JSTaggedValue> templateLiteral(thread, literal);
707    return RuntimeStubs::RuntimeGetTemplateObject(thread, templateLiteral);
708}
709
710JSTaggedValue SlowRuntimeStub::GetNextPropName(JSThread *thread, JSTaggedValue iter)
711{
712    INTERPRETER_TRACE(thread, GetNextPropName);
713    [[maybe_unused]] EcmaHandleScope handleScope(thread);
714
715    JSHandle<JSTaggedValue> iterator(thread, iter);
716    return RuntimeStubs::RuntimeGetNextPropName(thread, iterator);
717}
718
719JSTaggedValue SlowRuntimeStub::CopyDataProperties(JSThread *thread, JSTaggedValue dst, JSTaggedValue src)
720{
721    INTERPRETER_TRACE(thread, CopyDataProperties);
722    [[maybe_unused]] EcmaHandleScope handleScope(thread);
723
724    JSHandle<JSTaggedValue> dstHandle(thread, dst);
725    JSHandle<JSTaggedValue> srcHandle(thread, src);
726    return RuntimeStubs::RuntimeCopyDataProperties(thread, dstHandle, srcHandle);
727}
728
729JSTaggedValue SlowRuntimeStub::GetIteratorNext(JSThread *thread, JSTaggedValue obj, JSTaggedValue method)
730{
731    RUNTIME_TRACE(thread, GetIteratorNext);
732    [[maybe_unused]] EcmaHandleScope handleScope(thread);
733
734    JSHandle<JSTaggedValue> iter(thread, obj);
735    JSHandle<JSTaggedValue> next(thread, method);
736    return RuntimeStubs::RuntimeGetIteratorNext(thread, iter, next);
737}
738
739JSTaggedValue SlowRuntimeStub::GetUnmapedArgs(JSThread *thread, JSTaggedType *sp, uint32_t actualNumArgs,
740                                              uint32_t startIdx)
741{
742    INTERPRETER_TRACE(thread, GetUnmapedArgs);
743    [[maybe_unused]] EcmaHandleScope handleScope(thread);
744    return RuntimeStubs::RuntimeGetUnmapedArgs(thread, sp, actualNumArgs, startIdx);
745}
746
747JSTaggedValue SlowRuntimeStub::CopyRestArgs(JSThread *thread, JSTaggedType *sp, uint32_t restNumArgs, uint32_t startIdx)
748{
749    INTERPRETER_TRACE(thread, Copyrestargs);
750    [[maybe_unused]] EcmaHandleScope handleScope(thread);
751    return RuntimeStubs::RuntimeCopyRestArgs(thread, sp, restNumArgs, startIdx);
752}
753
754JSTaggedValue SlowRuntimeStub::GetIterator(JSThread *thread, JSTaggedValue obj)
755{
756    INTERPRETER_TRACE(thread, GetIterator);
757    [[maybe_unused]] EcmaHandleScope handleScope(thread);
758
759    JSHandle<JSTaggedValue> objHandle(thread, obj);
760    return RuntimeStubs::RuntimeGetIterator(thread, objHandle);
761}
762
763JSTaggedValue SlowRuntimeStub::GetAsyncIterator(JSThread *thread, JSTaggedValue obj)
764{
765    INTERPRETER_TRACE(thread, GetAsyncIterator);
766    [[maybe_unused]] EcmaHandleScope handleScope(thread);
767
768    JSHandle<JSTaggedValue> objHandle(thread, obj);
769    return RuntimeStubs::RuntimeGetAsyncIterator(thread, objHandle);
770}
771
772JSTaggedValue SlowRuntimeStub::DefineGetterSetterByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop,
773                                                         JSTaggedValue getter, JSTaggedValue setter, bool flag)
774{
775    INTERPRETER_TRACE(thread, DefineGetterSetterByValue);
776    [[maybe_unused]] EcmaHandleScope handleScope(thread);
777
778    JSHandle<JSObject> objHandle(thread, obj);
779    JSHandle<JSTaggedValue> propHandle(thread, prop);
780    JSHandle<JSTaggedValue> getterHandle(thread, getter);
781    JSHandle<JSTaggedValue> setterHandle(thread, setter);
782    JSHandle<JSTaggedValue> func(thread, JSTaggedValue::Undefined());
783    return RuntimeStubs::RuntimeDefineGetterSetterByValue(thread, objHandle, propHandle,
784                                                          getterHandle, setterHandle, flag,
785                                                          func, 0);
786}
787
788JSTaggedValue SlowRuntimeStub::LdObjByIndex(JSThread *thread, JSTaggedValue obj, uint32_t idx, bool callGetter,
789                                            JSTaggedValue receiver)
790{
791    INTERPRETER_TRACE(thread, LdObjByIndex);
792    [[maybe_unused]] EcmaHandleScope handleScope(thread);
793
794    JSHandle<JSTaggedValue> objHandle(thread, obj);
795    return RuntimeStubs::RuntimeLdObjByIndex(thread, objHandle, idx, callGetter, receiver);
796}
797
798JSTaggedValue SlowRuntimeStub::StObjByIndex(JSThread *thread, JSTaggedValue obj, uint32_t idx, JSTaggedValue value)
799{
800    INTERPRETER_TRACE(thread, StObjByIndex);
801    [[maybe_unused]] EcmaHandleScope handleScope(thread);
802
803    JSHandle<JSTaggedValue> objHandle(thread, obj);
804    JSHandle<JSTaggedValue> valueHandle(thread, value);
805    return RuntimeStubs::RuntimeStObjByIndex(thread, objHandle, idx, valueHandle);
806}
807
808JSTaggedValue SlowRuntimeStub::LdObjByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop, bool callGetter,
809                                           JSTaggedValue receiver)
810{
811    INTERPRETER_TRACE(thread, LdObjByName);
812    [[maybe_unused]] EcmaHandleScope handleScope(thread);
813    return RuntimeStubs::RuntimeLdObjByName(thread, obj, prop, callGetter, receiver);
814}
815
816JSTaggedValue SlowRuntimeStub::StObjByName(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop, JSTaggedValue value)
817{
818    INTERPRETER_TRACE(thread, StObjByName);
819    [[maybe_unused]] EcmaHandleScope handleScope(thread);
820
821    JSHandle<JSTaggedValue> objHandle(thread, obj);
822    JSHandle<JSTaggedValue> propHandle(thread, prop);
823    JSHandle<JSTaggedValue> valueHandle(thread, value);
824    return RuntimeStubs::RuntimeStObjByName(thread, objHandle, propHandle, valueHandle);
825}
826
827JSTaggedValue SlowRuntimeStub::LdObjByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop, bool callGetter,
828                                            JSTaggedValue receiver)
829{
830    INTERPRETER_TRACE(thread, LdObjByValue);
831    [[maybe_unused]] EcmaHandleScope handleScope(thread);
832
833    JSHandle<JSTaggedValue> objHandle(thread, obj);
834    JSHandle<JSTaggedValue> propHandle(thread, prop);
835    return RuntimeStubs::RuntimeLdObjByValue(thread, objHandle, propHandle, callGetter, receiver);
836}
837
838JSTaggedValue SlowRuntimeStub::StObjByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue prop,
839                                            JSTaggedValue value)
840{
841    INTERPRETER_TRACE(thread, StObjByValue);
842    [[maybe_unused]] EcmaHandleScope handleScope(thread);
843
844    JSHandle<JSTaggedValue> objHandle(thread, obj);
845    JSHandle<JSTaggedValue> propHandle(thread, prop);
846    JSHandle<JSTaggedValue> valueHandle(thread, value);
847    return RuntimeStubs::RuntimeStObjByValue(thread, objHandle, propHandle, valueHandle);
848}
849
850JSTaggedValue SlowRuntimeStub::TryLdGlobalByNameFromGlobalProto(JSThread *thread, JSTaggedValue global,
851                                                                JSTaggedValue prop)
852{
853    INTERPRETER_TRACE(thread, Trygetobjprop);
854    [[maybe_unused]] EcmaHandleScope handleScope(thread);
855
856    JSHandle<JSTaggedValue> obj(thread, global.GetTaggedObject()->GetClass()->GetPrototype());
857    JSHandle<JSTaggedValue> propHandle(thread, prop);
858    return RuntimeStubs::RuntimeTryLdGlobalByName(thread, obj, propHandle);
859}
860
861JSTaggedValue SlowRuntimeStub::TryStGlobalByName(JSThread *thread, JSTaggedValue prop)
862{
863    INTERPRETER_TRACE(thread, TryStGlobalByName);
864    // If fast path is fail, not need slow path, just throw error.
865    return ThrowReferenceError(thread, prop, " is not defined");
866}
867
868JSTaggedValue SlowRuntimeStub::LdGlobalVarFromGlobalProto(JSThread *thread, JSTaggedValue global, JSTaggedValue prop)
869{
870    INTERPRETER_TRACE(thread, LdGlobalVar);
871    [[maybe_unused]] EcmaHandleScope handleScope(thread);
872
873    JSHandle<JSTaggedValue> objHandle(thread, global);
874    JSHandle<JSTaggedValue> propHandle(thread, prop);
875    return RuntimeStubs::RuntimeLdGlobalVarFromProto(thread, objHandle, propHandle); // After checked global itself.
876}
877
878JSTaggedValue SlowRuntimeStub::StGlobalVar(JSThread *thread, JSTaggedValue prop, JSTaggedValue value)
879{
880    INTERPRETER_TRACE(thread, StGlobalVar);
881    [[maybe_unused]] EcmaHandleScope handleScope(thread);
882
883    JSHandle<JSTaggedValue> propHandle(thread, prop);
884    JSHandle<JSTaggedValue> valueHandle(thread, value);
885    return RuntimeStubs::RuntimeStGlobalVar(thread, propHandle, valueHandle);
886}
887
888JSTaggedValue SlowRuntimeStub::TryUpdateGlobalRecord(JSThread *thread, JSTaggedValue prop, JSTaggedValue value)
889{
890    INTERPRETER_TRACE(thread, TryUpdateGlobalRecord);
891    [[maybe_unused]] EcmaHandleScope handleScope(thread);
892
893    return RuntimeStubs::RuntimeTryUpdateGlobalRecord(thread, prop, value);
894}
895
896// return box
897JSTaggedValue SlowRuntimeStub::LdGlobalRecord(JSThread *thread, JSTaggedValue key)
898{
899    INTERPRETER_TRACE(thread, LdGlobalRecord);
900    [[maybe_unused]] EcmaHandleScope handleScope(thread);
901
902    return RuntimeStubs::RuntimeLdGlobalRecord(thread, key);
903}
904
905JSTaggedValue SlowRuntimeStub::StGlobalRecord(JSThread *thread, JSTaggedValue prop, JSTaggedValue value, bool isConst)
906{
907    INTERPRETER_TRACE(thread, StGlobalRecord);
908    [[maybe_unused]] EcmaHandleScope handleScope(thread);
909
910    JSHandle<JSTaggedValue> propHandle(thread, prop);
911    JSHandle<JSTaggedValue> valueHandle(thread, value);
912    return RuntimeStubs::RuntimeStGlobalRecord(thread, propHandle, valueHandle, isConst);
913}
914
915JSTaggedValue SlowRuntimeStub::ThrowReferenceError(JSThread *thread, JSTaggedValue prop, const char *desc)
916{
917    INTERPRETER_TRACE(thread, ThrowReferenceError);
918    [[maybe_unused]] EcmaHandleScope handleScope(thread);
919
920    JSHandle<JSTaggedValue> propHandle(thread, prop);
921    return RuntimeStubs::RuntimeThrowReferenceError(thread, propHandle, desc);
922}
923
924JSTaggedValue SlowRuntimeStub::ThrowTypeError(JSThread *thread, const char *message)
925{
926    INTERPRETER_TRACE(thread, ThrowTypeError);
927    [[maybe_unused]] EcmaHandleScope handleScope(thread);
928
929    return RuntimeStubs::RuntimeThrowTypeError(thread, message);
930}
931
932JSTaggedValue SlowRuntimeStub::ThrowSyntaxError(JSThread *thread, const char *message)
933{
934    INTERPRETER_TRACE(thread, ThrowSyntaxError);
935    [[maybe_unused]] EcmaHandleScope handleScope(thread);
936
937    return RuntimeStubs::RuntimeThrowSyntaxError(thread, message);
938}
939
940JSTaggedValue SlowRuntimeStub::StArraySpread(JSThread *thread, JSTaggedValue dst, JSTaggedValue index,
941                                             JSTaggedValue src)
942{
943    INTERPRETER_TRACE(thread, StArraySpread);
944    [[maybe_unused]] EcmaHandleScope handleScope(thread);
945
946    JSHandle<JSTaggedValue> dstHandle(thread, dst);
947    JSHandle<JSTaggedValue> srcHandle(thread, src);
948    return RuntimeStubs::RuntimeStArraySpread(thread, dstHandle, index, srcHandle);
949}
950
951JSTaggedValue SlowRuntimeStub::DefineFunc(JSThread *thread, JSTaggedValue constPool, uint16_t methodId,
952                                          JSTaggedValue module, uint16_t length, JSTaggedValue env,
953                                          JSTaggedValue homeObject)
954{
955    INTERPRETER_TRACE(thread, DefineFunc);
956    [[maybe_unused]] EcmaHandleScope handleScope(thread);
957    JSHandle<JSTaggedValue> constpoolHandle(thread, constPool);
958    JSHandle<JSTaggedValue> moduleHandle(thread, module);
959    JSHandle<JSTaggedValue> envHandle(thread, env);
960    JSHandle<JSTaggedValue> homeObjectHandle(thread, homeObject);
961    return RuntimeStubs::RuntimeDefinefunc(thread, constpoolHandle, methodId, moduleHandle,
962                                           length, envHandle, homeObjectHandle);
963}
964
965JSTaggedValue SlowRuntimeStub::GetSuperConstructor(JSThread *thread, JSTaggedValue ctor)
966{
967    INTERPRETER_TRACE(thread, GetSuperConstructor);
968    JSHandle<JSTaggedValue> ctorHandle(thread, ctor);
969    JSHandle<JSTaggedValue> superConstructor(thread, JSTaggedValue::GetPrototype(thread, ctorHandle));
970    RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
971    return superConstructor.GetTaggedValue();
972}
973
974JSTaggedValue SlowRuntimeStub::SuperCall(JSThread *thread, JSTaggedValue func, JSTaggedValue newTarget,
975                                         uint16_t firstVRegIdx, uint16_t length)
976{
977    INTERPRETER_TRACE(thread, SuperCall);
978    [[maybe_unused]] EcmaHandleScope handleScope(thread);
979
980    JSHandle<JSTaggedValue> funcHandle(thread, func);
981    JSHandle<JSTaggedValue> newTargetHandle(thread, newTarget);
982    return RuntimeStubs::RuntimeSuperCall(thread, funcHandle, newTargetHandle, firstVRegIdx, length);
983}
984
985JSTaggedValue SlowRuntimeStub::DynamicImport(JSThread *thread, JSTaggedValue specifier, JSTaggedValue currentFunc)
986{
987    INTERPRETER_TRACE(thread, DynamicImport);
988    [[maybe_unused]] EcmaHandleScope handleScope(thread);
989
990    JSHandle<JSTaggedValue> specifierHandle(thread, specifier);
991    JSHandle<JSTaggedValue> currentFuncHandle(thread, currentFunc);
992    return RuntimeStubs::RuntimeDynamicImport(thread, specifierHandle, currentFuncHandle);
993}
994
995JSTaggedValue SlowRuntimeStub::SuperCallSpread(JSThread *thread, JSTaggedValue func, JSTaggedValue newTarget,
996                                               JSTaggedValue array)
997{
998    INTERPRETER_TRACE(thread, SuperCallSpread);
999    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1000
1001    JSHandle<JSTaggedValue> funcHandle(thread, func);
1002    JSHandle<JSTaggedValue> newTargetHandle(thread, newTarget);
1003    JSHandle<JSTaggedValue> jsArray(thread, array);
1004    return RuntimeStubs::RuntimeSuperCallSpread(thread, funcHandle, newTargetHandle, jsArray);
1005}
1006
1007JSTaggedValue SlowRuntimeStub::SuperCallForwardAllArgs(JSThread *thread, JSTaggedType *sp, JSTaggedValue func,
1008                                                       JSTaggedValue newTarget, uint32_t restNumArgs, uint32_t startIdx)
1009{
1010    JSHandle<JSTaggedValue> superFunc(thread, GetSuperConstructor(thread, func));
1011    JSHandle<JSTaggedValue> newTargetHandle(thread, newTarget);
1012    return RuntimeStubs::RuntimeSuperCallForwardAllArgs(thread, sp, superFunc, newTargetHandle, restNumArgs, startIdx);
1013}
1014
1015JSTaggedValue SlowRuntimeStub::DefineMethod(JSThread *thread, Method *method, JSTaggedValue homeObject,
1016                                            uint16_t length, JSTaggedValue env, JSTaggedValue module)
1017{
1018    INTERPRETER_TRACE(thread, DefineMethod);
1019    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1020    JSHandle<Method> methodHandle(thread, method);
1021    JSHandle<JSTaggedValue> homeObjectHandle(thread, homeObject);
1022    JSHandle<JSTaggedValue> envHandle(thread, env);
1023    JSHandle<JSTaggedValue> moduleHandle(thread, module);
1024    return RuntimeStubs::RuntimeDefineMethod(thread, methodHandle, homeObjectHandle, length, envHandle, moduleHandle);
1025}
1026
1027JSTaggedValue SlowRuntimeStub::LdSendableClass(JSThread *thread, JSTaggedValue env, uint16_t level)
1028{
1029    INTERPRETER_TRACE(thread, LdSendableClass);
1030    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1031    JSHandle<JSTaggedValue> envHandle(thread, env);
1032    return RuntimeStubs::RuntimeLdSendableClass(envHandle, level);
1033}
1034
1035JSTaggedValue SlowRuntimeStub::LdSendableExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue thisFunc)
1036{
1037    RUNTIME_TRACE(thread, LdSendableExternalModuleVarByIndex);
1038    [[maybe_unused]] EcmaHandleScope scope(thread);
1039
1040    return RuntimeStubs::RuntimeLdSendableExternalModuleVar(thread, index, thisFunc);
1041}
1042
1043JSTaggedValue SlowRuntimeStub::LdLazyExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue thisFunc)
1044{
1045    RUNTIME_TRACE(thread, LdLazyExternalModuleVarByIndex);
1046    [[maybe_unused]] EcmaHandleScope scope(thread);
1047    return RuntimeStubs::RuntimeLdLazyExternalModuleVar(thread, index, thisFunc);
1048}
1049
1050JSTaggedValue SlowRuntimeStub::LdLazySendableExternalModuleVar(JSThread *thread, int32_t index, JSTaggedValue thisFunc)
1051{
1052    RUNTIME_TRACE(thread, LdLazySendableExternalModuleVarByIndex);
1053    [[maybe_unused]] EcmaHandleScope scope(thread);
1054
1055    return RuntimeStubs::RuntimeLdLazySendableExternalModuleVar(thread, index, thisFunc);
1056}
1057
1058JSTaggedValue SlowRuntimeStub::LdSuperByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue key,
1059                                              JSTaggedValue thisFunc)
1060{
1061    INTERPRETER_TRACE(thread, LdSuperByValue);
1062    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1063
1064    JSHandle<JSTaggedValue> objHandle(thread, obj);
1065    JSHandle<JSTaggedValue> propHandle(thread, key);
1066    return RuntimeStubs::RuntimeLdSuperByValue(thread, objHandle, propHandle, thisFunc);
1067}
1068
1069JSTaggedValue SlowRuntimeStub::StSuperByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue key,
1070                                              JSTaggedValue value, JSTaggedValue thisFunc)
1071{
1072    INTERPRETER_TRACE(thread, StSuperByValue);
1073    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1074
1075    JSHandle<JSTaggedValue> objHandle(thread, obj);
1076    JSHandle<JSTaggedValue> propHandle(thread, key);
1077    JSHandle<JSTaggedValue> valueHandle(thread, value);
1078    return RuntimeStubs::RuntimeStSuperByValue(thread, objHandle, propHandle, valueHandle, thisFunc);
1079}
1080
1081JSTaggedValue SlowRuntimeStub::GetCallSpreadArgs(JSThread *thread, JSTaggedValue array)
1082{
1083    INTERPRETER_TRACE(thread, GetCallSpreadArgs);
1084    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1085
1086    JSHandle<JSTaggedValue> jsArray(thread, array);
1087    return RuntimeStubs::RuntimeGetCallSpreadArgs(thread, jsArray);
1088}
1089
1090void SlowRuntimeStub::ThrowDeleteSuperProperty(JSThread *thread)
1091{
1092    INTERPRETER_TRACE(thread, ThrowDeleteSuperProperty);
1093    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1094
1095    return RuntimeStubs::RuntimeThrowDeleteSuperProperty(thread);
1096}
1097
1098JSTaggedValue SlowRuntimeStub::NotifyInlineCache(JSThread *thread, JSFunction *function)
1099{
1100    INTERPRETER_TRACE(thread, NotifyInlineCache);
1101    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1102
1103    JSHandle<JSFunction> functionHandle(thread, function);
1104    uint32_t slotSize = functionHandle->GetCallTarget()->GetSlotSize();
1105    return RuntimeStubs::RuntimeNotifyInlineCache(thread, functionHandle, slotSize);
1106}
1107
1108JSTaggedValue SlowRuntimeStub::ResolveClass(JSThread *thread, JSTaggedValue ctor, TaggedArray *literal,
1109                                            JSTaggedValue base, JSTaggedValue lexenv)
1110{
1111    JSHandle<JSFunction> cls(thread, ctor);
1112    JSHandle<TaggedArray> literalBuffer(thread, literal);
1113    JSHandle<JSTaggedValue> baseHandle(thread, base);
1114    JSHandle<JSTaggedValue> lexicalEnv(thread, lexenv);
1115    return RuntimeStubs::RuntimeResolveClass(thread, cls, literalBuffer, baseHandle, lexicalEnv);
1116}
1117
1118// clone class may need re-set inheritance relationship due to extends may be a variable.
1119JSTaggedValue SlowRuntimeStub::CloneClassFromTemplate(JSThread *thread, JSTaggedValue ctor, JSTaggedValue base,
1120                                                      JSTaggedValue lexenv)
1121{
1122    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1123
1124    JSHandle<JSTaggedValue> lexenvHandle(thread, lexenv);
1125    JSHandle<JSTaggedValue> baseHandle(thread, base);
1126    JSHandle<JSFunction> cls(thread, ctor);
1127    return RuntimeStubs::RuntimeCloneClassFromTemplate(thread, cls, baseHandle, lexenvHandle);
1128}
1129
1130// clone class may need re-set inheritance relationship due to extends may be a variable.
1131JSTaggedValue SlowRuntimeStub::CreateClassWithBuffer(JSThread *thread, JSTaggedValue base,
1132                                                     JSTaggedValue lexenv, JSTaggedValue constpool,
1133                                                     uint16_t methodId, uint16_t literalId, JSTaggedValue module,
1134                                                     JSTaggedValue length)
1135{
1136    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1137    JSHandle<JSTaggedValue> baseHandle(thread, base);
1138    JSHandle<JSTaggedValue> lexenvHandle(thread, lexenv);
1139    JSHandle<JSTaggedValue> constpoolHandle(thread, constpool);
1140    JSHandle<JSTaggedValue> moduleHandle(thread, module);
1141    JSHandle<JSTaggedValue> lengthHandle(thread, length);
1142    return RuntimeStubs::RuntimeCreateClassWithBuffer(thread, baseHandle, lexenvHandle,
1143                                                      constpoolHandle, methodId, literalId,
1144                                                      moduleHandle, lengthHandle);
1145}
1146
1147JSTaggedValue SlowRuntimeStub::CreateSharedClass(JSThread *thread, JSTaggedValue base,
1148                                                 JSTaggedValue constpool, uint16_t methodId, uint16_t literalId,
1149                                                 uint16_t length, JSTaggedValue module)
1150{
1151    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1152    JSHandle<JSTaggedValue> baseHandle(thread, base);
1153    JSHandle<JSTaggedValue> constpoolHandle(thread, constpool);
1154    JSHandle<JSTaggedValue> moduleHandle(thread, module);
1155    return RuntimeStubs::RuntimeCreateSharedClass(thread, baseHandle, constpoolHandle, methodId,
1156                                                  literalId, length, moduleHandle);
1157}
1158
1159JSTaggedValue SlowRuntimeStub::SetClassInheritanceRelationship(JSThread *thread, JSTaggedValue ctor, JSTaggedValue base)
1160{
1161    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1162
1163    JSHandle<JSTaggedValue> cls(thread, ctor);
1164    JSHandle<JSTaggedValue> parent(thread, base);
1165    return RuntimeStubs::RuntimeSetClassInheritanceRelationship(thread, cls, parent);
1166}
1167
1168JSTaggedValue SlowRuntimeStub::SetClassConstructorLength(JSThread *thread, JSTaggedValue ctor, JSTaggedValue length)
1169{
1170    return RuntimeStubs::RuntimeSetClassConstructorLength(thread, ctor, length);
1171}
1172
1173JSTaggedValue SlowRuntimeStub::GetModuleNamespace(JSThread *thread, int32_t index)
1174{
1175    return RuntimeStubs::RuntimeGetModuleNamespace(thread, index);
1176}
1177
1178JSTaggedValue SlowRuntimeStub::GetModuleNamespace(JSThread *thread, JSTaggedValue localName)
1179{
1180    return RuntimeStubs::RuntimeGetModuleNamespace(thread, localName);
1181}
1182
1183JSTaggedValue SlowRuntimeStub::LdBigInt(JSThread *thread, JSTaggedValue numberBigInt)
1184{
1185    INTERPRETER_TRACE(thread, LdBigInt);
1186    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1187    JSHandle<JSTaggedValue> bigint(thread, numberBigInt);
1188    return RuntimeStubs::RuntimeLdBigInt(thread, bigint);
1189}
1190JSTaggedValue SlowRuntimeStub::AsyncGeneratorResolve(JSThread *thread, JSTaggedValue asyncFuncObj,
1191                                                     const JSTaggedValue value, JSTaggedValue flag)
1192{
1193    INTERPRETER_TRACE(thread, AsyncGeneratorResolve);
1194    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1195
1196    JSHandle<JSTaggedValue> genObjHandle(thread, asyncFuncObj);
1197    JSHandle<JSTaggedValue> valueHandle(thread, value);
1198
1199    return RuntimeStubs::RuntimeAsyncGeneratorResolve(thread, genObjHandle, valueHandle, flag);
1200}
1201
1202JSTaggedValue SlowRuntimeStub::AsyncGeneratorReject(JSThread *thread, JSTaggedValue asyncFuncObj,
1203                                                    const JSTaggedValue value)
1204{
1205    INTERPRETER_TRACE(thread, AsyncGeneratorReject);
1206    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1207
1208    JSHandle<JSAsyncGeneratorObject> asyncFuncObjHandle(thread, asyncFuncObj);
1209    JSHandle<JSTaggedValue> valueHandle(thread, value);
1210
1211    return JSAsyncGeneratorObject::AsyncGeneratorReject(thread, asyncFuncObjHandle, valueHandle);
1212}
1213
1214JSTaggedValue SlowRuntimeStub::LdPatchVar(JSThread *thread, uint32_t index)
1215{
1216    INTERPRETER_TRACE(thread, LdPatchVar);
1217    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1218
1219    return RuntimeStubs::RuntimeLdPatchVar(thread, index);
1220}
1221
1222JSTaggedValue SlowRuntimeStub::StPatchVar(JSThread *thread, uint32_t index, JSTaggedValue value)
1223{
1224    INTERPRETER_TRACE(thread, StPatchVar);
1225    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1226
1227    JSHandle<JSTaggedValue> valueHandle(thread, value);
1228    return RuntimeStubs::RuntimeStPatchVar(thread, index, valueHandle);
1229}
1230
1231JSTaggedValue SlowRuntimeStub::NotifyConcurrentResult(JSThread *thread, JSTaggedValue result, JSTaggedValue hint)
1232{
1233    INTERPRETER_TRACE(thread, NotifyConcurrentResult);
1234    return RuntimeStubs::RuntimeNotifyConcurrentResult(thread, result, hint);
1235}
1236
1237JSTaggedValue SlowRuntimeStub::UpdateAOTHClass(JSThread *thread, JSTaggedValue jshclass,
1238                                               JSTaggedValue newjshclass, JSTaggedValue key)
1239{
1240    INTERPRETER_TRACE(thread, UpdateAOTHClass);
1241    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1242    JSHandle<JSHClass> oldhclass(thread, jshclass);
1243    JSHandle<JSHClass> newhclass(thread, newjshclass);
1244    return RuntimeStubs::RuntimeUpdateAOTHClass(thread, oldhclass, newhclass, key);
1245}
1246
1247JSTaggedValue SlowRuntimeStub::DefineField(JSThread *thread, JSTaggedValue obj,
1248                                           JSTaggedValue propKey, JSTaggedValue value)
1249{
1250    INTERPRETER_TRACE(thread, DefineField);
1251    return RuntimeStubs::RuntimeDefineField(thread, obj, propKey, value);
1252}
1253
1254JSTaggedValue SlowRuntimeStub::CreatePrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
1255    uint32_t count, JSTaggedValue constpool, uint32_t literalId, JSTaggedValue module)
1256{
1257    INTERPRETER_TRACE(thread, CreatePrivateProperty);
1258    return RuntimeStubs::RuntimeCreatePrivateProperty(thread, lexicalEnv, count, constpool, literalId, module);
1259}
1260
1261JSTaggedValue SlowRuntimeStub::DefinePrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
1262    uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj, JSTaggedValue value)
1263{
1264    INTERPRETER_TRACE(thread, DefinePrivateProperty);
1265    return RuntimeStubs::RuntimeDefinePrivateProperty(thread, lexicalEnv, levelIndex, slotIndex, obj, value);
1266}
1267
1268JSTaggedValue SlowRuntimeStub::LdPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
1269    uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj)
1270{
1271    INTERPRETER_TRACE(thread, LdPrivateProperty);
1272    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1273    return RuntimeStubs::RuntimeLdPrivateProperty(thread, lexicalEnv, levelIndex, slotIndex, obj);
1274}
1275
1276JSTaggedValue SlowRuntimeStub::StPrivateProperty(JSThread *thread, JSTaggedValue lexicalEnv,
1277    uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj, JSTaggedValue value)
1278{
1279    INTERPRETER_TRACE(thread, StPrivateProperty);
1280    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1281    return RuntimeStubs::RuntimeStPrivateProperty(thread, lexicalEnv, levelIndex, slotIndex, obj, value);
1282}
1283
1284JSTaggedValue SlowRuntimeStub::TestIn(JSThread *thread, JSTaggedValue lexicalEnv,
1285    uint32_t levelIndex, uint32_t slotIndex, JSTaggedValue obj)
1286{
1287    INTERPRETER_TRACE(thread, TestIn);
1288    [[maybe_unused]] EcmaHandleScope handleScope(thread);
1289    return RuntimeStubs::RuntimeTestIn(thread, lexicalEnv, levelIndex, slotIndex, obj);
1290}
1291}  // namespace panda::ecmascript
1292