14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2021 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#ifndef ECMASCRIPT_COMPILER_SLOWPATH_LOWERING_H
174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMPILER_SLOWPATH_LOWERING_H
184514f5e3Sopenharmony_ci
194514f5e3Sopenharmony_ci#include "ecmascript/compiler/argument_accessor.h"
204514f5e3Sopenharmony_ci#include "ecmascript/compiler/circuit.h"
214514f5e3Sopenharmony_ci#include "ecmascript/compiler/circuit_builder.h"
224514f5e3Sopenharmony_ci#include "ecmascript/compiler/gate_accessor.h"
234514f5e3Sopenharmony_ci#include "ecmascript/compiler/new_object_stub_builder.h"
244514f5e3Sopenharmony_ci#include "ecmascript/compiler/pass_manager.h"
254514f5e3Sopenharmony_ci#include <cstddef>
264514f5e3Sopenharmony_ci
274514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu {
284514f5e3Sopenharmony_ci// slowPath Lowering Process
294514f5e3Sopenharmony_ci// SW: state wire, DW: depend wire, VW: value wire
304514f5e3Sopenharmony_ci// Before lowering:
314514f5e3Sopenharmony_ci//                         SW        DW         VW
324514f5e3Sopenharmony_ci//                         |         |          |
334514f5e3Sopenharmony_ci//                         |         |          |
344514f5e3Sopenharmony_ci//                         v         v          v
354514f5e3Sopenharmony_ci//                     +-----------------------------+
364514f5e3Sopenharmony_ci//                     |            (HIR)            |
374514f5e3Sopenharmony_ci//                     |         JS_BYTECODE         |DW--------------------------------------
384514f5e3Sopenharmony_ci//                     |                             |                                       |
394514f5e3Sopenharmony_ci//                     +-----------------------------+                                       |
404514f5e3Sopenharmony_ci//                         SW                   SW                                           |
414514f5e3Sopenharmony_ci//                         |                     |                                           |
424514f5e3Sopenharmony_ci//                         |                     |                                           |
434514f5e3Sopenharmony_ci//                         |                     |                                           |
444514f5e3Sopenharmony_ci//                         v                     v                                           |
454514f5e3Sopenharmony_ci//                 +--------------+        +--------------+                                  |
464514f5e3Sopenharmony_ci//                 |  IF_SUCCESS  |        | IF_EXCEPTION |SW---------                       |
474514f5e3Sopenharmony_ci//                 +--------------+        +--------------+          |                       |
484514f5e3Sopenharmony_ci//                         SW                    SW                  |                       |
494514f5e3Sopenharmony_ci//                         |                     |                   |                       |
504514f5e3Sopenharmony_ci//                         v                     v                   |                       |
514514f5e3Sopenharmony_ci//     --------------------------------------------------------------|-----------------------|-------------------
524514f5e3Sopenharmony_ci//     catch processing                                              |                       |
534514f5e3Sopenharmony_ci//                                                                   |                       |
544514f5e3Sopenharmony_ci//                                                                   v                       V
554514f5e3Sopenharmony_ci//                                                            +--------------+       +-----------------+
564514f5e3Sopenharmony_ci//                                                            |    MERGE     |SW---->| DEPEND_SELECTOR |
574514f5e3Sopenharmony_ci//                                                            +--------------+       +-----------------+
584514f5e3Sopenharmony_ci//                                                                                          DW
594514f5e3Sopenharmony_ci//                                                                                          |
604514f5e3Sopenharmony_ci//                                                                                          v
614514f5e3Sopenharmony_ci//                                                                                   +-----------------+
624514f5e3Sopenharmony_ci//                                                                                   |  GET_EXCEPTION  |
634514f5e3Sopenharmony_ci//                                                                                   +-----------------+
644514f5e3Sopenharmony_ci
654514f5e3Sopenharmony_ci
664514f5e3Sopenharmony_ci// After lowering:
674514f5e3Sopenharmony_ci//         SW                                          DW      VW
684514f5e3Sopenharmony_ci//         |                                           |       |
694514f5e3Sopenharmony_ci//         |                                           |       |
704514f5e3Sopenharmony_ci//         |                                           v       v
714514f5e3Sopenharmony_ci//         |        +---------------------+         +------------------+
724514f5e3Sopenharmony_ci//         |        | CONSTANT(Exception) |         |       CALL       |DW---------------
734514f5e3Sopenharmony_ci//         |        +---------------------+         +------------------+                |
744514f5e3Sopenharmony_ci//         |                           VW            VW                                 |
754514f5e3Sopenharmony_ci//         |                           |             |                                  |
764514f5e3Sopenharmony_ci//         |                           |             |                                  |
774514f5e3Sopenharmony_ci//         |                           v             v                                  |
784514f5e3Sopenharmony_ci//         |                        +------------------+                                |
794514f5e3Sopenharmony_ci//         |                        |        EQ        |                                |
804514f5e3Sopenharmony_ci//         |                        +------------------+                                |
814514f5e3Sopenharmony_ci//         |                                VW                                          |
824514f5e3Sopenharmony_ci//         |                                |                                           |
834514f5e3Sopenharmony_ci//         |                                |                                           |
844514f5e3Sopenharmony_ci//         |                                v                                           |
854514f5e3Sopenharmony_ci//         |                        +------------------+                                |
864514f5e3Sopenharmony_ci//         ------------------------>|    IF_BRANCH     |                                |
874514f5e3Sopenharmony_ci//                                  +------------------+                                |
884514f5e3Sopenharmony_ci//                                   SW             SW                                  |
894514f5e3Sopenharmony_ci//                                   |              |                                   |
904514f5e3Sopenharmony_ci//                                   v              v                                   |
914514f5e3Sopenharmony_ci//                           +--------------+  +--------------+                         |
924514f5e3Sopenharmony_ci//                           |   IF_FALSE   |  |   IF_TRUE    |                         |
934514f5e3Sopenharmony_ci//                           |  (success)   |  |  (exception) |                         |
944514f5e3Sopenharmony_ci//                           +--------------+  +--------------+                         |
954514f5e3Sopenharmony_ci//                                 SW                SW   SW                            |
964514f5e3Sopenharmony_ci//                                 |                 |    |                             |
974514f5e3Sopenharmony_ci//                                 v                 v    |                             |
984514f5e3Sopenharmony_ci//     ---------------------------------------------------|-----------------------------|----------------------
994514f5e3Sopenharmony_ci//     catch processing                                   |                             |
1004514f5e3Sopenharmony_ci//                                                        |                             |
1014514f5e3Sopenharmony_ci//                                                        v                             v
1024514f5e3Sopenharmony_ci//                                                 +--------------+             +-----------------+
1034514f5e3Sopenharmony_ci//                                                 |    MERGE     |SW---------->| DEPEND_SELECTOR |
1044514f5e3Sopenharmony_ci//                                                 +--------------+             +-----------------+
1054514f5e3Sopenharmony_ci//                                                                                      DW
1064514f5e3Sopenharmony_ci//                                                                                      |
1074514f5e3Sopenharmony_ci//                                                                                      v
1084514f5e3Sopenharmony_ci//                                                                              +-----------------+
1094514f5e3Sopenharmony_ci//                                                                              |  GET_EXCEPTION  |
1104514f5e3Sopenharmony_ci//                                                                              +-----------------+
1114514f5e3Sopenharmony_ci
1124514f5e3Sopenharmony_ciclass SlowPathLowering {
1134514f5e3Sopenharmony_cipublic:
1144514f5e3Sopenharmony_ci    SlowPathLowering(Circuit *circuit, CompilationConfig *cmpCfg,
1154514f5e3Sopenharmony_ci                     PassContext *ctx, const MethodLiteral *methodLiteral,
1164514f5e3Sopenharmony_ci                     bool enableLog, const std::string& name)
1174514f5e3Sopenharmony_ci        : compilationEnv_(ctx->GetCompilationEnv()), methodLiteral_(methodLiteral),
1184514f5e3Sopenharmony_ci          circuit_(circuit), acc_(circuit),
1194514f5e3Sopenharmony_ci          argAcc_(circuit), builder_(circuit, cmpCfg),
1204514f5e3Sopenharmony_ci          enableLog_(enableLog), methodName_(name), glue_(acc_.GetGlueFromArgList())
1214514f5e3Sopenharmony_ci    {
1224514f5e3Sopenharmony_ci        traceBc_ = cmpCfg->IsTraceBC();
1234514f5e3Sopenharmony_ci        profiling_ = cmpCfg->IsProfiling();
1244514f5e3Sopenharmony_ci        stressDeopt_ = cmpCfg->IsStressDeopt();
1254514f5e3Sopenharmony_ci    }
1264514f5e3Sopenharmony_ci    ~SlowPathLowering() = default;
1274514f5e3Sopenharmony_ci    void CallRuntimeLowering();
1284514f5e3Sopenharmony_ci
1294514f5e3Sopenharmony_ci    bool IsLogEnabled() const
1304514f5e3Sopenharmony_ci    {
1314514f5e3Sopenharmony_ci        return enableLog_;
1324514f5e3Sopenharmony_ci    }
1334514f5e3Sopenharmony_ci
1344514f5e3Sopenharmony_ci    bool IsTraceBC() const
1354514f5e3Sopenharmony_ci    {
1364514f5e3Sopenharmony_ci        return traceBc_;
1374514f5e3Sopenharmony_ci    }
1384514f5e3Sopenharmony_ci
1394514f5e3Sopenharmony_ci    bool IsProfiling() const
1404514f5e3Sopenharmony_ci    {
1414514f5e3Sopenharmony_ci        return profiling_;
1424514f5e3Sopenharmony_ci    }
1434514f5e3Sopenharmony_ci
1444514f5e3Sopenharmony_ci    bool IsStressDeopt() const
1454514f5e3Sopenharmony_ci    {
1464514f5e3Sopenharmony_ci        return stressDeopt_;
1474514f5e3Sopenharmony_ci    }
1484514f5e3Sopenharmony_ci
1494514f5e3Sopenharmony_ciprivate:
1504514f5e3Sopenharmony_ci    const std::string& GetMethodName() const
1514514f5e3Sopenharmony_ci    {
1524514f5e3Sopenharmony_ci        return methodName_;
1534514f5e3Sopenharmony_ci    }
1544514f5e3Sopenharmony_ci
1554514f5e3Sopenharmony_ci    void ReplaceHirWithPendingException(GateRef hirGate, GateRef state, GateRef depend, GateRef value);
1564514f5e3Sopenharmony_ci    void ReplaceHirWithValue(GateRef hirGate, GateRef value, bool noThrow = false);
1574514f5e3Sopenharmony_ci    void ReplaceHirToThrowCall(GateRef hirGate, GateRef callGate);
1584514f5e3Sopenharmony_ci    void LowerExceptionHandler(GateRef hirGate);
1594514f5e3Sopenharmony_ci    void Lower(GateRef gate);
1604514f5e3Sopenharmony_ci    void LowerAdd2(GateRef gate);
1614514f5e3Sopenharmony_ci    void LowerCreateIterResultObj(GateRef gate);
1624514f5e3Sopenharmony_ci    void SaveFrameToContext(GateRef gate);
1634514f5e3Sopenharmony_ci    void LowerSuspendGenerator(GateRef gate);
1644514f5e3Sopenharmony_ci    void LowerAsyncFunctionAwaitUncaught(GateRef gate);
1654514f5e3Sopenharmony_ci    void LowerAsyncFunctionResolve(GateRef gate);
1664514f5e3Sopenharmony_ci    void LowerAsyncFunctionReject(GateRef gate);
1674514f5e3Sopenharmony_ci    void LowerStGlobalVar(GateRef gate);
1684514f5e3Sopenharmony_ci    void LowerTryLdGlobalByName(GateRef gate);
1694514f5e3Sopenharmony_ci    void LowerGetIterator(GateRef gate);
1704514f5e3Sopenharmony_ci    void LowerGetAsyncIterator(GateRef gate);
1714514f5e3Sopenharmony_ci    void LowerToJSCall(GateRef hirGate, const std::vector<GateRef> &args, const std::vector<GateRef> &argsFastCall);
1724514f5e3Sopenharmony_ci    void LowerFastCall(GateRef gate, GateRef glue, GateRef func, GateRef argc, const std::vector<GateRef> &args,
1734514f5e3Sopenharmony_ci        const std::vector<GateRef> &fastCallArgs, Variable *result, Label *exit, bool isNew);
1744514f5e3Sopenharmony_ci    void LowerNewFastCall(GateRef gate, GateRef glue, GateRef func, bool needPushArgv,
1754514f5e3Sopenharmony_ci        const std::vector<GateRef> &args, const std::vector<GateRef> &fastCallArgs,
1764514f5e3Sopenharmony_ci        Variable *result, Label *exit);
1774514f5e3Sopenharmony_ci    void LowerCallArg0(GateRef gate);
1784514f5e3Sopenharmony_ci    void LowerCallArg1Imm8V8(GateRef gate);
1794514f5e3Sopenharmony_ci    void LowerCallThisArg1(GateRef gate);
1804514f5e3Sopenharmony_ci    void LowerCallargs2Imm8V8V8(GateRef gate);
1814514f5e3Sopenharmony_ci    void LowerCallthis2Imm8V8V8V8(GateRef gate);
1824514f5e3Sopenharmony_ci    void LowerCallthis0Imm8V8(GateRef gate);
1834514f5e3Sopenharmony_ci    void LowerCallargs3Imm8V8V8(GateRef gate);
1844514f5e3Sopenharmony_ci    void LowerCallthis3Imm8V8V8V8V8(GateRef gate);
1854514f5e3Sopenharmony_ci    void LowerCallthisrangeImm8Imm8V8(GateRef gate);
1864514f5e3Sopenharmony_ci    void LowerWideCallthisrangePrefImm16V8(GateRef gate);
1874514f5e3Sopenharmony_ci    void LowerCallSpread(GateRef gate);
1884514f5e3Sopenharmony_ci    void LowerCallrangeImm8Imm8V8(GateRef gate);
1894514f5e3Sopenharmony_ci    void LowerWideCallrangePrefImm16V8(GateRef gate);
1904514f5e3Sopenharmony_ci    void LowerNewObjApply(GateRef gate);
1914514f5e3Sopenharmony_ci    void LowerThrow(GateRef gate);
1924514f5e3Sopenharmony_ci    void LowerThrowConstAssignment(GateRef gate);
1934514f5e3Sopenharmony_ci    void LowerThrowThrowNotExists(GateRef gate);
1944514f5e3Sopenharmony_ci    void LowerThrowPatternNonCoercible(GateRef gate);
1954514f5e3Sopenharmony_ci    void LowerThrowIfNotObject(GateRef gate);
1964514f5e3Sopenharmony_ci    void LowerThrowUndefinedIfHole(GateRef gate);
1974514f5e3Sopenharmony_ci    void LowerThrowUndefinedIfHoleWithName(GateRef Getgate);
1984514f5e3Sopenharmony_ci    void LowerThrowIfSuperNotCorrectCall(GateRef gate);
1994514f5e3Sopenharmony_ci    void LowerThrowDeleteSuperProperty(GateRef gate);
2004514f5e3Sopenharmony_ci    void LowerLdSymbol(GateRef gate);
2014514f5e3Sopenharmony_ci    void LowerLdGlobal(GateRef gate);
2024514f5e3Sopenharmony_ci    void LowerSub2(GateRef gate);
2034514f5e3Sopenharmony_ci    void LowerMul2(GateRef gate);
2044514f5e3Sopenharmony_ci    void LowerDiv2(GateRef gate);
2054514f5e3Sopenharmony_ci    void LowerMod2(GateRef gate);
2064514f5e3Sopenharmony_ci    void LowerEq(GateRef gate);
2074514f5e3Sopenharmony_ci    void LowerNotEq(GateRef gate);
2084514f5e3Sopenharmony_ci    void LowerLess(GateRef gate);
2094514f5e3Sopenharmony_ci    void LowerLessEq(GateRef gate);
2104514f5e3Sopenharmony_ci    void LowerGreater(GateRef gate);
2114514f5e3Sopenharmony_ci    void LowerGreaterEq(GateRef gate);
2124514f5e3Sopenharmony_ci    void LowerGetPropIterator(GateRef gate);
2134514f5e3Sopenharmony_ci    void LowerCloseIterator(GateRef gate);
2144514f5e3Sopenharmony_ci    void LowerInc(GateRef gate);
2154514f5e3Sopenharmony_ci    void LowerDec(GateRef gate);
2164514f5e3Sopenharmony_ci    void LowerToNumber(GateRef gate);
2174514f5e3Sopenharmony_ci    void LowerNeg(GateRef gate);
2184514f5e3Sopenharmony_ci    void LowerNot(GateRef gate);
2194514f5e3Sopenharmony_ci    void LowerShl2(GateRef gate);
2204514f5e3Sopenharmony_ci    void LowerShr2(GateRef gate);
2214514f5e3Sopenharmony_ci    void LowerAshr2(GateRef gate);
2224514f5e3Sopenharmony_ci    void LowerAnd2(GateRef gate);
2234514f5e3Sopenharmony_ci    void LowerOr2(GateRef gate);
2244514f5e3Sopenharmony_ci    void LowerXor2(GateRef gate);
2254514f5e3Sopenharmony_ci    void LowerDelObjProp(GateRef gate);
2264514f5e3Sopenharmony_ci    void LowerExp(GateRef gate);
2274514f5e3Sopenharmony_ci    void LowerIsIn(GateRef gate);
2284514f5e3Sopenharmony_ci    void LowerInstanceof(GateRef gate);
2294514f5e3Sopenharmony_ci    void LowerFastStrictNotEqual(GateRef gate);
2304514f5e3Sopenharmony_ci    void LowerFastStrictEqual(GateRef gate);
2314514f5e3Sopenharmony_ci    void LowerCreateEmptyArray(GateRef gate);
2324514f5e3Sopenharmony_ci    void LowerCreateEmptyObject(GateRef gate);
2334514f5e3Sopenharmony_ci    void LowerCreateArrayWithBuffer(GateRef gate);
2344514f5e3Sopenharmony_ci    void LowerCreateObjectWithBuffer(GateRef gate);
2354514f5e3Sopenharmony_ci    void LowerStModuleVar(GateRef gate);
2364514f5e3Sopenharmony_ci    void LowerGetTemplateObject(GateRef gate);
2374514f5e3Sopenharmony_ci    void LowerSetObjectWithProto(GateRef gate);
2384514f5e3Sopenharmony_ci    void LowerLdBigInt(GateRef gate);
2394514f5e3Sopenharmony_ci    void LowerToNumeric(GateRef gate);
2404514f5e3Sopenharmony_ci    void LowerDynamicImport(GateRef gate);
2414514f5e3Sopenharmony_ci    void LowerLdLocalModuleVarByIndex(GateRef gate);
2424514f5e3Sopenharmony_ci    void LowerExternalModule(GateRef gate);
2434514f5e3Sopenharmony_ci    void LowerGetModuleNamespace(GateRef gate);
2444514f5e3Sopenharmony_ci    void LowerSendableExternalModule(GateRef gate);
2454514f5e3Sopenharmony_ci    void LowerSuperCall(GateRef gate);
2464514f5e3Sopenharmony_ci    void LowerSuperCallArrow(GateRef gate);
2474514f5e3Sopenharmony_ci    void LowerSuperCallSpread(GateRef gate);
2484514f5e3Sopenharmony_ci    void LowerSuperCallForwardAllArgs(GateRef gate);
2494514f5e3Sopenharmony_ci    void CheckSuperAndNewTarget(NewObjectStubBuilder &objBuilder, GateRef super, Variable &newTarget,
2504514f5e3Sopenharmony_ci                                Variable &thisObj, Label &fastPath, Label &slowPath);
2514514f5e3Sopenharmony_ci    void CallNGCRuntimeWithCallTimer(int index, GateRef gate, GateRef func, Variable &result,
2524514f5e3Sopenharmony_ci                                     const std::vector<GateRef> &args);
2534514f5e3Sopenharmony_ci    GateRef IsAotOrFastCall(GateRef func, CircuitBuilder::JudgeMethodType type);
2544514f5e3Sopenharmony_ci    void LowerFastSuperCallWithArgArray(GateRef array, const std::vector<GateRef> &args, bool isSpread,
2554514f5e3Sopenharmony_ci                                        Variable &result, Label &exit);
2564514f5e3Sopenharmony_ci    void LowerFastSuperCall(const std::vector<GateRef> &args, GateRef elementsPtr,
2574514f5e3Sopenharmony_ci                            Variable &result, Label &exit);
2584514f5e3Sopenharmony_ci    void GenerateSuperCallForwardAllArgsWithoutArgv(const std::vector<GateRef> &args, Variable &result, Label &exit);
2594514f5e3Sopenharmony_ci    void LowerIsTrueOrFalse(GateRef gate, bool flag);
2604514f5e3Sopenharmony_ci    void LowerNewObjRange(GateRef gate);
2614514f5e3Sopenharmony_ci    bool IsDependIfStateMent(GateRef gate, size_t idx);
2624514f5e3Sopenharmony_ci    void LowerConditionJump(GateRef gate, bool isEqualJump);
2634514f5e3Sopenharmony_ci    void LowerGetNextPropName(GateRef gate);
2644514f5e3Sopenharmony_ci    void LowerCopyDataProperties(GateRef gate);
2654514f5e3Sopenharmony_ci    void LowerCreateObjectWithExcludedKeys(GateRef gate);
2664514f5e3Sopenharmony_ci    void LowerCreateRegExpWithLiteral(GateRef gate);
2674514f5e3Sopenharmony_ci    void LowerStOwnByValue(GateRef gate);
2684514f5e3Sopenharmony_ci    void LowerStOwnByIndex(GateRef gate);
2694514f5e3Sopenharmony_ci    void LowerStOwnByName(GateRef gate);
2704514f5e3Sopenharmony_ci    void LowerDefineFunc(GateRef gate);
2714514f5e3Sopenharmony_ci    void LowerNewLexicalEnv(GateRef gate);
2724514f5e3Sopenharmony_ci    void LowerNewLexicalEnvWithName(GateRef gate);
2734514f5e3Sopenharmony_ci    void LowerNewSendableEnv(GateRef gate);
2744514f5e3Sopenharmony_ci    void LowerPopLexicalEnv(GateRef gate);
2754514f5e3Sopenharmony_ci    void LowerLdSuperByValue(GateRef gate);
2764514f5e3Sopenharmony_ci    void LowerStSuperByValue(GateRef gate);
2774514f5e3Sopenharmony_ci    void LowerTryStGlobalByName(GateRef gate);
2784514f5e3Sopenharmony_ci    void LowerStConstToGlobalRecord(GateRef gate, bool isConst);
2794514f5e3Sopenharmony_ci    void LowerStOwnByValueWithNameSet(GateRef gate);
2804514f5e3Sopenharmony_ci    void LowerStOwnByNameWithNameSet(GateRef gate);
2814514f5e3Sopenharmony_ci    void LowerLdGlobalVar(GateRef gate);
2824514f5e3Sopenharmony_ci    void LowerLdObjByName(GateRef gate);
2834514f5e3Sopenharmony_ci    void LowerStObjByName(GateRef gate, bool isThis);
2844514f5e3Sopenharmony_ci    void LowerLdSuperByName(GateRef gate);
2854514f5e3Sopenharmony_ci    void LowerStSuperByName(GateRef gate);
2864514f5e3Sopenharmony_ci    void LowerDefineGetterSetterByValue(GateRef gate);
2874514f5e3Sopenharmony_ci    void LowerLdObjByIndex(GateRef gate);
2884514f5e3Sopenharmony_ci    void LowerStObjByIndex(GateRef gate);
2894514f5e3Sopenharmony_ci    void LowerLdObjByValue(GateRef gate, bool isThis);
2904514f5e3Sopenharmony_ci    void LowerStObjByValue(GateRef gate, bool isThis);
2914514f5e3Sopenharmony_ci    void LowerCreateGeneratorObj(GateRef gate);
2924514f5e3Sopenharmony_ci    void LowerStArraySpread(GateRef gate);
2934514f5e3Sopenharmony_ci    void LowerLdLexVar(GateRef gate);
2944514f5e3Sopenharmony_ci    void LowerLdSendableVar(GateRef gate);
2954514f5e3Sopenharmony_ci    void LowerStLexVar(GateRef gate);
2964514f5e3Sopenharmony_ci    void LowerStSendableVar(GateRef gate);
2974514f5e3Sopenharmony_ci    void LowerDefineClassWithBuffer(GateRef gate);
2984514f5e3Sopenharmony_ci    void LowerAsyncFunctionEnter(GateRef gate);
2994514f5e3Sopenharmony_ci    void LowerTypeof(GateRef gate);
3004514f5e3Sopenharmony_ci    void LowerResumeGenerator(GateRef gate);
3014514f5e3Sopenharmony_ci    void LowerStoreRegister(GateRef gate, GateRef arrayGate);
3024514f5e3Sopenharmony_ci    void LowerGetResumeMode(GateRef gate);
3034514f5e3Sopenharmony_ci    void LowerDefineMethod(GateRef gate);
3044514f5e3Sopenharmony_ci    void LowerGetUnmappedArgs(GateRef gate);
3054514f5e3Sopenharmony_ci    void LowerCopyRestArgs(GateRef gate);
3064514f5e3Sopenharmony_ci    void LowerCallStubWithIC(GateRef gate, int sign, const std::vector<GateRef> &args);
3074514f5e3Sopenharmony_ci    GateRef LowerCallRuntime(GateRef gate, int index, const std::vector<GateRef> &args, bool useLabel = false);
3084514f5e3Sopenharmony_ci    GateRef LowerCallNGCRuntime(GateRef gate, int index, const std::vector<GateRef> &args, bool useLabel = false);
3094514f5e3Sopenharmony_ci    void LowerCreateAsyncGeneratorObj(GateRef gate);
3104514f5e3Sopenharmony_ci    void LowerAsyncGeneratorResolve(GateRef gate);
3114514f5e3Sopenharmony_ci    void LowerAsyncGeneratorReject(GateRef gate);
3124514f5e3Sopenharmony_ci    void LowerSetGeneratorState(GateRef gate);
3134514f5e3Sopenharmony_ci    GateRef GetValueFromTaggedArray(GateRef arrayGate, GateRef indexOffset);
3144514f5e3Sopenharmony_ci    GateRef GetTaggedArrayFromValueIn(Environment *env, GateRef gate, size_t length);
3154514f5e3Sopenharmony_ci    GateRef LowerUpdateArrayHClassAtDefine(GateRef gate, GateRef array);
3164514f5e3Sopenharmony_ci    void AddProfiling(GateRef gate, bool skipGenerator = true);
3174514f5e3Sopenharmony_ci    GateRef FastStrictEqual(GateRef left, GateRef right);
3184514f5e3Sopenharmony_ci    void LowerWideLdPatchVar(GateRef gate);
3194514f5e3Sopenharmony_ci    void LowerWideStPatchVar(GateRef gate);
3204514f5e3Sopenharmony_ci    void LowerLdThisByName(GateRef gate);
3214514f5e3Sopenharmony_ci    bool IsFastCallArgs(size_t index);
3224514f5e3Sopenharmony_ci    void LowerConstruct(GateRef gate);
3234514f5e3Sopenharmony_ci    void LowerCallInternal(GateRef gate);
3244514f5e3Sopenharmony_ci    void LowerCallNew(GateRef gate);
3254514f5e3Sopenharmony_ci    void LowerTypedCall(GateRef gate);
3264514f5e3Sopenharmony_ci    void LowerTypedFastCall(GateRef gate);
3274514f5e3Sopenharmony_ci    void LowerCheckSafePointAndStackOver(GateRef gate);
3284514f5e3Sopenharmony_ci    void LowerLdPrivateProperty(GateRef gate);
3294514f5e3Sopenharmony_ci    void LowerStPrivateProperty(GateRef gate);
3304514f5e3Sopenharmony_ci    void LowerTestIn(GateRef gate);
3314514f5e3Sopenharmony_ci    void LowerNotifyConcurrentResult(GateRef gate);
3324514f5e3Sopenharmony_ci    void LowerDefineFieldByName(GateRef gate);
3334514f5e3Sopenharmony_ci    void LowerDefineFieldByValue(GateRef gate);
3344514f5e3Sopenharmony_ci    void LowerDefineFieldByIndex(GateRef gate);
3354514f5e3Sopenharmony_ci    void LowerToPropertyKey(GateRef gate);
3364514f5e3Sopenharmony_ci    void LowerCreatePrivateProperty(GateRef gate);
3374514f5e3Sopenharmony_ci    void LowerDefinePrivateProperty(GateRef gate);
3384514f5e3Sopenharmony_ci    void LowerCallInit(GateRef gate);
3394514f5e3Sopenharmony_ci    void LowerDefineSendableClass(GateRef gate);
3404514f5e3Sopenharmony_ci    void LowerLdSendableClass(GateRef gate);
3414514f5e3Sopenharmony_ci    void LowerGetEnv(GateRef gate);
3424514f5e3Sopenharmony_ci    void DeleteLoopExit(GateRef gate);
3434514f5e3Sopenharmony_ci    void DeleteLoopExitValue(GateRef gate);
3444514f5e3Sopenharmony_ci    void LowerLdStr(GateRef gate);
3454514f5e3Sopenharmony_ci    void LowerGetSharedConstPool(GateRef gate);
3464514f5e3Sopenharmony_ci    void LowerGetUnsharedConstPool(GateRef gate);
3474514f5e3Sopenharmony_ci    void LowerLdLazyExternalModuleVar(GateRef gate);
3484514f5e3Sopenharmony_ci    void LowerLdLazySendableExternalModuleVar(GateRef gate);
3494514f5e3Sopenharmony_ci
3504514f5e3Sopenharmony_ci    CompilationEnv *compilationEnv_;
3514514f5e3Sopenharmony_ci    const MethodLiteral *methodLiteral_ {nullptr};
3524514f5e3Sopenharmony_ci    Circuit *circuit_;
3534514f5e3Sopenharmony_ci    GateAccessor acc_;
3544514f5e3Sopenharmony_ci    ArgumentAccessor argAcc_;
3554514f5e3Sopenharmony_ci    CircuitBuilder builder_;
3564514f5e3Sopenharmony_ci    bool enableLog_ {false};
3574514f5e3Sopenharmony_ci    bool traceBc_ {false};
3584514f5e3Sopenharmony_ci    bool profiling_ {false};
3594514f5e3Sopenharmony_ci    bool stressDeopt_ {false};
3604514f5e3Sopenharmony_ci    std::string methodName_;
3614514f5e3Sopenharmony_ci    GateRef glue_ {Circuit::NullGate()};
3624514f5e3Sopenharmony_ci    CVector<GateRef> unsharedCP_;
3634514f5e3Sopenharmony_ci};
3644514f5e3Sopenharmony_ci}  // panda::ecmascript::kungfu
3654514f5e3Sopenharmony_ci#endif  // ECMASCRIPT_COMPILER_SLOWPATH_LOWERING_H
366