14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2022 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/operations_stub_builder.h" 174514f5e3Sopenharmony_ci#include "ecmascript/compiler/interpreter_stub-inl.h" 184514f5e3Sopenharmony_ci#include "ecmascript/compiler/rt_call_signature.h" 194514f5e3Sopenharmony_ci#include "ecmascript/compiler/stub_builder-inl.h" 204514f5e3Sopenharmony_ci 214514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu { 224514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Equal(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 234514f5e3Sopenharmony_ci{ 244514f5e3Sopenharmony_ci auto env = GetEnvironment(); 254514f5e3Sopenharmony_ci Label entry(env); 264514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 274514f5e3Sopenharmony_ci Label exit(env); 284514f5e3Sopenharmony_ci Label isHole(env); 294514f5e3Sopenharmony_ci Label notHole(env); 304514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 314514f5e3Sopenharmony_ci result = FastEqual(glue, left, right, callback); 324514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &isHole, ¬Hole); 334514f5e3Sopenharmony_ci Bind(&isHole); 344514f5e3Sopenharmony_ci { 354514f5e3Sopenharmony_ci // slow path 364514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Eq), { left, right }); 374514f5e3Sopenharmony_ci Jump(&exit); 384514f5e3Sopenharmony_ci } 394514f5e3Sopenharmony_ci Bind(¬Hole); 404514f5e3Sopenharmony_ci { 414514f5e3Sopenharmony_ci Label resultIsTrue(env); 424514f5e3Sopenharmony_ci Label resultNotTrue(env); 434514f5e3Sopenharmony_ci BRANCH(TaggedIsTrue(*result), &resultIsTrue, &resultNotTrue); 444514f5e3Sopenharmony_ci Bind(&resultIsTrue); 454514f5e3Sopenharmony_ci { 464514f5e3Sopenharmony_ci callback.ProfileBranch(true); 474514f5e3Sopenharmony_ci Jump(&exit); 484514f5e3Sopenharmony_ci } 494514f5e3Sopenharmony_ci Bind(&resultNotTrue); 504514f5e3Sopenharmony_ci { 514514f5e3Sopenharmony_ci callback.ProfileBranch(false); 524514f5e3Sopenharmony_ci Jump(&exit); 534514f5e3Sopenharmony_ci } 544514f5e3Sopenharmony_ci } 554514f5e3Sopenharmony_ci Bind(&exit); 564514f5e3Sopenharmony_ci auto ret = *result; 574514f5e3Sopenharmony_ci env->SubCfgExit(); 584514f5e3Sopenharmony_ci return ret; 594514f5e3Sopenharmony_ci} 604514f5e3Sopenharmony_ci 614514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::NotEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 624514f5e3Sopenharmony_ci{ 634514f5e3Sopenharmony_ci auto env = GetEnvironment(); 644514f5e3Sopenharmony_ci Label entry(env); 654514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 664514f5e3Sopenharmony_ci Label exit(env); 674514f5e3Sopenharmony_ci 684514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 694514f5e3Sopenharmony_ci result = FastEqual(glue, left, right, callback); 704514f5e3Sopenharmony_ci Label isHole(env); 714514f5e3Sopenharmony_ci Label notHole(env); 724514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &isHole, ¬Hole); 734514f5e3Sopenharmony_ci Bind(&isHole); 744514f5e3Sopenharmony_ci { 754514f5e3Sopenharmony_ci // slow path 764514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(NotEq), { left, right }); 774514f5e3Sopenharmony_ci Jump(&exit); 784514f5e3Sopenharmony_ci } 794514f5e3Sopenharmony_ci Bind(¬Hole); 804514f5e3Sopenharmony_ci { 814514f5e3Sopenharmony_ci Label resultIsTrue(env); 824514f5e3Sopenharmony_ci Label resultNotTrue(env); 834514f5e3Sopenharmony_ci BRANCH(TaggedIsTrue(*result), &resultIsTrue, &resultNotTrue); 844514f5e3Sopenharmony_ci Bind(&resultIsTrue); 854514f5e3Sopenharmony_ci { 864514f5e3Sopenharmony_ci result = TaggedFalse(); 874514f5e3Sopenharmony_ci callback.ProfileBranch(false); 884514f5e3Sopenharmony_ci Jump(&exit); 894514f5e3Sopenharmony_ci } 904514f5e3Sopenharmony_ci Bind(&resultNotTrue); 914514f5e3Sopenharmony_ci { 924514f5e3Sopenharmony_ci callback.ProfileBranch(true); 934514f5e3Sopenharmony_ci result = TaggedTrue(); 944514f5e3Sopenharmony_ci Jump(&exit); 954514f5e3Sopenharmony_ci } 964514f5e3Sopenharmony_ci } 974514f5e3Sopenharmony_ci Bind(&exit); 984514f5e3Sopenharmony_ci auto ret = *result; 994514f5e3Sopenharmony_ci env->SubCfgExit(); 1004514f5e3Sopenharmony_ci return ret; 1014514f5e3Sopenharmony_ci} 1024514f5e3Sopenharmony_ci 1034514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::StrictEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 1044514f5e3Sopenharmony_ci{ 1054514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1064514f5e3Sopenharmony_ci Label entry(env); 1074514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 1084514f5e3Sopenharmony_ci Label exit(env); 1094514f5e3Sopenharmony_ci Label strictEqual(env); 1104514f5e3Sopenharmony_ci Label notStrictEqual(env); 1114514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), TaggedTrue()); 1124514f5e3Sopenharmony_ci BRANCH(FastStrictEqual(glue, left, right, callback), &strictEqual, ¬StrictEqual); 1134514f5e3Sopenharmony_ci Bind(&strictEqual); 1144514f5e3Sopenharmony_ci { 1154514f5e3Sopenharmony_ci callback.ProfileBranch(true); 1164514f5e3Sopenharmony_ci Jump(&exit); 1174514f5e3Sopenharmony_ci } 1184514f5e3Sopenharmony_ci Bind(¬StrictEqual); 1194514f5e3Sopenharmony_ci { 1204514f5e3Sopenharmony_ci result = TaggedFalse(); 1214514f5e3Sopenharmony_ci callback.ProfileBranch(false); 1224514f5e3Sopenharmony_ci Jump(&exit); 1234514f5e3Sopenharmony_ci } 1244514f5e3Sopenharmony_ci Bind(&exit); 1254514f5e3Sopenharmony_ci auto ret = *result; 1264514f5e3Sopenharmony_ci env->SubCfgExit(); 1274514f5e3Sopenharmony_ci return ret; 1284514f5e3Sopenharmony_ci} 1294514f5e3Sopenharmony_ci 1304514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::StrictNotEqual(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 1314514f5e3Sopenharmony_ci{ 1324514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1334514f5e3Sopenharmony_ci Label entry(env); 1344514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 1354514f5e3Sopenharmony_ci Label exit(env); 1364514f5e3Sopenharmony_ci Label strictEqual(env); 1374514f5e3Sopenharmony_ci Label notStrictEqual(env); 1384514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), TaggedTrue()); 1394514f5e3Sopenharmony_ci BRANCH(FastStrictEqual(glue, left, right, callback), &strictEqual, ¬StrictEqual); 1404514f5e3Sopenharmony_ci Bind(&strictEqual); 1414514f5e3Sopenharmony_ci { 1424514f5e3Sopenharmony_ci result = TaggedFalse(); 1434514f5e3Sopenharmony_ci callback.ProfileBranch(false); 1444514f5e3Sopenharmony_ci Jump(&exit); 1454514f5e3Sopenharmony_ci } 1464514f5e3Sopenharmony_ci Bind(¬StrictEqual); 1474514f5e3Sopenharmony_ci { 1484514f5e3Sopenharmony_ci callback.ProfileBranch(true); 1494514f5e3Sopenharmony_ci Jump(&exit); 1504514f5e3Sopenharmony_ci } 1514514f5e3Sopenharmony_ci Bind(&exit); 1524514f5e3Sopenharmony_ci auto ret = *result; 1534514f5e3Sopenharmony_ci env->SubCfgExit(); 1544514f5e3Sopenharmony_ci return ret; 1554514f5e3Sopenharmony_ci} 1564514f5e3Sopenharmony_ci 1574514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Less(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 1584514f5e3Sopenharmony_ci{ 1594514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1604514f5e3Sopenharmony_ci Label entry(env); 1614514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 1624514f5e3Sopenharmony_ci Label exit(env); 1634514f5e3Sopenharmony_ci Label leftIsInt(env); 1644514f5e3Sopenharmony_ci Label leftOrRightNotInt(env); 1654514f5e3Sopenharmony_ci Label leftLessRight(env); 1664514f5e3Sopenharmony_ci Label leftNotLessRight(env); 1674514f5e3Sopenharmony_ci Label slowPath(env); 1684514f5e3Sopenharmony_ci 1694514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 1704514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftOrRightNotInt); 1714514f5e3Sopenharmony_ci Bind(&leftIsInt); 1724514f5e3Sopenharmony_ci { 1734514f5e3Sopenharmony_ci Label rightIsInt(env); 1744514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &leftOrRightNotInt); 1754514f5e3Sopenharmony_ci Bind(&rightIsInt); 1764514f5e3Sopenharmony_ci { 1774514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 1784514f5e3Sopenharmony_ci GateRef intLeft = TaggedGetInt(left); 1794514f5e3Sopenharmony_ci GateRef intRight = TaggedGetInt(right); 1804514f5e3Sopenharmony_ci BRANCH(Int32LessThan(intLeft, intRight), &leftLessRight, &leftNotLessRight); 1814514f5e3Sopenharmony_ci } 1824514f5e3Sopenharmony_ci } 1834514f5e3Sopenharmony_ci Bind(&leftOrRightNotInt); 1844514f5e3Sopenharmony_ci { 1854514f5e3Sopenharmony_ci Label leftIsNumber(env); 1864514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &slowPath); 1874514f5e3Sopenharmony_ci Bind(&leftIsNumber); 1884514f5e3Sopenharmony_ci { 1894514f5e3Sopenharmony_ci Label rightIsNumber(env); 1904514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &slowPath); 1914514f5e3Sopenharmony_ci Bind(&rightIsNumber); 1924514f5e3Sopenharmony_ci { 1934514f5e3Sopenharmony_ci // fast path 1944514f5e3Sopenharmony_ci DEFVARIABLE(doubleLeft, VariableType::FLOAT64(), Double(0)); 1954514f5e3Sopenharmony_ci DEFVARIABLE(doubleRight, VariableType::FLOAT64(), Double(0)); 1964514f5e3Sopenharmony_ci DEFVARIABLE(curType, VariableType::INT64(), TaggedInt(PGOSampleType::IntType())); 1974514f5e3Sopenharmony_ci Label leftIsInt1(env); 1984514f5e3Sopenharmony_ci Label leftNotInt1(env); 1994514f5e3Sopenharmony_ci Label exit1(env); 2004514f5e3Sopenharmony_ci Label exit2(env); 2014514f5e3Sopenharmony_ci Label rightIsInt1(env); 2024514f5e3Sopenharmony_ci Label rightNotInt1(env); 2034514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt1, &leftNotInt1); 2044514f5e3Sopenharmony_ci Bind(&leftIsInt1); 2054514f5e3Sopenharmony_ci { 2064514f5e3Sopenharmony_ci doubleLeft = ChangeInt32ToFloat64(TaggedGetInt(left)); 2074514f5e3Sopenharmony_ci Jump(&exit1); 2084514f5e3Sopenharmony_ci } 2094514f5e3Sopenharmony_ci Bind(&leftNotInt1); 2104514f5e3Sopenharmony_ci { 2114514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::DoubleType()); 2124514f5e3Sopenharmony_ci doubleLeft = GetDoubleOfTDouble(left); 2134514f5e3Sopenharmony_ci Jump(&exit1); 2144514f5e3Sopenharmony_ci } 2154514f5e3Sopenharmony_ci Bind(&exit1); 2164514f5e3Sopenharmony_ci { 2174514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt1, &rightNotInt1); 2184514f5e3Sopenharmony_ci } 2194514f5e3Sopenharmony_ci Bind(&rightIsInt1); 2204514f5e3Sopenharmony_ci { 2214514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::IntType()); 2224514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 2234514f5e3Sopenharmony_ci doubleRight = ChangeInt32ToFloat64(TaggedGetInt(right)); 2244514f5e3Sopenharmony_ci Jump(&exit2); 2254514f5e3Sopenharmony_ci } 2264514f5e3Sopenharmony_ci Bind(&rightNotInt1); 2274514f5e3Sopenharmony_ci { 2284514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::DoubleType()); 2294514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 2304514f5e3Sopenharmony_ci doubleRight = GetDoubleOfTDouble(right); 2314514f5e3Sopenharmony_ci Jump(&exit2); 2324514f5e3Sopenharmony_ci } 2334514f5e3Sopenharmony_ci Bind(&exit2); 2344514f5e3Sopenharmony_ci { 2354514f5e3Sopenharmony_ci BRANCH(DoubleLessThan(*doubleLeft, *doubleRight), &leftLessRight, &leftNotLessRight); 2364514f5e3Sopenharmony_ci } 2374514f5e3Sopenharmony_ci } 2384514f5e3Sopenharmony_ci } 2394514f5e3Sopenharmony_ci } 2404514f5e3Sopenharmony_ci Bind(&leftLessRight); 2414514f5e3Sopenharmony_ci { 2424514f5e3Sopenharmony_ci callback.ProfileBranch(true); 2434514f5e3Sopenharmony_ci result = TaggedTrue(); 2444514f5e3Sopenharmony_ci Jump(&exit); 2454514f5e3Sopenharmony_ci } 2464514f5e3Sopenharmony_ci Bind(&leftNotLessRight); 2474514f5e3Sopenharmony_ci { 2484514f5e3Sopenharmony_ci callback.ProfileBranch(false); 2494514f5e3Sopenharmony_ci result = TaggedFalse(); 2504514f5e3Sopenharmony_ci Jump(&exit); 2514514f5e3Sopenharmony_ci } 2524514f5e3Sopenharmony_ci Bind(&slowPath); 2534514f5e3Sopenharmony_ci { 2544514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 2554514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Less), { left, right }); 2564514f5e3Sopenharmony_ci Jump(&exit); 2574514f5e3Sopenharmony_ci } 2584514f5e3Sopenharmony_ci Bind(&exit); 2594514f5e3Sopenharmony_ci auto ret = *result; 2604514f5e3Sopenharmony_ci env->SubCfgExit(); 2614514f5e3Sopenharmony_ci return ret; 2624514f5e3Sopenharmony_ci} 2634514f5e3Sopenharmony_ci 2644514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::LessEq(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 2654514f5e3Sopenharmony_ci{ 2664514f5e3Sopenharmony_ci auto env = GetEnvironment(); 2674514f5e3Sopenharmony_ci Label entry(env); 2684514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 2694514f5e3Sopenharmony_ci Label exit(env); 2704514f5e3Sopenharmony_ci Label leftIsInt(env); 2714514f5e3Sopenharmony_ci Label leftOrRightNotInt(env); 2724514f5e3Sopenharmony_ci Label leftLessEqRight(env); 2734514f5e3Sopenharmony_ci Label leftNotLessEqRight(env); 2744514f5e3Sopenharmony_ci Label slowPath(env); 2754514f5e3Sopenharmony_ci 2764514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 2774514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftOrRightNotInt); 2784514f5e3Sopenharmony_ci Bind(&leftIsInt); 2794514f5e3Sopenharmony_ci { 2804514f5e3Sopenharmony_ci Label rightIsInt(env); 2814514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &leftOrRightNotInt); 2824514f5e3Sopenharmony_ci Bind(&rightIsInt); 2834514f5e3Sopenharmony_ci { 2844514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 2854514f5e3Sopenharmony_ci GateRef intLeft = TaggedGetInt(left); 2864514f5e3Sopenharmony_ci GateRef intRight = TaggedGetInt(right); 2874514f5e3Sopenharmony_ci BRANCH(Int32LessThanOrEqual(intLeft, intRight), &leftLessEqRight, &leftNotLessEqRight); 2884514f5e3Sopenharmony_ci } 2894514f5e3Sopenharmony_ci } 2904514f5e3Sopenharmony_ci Bind(&leftOrRightNotInt); 2914514f5e3Sopenharmony_ci { 2924514f5e3Sopenharmony_ci Label leftIsNumber(env); 2934514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &slowPath); 2944514f5e3Sopenharmony_ci Bind(&leftIsNumber); 2954514f5e3Sopenharmony_ci { 2964514f5e3Sopenharmony_ci Label rightIsNumber(env); 2974514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &slowPath); 2984514f5e3Sopenharmony_ci Bind(&rightIsNumber); 2994514f5e3Sopenharmony_ci { 3004514f5e3Sopenharmony_ci // fast path 3014514f5e3Sopenharmony_ci DEFVARIABLE(doubleLeft, VariableType::FLOAT64(), Double(0)); 3024514f5e3Sopenharmony_ci DEFVARIABLE(doubleRight, VariableType::FLOAT64(), Double(0)); 3034514f5e3Sopenharmony_ci DEFVARIABLE(curType, VariableType::INT64(), TaggedInt(PGOSampleType::IntType())); 3044514f5e3Sopenharmony_ci Label leftIsInt1(env); 3054514f5e3Sopenharmony_ci Label leftNotInt1(env); 3064514f5e3Sopenharmony_ci Label exit1(env); 3074514f5e3Sopenharmony_ci Label exit2(env); 3084514f5e3Sopenharmony_ci Label rightIsInt1(env); 3094514f5e3Sopenharmony_ci Label rightNotInt1(env); 3104514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt1, &leftNotInt1); 3114514f5e3Sopenharmony_ci Bind(&leftIsInt1); 3124514f5e3Sopenharmony_ci { 3134514f5e3Sopenharmony_ci doubleLeft = ChangeInt32ToFloat64(TaggedGetInt(left)); 3144514f5e3Sopenharmony_ci Jump(&exit1); 3154514f5e3Sopenharmony_ci } 3164514f5e3Sopenharmony_ci Bind(&leftNotInt1); 3174514f5e3Sopenharmony_ci { 3184514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::DoubleType()); 3194514f5e3Sopenharmony_ci doubleLeft = GetDoubleOfTDouble(left); 3204514f5e3Sopenharmony_ci Jump(&exit1); 3214514f5e3Sopenharmony_ci } 3224514f5e3Sopenharmony_ci Bind(&exit1); 3234514f5e3Sopenharmony_ci { 3244514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt1, &rightNotInt1); 3254514f5e3Sopenharmony_ci } 3264514f5e3Sopenharmony_ci Bind(&rightIsInt1); 3274514f5e3Sopenharmony_ci { 3284514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::IntType()); 3294514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 3304514f5e3Sopenharmony_ci doubleRight = ChangeInt32ToFloat64(TaggedGetInt(right)); 3314514f5e3Sopenharmony_ci Jump(&exit2); 3324514f5e3Sopenharmony_ci } 3334514f5e3Sopenharmony_ci Bind(&rightNotInt1); 3344514f5e3Sopenharmony_ci { 3354514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::DoubleType()); 3364514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 3374514f5e3Sopenharmony_ci doubleRight = GetDoubleOfTDouble(right); 3384514f5e3Sopenharmony_ci Jump(&exit2); 3394514f5e3Sopenharmony_ci } 3404514f5e3Sopenharmony_ci Bind(&exit2); 3414514f5e3Sopenharmony_ci { 3424514f5e3Sopenharmony_ci BRANCH(DoubleLessThanOrEqual(*doubleLeft, *doubleRight), &leftLessEqRight, &leftNotLessEqRight); 3434514f5e3Sopenharmony_ci } 3444514f5e3Sopenharmony_ci } 3454514f5e3Sopenharmony_ci } 3464514f5e3Sopenharmony_ci } 3474514f5e3Sopenharmony_ci Bind(&leftLessEqRight); 3484514f5e3Sopenharmony_ci { 3494514f5e3Sopenharmony_ci callback.ProfileBranch(true); 3504514f5e3Sopenharmony_ci result = TaggedTrue(); 3514514f5e3Sopenharmony_ci Jump(&exit); 3524514f5e3Sopenharmony_ci } 3534514f5e3Sopenharmony_ci Bind(&leftNotLessEqRight); 3544514f5e3Sopenharmony_ci { 3554514f5e3Sopenharmony_ci callback.ProfileBranch(false); 3564514f5e3Sopenharmony_ci result = TaggedFalse(); 3574514f5e3Sopenharmony_ci Jump(&exit); 3584514f5e3Sopenharmony_ci } 3594514f5e3Sopenharmony_ci Bind(&slowPath); 3604514f5e3Sopenharmony_ci { 3614514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 3624514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(LessEq), { left, right }); 3634514f5e3Sopenharmony_ci Jump(&exit); 3644514f5e3Sopenharmony_ci } 3654514f5e3Sopenharmony_ci Bind(&exit); 3664514f5e3Sopenharmony_ci auto ret = *result; 3674514f5e3Sopenharmony_ci env->SubCfgExit(); 3684514f5e3Sopenharmony_ci return ret; 3694514f5e3Sopenharmony_ci} 3704514f5e3Sopenharmony_ci 3714514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Greater(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 3724514f5e3Sopenharmony_ci{ 3734514f5e3Sopenharmony_ci auto env = GetEnvironment(); 3744514f5e3Sopenharmony_ci Label entry(env); 3754514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 3764514f5e3Sopenharmony_ci Label exit(env); 3774514f5e3Sopenharmony_ci Label leftIsInt(env); 3784514f5e3Sopenharmony_ci Label leftOrRightNotInt(env); 3794514f5e3Sopenharmony_ci Label leftGreaterRight(env); 3804514f5e3Sopenharmony_ci Label leftNotGreaterRight(env); 3814514f5e3Sopenharmony_ci Label slowPath(env); 3824514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 3834514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftOrRightNotInt); 3844514f5e3Sopenharmony_ci Bind(&leftIsInt); 3854514f5e3Sopenharmony_ci { 3864514f5e3Sopenharmony_ci Label rightIsInt(env); 3874514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &leftOrRightNotInt); 3884514f5e3Sopenharmony_ci Bind(&rightIsInt); 3894514f5e3Sopenharmony_ci { 3904514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 3914514f5e3Sopenharmony_ci GateRef intLeft = TaggedGetInt(left); 3924514f5e3Sopenharmony_ci GateRef intRight = TaggedGetInt(right); 3934514f5e3Sopenharmony_ci BRANCH(Int32GreaterThan(intLeft, intRight), &leftGreaterRight, &leftNotGreaterRight); 3944514f5e3Sopenharmony_ci } 3954514f5e3Sopenharmony_ci } 3964514f5e3Sopenharmony_ci Bind(&leftOrRightNotInt); 3974514f5e3Sopenharmony_ci { 3984514f5e3Sopenharmony_ci Label leftIsNumber(env); 3994514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &slowPath); 4004514f5e3Sopenharmony_ci Bind(&leftIsNumber); 4014514f5e3Sopenharmony_ci { 4024514f5e3Sopenharmony_ci Label rightIsNumber(env); 4034514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &slowPath); 4044514f5e3Sopenharmony_ci Bind(&rightIsNumber); 4054514f5e3Sopenharmony_ci { 4064514f5e3Sopenharmony_ci // fast path 4074514f5e3Sopenharmony_ci DEFVARIABLE(doubleLeft, VariableType::FLOAT64(), Double(0)); 4084514f5e3Sopenharmony_ci DEFVARIABLE(doubleRight, VariableType::FLOAT64(), Double(0)); 4094514f5e3Sopenharmony_ci DEFVARIABLE(curType, VariableType::INT64(), TaggedInt(PGOSampleType::IntType())); 4104514f5e3Sopenharmony_ci Label leftIsInt1(env); 4114514f5e3Sopenharmony_ci Label leftNotInt1(env); 4124514f5e3Sopenharmony_ci Label exit1(env); 4134514f5e3Sopenharmony_ci Label exit2(env); 4144514f5e3Sopenharmony_ci Label rightIsInt1(env); 4154514f5e3Sopenharmony_ci Label rightNotInt1(env); 4164514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt1, &leftNotInt1); 4174514f5e3Sopenharmony_ci Bind(&leftIsInt1); 4184514f5e3Sopenharmony_ci { 4194514f5e3Sopenharmony_ci doubleLeft = ChangeInt32ToFloat64(TaggedGetInt(left)); 4204514f5e3Sopenharmony_ci Jump(&exit1); 4214514f5e3Sopenharmony_ci } 4224514f5e3Sopenharmony_ci Bind(&leftNotInt1); 4234514f5e3Sopenharmony_ci { 4244514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::DoubleType()); 4254514f5e3Sopenharmony_ci doubleLeft = GetDoubleOfTDouble(left); 4264514f5e3Sopenharmony_ci Jump(&exit1); 4274514f5e3Sopenharmony_ci } 4284514f5e3Sopenharmony_ci Bind(&exit1); 4294514f5e3Sopenharmony_ci { 4304514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt1, &rightNotInt1); 4314514f5e3Sopenharmony_ci } 4324514f5e3Sopenharmony_ci Bind(&rightIsInt1); 4334514f5e3Sopenharmony_ci { 4344514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::IntType()); 4354514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 4364514f5e3Sopenharmony_ci doubleRight = ChangeInt32ToFloat64(TaggedGetInt(right)); 4374514f5e3Sopenharmony_ci Jump(&exit2); 4384514f5e3Sopenharmony_ci } 4394514f5e3Sopenharmony_ci Bind(&rightNotInt1); 4404514f5e3Sopenharmony_ci { 4414514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::DoubleType()); 4424514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 4434514f5e3Sopenharmony_ci doubleRight = GetDoubleOfTDouble(right); 4444514f5e3Sopenharmony_ci Jump(&exit2); 4454514f5e3Sopenharmony_ci } 4464514f5e3Sopenharmony_ci Bind(&exit2); 4474514f5e3Sopenharmony_ci { 4484514f5e3Sopenharmony_ci BRANCH(DoubleGreaterThan(*doubleLeft, *doubleRight), &leftGreaterRight, &leftNotGreaterRight); 4494514f5e3Sopenharmony_ci } 4504514f5e3Sopenharmony_ci } 4514514f5e3Sopenharmony_ci } 4524514f5e3Sopenharmony_ci } 4534514f5e3Sopenharmony_ci Bind(&leftGreaterRight); 4544514f5e3Sopenharmony_ci { 4554514f5e3Sopenharmony_ci callback.ProfileBranch(true); 4564514f5e3Sopenharmony_ci result = TaggedTrue(); 4574514f5e3Sopenharmony_ci Jump(&exit); 4584514f5e3Sopenharmony_ci } 4594514f5e3Sopenharmony_ci Bind(&leftNotGreaterRight); 4604514f5e3Sopenharmony_ci { 4614514f5e3Sopenharmony_ci callback.ProfileBranch(false); 4624514f5e3Sopenharmony_ci result = TaggedFalse(); 4634514f5e3Sopenharmony_ci Jump(&exit); 4644514f5e3Sopenharmony_ci } 4654514f5e3Sopenharmony_ci Bind(&slowPath); 4664514f5e3Sopenharmony_ci { 4674514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 4684514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Greater), { left, right }); 4694514f5e3Sopenharmony_ci Jump(&exit); 4704514f5e3Sopenharmony_ci } 4714514f5e3Sopenharmony_ci Bind(&exit); 4724514f5e3Sopenharmony_ci auto ret = *result; 4734514f5e3Sopenharmony_ci env->SubCfgExit(); 4744514f5e3Sopenharmony_ci return ret; 4754514f5e3Sopenharmony_ci} 4764514f5e3Sopenharmony_ci 4774514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::GreaterEq(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 4784514f5e3Sopenharmony_ci{ 4794514f5e3Sopenharmony_ci auto env = GetEnvironment(); 4804514f5e3Sopenharmony_ci Label entry(env); 4814514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 4824514f5e3Sopenharmony_ci Label exit(env); 4834514f5e3Sopenharmony_ci Label leftIsInt(env); 4844514f5e3Sopenharmony_ci Label leftOrRightNotInt(env); 4854514f5e3Sopenharmony_ci Label leftGreaterEqRight(env); 4864514f5e3Sopenharmony_ci Label leftNotGreaterEQRight(env); 4874514f5e3Sopenharmony_ci Label slowPath(env); 4884514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 4894514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftOrRightNotInt); 4904514f5e3Sopenharmony_ci Bind(&leftIsInt); 4914514f5e3Sopenharmony_ci { 4924514f5e3Sopenharmony_ci Label rightIsInt(env); 4934514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &leftOrRightNotInt); 4944514f5e3Sopenharmony_ci Bind(&rightIsInt); 4954514f5e3Sopenharmony_ci { 4964514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 4974514f5e3Sopenharmony_ci GateRef intLeft = TaggedGetInt(left); 4984514f5e3Sopenharmony_ci GateRef intRight = TaggedGetInt(right); 4994514f5e3Sopenharmony_ci BRANCH(Int32GreaterThanOrEqual(intLeft, intRight), &leftGreaterEqRight, &leftNotGreaterEQRight); 5004514f5e3Sopenharmony_ci } 5014514f5e3Sopenharmony_ci } 5024514f5e3Sopenharmony_ci Bind(&leftOrRightNotInt); 5034514f5e3Sopenharmony_ci { 5044514f5e3Sopenharmony_ci Label leftIsNumber(env); 5054514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &slowPath); 5064514f5e3Sopenharmony_ci Bind(&leftIsNumber); 5074514f5e3Sopenharmony_ci { 5084514f5e3Sopenharmony_ci Label rightIsNumber(env); 5094514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &slowPath); 5104514f5e3Sopenharmony_ci Bind(&rightIsNumber); 5114514f5e3Sopenharmony_ci { 5124514f5e3Sopenharmony_ci // fast path 5134514f5e3Sopenharmony_ci DEFVARIABLE(doubleLeft, VariableType::FLOAT64(), Double(0)); 5144514f5e3Sopenharmony_ci DEFVARIABLE(doubleRight, VariableType::FLOAT64(), Double(0)); 5154514f5e3Sopenharmony_ci DEFVARIABLE(curType, VariableType::INT64(), TaggedInt(PGOSampleType::IntType())); 5164514f5e3Sopenharmony_ci Label leftIsInt1(env); 5174514f5e3Sopenharmony_ci Label leftNotInt1(env); 5184514f5e3Sopenharmony_ci Label exit1(env); 5194514f5e3Sopenharmony_ci Label exit2(env); 5204514f5e3Sopenharmony_ci Label rightIsInt1(env); 5214514f5e3Sopenharmony_ci Label rightNotInt1(env); 5224514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt1, &leftNotInt1); 5234514f5e3Sopenharmony_ci Bind(&leftIsInt1); 5244514f5e3Sopenharmony_ci { 5254514f5e3Sopenharmony_ci doubleLeft = ChangeInt32ToFloat64(TaggedGetInt(left)); 5264514f5e3Sopenharmony_ci Jump(&exit1); 5274514f5e3Sopenharmony_ci } 5284514f5e3Sopenharmony_ci Bind(&leftNotInt1); 5294514f5e3Sopenharmony_ci { 5304514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::DoubleType()); 5314514f5e3Sopenharmony_ci doubleLeft = GetDoubleOfTDouble(left); 5324514f5e3Sopenharmony_ci Jump(&exit1); 5334514f5e3Sopenharmony_ci } 5344514f5e3Sopenharmony_ci Bind(&exit1); 5354514f5e3Sopenharmony_ci { 5364514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt1, &rightNotInt1); 5374514f5e3Sopenharmony_ci } 5384514f5e3Sopenharmony_ci Bind(&rightIsInt1); 5394514f5e3Sopenharmony_ci { 5404514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::IntType()); 5414514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 5424514f5e3Sopenharmony_ci doubleRight = ChangeInt32ToFloat64(TaggedGetInt(right)); 5434514f5e3Sopenharmony_ci Jump(&exit2); 5444514f5e3Sopenharmony_ci } 5454514f5e3Sopenharmony_ci Bind(&rightNotInt1); 5464514f5e3Sopenharmony_ci { 5474514f5e3Sopenharmony_ci GateRef type = TaggedInt(PGOSampleType::DoubleType()); 5484514f5e3Sopenharmony_ci COMBINE_TYPE_CALL_BACK(curType, type); 5494514f5e3Sopenharmony_ci doubleRight = GetDoubleOfTDouble(right); 5504514f5e3Sopenharmony_ci Jump(&exit2); 5514514f5e3Sopenharmony_ci } 5524514f5e3Sopenharmony_ci Bind(&exit2); 5534514f5e3Sopenharmony_ci { 5544514f5e3Sopenharmony_ci BRANCH(DoubleGreaterThanOrEqual(*doubleLeft, *doubleRight), 5554514f5e3Sopenharmony_ci &leftGreaterEqRight, &leftNotGreaterEQRight); 5564514f5e3Sopenharmony_ci } 5574514f5e3Sopenharmony_ci } 5584514f5e3Sopenharmony_ci } 5594514f5e3Sopenharmony_ci } 5604514f5e3Sopenharmony_ci Bind(&leftGreaterEqRight); 5614514f5e3Sopenharmony_ci { 5624514f5e3Sopenharmony_ci callback.ProfileBranch(true); 5634514f5e3Sopenharmony_ci result = TaggedTrue(); 5644514f5e3Sopenharmony_ci Jump(&exit); 5654514f5e3Sopenharmony_ci } 5664514f5e3Sopenharmony_ci Bind(&leftNotGreaterEQRight); 5674514f5e3Sopenharmony_ci { 5684514f5e3Sopenharmony_ci callback.ProfileBranch(false); 5694514f5e3Sopenharmony_ci result = TaggedFalse(); 5704514f5e3Sopenharmony_ci Jump(&exit); 5714514f5e3Sopenharmony_ci } 5724514f5e3Sopenharmony_ci Bind(&slowPath); 5734514f5e3Sopenharmony_ci { 5744514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 5754514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(GreaterEq), { left, right }); 5764514f5e3Sopenharmony_ci Jump(&exit); 5774514f5e3Sopenharmony_ci } 5784514f5e3Sopenharmony_ci Bind(&exit); 5794514f5e3Sopenharmony_ci auto ret = *result; 5804514f5e3Sopenharmony_ci env->SubCfgExit(); 5814514f5e3Sopenharmony_ci return ret; 5824514f5e3Sopenharmony_ci} 5834514f5e3Sopenharmony_ci 5844514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Add(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 5854514f5e3Sopenharmony_ci{ 5864514f5e3Sopenharmony_ci auto env = GetEnvironment(); 5874514f5e3Sopenharmony_ci Label entry(env); 5884514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 5894514f5e3Sopenharmony_ci Label exit(env); 5904514f5e3Sopenharmony_ci Label slowPath(env); 5914514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), FastAdd(glue, left, right, callback)); 5924514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 5934514f5e3Sopenharmony_ci Bind(&slowPath); 5944514f5e3Sopenharmony_ci { 5954514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 5964514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Add2), { left, right }); 5974514f5e3Sopenharmony_ci Jump(&exit); 5984514f5e3Sopenharmony_ci } 5994514f5e3Sopenharmony_ci Bind(&exit); 6004514f5e3Sopenharmony_ci auto ret = *result; 6014514f5e3Sopenharmony_ci env->SubCfgExit(); 6024514f5e3Sopenharmony_ci return ret; 6034514f5e3Sopenharmony_ci} 6044514f5e3Sopenharmony_ci 6054514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Sub(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 6064514f5e3Sopenharmony_ci{ 6074514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6084514f5e3Sopenharmony_ci Label entry(env); 6094514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6104514f5e3Sopenharmony_ci Label exit(env); 6114514f5e3Sopenharmony_ci Label slowPath(env); 6124514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), FastSub(glue, left, right, callback)); 6134514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 6144514f5e3Sopenharmony_ci Bind(&slowPath); 6154514f5e3Sopenharmony_ci { 6164514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 6174514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Sub2), { left, right }); 6184514f5e3Sopenharmony_ci Jump(&exit); 6194514f5e3Sopenharmony_ci } 6204514f5e3Sopenharmony_ci Bind(&exit); 6214514f5e3Sopenharmony_ci auto ret = *result; 6224514f5e3Sopenharmony_ci env->SubCfgExit(); 6234514f5e3Sopenharmony_ci return ret; 6244514f5e3Sopenharmony_ci} 6254514f5e3Sopenharmony_ci 6264514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Mul(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 6274514f5e3Sopenharmony_ci{ 6284514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6294514f5e3Sopenharmony_ci Label entry(env); 6304514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6314514f5e3Sopenharmony_ci Label exit(env); 6324514f5e3Sopenharmony_ci Label slowPath(env); 6334514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), FastMul(glue, left, right, callback)); 6344514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 6354514f5e3Sopenharmony_ci Bind(&slowPath); 6364514f5e3Sopenharmony_ci { 6374514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 6384514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Mul2), { left, right }); 6394514f5e3Sopenharmony_ci Jump(&exit); 6404514f5e3Sopenharmony_ci } 6414514f5e3Sopenharmony_ci Bind(&exit); 6424514f5e3Sopenharmony_ci auto ret = *result; 6434514f5e3Sopenharmony_ci env->SubCfgExit(); 6444514f5e3Sopenharmony_ci return ret; 6454514f5e3Sopenharmony_ci} 6464514f5e3Sopenharmony_ci 6474514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Div(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 6484514f5e3Sopenharmony_ci{ 6494514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6504514f5e3Sopenharmony_ci Label entry(env); 6514514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6524514f5e3Sopenharmony_ci Label exit(env); 6534514f5e3Sopenharmony_ci Label slowPath(env); 6544514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), FastDiv(left, right, callback)); 6554514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 6564514f5e3Sopenharmony_ci Bind(&slowPath); 6574514f5e3Sopenharmony_ci { 6584514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 6594514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Div2), { left, right }); 6604514f5e3Sopenharmony_ci Jump(&exit); 6614514f5e3Sopenharmony_ci } 6624514f5e3Sopenharmony_ci Bind(&exit); 6634514f5e3Sopenharmony_ci auto ret = *result; 6644514f5e3Sopenharmony_ci env->SubCfgExit(); 6654514f5e3Sopenharmony_ci return ret; 6664514f5e3Sopenharmony_ci} 6674514f5e3Sopenharmony_ci 6684514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Mod(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 6694514f5e3Sopenharmony_ci{ 6704514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6714514f5e3Sopenharmony_ci Label entry(env); 6724514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6734514f5e3Sopenharmony_ci Label exit(env); 6744514f5e3Sopenharmony_ci Label slowPath(env); 6754514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), FastMod(glue, left, right, callback)); 6764514f5e3Sopenharmony_ci BRANCH(TaggedIsHole(*result), &slowPath, &exit); 6774514f5e3Sopenharmony_ci Bind(&slowPath); 6784514f5e3Sopenharmony_ci { 6794514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 6804514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Mod2), { left, right }); 6814514f5e3Sopenharmony_ci Jump(&exit); 6824514f5e3Sopenharmony_ci } 6834514f5e3Sopenharmony_ci Bind(&exit); 6844514f5e3Sopenharmony_ci auto ret = *result; 6854514f5e3Sopenharmony_ci env->SubCfgExit(); 6864514f5e3Sopenharmony_ci return ret; 6874514f5e3Sopenharmony_ci} 6884514f5e3Sopenharmony_ci 6894514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Shl(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 6904514f5e3Sopenharmony_ci{ 6914514f5e3Sopenharmony_ci auto env = GetEnvironment(); 6924514f5e3Sopenharmony_ci Label entry(env); 6934514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 6944514f5e3Sopenharmony_ci Label exit(env); 6954514f5e3Sopenharmony_ci 6964514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 6974514f5e3Sopenharmony_ci DEFVARIABLE(opNumber0, VariableType::INT32(), Int32(0)); 6984514f5e3Sopenharmony_ci DEFVARIABLE(opNumber1, VariableType::INT32(), Int32(0)); 6994514f5e3Sopenharmony_ci 7004514f5e3Sopenharmony_ci Label calculate(env); 7014514f5e3Sopenharmony_ci Label leftIsNumber(env); 7024514f5e3Sopenharmony_ci Label leftNotNumberOrRightNotNumber(env); 7034514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &leftNotNumberOrRightNotNumber); 7044514f5e3Sopenharmony_ci Bind(&leftIsNumber); 7054514f5e3Sopenharmony_ci { 7064514f5e3Sopenharmony_ci Label rightIsNumber(env); 7074514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &leftNotNumberOrRightNotNumber); 7084514f5e3Sopenharmony_ci Bind(&rightIsNumber); 7094514f5e3Sopenharmony_ci { 7104514f5e3Sopenharmony_ci Label leftIsInt(env); 7114514f5e3Sopenharmony_ci Label leftIsDouble(env); 7124514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftIsDouble); 7134514f5e3Sopenharmony_ci Bind(&leftIsInt); 7144514f5e3Sopenharmony_ci { 7154514f5e3Sopenharmony_ci Label rightIsInt(env); 7164514f5e3Sopenharmony_ci Label rightIsDouble(env); 7174514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 7184514f5e3Sopenharmony_ci Bind(&rightIsInt); 7194514f5e3Sopenharmony_ci { 7204514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 7214514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 7224514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 7234514f5e3Sopenharmony_ci Jump(&calculate); 7244514f5e3Sopenharmony_ci } 7254514f5e3Sopenharmony_ci Bind(&rightIsDouble); 7264514f5e3Sopenharmony_ci { 7274514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 7284514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 7294514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 7304514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 7314514f5e3Sopenharmony_ci Jump(&calculate); 7324514f5e3Sopenharmony_ci } 7334514f5e3Sopenharmony_ci } 7344514f5e3Sopenharmony_ci Bind(&leftIsDouble); 7354514f5e3Sopenharmony_ci { 7364514f5e3Sopenharmony_ci Label rightIsInt(env); 7374514f5e3Sopenharmony_ci Label rightIsDouble(env); 7384514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 7394514f5e3Sopenharmony_ci Bind(&rightIsInt); 7404514f5e3Sopenharmony_ci { 7414514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 7424514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 7434514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 7444514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 7454514f5e3Sopenharmony_ci Jump(&calculate); 7464514f5e3Sopenharmony_ci } 7474514f5e3Sopenharmony_ci Bind(&rightIsDouble); 7484514f5e3Sopenharmony_ci { 7494514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 7504514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 7514514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 7524514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 7534514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 7544514f5e3Sopenharmony_ci Jump(&calculate); 7554514f5e3Sopenharmony_ci } 7564514f5e3Sopenharmony_ci } 7574514f5e3Sopenharmony_ci } 7584514f5e3Sopenharmony_ci } 7594514f5e3Sopenharmony_ci // slow path 7604514f5e3Sopenharmony_ci Bind(&leftNotNumberOrRightNotNumber); 7614514f5e3Sopenharmony_ci { 7624514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 7634514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Shl2), { left, right }); 7644514f5e3Sopenharmony_ci Jump(&exit); 7654514f5e3Sopenharmony_ci } 7664514f5e3Sopenharmony_ci Bind(&calculate); 7674514f5e3Sopenharmony_ci { 7684514f5e3Sopenharmony_ci GateRef shift = Int32And(*opNumber1, Int32(0x1f)); 7694514f5e3Sopenharmony_ci GateRef val = Int32LSL(*opNumber0, shift); 7704514f5e3Sopenharmony_ci result = IntToTaggedPtr(val); 7714514f5e3Sopenharmony_ci Jump(&exit); 7724514f5e3Sopenharmony_ci } 7734514f5e3Sopenharmony_ci Bind(&exit); 7744514f5e3Sopenharmony_ci auto ret = *result; 7754514f5e3Sopenharmony_ci env->SubCfgExit(); 7764514f5e3Sopenharmony_ci return ret; 7774514f5e3Sopenharmony_ci} 7784514f5e3Sopenharmony_ci 7794514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Shr(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 7804514f5e3Sopenharmony_ci{ 7814514f5e3Sopenharmony_ci auto env = GetEnvironment(); 7824514f5e3Sopenharmony_ci Label entry(env); 7834514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 7844514f5e3Sopenharmony_ci Label exit(env); 7854514f5e3Sopenharmony_ci 7864514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 7874514f5e3Sopenharmony_ci DEFVARIABLE(opNumber0, VariableType::INT32(), Int32(0)); 7884514f5e3Sopenharmony_ci DEFVARIABLE(opNumber1, VariableType::INT32(), Int32(0)); 7894514f5e3Sopenharmony_ci DEFVARIABLE(curType, VariableType::INT64(), TaggedInt(PGOSampleType::None())); 7904514f5e3Sopenharmony_ci 7914514f5e3Sopenharmony_ci Label doShr(env); 7924514f5e3Sopenharmony_ci Label overflow(env); 7934514f5e3Sopenharmony_ci Label notOverflow(env); 7944514f5e3Sopenharmony_ci Label leftIsNumber(env); 7954514f5e3Sopenharmony_ci Label leftNotNumberOrRightNotNumber(env); 7964514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &leftNotNumberOrRightNotNumber); 7974514f5e3Sopenharmony_ci Bind(&leftIsNumber); 7984514f5e3Sopenharmony_ci { 7994514f5e3Sopenharmony_ci Label rightIsNumber(env); 8004514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &leftNotNumberOrRightNotNumber); 8014514f5e3Sopenharmony_ci Bind(&rightIsNumber); 8024514f5e3Sopenharmony_ci { 8034514f5e3Sopenharmony_ci Label leftIsInt(env); 8044514f5e3Sopenharmony_ci Label leftIsDouble(env); 8054514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftIsDouble); 8064514f5e3Sopenharmony_ci Bind(&leftIsInt); 8074514f5e3Sopenharmony_ci { 8084514f5e3Sopenharmony_ci Label rightIsInt(env); 8094514f5e3Sopenharmony_ci Label rightIsDouble(env); 8104514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 8114514f5e3Sopenharmony_ci Bind(&rightIsInt); 8124514f5e3Sopenharmony_ci { 8134514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::IntType()); 8144514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 8154514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 8164514f5e3Sopenharmony_ci Jump(&doShr); 8174514f5e3Sopenharmony_ci } 8184514f5e3Sopenharmony_ci Bind(&rightIsDouble); 8194514f5e3Sopenharmony_ci { 8204514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::NumberType()); 8214514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 8224514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 8234514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 8244514f5e3Sopenharmony_ci Jump(&doShr); 8254514f5e3Sopenharmony_ci } 8264514f5e3Sopenharmony_ci } 8274514f5e3Sopenharmony_ci Bind(&leftIsDouble); 8284514f5e3Sopenharmony_ci { 8294514f5e3Sopenharmony_ci Label rightIsInt(env); 8304514f5e3Sopenharmony_ci Label rightIsDouble(env); 8314514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 8324514f5e3Sopenharmony_ci Bind(&rightIsInt); 8334514f5e3Sopenharmony_ci { 8344514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::NumberType()); 8354514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 8364514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 8374514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 8384514f5e3Sopenharmony_ci Jump(&doShr); 8394514f5e3Sopenharmony_ci } 8404514f5e3Sopenharmony_ci Bind(&rightIsDouble); 8414514f5e3Sopenharmony_ci { 8424514f5e3Sopenharmony_ci curType = TaggedInt(PGOSampleType::DoubleType()); 8434514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 8444514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 8454514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 8464514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 8474514f5e3Sopenharmony_ci Jump(&doShr); 8484514f5e3Sopenharmony_ci } 8494514f5e3Sopenharmony_ci } 8504514f5e3Sopenharmony_ci } 8514514f5e3Sopenharmony_ci } 8524514f5e3Sopenharmony_ci // slow path 8534514f5e3Sopenharmony_ci Bind(&leftNotNumberOrRightNotNumber); 8544514f5e3Sopenharmony_ci { 8554514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 8564514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Shr2), { left, right }); 8574514f5e3Sopenharmony_ci Jump(&exit); 8584514f5e3Sopenharmony_ci } 8594514f5e3Sopenharmony_ci Bind(&doShr); 8604514f5e3Sopenharmony_ci { 8614514f5e3Sopenharmony_ci GateRef shift = Int32And(*opNumber1, Int32(0x1f)); 8624514f5e3Sopenharmony_ci GateRef val = Int32LSR(*opNumber0, shift); 8634514f5e3Sopenharmony_ci auto condition = Int32UnsignedGreaterThan(val, Int32(INT32_MAX)); 8644514f5e3Sopenharmony_ci BRANCH(condition, &overflow, ¬Overflow); 8654514f5e3Sopenharmony_ci Bind(&overflow); 8664514f5e3Sopenharmony_ci { 8674514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntOverFlowType())); 8684514f5e3Sopenharmony_ci result = DoubleToTaggedDoublePtr(ChangeUInt32ToFloat64(val)); 8694514f5e3Sopenharmony_ci Jump(&exit); 8704514f5e3Sopenharmony_ci } 8714514f5e3Sopenharmony_ci Bind(¬Overflow); 8724514f5e3Sopenharmony_ci { 8734514f5e3Sopenharmony_ci callback.ProfileOpType(*curType); 8744514f5e3Sopenharmony_ci result = IntToTaggedPtr(val); 8754514f5e3Sopenharmony_ci Jump(&exit); 8764514f5e3Sopenharmony_ci } 8774514f5e3Sopenharmony_ci } 8784514f5e3Sopenharmony_ci Bind(&exit); 8794514f5e3Sopenharmony_ci auto ret = *result; 8804514f5e3Sopenharmony_ci env->SubCfgExit(); 8814514f5e3Sopenharmony_ci return ret; 8824514f5e3Sopenharmony_ci} 8834514f5e3Sopenharmony_ci 8844514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Ashr(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 8854514f5e3Sopenharmony_ci{ 8864514f5e3Sopenharmony_ci auto env = GetEnvironment(); 8874514f5e3Sopenharmony_ci Label entry(env); 8884514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 8894514f5e3Sopenharmony_ci Label exit(env); 8904514f5e3Sopenharmony_ci 8914514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 8924514f5e3Sopenharmony_ci DEFVARIABLE(opNumber0, VariableType::INT32(), Int32(0)); 8934514f5e3Sopenharmony_ci DEFVARIABLE(opNumber1, VariableType::INT32(), Int32(0)); 8944514f5e3Sopenharmony_ci 8954514f5e3Sopenharmony_ci Label calculate(env); 8964514f5e3Sopenharmony_ci Label leftIsNumber(env); 8974514f5e3Sopenharmony_ci Label leftNotNumberOrRightNotNumber(env); 8984514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &leftNotNumberOrRightNotNumber); 8994514f5e3Sopenharmony_ci Bind(&leftIsNumber); 9004514f5e3Sopenharmony_ci { 9014514f5e3Sopenharmony_ci Label rightIsNumber(env); 9024514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &leftNotNumberOrRightNotNumber); 9034514f5e3Sopenharmony_ci Bind(&rightIsNumber); 9044514f5e3Sopenharmony_ci { 9054514f5e3Sopenharmony_ci Label leftIsInt(env); 9064514f5e3Sopenharmony_ci Label leftIsDouble(env); 9074514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftIsDouble); 9084514f5e3Sopenharmony_ci Bind(&leftIsInt); 9094514f5e3Sopenharmony_ci { 9104514f5e3Sopenharmony_ci Label rightIsInt(env); 9114514f5e3Sopenharmony_ci Label rightIsDouble(env); 9124514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 9134514f5e3Sopenharmony_ci Bind(&rightIsInt); 9144514f5e3Sopenharmony_ci { 9154514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 9164514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 9174514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 9184514f5e3Sopenharmony_ci Jump(&calculate); 9194514f5e3Sopenharmony_ci } 9204514f5e3Sopenharmony_ci Bind(&rightIsDouble); 9214514f5e3Sopenharmony_ci { 9224514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 9234514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 9244514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 9254514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 9264514f5e3Sopenharmony_ci Jump(&calculate); 9274514f5e3Sopenharmony_ci } 9284514f5e3Sopenharmony_ci } 9294514f5e3Sopenharmony_ci Bind(&leftIsDouble); 9304514f5e3Sopenharmony_ci { 9314514f5e3Sopenharmony_ci Label rightIsInt(env); 9324514f5e3Sopenharmony_ci Label rightIsDouble(env); 9334514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 9344514f5e3Sopenharmony_ci Bind(&rightIsInt); 9354514f5e3Sopenharmony_ci { 9364514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 9374514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 9384514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 9394514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 9404514f5e3Sopenharmony_ci Jump(&calculate); 9414514f5e3Sopenharmony_ci } 9424514f5e3Sopenharmony_ci Bind(&rightIsDouble); 9434514f5e3Sopenharmony_ci { 9444514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 9454514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 9464514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 9474514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 9484514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 9494514f5e3Sopenharmony_ci Jump(&calculate); 9504514f5e3Sopenharmony_ci } 9514514f5e3Sopenharmony_ci } 9524514f5e3Sopenharmony_ci } 9534514f5e3Sopenharmony_ci } 9544514f5e3Sopenharmony_ci // slow path 9554514f5e3Sopenharmony_ci Bind(&leftNotNumberOrRightNotNumber); 9564514f5e3Sopenharmony_ci { 9574514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 9584514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Ashr2), { left, right }); 9594514f5e3Sopenharmony_ci Jump(&exit); 9604514f5e3Sopenharmony_ci } 9614514f5e3Sopenharmony_ci Bind(&calculate); 9624514f5e3Sopenharmony_ci { 9634514f5e3Sopenharmony_ci GateRef shift = Int32And(*opNumber1, Int32(0x1f)); 9644514f5e3Sopenharmony_ci GateRef val = Int32ASR(*opNumber0, shift); 9654514f5e3Sopenharmony_ci result = IntToTaggedPtr(val); 9664514f5e3Sopenharmony_ci Jump(&exit); 9674514f5e3Sopenharmony_ci } 9684514f5e3Sopenharmony_ci Bind(&exit); 9694514f5e3Sopenharmony_ci auto ret = *result; 9704514f5e3Sopenharmony_ci env->SubCfgExit(); 9714514f5e3Sopenharmony_ci return ret; 9724514f5e3Sopenharmony_ci} 9734514f5e3Sopenharmony_ci 9744514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::And(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 9754514f5e3Sopenharmony_ci{ 9764514f5e3Sopenharmony_ci auto env = GetEnvironment(); 9774514f5e3Sopenharmony_ci Label entry(env); 9784514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 9794514f5e3Sopenharmony_ci Label exit(env); 9804514f5e3Sopenharmony_ci 9814514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 9824514f5e3Sopenharmony_ci DEFVARIABLE(opNumber0, VariableType::INT32(), Int32(0)); 9834514f5e3Sopenharmony_ci DEFVARIABLE(opNumber1, VariableType::INT32(), Int32(0)); 9844514f5e3Sopenharmony_ci 9854514f5e3Sopenharmony_ci Label calculate(env); 9864514f5e3Sopenharmony_ci Label leftIsNumber(env); 9874514f5e3Sopenharmony_ci Label leftNotNumberOrRightNotNumber(env); 9884514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &leftNotNumberOrRightNotNumber); 9894514f5e3Sopenharmony_ci Bind(&leftIsNumber); 9904514f5e3Sopenharmony_ci { 9914514f5e3Sopenharmony_ci Label rightIsNumber(env); 9924514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &leftNotNumberOrRightNotNumber); 9934514f5e3Sopenharmony_ci Bind(&rightIsNumber); 9944514f5e3Sopenharmony_ci { 9954514f5e3Sopenharmony_ci Label leftIsInt(env); 9964514f5e3Sopenharmony_ci Label leftIsDouble(env); 9974514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftIsDouble); 9984514f5e3Sopenharmony_ci Bind(&leftIsInt); 9994514f5e3Sopenharmony_ci { 10004514f5e3Sopenharmony_ci Label rightIsInt(env); 10014514f5e3Sopenharmony_ci Label rightIsDouble(env); 10024514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 10034514f5e3Sopenharmony_ci Bind(&rightIsInt); 10044514f5e3Sopenharmony_ci { 10054514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 10064514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 10074514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 10084514f5e3Sopenharmony_ci Jump(&calculate); 10094514f5e3Sopenharmony_ci } 10104514f5e3Sopenharmony_ci Bind(&rightIsDouble); 10114514f5e3Sopenharmony_ci { 10124514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 10134514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 10144514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 10154514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 10164514f5e3Sopenharmony_ci Jump(&calculate); 10174514f5e3Sopenharmony_ci } 10184514f5e3Sopenharmony_ci } 10194514f5e3Sopenharmony_ci Bind(&leftIsDouble); 10204514f5e3Sopenharmony_ci { 10214514f5e3Sopenharmony_ci Label rightIsInt(env); 10224514f5e3Sopenharmony_ci Label rightIsDouble(env); 10234514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 10244514f5e3Sopenharmony_ci Bind(&rightIsInt); 10254514f5e3Sopenharmony_ci { 10264514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 10274514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 10284514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 10294514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 10304514f5e3Sopenharmony_ci Jump(&calculate); 10314514f5e3Sopenharmony_ci } 10324514f5e3Sopenharmony_ci Bind(&rightIsDouble); 10334514f5e3Sopenharmony_ci { 10344514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 10354514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 10364514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 10374514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 10384514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 10394514f5e3Sopenharmony_ci Jump(&calculate); 10404514f5e3Sopenharmony_ci } 10414514f5e3Sopenharmony_ci } 10424514f5e3Sopenharmony_ci } 10434514f5e3Sopenharmony_ci } 10444514f5e3Sopenharmony_ci // slow path 10454514f5e3Sopenharmony_ci Bind(&leftNotNumberOrRightNotNumber); 10464514f5e3Sopenharmony_ci { 10474514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 10484514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(And2), { left, right }); 10494514f5e3Sopenharmony_ci Jump(&exit); 10504514f5e3Sopenharmony_ci } 10514514f5e3Sopenharmony_ci Bind(&calculate); 10524514f5e3Sopenharmony_ci { 10534514f5e3Sopenharmony_ci GateRef val = Int32And(*opNumber0, *opNumber1); 10544514f5e3Sopenharmony_ci result = IntToTaggedPtr(val); 10554514f5e3Sopenharmony_ci Jump(&exit); 10564514f5e3Sopenharmony_ci } 10574514f5e3Sopenharmony_ci Bind(&exit); 10584514f5e3Sopenharmony_ci auto ret = *result; 10594514f5e3Sopenharmony_ci env->SubCfgExit(); 10604514f5e3Sopenharmony_ci return ret; 10614514f5e3Sopenharmony_ci} 10624514f5e3Sopenharmony_ci 10634514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Or(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 10644514f5e3Sopenharmony_ci{ 10654514f5e3Sopenharmony_ci auto env = GetEnvironment(); 10664514f5e3Sopenharmony_ci Label entry(env); 10674514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 10684514f5e3Sopenharmony_ci Label exit(env); 10694514f5e3Sopenharmony_ci 10704514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 10714514f5e3Sopenharmony_ci DEFVARIABLE(opNumber0, VariableType::INT32(), Int32(0)); 10724514f5e3Sopenharmony_ci DEFVARIABLE(opNumber1, VariableType::INT32(), Int32(0)); 10734514f5e3Sopenharmony_ci 10744514f5e3Sopenharmony_ci Label calculate(env); 10754514f5e3Sopenharmony_ci Label leftIsNumber(env); 10764514f5e3Sopenharmony_ci Label leftNotNumberOrRightNotNumber(env); 10774514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &leftNotNumberOrRightNotNumber); 10784514f5e3Sopenharmony_ci Bind(&leftIsNumber); 10794514f5e3Sopenharmony_ci { 10804514f5e3Sopenharmony_ci Label rightIsNumber(env); 10814514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &leftNotNumberOrRightNotNumber); 10824514f5e3Sopenharmony_ci Bind(&rightIsNumber); 10834514f5e3Sopenharmony_ci { 10844514f5e3Sopenharmony_ci Label leftIsInt(env); 10854514f5e3Sopenharmony_ci Label leftIsDouble(env); 10864514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftIsDouble); 10874514f5e3Sopenharmony_ci Bind(&leftIsInt); 10884514f5e3Sopenharmony_ci { 10894514f5e3Sopenharmony_ci Label rightIsInt(env); 10904514f5e3Sopenharmony_ci Label rightIsDouble(env); 10914514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 10924514f5e3Sopenharmony_ci Bind(&rightIsInt); 10934514f5e3Sopenharmony_ci { 10944514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 10954514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 10964514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 10974514f5e3Sopenharmony_ci Jump(&calculate); 10984514f5e3Sopenharmony_ci } 10994514f5e3Sopenharmony_ci Bind(&rightIsDouble); 11004514f5e3Sopenharmony_ci { 11014514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 11024514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 11034514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 11044514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 11054514f5e3Sopenharmony_ci Jump(&calculate); 11064514f5e3Sopenharmony_ci } 11074514f5e3Sopenharmony_ci } 11084514f5e3Sopenharmony_ci Bind(&leftIsDouble); 11094514f5e3Sopenharmony_ci { 11104514f5e3Sopenharmony_ci Label rightIsInt(env); 11114514f5e3Sopenharmony_ci Label rightIsDouble(env); 11124514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 11134514f5e3Sopenharmony_ci Bind(&rightIsInt); 11144514f5e3Sopenharmony_ci { 11154514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 11164514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 11174514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 11184514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 11194514f5e3Sopenharmony_ci Jump(&calculate); 11204514f5e3Sopenharmony_ci } 11214514f5e3Sopenharmony_ci Bind(&rightIsDouble); 11224514f5e3Sopenharmony_ci { 11234514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 11244514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 11254514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 11264514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 11274514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 11284514f5e3Sopenharmony_ci Jump(&calculate); 11294514f5e3Sopenharmony_ci } 11304514f5e3Sopenharmony_ci } 11314514f5e3Sopenharmony_ci } 11324514f5e3Sopenharmony_ci } 11334514f5e3Sopenharmony_ci // slow path 11344514f5e3Sopenharmony_ci Bind(&leftNotNumberOrRightNotNumber); 11354514f5e3Sopenharmony_ci { 11364514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 11374514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Or2), { left, right }); 11384514f5e3Sopenharmony_ci Jump(&exit); 11394514f5e3Sopenharmony_ci } 11404514f5e3Sopenharmony_ci Bind(&calculate); 11414514f5e3Sopenharmony_ci { 11424514f5e3Sopenharmony_ci GateRef val = Int32Or(*opNumber0, *opNumber1); 11434514f5e3Sopenharmony_ci result = IntToTaggedPtr(val); 11444514f5e3Sopenharmony_ci Jump(&exit); 11454514f5e3Sopenharmony_ci } 11464514f5e3Sopenharmony_ci Bind(&exit); 11474514f5e3Sopenharmony_ci auto ret = *result; 11484514f5e3Sopenharmony_ci env->SubCfgExit(); 11494514f5e3Sopenharmony_ci return ret; 11504514f5e3Sopenharmony_ci} 11514514f5e3Sopenharmony_ci 11524514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Xor(GateRef glue, GateRef left, GateRef right, ProfileOperation callback) 11534514f5e3Sopenharmony_ci{ 11544514f5e3Sopenharmony_ci auto env = GetEnvironment(); 11554514f5e3Sopenharmony_ci Label entry(env); 11564514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 11574514f5e3Sopenharmony_ci Label exit(env); 11584514f5e3Sopenharmony_ci 11594514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 11604514f5e3Sopenharmony_ci DEFVARIABLE(opNumber0, VariableType::INT32(), Int32(0)); 11614514f5e3Sopenharmony_ci DEFVARIABLE(opNumber1, VariableType::INT32(), Int32(0)); 11624514f5e3Sopenharmony_ci 11634514f5e3Sopenharmony_ci Label calculate(env); 11644514f5e3Sopenharmony_ci Label leftIsNumber(env); 11654514f5e3Sopenharmony_ci Label leftNotNumberOrRightNotNumber(env); 11664514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(left), &leftIsNumber, &leftNotNumberOrRightNotNumber); 11674514f5e3Sopenharmony_ci Bind(&leftIsNumber); 11684514f5e3Sopenharmony_ci { 11694514f5e3Sopenharmony_ci Label rightIsNumber(env); 11704514f5e3Sopenharmony_ci BRANCH(TaggedIsNumber(right), &rightIsNumber, &leftNotNumberOrRightNotNumber); 11714514f5e3Sopenharmony_ci Bind(&rightIsNumber); 11724514f5e3Sopenharmony_ci { 11734514f5e3Sopenharmony_ci Label leftIsInt(env); 11744514f5e3Sopenharmony_ci Label leftIsDouble(env); 11754514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(left), &leftIsInt, &leftIsDouble); 11764514f5e3Sopenharmony_ci Bind(&leftIsInt); 11774514f5e3Sopenharmony_ci { 11784514f5e3Sopenharmony_ci Label rightIsInt(env); 11794514f5e3Sopenharmony_ci Label rightIsDouble(env); 11804514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 11814514f5e3Sopenharmony_ci Bind(&rightIsInt); 11824514f5e3Sopenharmony_ci { 11834514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 11844514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 11854514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 11864514f5e3Sopenharmony_ci Jump(&calculate); 11874514f5e3Sopenharmony_ci } 11884514f5e3Sopenharmony_ci Bind(&rightIsDouble); 11894514f5e3Sopenharmony_ci { 11904514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 11914514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 11924514f5e3Sopenharmony_ci opNumber0 = GetInt32OfTInt(left); 11934514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 11944514f5e3Sopenharmony_ci Jump(&calculate); 11954514f5e3Sopenharmony_ci } 11964514f5e3Sopenharmony_ci } 11974514f5e3Sopenharmony_ci Bind(&leftIsDouble); 11984514f5e3Sopenharmony_ci { 11994514f5e3Sopenharmony_ci Label rightIsInt(env); 12004514f5e3Sopenharmony_ci Label rightIsDouble(env); 12014514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(right), &rightIsInt, &rightIsDouble); 12024514f5e3Sopenharmony_ci Bind(&rightIsInt); 12034514f5e3Sopenharmony_ci { 12044514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::NumberType())); 12054514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 12064514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 12074514f5e3Sopenharmony_ci opNumber1 = GetInt32OfTInt(right); 12084514f5e3Sopenharmony_ci Jump(&calculate); 12094514f5e3Sopenharmony_ci } 12104514f5e3Sopenharmony_ci Bind(&rightIsDouble); 12114514f5e3Sopenharmony_ci { 12124514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 12134514f5e3Sopenharmony_ci GateRef rightDouble = GetDoubleOfTDouble(right); 12144514f5e3Sopenharmony_ci GateRef leftDouble = GetDoubleOfTDouble(left); 12154514f5e3Sopenharmony_ci opNumber0 = DoubleToInt(glue, leftDouble); 12164514f5e3Sopenharmony_ci opNumber1 = DoubleToInt(glue, rightDouble); 12174514f5e3Sopenharmony_ci Jump(&calculate); 12184514f5e3Sopenharmony_ci } 12194514f5e3Sopenharmony_ci } 12204514f5e3Sopenharmony_ci } 12214514f5e3Sopenharmony_ci } 12224514f5e3Sopenharmony_ci // slow path 12234514f5e3Sopenharmony_ci Bind(&leftNotNumberOrRightNotNumber); 12244514f5e3Sopenharmony_ci { 12254514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 12264514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Xor2), { left, right }); 12274514f5e3Sopenharmony_ci Jump(&exit); 12284514f5e3Sopenharmony_ci } 12294514f5e3Sopenharmony_ci Bind(&calculate); 12304514f5e3Sopenharmony_ci { 12314514f5e3Sopenharmony_ci GateRef val = Int32Xor(*opNumber0, *opNumber1); 12324514f5e3Sopenharmony_ci result = IntToTaggedPtr(val); 12334514f5e3Sopenharmony_ci Jump(&exit); 12344514f5e3Sopenharmony_ci } 12354514f5e3Sopenharmony_ci Bind(&exit); 12364514f5e3Sopenharmony_ci auto ret = *result; 12374514f5e3Sopenharmony_ci env->SubCfgExit(); 12384514f5e3Sopenharmony_ci return ret; 12394514f5e3Sopenharmony_ci} 12404514f5e3Sopenharmony_ci 12414514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Inc(GateRef glue, GateRef value, ProfileOperation callback) 12424514f5e3Sopenharmony_ci{ 12434514f5e3Sopenharmony_ci auto env = GetEnvironment(); 12444514f5e3Sopenharmony_ci Label entry(env); 12454514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 12464514f5e3Sopenharmony_ci Label exit(env); 12474514f5e3Sopenharmony_ci 12484514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 12494514f5e3Sopenharmony_ci Label valueIsInt(env); 12504514f5e3Sopenharmony_ci Label valueNotInt(env); 12514514f5e3Sopenharmony_ci Label slowPath(env); 12524514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(value), &valueIsInt, &valueNotInt); 12534514f5e3Sopenharmony_ci Bind(&valueIsInt); 12544514f5e3Sopenharmony_ci { 12554514f5e3Sopenharmony_ci GateRef valueInt = GetInt32OfTInt(value); 12564514f5e3Sopenharmony_ci Label valueNoOverflow(env); 12574514f5e3Sopenharmony_ci BRANCH(Int32Equal(valueInt, Int32(INT32_MAX)), &valueNotInt, &valueNoOverflow); 12584514f5e3Sopenharmony_ci Bind(&valueNoOverflow); 12594514f5e3Sopenharmony_ci { 12604514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 12614514f5e3Sopenharmony_ci result = IntToTaggedPtr(Int32Add(valueInt, Int32(1))); 12624514f5e3Sopenharmony_ci Jump(&exit); 12634514f5e3Sopenharmony_ci } 12644514f5e3Sopenharmony_ci } 12654514f5e3Sopenharmony_ci Bind(&valueNotInt); 12664514f5e3Sopenharmony_ci { 12674514f5e3Sopenharmony_ci Label valueIsDouble(env); 12684514f5e3Sopenharmony_ci BRANCH(TaggedIsDouble(value), &valueIsDouble, &slowPath); 12694514f5e3Sopenharmony_ci Bind(&valueIsDouble); 12704514f5e3Sopenharmony_ci { 12714514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 12724514f5e3Sopenharmony_ci GateRef valueDouble = GetDoubleOfTDouble(value); 12734514f5e3Sopenharmony_ci result = DoubleToTaggedDoublePtr(DoubleAdd(valueDouble, Double(1.0))); 12744514f5e3Sopenharmony_ci Jump(&exit); 12754514f5e3Sopenharmony_ci } 12764514f5e3Sopenharmony_ci } 12774514f5e3Sopenharmony_ci Bind(&slowPath); 12784514f5e3Sopenharmony_ci { 12794514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 12804514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Inc), { value }); 12814514f5e3Sopenharmony_ci Jump(&exit); 12824514f5e3Sopenharmony_ci } 12834514f5e3Sopenharmony_ci Bind(&exit); 12844514f5e3Sopenharmony_ci auto ret = *result; 12854514f5e3Sopenharmony_ci env->SubCfgExit(); 12864514f5e3Sopenharmony_ci return ret; 12874514f5e3Sopenharmony_ci} 12884514f5e3Sopenharmony_ci 12894514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Dec(GateRef glue, GateRef value, ProfileOperation callback) 12904514f5e3Sopenharmony_ci{ 12914514f5e3Sopenharmony_ci auto env = GetEnvironment(); 12924514f5e3Sopenharmony_ci Label entry(env); 12934514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 12944514f5e3Sopenharmony_ci Label exit(env); 12954514f5e3Sopenharmony_ci 12964514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 12974514f5e3Sopenharmony_ci Label valueIsInt(env); 12984514f5e3Sopenharmony_ci Label valueNotInt(env); 12994514f5e3Sopenharmony_ci Label slowPath(env); 13004514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(value), &valueIsInt, &valueNotInt); 13014514f5e3Sopenharmony_ci Bind(&valueIsInt); 13024514f5e3Sopenharmony_ci { 13034514f5e3Sopenharmony_ci GateRef valueInt = GetInt32OfTInt(value); 13044514f5e3Sopenharmony_ci Label valueNoOverflow(env); 13054514f5e3Sopenharmony_ci BRANCH(Int32Equal(valueInt, Int32(INT32_MIN)), &valueNotInt, &valueNoOverflow); 13064514f5e3Sopenharmony_ci Bind(&valueNoOverflow); 13074514f5e3Sopenharmony_ci { 13084514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 13094514f5e3Sopenharmony_ci result = IntToTaggedPtr(Int32Sub(valueInt, Int32(1))); 13104514f5e3Sopenharmony_ci Jump(&exit); 13114514f5e3Sopenharmony_ci } 13124514f5e3Sopenharmony_ci } 13134514f5e3Sopenharmony_ci Bind(&valueNotInt); 13144514f5e3Sopenharmony_ci { 13154514f5e3Sopenharmony_ci Label valueIsDouble(env); 13164514f5e3Sopenharmony_ci BRANCH(TaggedIsDouble(value), &valueIsDouble, &slowPath); 13174514f5e3Sopenharmony_ci Bind(&valueIsDouble); 13184514f5e3Sopenharmony_ci { 13194514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 13204514f5e3Sopenharmony_ci GateRef valueDouble = GetDoubleOfTDouble(value); 13214514f5e3Sopenharmony_ci result = DoubleToTaggedDoublePtr(DoubleSub(valueDouble, Double(1.0))); 13224514f5e3Sopenharmony_ci Jump(&exit); 13234514f5e3Sopenharmony_ci } 13244514f5e3Sopenharmony_ci } 13254514f5e3Sopenharmony_ci Bind(&slowPath); 13264514f5e3Sopenharmony_ci { 13274514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 13284514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Dec), { value }); 13294514f5e3Sopenharmony_ci Jump(&exit); 13304514f5e3Sopenharmony_ci } 13314514f5e3Sopenharmony_ci 13324514f5e3Sopenharmony_ci Bind(&exit); 13334514f5e3Sopenharmony_ci auto ret = *result; 13344514f5e3Sopenharmony_ci env->SubCfgExit(); 13354514f5e3Sopenharmony_ci return ret; 13364514f5e3Sopenharmony_ci} 13374514f5e3Sopenharmony_ci 13384514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Neg(GateRef glue, GateRef value, ProfileOperation callback) 13394514f5e3Sopenharmony_ci{ 13404514f5e3Sopenharmony_ci auto env = GetEnvironment(); 13414514f5e3Sopenharmony_ci Label entry(env); 13424514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 13434514f5e3Sopenharmony_ci Label exit(env); 13444514f5e3Sopenharmony_ci 13454514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 13464514f5e3Sopenharmony_ci Label valueIsInt(env); 13474514f5e3Sopenharmony_ci Label valueNotInt(env); 13484514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(value), &valueIsInt, &valueNotInt); 13494514f5e3Sopenharmony_ci Bind(&valueIsInt); 13504514f5e3Sopenharmony_ci { 13514514f5e3Sopenharmony_ci GateRef valueInt = GetInt32OfTInt(value); 13524514f5e3Sopenharmony_ci Label valueIsZero(env); 13534514f5e3Sopenharmony_ci Label valueNotZero(env); 13544514f5e3Sopenharmony_ci BRANCH(Int32Equal(valueInt, Int32(0)), &valueIsZero, &valueNotZero); 13554514f5e3Sopenharmony_ci Bind(&valueIsZero); 13564514f5e3Sopenharmony_ci { 13574514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntOverFlowType())); 13584514f5e3Sopenharmony_ci result = DoubleToTaggedDoublePtr(Double(-0.0)); 13594514f5e3Sopenharmony_ci Jump(&exit); 13604514f5e3Sopenharmony_ci } 13614514f5e3Sopenharmony_ci Bind(&valueNotZero); 13624514f5e3Sopenharmony_ci { 13634514f5e3Sopenharmony_ci Label valueIsInt32Min(env); 13644514f5e3Sopenharmony_ci Label valueNotInt32Min(env); 13654514f5e3Sopenharmony_ci BRANCH(Int32Equal(valueInt, Int32(INT32_MIN)), &valueIsInt32Min, &valueNotInt32Min); 13664514f5e3Sopenharmony_ci Bind(&valueIsInt32Min); 13674514f5e3Sopenharmony_ci { 13684514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntOverFlowType())); 13694514f5e3Sopenharmony_ci result = DoubleToTaggedDoublePtr(Double(-static_cast<double>(INT32_MIN))); 13704514f5e3Sopenharmony_ci Jump(&exit); 13714514f5e3Sopenharmony_ci } 13724514f5e3Sopenharmony_ci Bind(&valueNotInt32Min); 13734514f5e3Sopenharmony_ci { 13744514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 13754514f5e3Sopenharmony_ci result = IntToTaggedPtr(Int32Sub(Int32(0), valueInt)); 13764514f5e3Sopenharmony_ci Jump(&exit); 13774514f5e3Sopenharmony_ci } 13784514f5e3Sopenharmony_ci } 13794514f5e3Sopenharmony_ci } 13804514f5e3Sopenharmony_ci Bind(&valueNotInt); 13814514f5e3Sopenharmony_ci { 13824514f5e3Sopenharmony_ci Label valueIsDouble(env); 13834514f5e3Sopenharmony_ci Label valueNotDouble(env); 13844514f5e3Sopenharmony_ci BRANCH(TaggedIsDouble(value), &valueIsDouble, &valueNotDouble); 13854514f5e3Sopenharmony_ci Bind(&valueIsDouble); 13864514f5e3Sopenharmony_ci { 13874514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 13884514f5e3Sopenharmony_ci GateRef valueDouble = GetDoubleOfTDouble(value); 13894514f5e3Sopenharmony_ci result = DoubleToTaggedDoublePtr(DoubleMul(Double(-1), valueDouble)); 13904514f5e3Sopenharmony_ci Jump(&exit); 13914514f5e3Sopenharmony_ci } 13924514f5e3Sopenharmony_ci Bind(&valueNotDouble); 13934514f5e3Sopenharmony_ci { 13944514f5e3Sopenharmony_ci // slow path 13954514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 13964514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Neg), { value }); 13974514f5e3Sopenharmony_ci Jump(&exit); 13984514f5e3Sopenharmony_ci } 13994514f5e3Sopenharmony_ci } 14004514f5e3Sopenharmony_ci Bind(&exit); 14014514f5e3Sopenharmony_ci auto ret = *result; 14024514f5e3Sopenharmony_ci env->SubCfgExit(); 14034514f5e3Sopenharmony_ci return ret; 14044514f5e3Sopenharmony_ci} 14054514f5e3Sopenharmony_ci 14064514f5e3Sopenharmony_ciGateRef OperationsStubBuilder::Not(GateRef glue, GateRef value, ProfileOperation callback) 14074514f5e3Sopenharmony_ci{ 14084514f5e3Sopenharmony_ci auto env = GetEnvironment(); 14094514f5e3Sopenharmony_ci Label entry(env); 14104514f5e3Sopenharmony_ci env->SubCfgEntry(&entry); 14114514f5e3Sopenharmony_ci Label exit(env); 14124514f5e3Sopenharmony_ci 14134514f5e3Sopenharmony_ci DEFVARIABLE(result, VariableType::JS_ANY(), Hole()); 14144514f5e3Sopenharmony_ci Label numberIsInt(env); 14154514f5e3Sopenharmony_ci Label numberNotInt(env); 14164514f5e3Sopenharmony_ci BRANCH(TaggedIsInt(value), &numberIsInt, &numberNotInt); 14174514f5e3Sopenharmony_ci Bind(&numberIsInt); 14184514f5e3Sopenharmony_ci { 14194514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::IntType())); 14204514f5e3Sopenharmony_ci GateRef valueInt = GetInt32OfTInt(value); 14214514f5e3Sopenharmony_ci result = IntToTaggedPtr(Int32Not(valueInt)); 14224514f5e3Sopenharmony_ci Jump(&exit); 14234514f5e3Sopenharmony_ci } 14244514f5e3Sopenharmony_ci Bind(&numberNotInt); 14254514f5e3Sopenharmony_ci { 14264514f5e3Sopenharmony_ci Label numberIsDouble(env); 14274514f5e3Sopenharmony_ci Label numberNotDouble(env); 14284514f5e3Sopenharmony_ci BRANCH(TaggedIsDouble(value), &numberIsDouble, &numberNotDouble); 14294514f5e3Sopenharmony_ci Bind(&numberIsDouble); 14304514f5e3Sopenharmony_ci { 14314514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType())); 14324514f5e3Sopenharmony_ci GateRef valueDouble = GetDoubleOfTDouble(value); 14334514f5e3Sopenharmony_ci result = IntToTaggedPtr(Int32Not(DoubleToInt(glue, valueDouble))); 14344514f5e3Sopenharmony_ci Jump(&exit); 14354514f5e3Sopenharmony_ci } 14364514f5e3Sopenharmony_ci Bind(&numberNotDouble); 14374514f5e3Sopenharmony_ci { 14384514f5e3Sopenharmony_ci // slow path 14394514f5e3Sopenharmony_ci callback.ProfileOpType(TaggedInt(PGOSampleType::AnyType())); 14404514f5e3Sopenharmony_ci result = CallRuntime(glue, RTSTUB_ID(Not), { value }); 14414514f5e3Sopenharmony_ci Jump(&exit); 14424514f5e3Sopenharmony_ci } 14434514f5e3Sopenharmony_ci } 14444514f5e3Sopenharmony_ci Bind(&exit); 14454514f5e3Sopenharmony_ci auto ret = *result; 14464514f5e3Sopenharmony_ci env->SubCfgExit(); 14474514f5e3Sopenharmony_ci return ret; 14484514f5e3Sopenharmony_ci} 14494514f5e3Sopenharmony_ci} // namespace panda::ecmascript::kungfu 1450