14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_stubs.h"
174514f5e3Sopenharmony_ci
184514f5e3Sopenharmony_ci#include "ecmascript/base/number_helper.h"
194514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_array_stub_builder.h"
204514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_call_signature.h"
214514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_dataview_stub_builder.h"
224514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_function_stub_builder.h"
234514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_string_stub_builder.h"
244514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_regexp_stub_builder.h"
254514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_number_stub_builder.h"
264514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_proxy_stub_builder.h"
274514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_reflect_stub_builder.h"
284514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_typedarray_stub_builder.h"
294514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/containers_vector_stub_builder.h"
304514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/containers_stub_builder.h"
314514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_collator_stub_builder.h"
324514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_collection_stub_builder.h"
334514f5e3Sopenharmony_ci#include "ecmascript/compiler/builtins/builtins_object_stub_builder.h"
344514f5e3Sopenharmony_ci#include "ecmascript/compiler/codegen/llvm/llvm_ir_builder.h"
354514f5e3Sopenharmony_ci#include "ecmascript/compiler/interpreter_stub-inl.h"
364514f5e3Sopenharmony_ci#include "ecmascript/compiler/new_object_stub_builder.h"
374514f5e3Sopenharmony_ci#include "ecmascript/compiler/stub_builder-inl.h"
384514f5e3Sopenharmony_ci#include "ecmascript/compiler/stub_builder.h"
394514f5e3Sopenharmony_ci#include "ecmascript/compiler/hash_stub_builder.h"
404514f5e3Sopenharmony_ci#include "ecmascript/compiler/variable_type.h"
414514f5e3Sopenharmony_ci#include "ecmascript/js_dataview.h"
424514f5e3Sopenharmony_ci#include "ecmascript/js_date.h"
434514f5e3Sopenharmony_ci#include "ecmascript/js_primitive_ref.h"
444514f5e3Sopenharmony_ci#include "ecmascript/linked_hash_table.h"
454514f5e3Sopenharmony_ci#include "ecmascript/js_set.h"
464514f5e3Sopenharmony_ci#include "ecmascript/js_map.h"
474514f5e3Sopenharmony_ci
484514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu {
494514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_BUILTIN_LOG
504514f5e3Sopenharmony_ci#define DECLARE_BUILTINS(name)                                                                      \
514514f5e3Sopenharmony_civoid name##StubBuilder::GenerateCircuit()                                                           \
524514f5e3Sopenharmony_ci{                                                                                                   \
534514f5e3Sopenharmony_ci    GateRef glue = PtrArgument(static_cast<size_t>(BuiltinsArgs::GLUE));                            \
544514f5e3Sopenharmony_ci    GateRef nativeCode = PtrArgument(static_cast<size_t>(BuiltinsArgs::NATIVECODE));                \
554514f5e3Sopenharmony_ci    GateRef func = TaggedArgument(static_cast<size_t>(BuiltinsArgs::FUNC));                         \
564514f5e3Sopenharmony_ci    GateRef newTarget = TaggedArgument(static_cast<size_t>(BuiltinsArgs::NEWTARGET));               \
574514f5e3Sopenharmony_ci    GateRef thisValue = TaggedArgument(static_cast<size_t>(BuiltinsArgs::THISVALUE));               \
584514f5e3Sopenharmony_ci    GateRef numArgs = PtrArgument(static_cast<size_t>(BuiltinsArgs::NUMARGS));                      \
594514f5e3Sopenharmony_ci    DebugPrint(glue, { Int32(GET_MESSAGE_STRING_ID(name)) });                                       \
604514f5e3Sopenharmony_ci    GenerateCircuitImpl(glue, nativeCode, func, newTarget, thisValue, numArgs);                     \
614514f5e3Sopenharmony_ci}                                                                                                   \
624514f5e3Sopenharmony_civoid name##StubBuilder::GenerateCircuitImpl(GateRef glue, GateRef nativeCode, GateRef func,         \
634514f5e3Sopenharmony_ci                                            GateRef newTarget, GateRef thisValue, GateRef numArgs)
644514f5e3Sopenharmony_ci#else
654514f5e3Sopenharmony_ci#ifndef NDEBUG
664514f5e3Sopenharmony_ci#define DECLARE_BUILTINS(name)                                                                      \
674514f5e3Sopenharmony_civoid name##StubBuilder::GenerateCircuit()                                                           \
684514f5e3Sopenharmony_ci{                                                                                                   \
694514f5e3Sopenharmony_ci    GateRef glue = PtrArgument(static_cast<size_t>(BuiltinsArgs::GLUE));                            \
704514f5e3Sopenharmony_ci    GateRef nativeCode = PtrArgument(static_cast<size_t>(BuiltinsArgs::NATIVECODE));                \
714514f5e3Sopenharmony_ci    GateRef func = TaggedArgument(static_cast<size_t>(BuiltinsArgs::FUNC));                         \
724514f5e3Sopenharmony_ci    GateRef newTarget = TaggedArgument(static_cast<size_t>(BuiltinsArgs::NEWTARGET));               \
734514f5e3Sopenharmony_ci    GateRef thisValue = TaggedArgument(static_cast<size_t>(BuiltinsArgs::THISVALUE));               \
744514f5e3Sopenharmony_ci    GateRef numArgs = PtrArgument(static_cast<size_t>(BuiltinsArgs::NUMARGS));                      \
754514f5e3Sopenharmony_ci    CallRuntime(glue, RTSTUB_ID(ForceGC), {});                                                      \
764514f5e3Sopenharmony_ci    GenerateCircuitImpl(glue, nativeCode, func, newTarget, thisValue, numArgs);                     \
774514f5e3Sopenharmony_ci}                                                                                                   \
784514f5e3Sopenharmony_civoid name##StubBuilder::GenerateCircuitImpl(GateRef glue, GateRef nativeCode, GateRef func,         \
794514f5e3Sopenharmony_ci                                            GateRef newTarget, GateRef thisValue, GateRef numArgs)
804514f5e3Sopenharmony_ci#else
814514f5e3Sopenharmony_ci#define DECLARE_BUILTINS(name)                                                                      \
824514f5e3Sopenharmony_civoid name##StubBuilder::GenerateCircuit()                                                           \
834514f5e3Sopenharmony_ci{                                                                                                   \
844514f5e3Sopenharmony_ci    GateRef glue = PtrArgument(static_cast<size_t>(BuiltinsArgs::GLUE));                            \
854514f5e3Sopenharmony_ci    GateRef nativeCode = PtrArgument(static_cast<size_t>(BuiltinsArgs::NATIVECODE));                \
864514f5e3Sopenharmony_ci    GateRef func = TaggedArgument(static_cast<size_t>(BuiltinsArgs::FUNC));                         \
874514f5e3Sopenharmony_ci    GateRef newTarget = TaggedArgument(static_cast<size_t>(BuiltinsArgs::NEWTARGET));               \
884514f5e3Sopenharmony_ci    GateRef thisValue = TaggedArgument(static_cast<size_t>(BuiltinsArgs::THISVALUE));               \
894514f5e3Sopenharmony_ci    GateRef numArgs = PtrArgument(static_cast<size_t>(BuiltinsArgs::NUMARGS));                      \
904514f5e3Sopenharmony_ci    GenerateCircuitImpl(glue, nativeCode, func, newTarget, thisValue, numArgs);                     \
914514f5e3Sopenharmony_ci}                                                                                                   \
924514f5e3Sopenharmony_civoid name##StubBuilder::GenerateCircuitImpl(GateRef glue, GateRef nativeCode, GateRef func,         \
934514f5e3Sopenharmony_ci                                            GateRef newTarget, GateRef thisValue, GateRef numArgs)
944514f5e3Sopenharmony_ci#endif
954514f5e3Sopenharmony_ci#endif
964514f5e3Sopenharmony_ci
974514f5e3Sopenharmony_ciGateRef BuiltinsStubBuilder::GetCallArg0(GateRef numArg)
984514f5e3Sopenharmony_ci{
994514f5e3Sopenharmony_ci    auto env = GetEnvironment();
1004514f5e3Sopenharmony_ci    Label subentry(env);
1014514f5e3Sopenharmony_ci    env->SubCfgEntry(&subentry);
1024514f5e3Sopenharmony_ci    DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1034514f5e3Sopenharmony_ci    Label isValid(env);
1044514f5e3Sopenharmony_ci    Label exit(env);
1054514f5e3Sopenharmony_ci    BRANCH(Int32GreaterThan(TruncPtrToInt32(numArg), Int32(0)), &isValid, &exit);
1064514f5e3Sopenharmony_ci    Bind(&isValid);
1074514f5e3Sopenharmony_ci    {
1084514f5e3Sopenharmony_ci        result = TaggedArgument(static_cast<size_t>(BuiltinsArgs::ARG0_OR_ARGV));
1094514f5e3Sopenharmony_ci        Jump(&exit);
1104514f5e3Sopenharmony_ci    }
1114514f5e3Sopenharmony_ci    Bind(&exit);
1124514f5e3Sopenharmony_ci    auto res = *result;
1134514f5e3Sopenharmony_ci    env->SubCfgExit();
1144514f5e3Sopenharmony_ci    return res;
1154514f5e3Sopenharmony_ci}
1164514f5e3Sopenharmony_ci
1174514f5e3Sopenharmony_ciGateRef BuiltinsStubBuilder::GetCallArg1(GateRef numArg)
1184514f5e3Sopenharmony_ci{
1194514f5e3Sopenharmony_ci    auto env = GetEnvironment();
1204514f5e3Sopenharmony_ci    Label subentry(env);
1214514f5e3Sopenharmony_ci    env->SubCfgEntry(&subentry);
1224514f5e3Sopenharmony_ci    DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1234514f5e3Sopenharmony_ci    Label isValid(env);
1244514f5e3Sopenharmony_ci    Label exit(env);
1254514f5e3Sopenharmony_ci    BRANCH(Int32GreaterThan(TruncPtrToInt32(numArg), Int32(1)), &isValid, &exit);
1264514f5e3Sopenharmony_ci    Bind(&isValid);
1274514f5e3Sopenharmony_ci    {
1284514f5e3Sopenharmony_ci        result = TaggedArgument(static_cast<size_t>(BuiltinsArgs::ARG1));
1294514f5e3Sopenharmony_ci        Jump(&exit);
1304514f5e3Sopenharmony_ci    }
1314514f5e3Sopenharmony_ci    Bind(&exit);
1324514f5e3Sopenharmony_ci    auto res = *result;
1334514f5e3Sopenharmony_ci    env->SubCfgExit();
1344514f5e3Sopenharmony_ci    return res;
1354514f5e3Sopenharmony_ci}
1364514f5e3Sopenharmony_ci
1374514f5e3Sopenharmony_ciGateRef BuiltinsStubBuilder::GetCallArg2(GateRef numArg)
1384514f5e3Sopenharmony_ci{
1394514f5e3Sopenharmony_ci    auto env = GetEnvironment();
1404514f5e3Sopenharmony_ci    Label subentry(env);
1414514f5e3Sopenharmony_ci    env->SubCfgEntry(&subentry);
1424514f5e3Sopenharmony_ci    DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1434514f5e3Sopenharmony_ci    Label isValid(env);
1444514f5e3Sopenharmony_ci    Label exit(env);
1454514f5e3Sopenharmony_ci    // 2: 2 args
1464514f5e3Sopenharmony_ci    BRANCH(Int32GreaterThan(TruncPtrToInt32(numArg), Int32(2)), &isValid, &exit);
1474514f5e3Sopenharmony_ci    Bind(&isValid);
1484514f5e3Sopenharmony_ci    {
1494514f5e3Sopenharmony_ci        result = TaggedArgument(static_cast<size_t>(BuiltinsArgs::ARG2));
1504514f5e3Sopenharmony_ci        Jump(&exit);
1514514f5e3Sopenharmony_ci    }
1524514f5e3Sopenharmony_ci    Bind(&exit);
1534514f5e3Sopenharmony_ci    auto res = *result;
1544514f5e3Sopenharmony_ci    env->SubCfgExit();
1554514f5e3Sopenharmony_ci    return res;
1564514f5e3Sopenharmony_ci}
1574514f5e3Sopenharmony_ci
1584514f5e3Sopenharmony_ciGateRef BuiltinsStubBuilder::GetArgFromArgv(GateRef index, GateRef numArgs, bool needCheck)
1594514f5e3Sopenharmony_ci{
1604514f5e3Sopenharmony_ci    if (!needCheck) {
1614514f5e3Sopenharmony_ci        GateRef argv = GetArgv();
1624514f5e3Sopenharmony_ci        return Load(VariableType::JS_ANY(), argv, PtrMul(index, IntPtr(JSTaggedValue::TaggedTypeSize())));
1634514f5e3Sopenharmony_ci    }
1644514f5e3Sopenharmony_ci    auto env = GetEnvironment();
1654514f5e3Sopenharmony_ci    Label entry(env);
1664514f5e3Sopenharmony_ci    env->SubCfgEntry(&entry);
1674514f5e3Sopenharmony_ci    DEFVARIABLE(arg, VariableType::JS_ANY(), Undefined());
1684514f5e3Sopenharmony_ci    Label validIndex(env);
1694514f5e3Sopenharmony_ci    Label exit(env);
1704514f5e3Sopenharmony_ci    BRANCH(IntPtrGreaterThan(numArgs, index), &validIndex, &exit);
1714514f5e3Sopenharmony_ci    Bind(&validIndex);
1724514f5e3Sopenharmony_ci    {
1734514f5e3Sopenharmony_ci        GateRef argv = GetArgv();
1744514f5e3Sopenharmony_ci        arg = Load(VariableType::JS_ANY(), argv, PtrMul(index, IntPtr(JSTaggedValue::TaggedTypeSize())));
1754514f5e3Sopenharmony_ci        Jump(&exit);
1764514f5e3Sopenharmony_ci    }
1774514f5e3Sopenharmony_ci    Bind(&exit);
1784514f5e3Sopenharmony_ci    GateRef ret = *arg;
1794514f5e3Sopenharmony_ci    env->SubCfgExit();
1804514f5e3Sopenharmony_ci    return ret;
1814514f5e3Sopenharmony_ci}
1824514f5e3Sopenharmony_ci
1834514f5e3Sopenharmony_ciGateRef BuiltinsStubBuilder::CallSlowPath(GateRef nativeCode, GateRef glue, GateRef thisValue,
1844514f5e3Sopenharmony_ci                                          GateRef numArgs, GateRef func, GateRef newTarget)
1854514f5e3Sopenharmony_ci{
1864514f5e3Sopenharmony_ci    auto env = GetEnvironment();
1874514f5e3Sopenharmony_ci    Label entry(env);
1884514f5e3Sopenharmony_ci    env->SubCfgEntry(&entry);
1894514f5e3Sopenharmony_ci    Label exit(env);
1904514f5e3Sopenharmony_ci    Label callThis0(env);
1914514f5e3Sopenharmony_ci    Label notcallThis0(env);
1924514f5e3Sopenharmony_ci    Label notcallThis1(env);
1934514f5e3Sopenharmony_ci    Label callThis1(env);
1944514f5e3Sopenharmony_ci    Label callThis2(env);
1954514f5e3Sopenharmony_ci    Label callThis3(env);
1964514f5e3Sopenharmony_ci    DEFVARIABLE(result, VariableType::JS_ANY(), Undefined());
1974514f5e3Sopenharmony_ci    GateRef runtimeCallInfoArgs = PtrAdd(numArgs, IntPtr(NUM_MANDATORY_JSFUNC_ARGS));
1984514f5e3Sopenharmony_ci    BRANCH(Int64Equal(numArgs, IntPtr(0)), &callThis0, &notcallThis0);
1994514f5e3Sopenharmony_ci    Bind(&callThis0);
2004514f5e3Sopenharmony_ci    {
2014514f5e3Sopenharmony_ci        auto args = { nativeCode, glue, runtimeCallInfoArgs, func, newTarget, thisValue };
2024514f5e3Sopenharmony_ci        result = CallBuiltinRuntime(glue, args, false);
2034514f5e3Sopenharmony_ci        Jump(&exit);
2044514f5e3Sopenharmony_ci    }
2054514f5e3Sopenharmony_ci    Bind(&notcallThis0);
2064514f5e3Sopenharmony_ci    {
2074514f5e3Sopenharmony_ci        BRANCH(Int64Equal(numArgs, IntPtr(1)), &callThis1, &notcallThis1);
2084514f5e3Sopenharmony_ci        Bind(&callThis1);
2094514f5e3Sopenharmony_ci        {
2104514f5e3Sopenharmony_ci            GateRef arg0 = GetCallArg0(numArgs);
2114514f5e3Sopenharmony_ci            auto args = { nativeCode, glue, runtimeCallInfoArgs, func, newTarget, thisValue, arg0 };
2124514f5e3Sopenharmony_ci            result = CallBuiltinRuntime(glue, args, false);
2134514f5e3Sopenharmony_ci            Jump(&exit);
2144514f5e3Sopenharmony_ci        }
2154514f5e3Sopenharmony_ci        Bind(&notcallThis1);
2164514f5e3Sopenharmony_ci        {
2174514f5e3Sopenharmony_ci            BRANCH(Int64Equal(numArgs, IntPtr(2)), &callThis2, &callThis3); // 2: args2
2184514f5e3Sopenharmony_ci            Bind(&callThis2);
2194514f5e3Sopenharmony_ci            {
2204514f5e3Sopenharmony_ci                GateRef arg0 = GetCallArg0(numArgs);
2214514f5e3Sopenharmony_ci                GateRef arg1 = GetCallArg1(numArgs);
2224514f5e3Sopenharmony_ci                auto args = { nativeCode, glue, runtimeCallInfoArgs, func, newTarget, thisValue, arg0, arg1 };
2234514f5e3Sopenharmony_ci                result = CallBuiltinRuntime(glue, args, false);
2244514f5e3Sopenharmony_ci                Jump(&exit);
2254514f5e3Sopenharmony_ci            }
2264514f5e3Sopenharmony_ci            Bind(&callThis3);
2274514f5e3Sopenharmony_ci            {
2284514f5e3Sopenharmony_ci                GateRef arg0 = GetCallArg0(numArgs);
2294514f5e3Sopenharmony_ci                GateRef arg1 = GetCallArg1(numArgs);
2304514f5e3Sopenharmony_ci                GateRef arg2 = GetCallArg2(numArgs);
2314514f5e3Sopenharmony_ci                auto args = { nativeCode, glue, runtimeCallInfoArgs, func, newTarget, thisValue, arg0, arg1, arg2 };
2324514f5e3Sopenharmony_ci                result = CallBuiltinRuntime(glue, args, false);
2334514f5e3Sopenharmony_ci                Jump(&exit);
2344514f5e3Sopenharmony_ci            }
2354514f5e3Sopenharmony_ci        }
2364514f5e3Sopenharmony_ci    }
2374514f5e3Sopenharmony_ci
2384514f5e3Sopenharmony_ci    Bind(&exit);
2394514f5e3Sopenharmony_ci    auto ret = *result;
2404514f5e3Sopenharmony_ci    env->SubCfgExit();
2414514f5e3Sopenharmony_ci    return ret;
2424514f5e3Sopenharmony_ci}
2434514f5e3Sopenharmony_ci
2444514f5e3Sopenharmony_ci#define DECLARE_BUILTINS_STUB_BUILDER(method, type, initValue)                                      \
2454514f5e3Sopenharmony_ciDECLARE_BUILTINS(type##method)                                                                      \
2464514f5e3Sopenharmony_ci{                                                                                                   \
2474514f5e3Sopenharmony_ci    auto env = GetEnvironment();                                                                    \
2484514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), initValue);                                            \
2494514f5e3Sopenharmony_ci    Label exit(env);                                                                                \
2504514f5e3Sopenharmony_ci    Label slowPath(env);                                                                            \
2514514f5e3Sopenharmony_ci    Builtins##type##StubBuilder builder(this);                                                      \
2524514f5e3Sopenharmony_ci    builder.method(glue, thisValue, numArgs, &res, &exit, &slowPath);                               \
2534514f5e3Sopenharmony_ci    Bind(&slowPath);                                                                                \
2544514f5e3Sopenharmony_ci    {                                                                                               \
2554514f5e3Sopenharmony_ci        res = CallSlowPath(nativeCode, glue, thisValue, numArgs, func, newTarget);                  \
2564514f5e3Sopenharmony_ci        Jump(&exit);                                                                                \
2574514f5e3Sopenharmony_ci    }                                                                                               \
2584514f5e3Sopenharmony_ci    Bind(&exit);                                                                                    \
2594514f5e3Sopenharmony_ci    Return(*res);                                                                                   \
2604514f5e3Sopenharmony_ci}
2614514f5e3Sopenharmony_ci
2624514f5e3Sopenharmony_ci#define DECLARE_BUILTINS_STUB_BUILDER1(method, type, initValue)                                     \
2634514f5e3Sopenharmony_ciDECLARE_BUILTINS(type##method)                                                                      \
2644514f5e3Sopenharmony_ci{                                                                                                   \
2654514f5e3Sopenharmony_ci    auto env = GetEnvironment();                                                                    \
2664514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), initValue);                                            \
2674514f5e3Sopenharmony_ci    Label thisCollectionObj(env);                                                                   \
2684514f5e3Sopenharmony_ci    Label slowPath(env);                                                                            \
2694514f5e3Sopenharmony_ci    Label exit(env);                                                                                \
2704514f5e3Sopenharmony_ci    Builtins##type##StubBuilder builder(this, glue, thisValue, numArgs);                            \
2714514f5e3Sopenharmony_ci    builder.method(&res, &exit, &slowPath);                                                         \
2724514f5e3Sopenharmony_ci    Bind(&slowPath);                                                                                \
2734514f5e3Sopenharmony_ci    {                                                                                               \
2744514f5e3Sopenharmony_ci        res = CallSlowPath(nativeCode, glue, thisValue, numArgs, func, newTarget);                  \
2754514f5e3Sopenharmony_ci        Jump(&exit);                                                                                \
2764514f5e3Sopenharmony_ci    }                                                                                               \
2774514f5e3Sopenharmony_ci    Bind(&exit);                                                                                    \
2784514f5e3Sopenharmony_ci    Return(*res);                                                                                   \
2794514f5e3Sopenharmony_ci}
2804514f5e3Sopenharmony_ci
2814514f5e3Sopenharmony_ci// map and set stub function
2824514f5e3Sopenharmony_ci#define DECLARE_BUILTINS_COLLECTION_STUB_BUILDER(method, type, retDefaultValue)                     \
2834514f5e3Sopenharmony_ciDECLARE_BUILTINS(type##method)                                                                      \
2844514f5e3Sopenharmony_ci{                                                                                                   \
2854514f5e3Sopenharmony_ci    auto env = GetEnvironment();                                                                    \
2864514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), retDefaultValue);                                      \
2874514f5e3Sopenharmony_ci    Label slowPath(env);                                                                            \
2884514f5e3Sopenharmony_ci    Label exit(env);                                                                                \
2894514f5e3Sopenharmony_ci    BuiltinsCollectionStubBuilder<JS##type> builder(this, glue, thisValue, numArgs);                \
2904514f5e3Sopenharmony_ci    builder.method(&res, &exit, &slowPath);                                                         \
2914514f5e3Sopenharmony_ci    Bind(&slowPath);                                                                                \
2924514f5e3Sopenharmony_ci    {                                                                                               \
2934514f5e3Sopenharmony_ci        res = CallSlowPath(nativeCode, glue, thisValue, numArgs, func, newTarget);                  \
2944514f5e3Sopenharmony_ci        Jump(&exit);                                                                                \
2954514f5e3Sopenharmony_ci    }                                                                                               \
2964514f5e3Sopenharmony_ci    Bind(&exit);                                                                                    \
2974514f5e3Sopenharmony_ci    Return(*res);                                                                                   \
2984514f5e3Sopenharmony_ci}
2994514f5e3Sopenharmony_ci
3004514f5e3Sopenharmony_ci// map and set stub function
3014514f5e3Sopenharmony_ci#define DECLARE_BUILTINS_DATAVIEW_STUB_BUILDER(method, type, numType, function, retDefaultValue)    \
3024514f5e3Sopenharmony_ciDECLARE_BUILTINS(type##method)                                                                      \
3034514f5e3Sopenharmony_ci{                                                                                                   \
3044514f5e3Sopenharmony_ci    auto env = GetEnvironment();                                                                    \
3054514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), retDefaultValue);                                      \
3064514f5e3Sopenharmony_ci    Label slowPath(env);                                                                            \
3074514f5e3Sopenharmony_ci    Label exit(env);                                                                                \
3084514f5e3Sopenharmony_ci    BuiltinsDataViewStubBuilder builder(this);                                                      \
3094514f5e3Sopenharmony_ci    builder.function<DataViewType::numType>(glue, thisValue, numArgs, &res, &exit, &slowPath);      \
3104514f5e3Sopenharmony_ci    Bind(&slowPath);                                                                                \
3114514f5e3Sopenharmony_ci    {                                                                                               \
3124514f5e3Sopenharmony_ci        auto name = BuiltinsStubCSigns::GetName(BUILTINS_STUB_ID(type##method));                    \
3134514f5e3Sopenharmony_ci        res = CallSlowPath(nativeCode, glue, thisValue, numArgs, func, newTarget);                  \
3144514f5e3Sopenharmony_ci        Jump(&exit);                                                                                \
3154514f5e3Sopenharmony_ci    }                                                                                               \
3164514f5e3Sopenharmony_ci    Bind(&exit);                                                                                    \
3174514f5e3Sopenharmony_ci    Return(*res);                                                                                   \
3184514f5e3Sopenharmony_ci}
3194514f5e3Sopenharmony_ci
3204514f5e3Sopenharmony_ciBUILTINS_METHOD_STUB_LIST(DECLARE_BUILTINS_STUB_BUILDER, DECLARE_BUILTINS_STUB_BUILDER1,
3214514f5e3Sopenharmony_ci                          DECLARE_BUILTINS_COLLECTION_STUB_BUILDER, DECLARE_BUILTINS_DATAVIEW_STUB_BUILDER)
3224514f5e3Sopenharmony_ci#undef DECLARE_BUILTINS_STUB_BUILDER
3234514f5e3Sopenharmony_ci#undef DECLARE_BUILTINS_STUB_BUILDER1
3244514f5e3Sopenharmony_ci#undef DECLARE_BUILTINS_COLLECTION_STUB_BUILDER
3254514f5e3Sopenharmony_ci#undef DECLARE_BUILTINS_DATAVIEW_STUB_BUILDER
3264514f5e3Sopenharmony_ci
3274514f5e3Sopenharmony_ciDECLARE_BUILTINS(ArkToolsHashCode)
3284514f5e3Sopenharmony_ci{
3294514f5e3Sopenharmony_ci    (void) nativeCode;
3304514f5e3Sopenharmony_ci    (void) func;
3314514f5e3Sopenharmony_ci    (void) newTarget;
3324514f5e3Sopenharmony_ci    (void) thisValue;
3334514f5e3Sopenharmony_ci    auto env = GetEnvironment();
3344514f5e3Sopenharmony_ci    GateRef key = GetCallArg0(numArgs);
3354514f5e3Sopenharmony_ci
3364514f5e3Sopenharmony_ci    Label irHash(env);
3374514f5e3Sopenharmony_ci    Label rtHash(env);
3384514f5e3Sopenharmony_ci    BRANCH(IntPtrEqual(numArgs, IntPtr(1)), &irHash, &rtHash);
3394514f5e3Sopenharmony_ci    Bind(&irHash);
3404514f5e3Sopenharmony_ci    {
3414514f5e3Sopenharmony_ci        HashStubBuilder hashBuilder(this, glue);
3424514f5e3Sopenharmony_ci        GateRef hash = hashBuilder.GetHash(key);
3434514f5e3Sopenharmony_ci        Return(env->GetBuilder()->Int32ToTaggedPtr(hash));
3444514f5e3Sopenharmony_ci    }
3454514f5e3Sopenharmony_ci    Bind(&rtHash);
3464514f5e3Sopenharmony_ci    Return(CallRuntime(glue, RTSTUB_ID(GetLinkedHash), { key }));
3474514f5e3Sopenharmony_ci}
3484514f5e3Sopenharmony_ci
3494514f5e3Sopenharmony_ci// aot and builtins public stub function
3504514f5e3Sopenharmony_ci#define DECLARE_AOT_AND_BUILTINS_STUB_BUILDER(stubName, method, type, initValue)                    \
3514514f5e3Sopenharmony_ciDECLARE_BUILTINS(stubName)                                                                          \
3524514f5e3Sopenharmony_ci{                                                                                                   \
3534514f5e3Sopenharmony_ci    auto env = GetEnvironment();                                                                    \
3544514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), initValue);                                            \
3554514f5e3Sopenharmony_ci    Label exit(env);                                                                                \
3564514f5e3Sopenharmony_ci    Label slowPath(env);                                                                            \
3574514f5e3Sopenharmony_ci    Builtins##type##StubBuilder builder(this);                                                      \
3584514f5e3Sopenharmony_ci    builder.method(glue, thisValue, numArgs, &res, &exit, &slowPath);                               \
3594514f5e3Sopenharmony_ci    Bind(&slowPath);                                                                                \
3604514f5e3Sopenharmony_ci    {                                                                                               \
3614514f5e3Sopenharmony_ci        res = CallSlowPath(nativeCode, glue, thisValue, numArgs, func, newTarget);                  \
3624514f5e3Sopenharmony_ci        Jump(&exit);                                                                                \
3634514f5e3Sopenharmony_ci    }                                                                                               \
3644514f5e3Sopenharmony_ci    Bind(&exit);                                                                                    \
3654514f5e3Sopenharmony_ci    Return(*res);                                                                                   \
3664514f5e3Sopenharmony_ci}
3674514f5e3Sopenharmony_ci
3684514f5e3Sopenharmony_ci#define AOT_AND_BUILTINS_STUB_LIST_WITH_METHOD(V)                                                 \
3694514f5e3Sopenharmony_ci    V(StringLocaleCompare,              LocaleCompare,      String, Undefined())                  \
3704514f5e3Sopenharmony_ci    V(StringIteratorProtoNext,  StringIteratorNext, String, Undefined())                          \
3714514f5e3Sopenharmony_ci    V(ArraySort,           Sort,               Array,  Undefined())
3724514f5e3Sopenharmony_ci
3734514f5e3Sopenharmony_ciAOT_AND_BUILTINS_STUB_LIST_WITH_METHOD(DECLARE_AOT_AND_BUILTINS_STUB_BUILDER)
3744514f5e3Sopenharmony_ci#undef AOT_AND_BUILTINS_STUB_LIST
3754514f5e3Sopenharmony_ci#undef DECLARE_AOT_AND_BUILTINS_STUB_BUILDER
3764514f5e3Sopenharmony_ci
3774514f5e3Sopenharmony_ci// containers stub function
3784514f5e3Sopenharmony_ci#define DECLARE_BUILTINS_WITH_CONTAINERS_STUB_BUILDER(funcName, type, method, methodType, resultVariableType)   \
3794514f5e3Sopenharmony_ciDECLARE_BUILTINS(type##funcName)                                                                                \
3804514f5e3Sopenharmony_ci{                                                                                                               \
3814514f5e3Sopenharmony_ci    auto env = GetEnvironment();                                                                                \
3824514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::resultVariableType(), Undefined());                                          \
3834514f5e3Sopenharmony_ci    Label exit(env);                                                                                            \
3844514f5e3Sopenharmony_ci    Label slowPath(env);                                                                                        \
3854514f5e3Sopenharmony_ci    ContainersStubBuilder containersBuilder(this);                                                              \
3864514f5e3Sopenharmony_ci    containersBuilder.method(glue, thisValue, numArgs, &res, &exit, &slowPath, ContainersType::methodType);     \
3874514f5e3Sopenharmony_ci    Bind(&slowPath);                                                                                            \
3884514f5e3Sopenharmony_ci    {                                                                                                           \
3894514f5e3Sopenharmony_ci        res = CallSlowPath(nativeCode, glue, thisValue, numArgs, func, newTarget);                              \
3904514f5e3Sopenharmony_ci        Jump(&exit);                                                                                            \
3914514f5e3Sopenharmony_ci    }                                                                                                           \
3924514f5e3Sopenharmony_ci    Bind(&exit);                                                                                                \
3934514f5e3Sopenharmony_ci    Return(*res);                                                                                               \
3944514f5e3Sopenharmony_ci}
3954514f5e3Sopenharmony_ci
3964514f5e3Sopenharmony_ciBUILTINS_WITH_CONTAINERS_STUB_BUILDER(DECLARE_BUILTINS_WITH_CONTAINERS_STUB_BUILDER)
3974514f5e3Sopenharmony_ci#undef DECLARE_BUILTINS_WITH_CONTAINERS_STUB_BUILDER
3984514f5e3Sopenharmony_ci
3994514f5e3Sopenharmony_ciDECLARE_BUILTINS(BooleanConstructor)
4004514f5e3Sopenharmony_ci{
4014514f5e3Sopenharmony_ci    auto env = GetEnvironment();
4024514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
4034514f5e3Sopenharmony_ci
4044514f5e3Sopenharmony_ci    Label newTargetIsHeapObject(env);
4054514f5e3Sopenharmony_ci    Label newTargetIsJSFunction(env);
4064514f5e3Sopenharmony_ci    Label slowPath(env);
4074514f5e3Sopenharmony_ci    Label slowPath1(env);
4084514f5e3Sopenharmony_ci    Label exit(env);
4094514f5e3Sopenharmony_ci
4104514f5e3Sopenharmony_ci    BRANCH(TaggedIsHeapObject(newTarget), &newTargetIsHeapObject, &slowPath);
4114514f5e3Sopenharmony_ci    Bind(&newTargetIsHeapObject);
4124514f5e3Sopenharmony_ci    BRANCH(IsJSFunction(newTarget), &newTargetIsJSFunction, &slowPath);
4134514f5e3Sopenharmony_ci    Bind(&newTargetIsJSFunction);
4144514f5e3Sopenharmony_ci    {
4154514f5e3Sopenharmony_ci        Label intialHClassIsHClass(env);
4164514f5e3Sopenharmony_ci        GateRef intialHClass = Load(VariableType::JS_ANY(), newTarget,
4174514f5e3Sopenharmony_ci                                    IntPtr(JSFunction::PROTO_OR_DYNCLASS_OFFSET));
4184514f5e3Sopenharmony_ci        BRANCH(IsJSHClass(intialHClass), &intialHClassIsHClass, &slowPath1);
4194514f5e3Sopenharmony_ci        Bind(&intialHClassIsHClass);
4204514f5e3Sopenharmony_ci        {
4214514f5e3Sopenharmony_ci            NewObjectStubBuilder newBuilder(this);
4224514f5e3Sopenharmony_ci            newBuilder.SetParameters(glue, 0);
4234514f5e3Sopenharmony_ci            Label afterNew(env);
4244514f5e3Sopenharmony_ci            newBuilder.NewJSObject(&res, &afterNew, intialHClass);
4254514f5e3Sopenharmony_ci            Bind(&afterNew);
4264514f5e3Sopenharmony_ci            {
4274514f5e3Sopenharmony_ci                GateRef valueOffset = IntPtr(JSPrimitiveRef::VALUE_OFFSET);
4284514f5e3Sopenharmony_ci                GateRef value = GetArgFromArgv(IntPtr(0), numArgs, true);
4294514f5e3Sopenharmony_ci                Store(VariableType::INT64(), glue, *res, valueOffset, FastToBoolean(value));
4304514f5e3Sopenharmony_ci                Jump(&exit);
4314514f5e3Sopenharmony_ci            }
4324514f5e3Sopenharmony_ci        }
4334514f5e3Sopenharmony_ci        Bind(&slowPath1);
4344514f5e3Sopenharmony_ci        {
4354514f5e3Sopenharmony_ci            GateRef argv = GetArgv();
4364514f5e3Sopenharmony_ci            auto args = { glue, nativeCode, func, thisValue, numArgs, argv, newTarget };
4374514f5e3Sopenharmony_ci            res = CallBuiltinRuntimeWithNewTarget(glue, args);
4384514f5e3Sopenharmony_ci            Jump(&exit);
4394514f5e3Sopenharmony_ci        }
4404514f5e3Sopenharmony_ci    }
4414514f5e3Sopenharmony_ci    Bind(&slowPath);
4424514f5e3Sopenharmony_ci    {
4434514f5e3Sopenharmony_ci        GateRef argv = GetArgv();
4444514f5e3Sopenharmony_ci        auto args = { glue, nativeCode, func, thisValue, numArgs, argv };
4454514f5e3Sopenharmony_ci        res = CallBuiltinRuntime(glue, args, true);
4464514f5e3Sopenharmony_ci        Jump(&exit);
4474514f5e3Sopenharmony_ci    }
4484514f5e3Sopenharmony_ci    Bind(&exit);
4494514f5e3Sopenharmony_ci    Return(*res);
4504514f5e3Sopenharmony_ci}
4514514f5e3Sopenharmony_ci
4524514f5e3Sopenharmony_ciDECLARE_BUILTINS(DateConstructor)
4534514f5e3Sopenharmony_ci{
4544514f5e3Sopenharmony_ci    auto env = GetEnvironment();
4554514f5e3Sopenharmony_ci    DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
4564514f5e3Sopenharmony_ci
4574514f5e3Sopenharmony_ci    Label newTargetIsHeapObject(env);
4584514f5e3Sopenharmony_ci    Label newTargetIsJSFunction(env);
4594514f5e3Sopenharmony_ci    Label slowPath(env);
4604514f5e3Sopenharmony_ci    Label slowPath1(env);
4614514f5e3Sopenharmony_ci    Label exit(env);
4624514f5e3Sopenharmony_ci
4634514f5e3Sopenharmony_ci    BRANCH(TaggedIsHeapObject(newTarget), &newTargetIsHeapObject, &slowPath);
4644514f5e3Sopenharmony_ci    Bind(&newTargetIsHeapObject);
4654514f5e3Sopenharmony_ci    BRANCH(IsJSFunction(newTarget), &newTargetIsJSFunction, &slowPath);
4664514f5e3Sopenharmony_ci    Bind(&newTargetIsJSFunction);
4674514f5e3Sopenharmony_ci    {
4684514f5e3Sopenharmony_ci        Label intialHClassIsHClass(env);
4694514f5e3Sopenharmony_ci        GateRef intialHClass = Load(VariableType::JS_ANY(), newTarget,
4704514f5e3Sopenharmony_ci                                    IntPtr(JSFunction::PROTO_OR_DYNCLASS_OFFSET));
4714514f5e3Sopenharmony_ci        BRANCH(IsJSHClass(intialHClass), &intialHClassIsHClass, &slowPath1);
4724514f5e3Sopenharmony_ci        Bind(&intialHClassIsHClass);
4734514f5e3Sopenharmony_ci        {
4744514f5e3Sopenharmony_ci            Label oneArg(env);
4754514f5e3Sopenharmony_ci            Label notOneArg(env);
4764514f5e3Sopenharmony_ci            Label newJSDate(env);
4774514f5e3Sopenharmony_ci            DEFVARIABLE(timeValue, VariableType::FLOAT64(), Double(0));
4784514f5e3Sopenharmony_ci            BRANCH(Int64Equal(numArgs, IntPtr(1)), &oneArg, &notOneArg);
4794514f5e3Sopenharmony_ci            Bind(&oneArg);
4804514f5e3Sopenharmony_ci            {
4814514f5e3Sopenharmony_ci                Label valueIsNumber(env);
4824514f5e3Sopenharmony_ci                GateRef value = GetArgFromArgv(IntPtr(0));
4834514f5e3Sopenharmony_ci                BRANCH(TaggedIsNumber(value), &valueIsNumber, &slowPath);
4844514f5e3Sopenharmony_ci                Bind(&valueIsNumber);
4854514f5e3Sopenharmony_ci                {
4864514f5e3Sopenharmony_ci                    timeValue = CallNGCRuntime(glue, RTSTUB_ID(TimeClip), {GetDoubleOfTNumber(value)});
4874514f5e3Sopenharmony_ci                    Jump(&newJSDate);
4884514f5e3Sopenharmony_ci                }
4894514f5e3Sopenharmony_ci            }
4904514f5e3Sopenharmony_ci            Bind(&notOneArg);
4914514f5e3Sopenharmony_ci            {
4924514f5e3Sopenharmony_ci                Label threeArgs(env);
4934514f5e3Sopenharmony_ci                BRANCH(Int64Equal(numArgs, IntPtr(3)), &threeArgs, &slowPath);  // 3: year month day
4944514f5e3Sopenharmony_ci                Bind(&threeArgs);
4954514f5e3Sopenharmony_ci                {
4964514f5e3Sopenharmony_ci                    Label numberYearMonthDay(env);
4974514f5e3Sopenharmony_ci                    GateRef year = GetArgFromArgv(IntPtr(0));
4984514f5e3Sopenharmony_ci                    GateRef month = GetArgFromArgv(IntPtr(1));
4994514f5e3Sopenharmony_ci                    GateRef day = GetArgFromArgv(IntPtr(2));
5004514f5e3Sopenharmony_ci                    BRANCH(IsNumberYearMonthDay(year, month, day), &numberYearMonthDay, &slowPath);
5014514f5e3Sopenharmony_ci                    Bind(&numberYearMonthDay);
5024514f5e3Sopenharmony_ci                    {
5034514f5e3Sopenharmony_ci                        GateRef y = GetDoubleOfTNumber(year);
5044514f5e3Sopenharmony_ci                        GateRef m = GetDoubleOfTNumber(month);
5054514f5e3Sopenharmony_ci                        GateRef d = GetDoubleOfTNumber(day);
5064514f5e3Sopenharmony_ci                        timeValue = CallNGCRuntime(glue, RTSTUB_ID(SetDateValues), {y, m, d});
5074514f5e3Sopenharmony_ci                        Jump(&newJSDate);
5084514f5e3Sopenharmony_ci                    }
5094514f5e3Sopenharmony_ci                }
5104514f5e3Sopenharmony_ci            }
5114514f5e3Sopenharmony_ci            Bind(&newJSDate);
5124514f5e3Sopenharmony_ci            {
5134514f5e3Sopenharmony_ci                NewObjectStubBuilder newBuilder(this);
5144514f5e3Sopenharmony_ci                newBuilder.SetParameters(glue, 0);
5154514f5e3Sopenharmony_ci                Label afterNew(env);
5164514f5e3Sopenharmony_ci                newBuilder.NewJSObject(&res, &afterNew, intialHClass);
5174514f5e3Sopenharmony_ci                Bind(&afterNew);
5184514f5e3Sopenharmony_ci                {
5194514f5e3Sopenharmony_ci                    GateRef timeValueOffset = IntPtr(JSDate::TIME_VALUE_OFFSET);
5204514f5e3Sopenharmony_ci                    Store(VariableType::JS_NOT_POINTER(), glue, *res, timeValueOffset,
5214514f5e3Sopenharmony_ci                          DoubleToTaggedDoublePtr(*timeValue));
5224514f5e3Sopenharmony_ci                    Jump(&exit);
5234514f5e3Sopenharmony_ci                }
5244514f5e3Sopenharmony_ci            }
5254514f5e3Sopenharmony_ci        }
5264514f5e3Sopenharmony_ci        Bind(&slowPath1);
5274514f5e3Sopenharmony_ci        {
5284514f5e3Sopenharmony_ci            GateRef argv = GetArgv();
5294514f5e3Sopenharmony_ci            res = CallBuiltinRuntimeWithNewTarget(glue,
5304514f5e3Sopenharmony_ci                { glue, nativeCode, func, thisValue, numArgs, argv, newTarget });
5314514f5e3Sopenharmony_ci            Jump(&exit);
5324514f5e3Sopenharmony_ci        }
5334514f5e3Sopenharmony_ci    }
5344514f5e3Sopenharmony_ci    Bind(&slowPath);
5354514f5e3Sopenharmony_ci    {
5364514f5e3Sopenharmony_ci        GateRef argv = GetArgv();
5374514f5e3Sopenharmony_ci        res = CallBuiltinRuntime(glue, { glue, nativeCode, func, thisValue, numArgs, argv }, true);
5384514f5e3Sopenharmony_ci        Jump(&exit);
5394514f5e3Sopenharmony_ci    }
5404514f5e3Sopenharmony_ci    Bind(&exit);
5414514f5e3Sopenharmony_ci    Return(*res);
5424514f5e3Sopenharmony_ci}
5434514f5e3Sopenharmony_ci
5444514f5e3Sopenharmony_ciDECLARE_BUILTINS(NumberConstructor)
5454514f5e3Sopenharmony_ci{
5464514f5e3Sopenharmony_ci    BuiltinsNumberStubBuilder builder(this, glue, thisValue, numArgs);
5474514f5e3Sopenharmony_ci    builder.GenNumberConstructor(nativeCode, func, newTarget);
5484514f5e3Sopenharmony_ci}
5494514f5e3Sopenharmony_ci
5504514f5e3Sopenharmony_ciDECLARE_BUILTINS(ProxyConstructor)
5514514f5e3Sopenharmony_ci{
5524514f5e3Sopenharmony_ci    BuiltinsProxyStubBuilder builder(this, glue, thisValue, numArgs);
5534514f5e3Sopenharmony_ci    builder.GenProxyConstructor(nativeCode, func, newTarget);
5544514f5e3Sopenharmony_ci}
5554514f5e3Sopenharmony_ci
5564514f5e3Sopenharmony_ciDECLARE_BUILTINS(ArrayConstructor)
5574514f5e3Sopenharmony_ci{
5584514f5e3Sopenharmony_ci    BuiltinsArrayStubBuilder builder(this);
5594514f5e3Sopenharmony_ci    builder.GenArrayConstructor(glue, nativeCode, func, newTarget, thisValue, numArgs);
5604514f5e3Sopenharmony_ci}
5614514f5e3Sopenharmony_ci
5624514f5e3Sopenharmony_ciDECLARE_BUILTINS(MapConstructor)
5634514f5e3Sopenharmony_ci{
5644514f5e3Sopenharmony_ci    LinkedHashTableStubBuilder<LinkedHashMap, LinkedHashMapObject> hashTableBuilder(this, glue);
5654514f5e3Sopenharmony_ci    GateRef arg0 = GetArgFromArgv(IntPtr(0), numArgs, true);
5664514f5e3Sopenharmony_ci    hashTableBuilder.GenMapSetConstructor(nativeCode, func, newTarget, thisValue, numArgs, arg0, GetArgv());
5674514f5e3Sopenharmony_ci}
5684514f5e3Sopenharmony_ci
5694514f5e3Sopenharmony_ciDECLARE_BUILTINS(SetConstructor)
5704514f5e3Sopenharmony_ci{
5714514f5e3Sopenharmony_ci    LinkedHashTableStubBuilder<LinkedHashSet, LinkedHashSetObject> hashTableBuilder(this, glue);
5724514f5e3Sopenharmony_ci    GateRef arg0 = GetArgFromArgv(IntPtr(0), numArgs, true);
5734514f5e3Sopenharmony_ci    hashTableBuilder.GenMapSetConstructor(nativeCode, func, newTarget, thisValue, numArgs, arg0, GetArgv());
5744514f5e3Sopenharmony_ci}
5754514f5e3Sopenharmony_ci
5764514f5e3Sopenharmony_ci#define DECLARE_BUILTINS_TYPED_ARRAY_STUB_BUILDER(TYPE, type, index)                                \
5774514f5e3Sopenharmony_ciDECLARE_BUILTINS(type##ArrayConstructor)                                                            \
5784514f5e3Sopenharmony_ci{                                                                                                   \
5794514f5e3Sopenharmony_ci    GateRef ctorName = GetGlobalConstantValue(VariableType::JS_POINTER(), glue,                     \
5804514f5e3Sopenharmony_ci                                              ConstantIndex::TYPE##_ARRAY_STRING_INDEX);            \
5814514f5e3Sopenharmony_ci    BuiltinsTypedArrayStubBuilder builtinsTypedArrayStubBuilder(this);                              \
5824514f5e3Sopenharmony_ci    builtinsTypedArrayStubBuilder.GenTypedArrayConstructor(glue, nativeCode, func, newTarget,       \
5834514f5e3Sopenharmony_ci        thisValue, numArgs, ctorName, DataViewType::TYPE);                                          \
5844514f5e3Sopenharmony_ci}
5854514f5e3Sopenharmony_ciBUILTIN_COMPILER_TYPED_ARRAY_TYPES(DECLARE_BUILTINS_TYPED_ARRAY_STUB_BUILDER)
5864514f5e3Sopenharmony_ci#undef DECLARE_BUILTINS_TYPED_ARRAY_STUB_BUILDER
5874514f5e3Sopenharmony_ci}  // namespace panda::ecmascript::kungfu
588