14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_COMPILER_BASELINE_BASELINE_STUBS_INL_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMPILER_BASELINE_BASELINE_STUBS_INL_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/compiler/baseline/baseline_stubs.h" 204514f5e3Sopenharmony_ci#include "ecmascript/js_function.h" 214514f5e3Sopenharmony_ci#include "ecmascript/js_generator_object.h" 224514f5e3Sopenharmony_ci#include "ecmascript/js_async_generator_object.h" 234514f5e3Sopenharmony_ci 244514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu { 254514f5e3Sopenharmony_ciusing namespace panda::ecmascript; 264514f5e3Sopenharmony_ci 274514f5e3Sopenharmony_civoid BaselineStubBuilder::SetEnvToFrame(GateRef glue, GateRef frame, GateRef value) 284514f5e3Sopenharmony_ci{ 294514f5e3Sopenharmony_ci Store(VariableType::INT64(), glue, frame, 304514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetEnvOffset(GetEnvironment()->IsArch32Bit())), value); 314514f5e3Sopenharmony_ci} 324514f5e3Sopenharmony_ci 334514f5e3Sopenharmony_civoid BaselineStubBuilder::CheckExceptionWithVar(GateRef glue, GateRef sp, GateRef res, GateRef acc) 344514f5e3Sopenharmony_ci{ 354514f5e3Sopenharmony_ci auto env = GetEnvironment(); 364514f5e3Sopenharmony_ci Label isException(env); 374514f5e3Sopenharmony_ci Label notException(env); 384514f5e3Sopenharmony_ci Branch(TaggedIsException(res), &isException, ¬Exception); 394514f5e3Sopenharmony_ci Bind(&isException); 404514f5e3Sopenharmony_ci { 414514f5e3Sopenharmony_ci DispatchLast(glue, sp, acc); 424514f5e3Sopenharmony_ci Return(acc); 434514f5e3Sopenharmony_ci } 444514f5e3Sopenharmony_ci Bind(¬Exception); 454514f5e3Sopenharmony_ci { 464514f5e3Sopenharmony_ci Return(res); 474514f5e3Sopenharmony_ci } 484514f5e3Sopenharmony_ci} 494514f5e3Sopenharmony_ci 504514f5e3Sopenharmony_civoid BaselineStubBuilder::CheckException(GateRef glue, GateRef sp, GateRef res) 514514f5e3Sopenharmony_ci{ 524514f5e3Sopenharmony_ci auto env = GetEnvironment(); 534514f5e3Sopenharmony_ci Label isException(env); 544514f5e3Sopenharmony_ci Label notException(env); 554514f5e3Sopenharmony_ci Branch(TaggedIsException(res), &isException, ¬Exception); 564514f5e3Sopenharmony_ci Bind(&isException); 574514f5e3Sopenharmony_ci { 584514f5e3Sopenharmony_ci GateRef frame = GetFrame(sp); 594514f5e3Sopenharmony_ci GateRef acc = GetAccFromFrame(frame); 604514f5e3Sopenharmony_ci DispatchLast(glue, sp, acc); 614514f5e3Sopenharmony_ci Return(); 624514f5e3Sopenharmony_ci } 634514f5e3Sopenharmony_ci Bind(¬Exception); 644514f5e3Sopenharmony_ci { 654514f5e3Sopenharmony_ci Return(); 664514f5e3Sopenharmony_ci } 674514f5e3Sopenharmony_ci} 684514f5e3Sopenharmony_ci 694514f5e3Sopenharmony_civoid BaselineStubBuilder::CheckExceptionReturn(GateRef glue, GateRef sp, GateRef res) 704514f5e3Sopenharmony_ci{ 714514f5e3Sopenharmony_ci auto env = GetEnvironment(); 724514f5e3Sopenharmony_ci Label isException(env); 734514f5e3Sopenharmony_ci Label notException(env); 744514f5e3Sopenharmony_ci Branch(TaggedIsException(res), &isException, ¬Exception); 754514f5e3Sopenharmony_ci Bind(&isException); 764514f5e3Sopenharmony_ci { 774514f5e3Sopenharmony_ci GateRef frame = GetFrame(sp); 784514f5e3Sopenharmony_ci GateRef acc = GetAccFromFrame(frame); 794514f5e3Sopenharmony_ci DispatchLast(glue, sp, acc); 804514f5e3Sopenharmony_ci Return(acc); 814514f5e3Sopenharmony_ci } 824514f5e3Sopenharmony_ci Bind(¬Exception); 834514f5e3Sopenharmony_ci { 844514f5e3Sopenharmony_ci Return(res); 854514f5e3Sopenharmony_ci } 864514f5e3Sopenharmony_ci} 874514f5e3Sopenharmony_ci 884514f5e3Sopenharmony_civoid BaselineStubBuilder::CheckExceptionWithJump(GateRef glue, GateRef sp, GateRef res, GateRef acc, Label *jump) 894514f5e3Sopenharmony_ci{ 904514f5e3Sopenharmony_ci auto env = GetEnvironment(); 914514f5e3Sopenharmony_ci Label isException(env); 924514f5e3Sopenharmony_ci Label notException(env); 934514f5e3Sopenharmony_ci Branch(TaggedIsException(res), &isException, ¬Exception); 944514f5e3Sopenharmony_ci Bind(&isException); 954514f5e3Sopenharmony_ci { 964514f5e3Sopenharmony_ci DispatchLast(glue, sp, acc); 974514f5e3Sopenharmony_ci Return(); 984514f5e3Sopenharmony_ci } 994514f5e3Sopenharmony_ci Bind(¬Exception); 1004514f5e3Sopenharmony_ci { 1014514f5e3Sopenharmony_ci Jump(jump); 1024514f5e3Sopenharmony_ci } 1034514f5e3Sopenharmony_ci} 1044514f5e3Sopenharmony_ci 1054514f5e3Sopenharmony_civoid BaselineStubBuilder::CheckExceptionWithJumpAndReturn(GateRef glue, GateRef sp, GateRef res, GateRef acc, 1064514f5e3Sopenharmony_ci Label *jump) 1074514f5e3Sopenharmony_ci{ 1084514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1094514f5e3Sopenharmony_ci Label isException(env); 1104514f5e3Sopenharmony_ci Label notException(env); 1114514f5e3Sopenharmony_ci Branch(TaggedIsException(res), &isException, ¬Exception); 1124514f5e3Sopenharmony_ci Bind(&isException); 1134514f5e3Sopenharmony_ci { 1144514f5e3Sopenharmony_ci DispatchLast(glue, sp, acc); 1154514f5e3Sopenharmony_ci Return(acc); 1164514f5e3Sopenharmony_ci } 1174514f5e3Sopenharmony_ci Bind(¬Exception); 1184514f5e3Sopenharmony_ci { 1194514f5e3Sopenharmony_ci Jump(jump); 1204514f5e3Sopenharmony_ci } 1214514f5e3Sopenharmony_ci} 1224514f5e3Sopenharmony_ci 1234514f5e3Sopenharmony_civoid BaselineStubBuilder::CheckPendingException(GateRef glue, GateRef sp, GateRef res, GateRef acc) 1244514f5e3Sopenharmony_ci{ 1254514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1264514f5e3Sopenharmony_ci Label isException(env); 1274514f5e3Sopenharmony_ci Label notException(env); 1284514f5e3Sopenharmony_ci Branch(HasPendingException(glue), &isException, ¬Exception); 1294514f5e3Sopenharmony_ci Bind(&isException); 1304514f5e3Sopenharmony_ci { 1314514f5e3Sopenharmony_ci DispatchLast(glue, sp, acc); 1324514f5e3Sopenharmony_ci Return(acc); 1334514f5e3Sopenharmony_ci } 1344514f5e3Sopenharmony_ci Bind(¬Exception); 1354514f5e3Sopenharmony_ci { 1364514f5e3Sopenharmony_ci Return(res); 1374514f5e3Sopenharmony_ci } 1384514f5e3Sopenharmony_ci} 1394514f5e3Sopenharmony_ci 1404514f5e3Sopenharmony_civoid BaselineStubBuilder::DispatchLast(GateRef glue, GateRef sp, GateRef acc) 1414514f5e3Sopenharmony_ci{ 1424514f5e3Sopenharmony_ci // Get baseline exceptionHandler index 1434514f5e3Sopenharmony_ci GateRef baselineEHIndex = BaselineStubCSigns::BaselineExceptionHandler; 1444514f5e3Sopenharmony_ci CallBaselineStub(glue, baselineEHIndex, { glue, sp, acc }); 1454514f5e3Sopenharmony_ci} 1464514f5e3Sopenharmony_ci 1474514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::CallBaselineStub(GateRef glue, int index, const std::initializer_list<GateRef>& args) 1484514f5e3Sopenharmony_ci{ 1494514f5e3Sopenharmony_ci auto env = GetEnvironment(); 1504514f5e3Sopenharmony_ci const std::string name = BaselineStubCSigns::GetName(index); 1514514f5e3Sopenharmony_ci GateRef result = env->GetBuilder()->CallStub(glue, Circuit::NullGate(), index, args, name.c_str()); 1524514f5e3Sopenharmony_ci return result; 1534514f5e3Sopenharmony_ci} 1544514f5e3Sopenharmony_ci 1554514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetFunctionFromFrame(GateRef frame) 1564514f5e3Sopenharmony_ci{ 1574514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), frame, 1584514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetFunctionOffset(GetEnvironment()->IsArch32Bit()))); 1594514f5e3Sopenharmony_ci} 1604514f5e3Sopenharmony_ci 1614514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetEnvFromFrame(GateRef frame) 1624514f5e3Sopenharmony_ci{ 1634514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), frame, 1644514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetEnvOffset(GetEnvironment()->IsArch32Bit()))); 1654514f5e3Sopenharmony_ci} 1664514f5e3Sopenharmony_ci 1674514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetAccFromFrame(GateRef frame) 1684514f5e3Sopenharmony_ci{ 1694514f5e3Sopenharmony_ci return Load(VariableType::JS_ANY(), frame, 1704514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetAccOffset(GetEnvironment()->IsArch32Bit()))); 1714514f5e3Sopenharmony_ci} 1724514f5e3Sopenharmony_ci 1734514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetConstpoolFromMethod(GateRef method) 1744514f5e3Sopenharmony_ci{ 1754514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), method, IntPtr(Method::CONSTANT_POOL_OFFSET)); 1764514f5e3Sopenharmony_ci} 1774514f5e3Sopenharmony_ci 1784514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetProfileTypeInfoFromFunction(GateRef function) 1794514f5e3Sopenharmony_ci{ 1804514f5e3Sopenharmony_ci GateRef raw = Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::RAW_PROFILE_TYPE_INFO_OFFSET)); 1814514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), raw, IntPtr(ProfileTypeInfoCell::VALUE_OFFSET)); 1824514f5e3Sopenharmony_ci} 1834514f5e3Sopenharmony_ci 1844514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetHotnessCounterFromMethod(GateRef method) 1854514f5e3Sopenharmony_ci{ 1864514f5e3Sopenharmony_ci GateRef x = Load(VariableType::INT16(), method, IntPtr(Method::LITERAL_INFO_OFFSET)); 1874514f5e3Sopenharmony_ci return GetEnvironment()->GetBuilder()->SExtInt1ToInt32(x); 1884514f5e3Sopenharmony_ci} 1894514f5e3Sopenharmony_ci 1904514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetModuleFromFunction(GateRef function) 1914514f5e3Sopenharmony_ci{ 1924514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::ECMA_MODULE_OFFSET)); 1934514f5e3Sopenharmony_ci} 1944514f5e3Sopenharmony_ci 1954514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetHomeObjectFromFunction(GateRef function) 1964514f5e3Sopenharmony_ci{ 1974514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::HOME_OBJECT_OFFSET)); 1984514f5e3Sopenharmony_ci} 1994514f5e3Sopenharmony_ci 2004514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetModule(GateRef sp) 2014514f5e3Sopenharmony_ci{ 2024514f5e3Sopenharmony_ci GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp)); 2034514f5e3Sopenharmony_ci return GetModuleFromFunction(currentFunc); 2044514f5e3Sopenharmony_ci} 2054514f5e3Sopenharmony_ci 2064514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetCurrentFrame(GateRef glue) 2074514f5e3Sopenharmony_ci{ 2084514f5e3Sopenharmony_ci return GetLastLeaveFrame(glue); 2094514f5e3Sopenharmony_ci} 2104514f5e3Sopenharmony_ci 2114514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetFrame(GateRef CurrentSp) 2124514f5e3Sopenharmony_ci{ 2134514f5e3Sopenharmony_ci return PtrSub(CurrentSp, IntPtr(AsmInterpretedFrame::GetSize(GetEnvironment()->IsArch32Bit()))); 2144514f5e3Sopenharmony_ci} 2154514f5e3Sopenharmony_ci 2164514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetPcFromFrame(GateRef frame) 2174514f5e3Sopenharmony_ci{ 2184514f5e3Sopenharmony_ci return Load(VariableType::NATIVE_POINTER(), frame, 2194514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetPcOffset(GetEnvironment()->IsArch32Bit()))); 2204514f5e3Sopenharmony_ci} 2214514f5e3Sopenharmony_ci 2224514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetCallSizeFromFrame(GateRef frame) 2234514f5e3Sopenharmony_ci{ 2244514f5e3Sopenharmony_ci return Load(VariableType::NATIVE_POINTER(), frame, 2254514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetCallSizeOffset(GetEnvironment()->IsArch32Bit()))); 2264514f5e3Sopenharmony_ci} 2274514f5e3Sopenharmony_ci 2284514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetThisFromFrame(GateRef frame) 2294514f5e3Sopenharmony_ci{ 2304514f5e3Sopenharmony_ci return Load(VariableType::JS_POINTER(), frame, 2314514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetThisOffset(GetEnvironment()->IsArch32Bit()))); 2324514f5e3Sopenharmony_ci} 2334514f5e3Sopenharmony_ci 2344514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetNewTarget(GateRef sp) 2354514f5e3Sopenharmony_ci{ 2364514f5e3Sopenharmony_ci GateRef function = Load(VariableType::JS_POINTER(), GetFrame(sp), 2374514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetFunctionOffset(GetEnvironment()->IsArch32Bit()))); 2384514f5e3Sopenharmony_ci GateRef method = GetMethodFromFunction(function); 2394514f5e3Sopenharmony_ci GateRef callField = GetCallFieldFromMethod(method); 2404514f5e3Sopenharmony_ci // ASSERT: callField has "extra" bit. 2414514f5e3Sopenharmony_ci GateRef numVregs = 2424514f5e3Sopenharmony_ci TruncInt64ToInt32(Int64And(Int64LSR(callField, Int64(MethodLiteral::NumVregsBits::START_BIT)), 2434514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::NumVregsBits::SIZE) - 1))); 2444514f5e3Sopenharmony_ci GateRef haveFunc = 2454514f5e3Sopenharmony_ci ZExtInt1ToInt32(Int64NotEqual(Int64And(Int64LSR(callField, Int64(MethodLiteral::HaveFuncBit::START_BIT)), 2464514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::HaveFuncBit::SIZE) - 1)), Int64(0))); 2474514f5e3Sopenharmony_ci GateRef idx = ZExtInt32ToPtr(Int32Add(numVregs, haveFunc)); 2484514f5e3Sopenharmony_ci return Load(VariableType::JS_ANY(), sp, PtrMul(IntPtr(JSTaggedValue::TaggedTypeSize()), idx)); 2494514f5e3Sopenharmony_ci} 2504514f5e3Sopenharmony_ci 2514514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetStartIdxAndNumArgs(GateRef sp, GateRef restIdx) 2524514f5e3Sopenharmony_ci{ 2534514f5e3Sopenharmony_ci auto env = GetEnvironment(); 2544514f5e3Sopenharmony_ci Label subEntry(env); 2554514f5e3Sopenharmony_ci env->SubCfgEntry(&subEntry); 2564514f5e3Sopenharmony_ci DEFVARIABLE(numArgs, VariableType::INT32(), Int32(0)); 2574514f5e3Sopenharmony_ci GateRef state = PtrSub(sp, IntPtr(AsmInterpretedFrame::GetSize(env->IsArch32Bit()))); 2584514f5e3Sopenharmony_ci GateRef function = GetFunctionFromFrame(state); 2594514f5e3Sopenharmony_ci GateRef method = GetMethodFromJSFunctionOrProxy(function); 2604514f5e3Sopenharmony_ci GateRef callField = GetCallFieldFromMethod(method); 2614514f5e3Sopenharmony_ci // ASSERT: callField has "extra" bit. 2624514f5e3Sopenharmony_ci GateRef numVregs = TruncInt64ToInt32(Int64And( 2634514f5e3Sopenharmony_ci Int64LSR(callField, Int64(MethodLiteral::NumVregsBits::START_BIT)), 2644514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::NumVregsBits::SIZE) - 1))); 2654514f5e3Sopenharmony_ci GateRef haveFunc = Int64NotEqual(Int64And(Int64LSR(callField, Int64(MethodLiteral::HaveFuncBit::START_BIT)), 2664514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::HaveFuncBit::SIZE) - 1)), Int64(0)); 2674514f5e3Sopenharmony_ci GateRef haveNewTarget = Int64NotEqual( 2684514f5e3Sopenharmony_ci Int64And(Int64LSR(callField, Int64(MethodLiteral::HaveNewTargetBit::START_BIT)), 2694514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::HaveNewTargetBit::SIZE) - 1)), Int64(0)); 2704514f5e3Sopenharmony_ci GateRef haveThis = Int64NotEqual(Int64And(Int64LSR(callField, Int64(MethodLiteral::HaveThisBit::START_BIT)), 2714514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::HaveThisBit::SIZE) - 1)), Int64(0)); 2724514f5e3Sopenharmony_ci GateRef copyArgs = Int32Add(Int32Add(ZExtInt1ToInt32(haveFunc), ZExtInt1ToInt32(haveNewTarget)), 2734514f5e3Sopenharmony_ci ZExtInt1ToInt32(haveThis)); 2744514f5e3Sopenharmony_ci numArgs = TruncInt64ToInt32(Int64And(Int64LSR(callField, Int64(MethodLiteral::NumArgsBits::START_BIT)), 2754514f5e3Sopenharmony_ci Int64((1LLU << MethodLiteral::NumArgsBits::SIZE) - 1))); 2764514f5e3Sopenharmony_ci GateRef fp = Load(VariableType::NATIVE_POINTER(), state, 2774514f5e3Sopenharmony_ci IntPtr(AsmInterpretedFrame::GetFpOffset(env->IsArch32Bit()))); 2784514f5e3Sopenharmony_ci Label actualEqualDeclared(env); 2794514f5e3Sopenharmony_ci Label actualNotEqualDeclared(env); 2804514f5e3Sopenharmony_ci Branch(Int32UnsignedGreaterThan(ChangeIntPtrToInt32(PtrSub(fp, sp)), 2814514f5e3Sopenharmony_ci Int32Mul(Int32Add(Int32Add(numVregs, copyArgs), *numArgs), 2824514f5e3Sopenharmony_ci Int32(sizeof(JSTaggedType)))), 2834514f5e3Sopenharmony_ci &actualNotEqualDeclared, &actualEqualDeclared); 2844514f5e3Sopenharmony_ci Bind(&actualNotEqualDeclared); 2854514f5e3Sopenharmony_ci { 2864514f5e3Sopenharmony_ci numArgs = GetInt32OfTInt(Load(VariableType::JS_ANY(), fp, IntPtr(static_cast<int64_t>(-sizeof(JSTaggedType))))); 2874514f5e3Sopenharmony_ci Jump(&actualEqualDeclared); 2884514f5e3Sopenharmony_ci } 2894514f5e3Sopenharmony_ci Bind(&actualEqualDeclared); 2904514f5e3Sopenharmony_ci GateRef startIdx = Int32Add(Int32Add(numVregs, copyArgs), restIdx); 2914514f5e3Sopenharmony_ci Label numArgsGreater(env); 2924514f5e3Sopenharmony_ci Label numArgsNotGreater(env); 2934514f5e3Sopenharmony_ci Label exit(env); 2944514f5e3Sopenharmony_ci Branch(Int32UnsignedGreaterThan(*numArgs, restIdx), &numArgsGreater, &numArgsNotGreater); 2954514f5e3Sopenharmony_ci Bind(&numArgsGreater); 2964514f5e3Sopenharmony_ci { 2974514f5e3Sopenharmony_ci numArgs = Int32Sub(*numArgs, restIdx); 2984514f5e3Sopenharmony_ci Jump(&exit); 2994514f5e3Sopenharmony_ci } 3004514f5e3Sopenharmony_ci Bind(&numArgsNotGreater); 3014514f5e3Sopenharmony_ci { 3024514f5e3Sopenharmony_ci numArgs = Int32(0); 3034514f5e3Sopenharmony_ci Jump(&exit); 3044514f5e3Sopenharmony_ci } 3054514f5e3Sopenharmony_ci Bind(&exit); 3064514f5e3Sopenharmony_ci // 32: high 32 bits = startIdx, low 32 bits = numArgs 3074514f5e3Sopenharmony_ci GateRef ret = Int64Or(Int64LSL(ZExtInt32ToInt64(startIdx), Int64(32)), ZExtInt32ToInt64(*numArgs)); 3084514f5e3Sopenharmony_ci env->SubCfgExit(); 3094514f5e3Sopenharmony_ci return ret; 3104514f5e3Sopenharmony_ci} 3114514f5e3Sopenharmony_ci 3124514f5e3Sopenharmony_civoid BaselineStubBuilder::SetVregValue(GateRef glue, GateRef sp, GateRef idx, GateRef val) 3134514f5e3Sopenharmony_ci{ 3144514f5e3Sopenharmony_ci Store(VariableType::INT64(), glue, sp, PtrMul(IntPtr(sizeof(JSTaggedType)), idx), val); 3154514f5e3Sopenharmony_ci} 3164514f5e3Sopenharmony_ci 3174514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetVregValue(GateRef sp, GateRef idx) 3184514f5e3Sopenharmony_ci{ 3194514f5e3Sopenharmony_ci return Load(VariableType::JS_ANY(), sp, PtrMul(IntPtr(sizeof(JSTaggedType)), idx)); 3204514f5e3Sopenharmony_ci} 3214514f5e3Sopenharmony_ci 3224514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetResumeModeFromGeneratorObject(GateRef obj) 3234514f5e3Sopenharmony_ci{ 3244514f5e3Sopenharmony_ci GateRef bitfieldOffset = IntPtr(JSGeneratorObject::BIT_FIELD_OFFSET); 3254514f5e3Sopenharmony_ci GateRef bitfield = Load(VariableType::INT32(), obj, bitfieldOffset); 3264514f5e3Sopenharmony_ci return Int32And( 3274514f5e3Sopenharmony_ci Int32LSR(bitfield, Int32(JSGeneratorObject::ResumeModeBits::START_BIT)), 3284514f5e3Sopenharmony_ci Int32((1LU << JSGeneratorObject::ResumeModeBits::SIZE) - 1)); 3294514f5e3Sopenharmony_ci} 3304514f5e3Sopenharmony_ci 3314514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetResumeModeFromAsyncGeneratorObject(GateRef obj) 3324514f5e3Sopenharmony_ci{ 3334514f5e3Sopenharmony_ci GateRef bitfieldOffset = IntPtr(JSAsyncGeneratorObject::BIT_FIELD_OFFSET); 3344514f5e3Sopenharmony_ci GateRef bitfield = Load(VariableType::INT32(), obj, bitfieldOffset); 3354514f5e3Sopenharmony_ci return Int32And( 3364514f5e3Sopenharmony_ci Int32LSR(bitfield, Int32(JSAsyncGeneratorObject::ResumeModeBits::START_BIT)), 3374514f5e3Sopenharmony_ci Int32((1LU << JSAsyncGeneratorObject::ResumeModeBits::SIZE) - 1)); 3384514f5e3Sopenharmony_ci} 3394514f5e3Sopenharmony_ci 3404514f5e3Sopenharmony_ciGateRef BaselineStubBuilder::GetLastLeaveFrame(GateRef glue) 3414514f5e3Sopenharmony_ci{ 3424514f5e3Sopenharmony_ci bool isArch32 = GetEnvironment()->Is32Bit(); 3434514f5e3Sopenharmony_ci GateRef spOffset = IntPtr(JSThread::GlueData::GetLeaveFrameOffset(isArch32)); 3444514f5e3Sopenharmony_ci return Load(VariableType::NATIVE_POINTER(), glue, spOffset); 3454514f5e3Sopenharmony_ci} 3464514f5e3Sopenharmony_ci} 3474514f5e3Sopenharmony_ci 3484514f5e3Sopenharmony_ci#endif // ECMASCRIPT_COMPILER_BASELINE_BASELINE_STUBS_INL_H 349