14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_COMPILER_STUB_INL_H
174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMPILER_STUB_INL_H
184514f5e3Sopenharmony_ci
194514f5e3Sopenharmony_ci#include "ecmascript/compiler/share_gate_meta_data.h"
204514f5e3Sopenharmony_ci#include "ecmascript/compiler/stub_builder.h"
214514f5e3Sopenharmony_ci
224514f5e3Sopenharmony_ci#include "ecmascript/accessor_data.h"
234514f5e3Sopenharmony_ci#include "ecmascript/base/number_helper.h"
244514f5e3Sopenharmony_ci#include "ecmascript/compiler/assembler_module.h"
254514f5e3Sopenharmony_ci#include "ecmascript/compiler/bc_call_signature.h"
264514f5e3Sopenharmony_ci#include "ecmascript/compiler/baseline/baseline_call_signature.h"
274514f5e3Sopenharmony_ci#include "ecmascript/global_dictionary.h"
284514f5e3Sopenharmony_ci#include "ecmascript/global_env.h"
294514f5e3Sopenharmony_ci#include "ecmascript/global_env_constants.h"
304514f5e3Sopenharmony_ci#include "ecmascript/ic/ic_handler.h"
314514f5e3Sopenharmony_ci#include "ecmascript/ic/profile_type_info.h"
324514f5e3Sopenharmony_ci#include "ecmascript/ic/proto_change_details.h"
334514f5e3Sopenharmony_ci#include "ecmascript/js_array.h"
344514f5e3Sopenharmony_ci#include "ecmascript/js_arraybuffer.h"
354514f5e3Sopenharmony_ci#include "ecmascript/js_function.h"
364514f5e3Sopenharmony_ci#include "ecmascript/js_for_in_iterator.h"
374514f5e3Sopenharmony_ci#include "ecmascript/js_generator_object.h"
384514f5e3Sopenharmony_ci#include "ecmascript/js_object.h"
394514f5e3Sopenharmony_ci#include "ecmascript/js_tagged_value.h"
404514f5e3Sopenharmony_ci#include "ecmascript/jspandafile/program_object.h"
414514f5e3Sopenharmony_ci#include "ecmascript/layout_info.h"
424514f5e3Sopenharmony_ci#include "ecmascript/message_string.h"
434514f5e3Sopenharmony_ci#include "ecmascript/mem/slots.h"
444514f5e3Sopenharmony_ci#include "ecmascript/mem/visitor.h"
454514f5e3Sopenharmony_ci#include "ecmascript/ic/properties_cache.h"
464514f5e3Sopenharmony_ci#include "ecmascript/property_attributes.h"
474514f5e3Sopenharmony_ci
484514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu {
494514f5e3Sopenharmony_ciusing JSFunction = panda::ecmascript::JSFunction;
504514f5e3Sopenharmony_ciusing PropertyBox = panda::ecmascript::PropertyBox;
514514f5e3Sopenharmony_ciinline int StubBuilder::NextVariableId()
524514f5e3Sopenharmony_ci{
534514f5e3Sopenharmony_ci    return env_->NextVariableId();
544514f5e3Sopenharmony_ci}
554514f5e3Sopenharmony_ci
564514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8(int8_t value)
574514f5e3Sopenharmony_ci{
584514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int8(value);
594514f5e3Sopenharmony_ci}
604514f5e3Sopenharmony_ci
614514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int16(int16_t value)
624514f5e3Sopenharmony_ci{
634514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int16(value);
644514f5e3Sopenharmony_ci}
654514f5e3Sopenharmony_ci
664514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32(int32_t value)
674514f5e3Sopenharmony_ci{
684514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32(value);
694514f5e3Sopenharmony_ci}
704514f5e3Sopenharmony_ci
714514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64(int64_t value)
724514f5e3Sopenharmony_ci{
734514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64(value);
744514f5e3Sopenharmony_ci}
754514f5e3Sopenharmony_ci
764514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedInt(int32_t value)
774514f5e3Sopenharmony_ci{
784514f5e3Sopenharmony_ci    JSTaggedType value64 = static_cast<JSTaggedType>(value) | JSTaggedValue::TAG_INT;
794514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64(value64);
804514f5e3Sopenharmony_ci}
814514f5e3Sopenharmony_ci
824514f5e3Sopenharmony_ciinline GateRef StubBuilder::StringPtr(std::string_view str)
834514f5e3Sopenharmony_ci{
844514f5e3Sopenharmony_ci    return env_->GetBuilder()->StringPtr(str);
854514f5e3Sopenharmony_ci}
864514f5e3Sopenharmony_ci
874514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtr(int64_t value)
884514f5e3Sopenharmony_ci{
894514f5e3Sopenharmony_ci    return env_->Is32Bit() ? Int32(value) : Int64(value);
904514f5e3Sopenharmony_ci}
914514f5e3Sopenharmony_ci
924514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrSize()
934514f5e3Sopenharmony_ci{
944514f5e3Sopenharmony_ci    return env_->Is32Bit() ? Int32(sizeof(uint32_t)) : Int64(sizeof(uint64_t));
954514f5e3Sopenharmony_ci}
964514f5e3Sopenharmony_ci
974514f5e3Sopenharmony_ciinline GateRef StubBuilder::True()
984514f5e3Sopenharmony_ci{
994514f5e3Sopenharmony_ci    return TruncInt32ToInt1(Int32(1));
1004514f5e3Sopenharmony_ci}
1014514f5e3Sopenharmony_ci
1024514f5e3Sopenharmony_ciinline GateRef StubBuilder::False()
1034514f5e3Sopenharmony_ci{
1044514f5e3Sopenharmony_ci    return TruncInt32ToInt1(Int32(0));
1054514f5e3Sopenharmony_ci}
1064514f5e3Sopenharmony_ci
1074514f5e3Sopenharmony_ciinline GateRef StubBuilder::Boolean(bool value)
1084514f5e3Sopenharmony_ci{
1094514f5e3Sopenharmony_ci    return env_->GetBuilder()->Boolean(value);
1104514f5e3Sopenharmony_ci}
1114514f5e3Sopenharmony_ci
1124514f5e3Sopenharmony_ciinline GateRef StubBuilder::Double(double value)
1134514f5e3Sopenharmony_ci{
1144514f5e3Sopenharmony_ci    return env_->GetBuilder()->Double(value);
1154514f5e3Sopenharmony_ci}
1164514f5e3Sopenharmony_ci
1174514f5e3Sopenharmony_ciinline GateRef StubBuilder::Undefined()
1184514f5e3Sopenharmony_ci{
1194514f5e3Sopenharmony_ci    return env_->GetBuilder()->UndefineConstant();
1204514f5e3Sopenharmony_ci}
1214514f5e3Sopenharmony_ci
1224514f5e3Sopenharmony_ciinline GateRef StubBuilder::Hole()
1234514f5e3Sopenharmony_ci{
1244514f5e3Sopenharmony_ci    return env_->GetBuilder()->HoleConstant();
1254514f5e3Sopenharmony_ci}
1264514f5e3Sopenharmony_ci
1274514f5e3Sopenharmony_ciinline GateRef StubBuilder::SpecialHole()
1284514f5e3Sopenharmony_ci{
1294514f5e3Sopenharmony_ci    return env_->GetBuilder()->SpecialHoleConstant();
1304514f5e3Sopenharmony_ci}
1314514f5e3Sopenharmony_ci
1324514f5e3Sopenharmony_ciinline GateRef StubBuilder::Null()
1334514f5e3Sopenharmony_ci{
1344514f5e3Sopenharmony_ci    return env_->GetBuilder()->NullConstant();
1354514f5e3Sopenharmony_ci}
1364514f5e3Sopenharmony_ci
1374514f5e3Sopenharmony_ciinline GateRef StubBuilder::NullPtr()
1384514f5e3Sopenharmony_ci{
1394514f5e3Sopenharmony_ci    return env_->GetBuilder()->NullPtrConstant();
1404514f5e3Sopenharmony_ci}
1414514f5e3Sopenharmony_ci
1424514f5e3Sopenharmony_ciinline GateRef StubBuilder::Exception()
1434514f5e3Sopenharmony_ci{
1444514f5e3Sopenharmony_ci    return env_->GetBuilder()->ExceptionConstant();
1454514f5e3Sopenharmony_ci}
1464514f5e3Sopenharmony_ci
1474514f5e3Sopenharmony_ciinline GateRef StubBuilder::RelocatableData(uint64_t value)
1484514f5e3Sopenharmony_ci{
1494514f5e3Sopenharmony_ci    return env_->GetBuilder()->RelocatableData(value);
1504514f5e3Sopenharmony_ci}
1514514f5e3Sopenharmony_ci
1524514f5e3Sopenharmony_ci// parameter
1534514f5e3Sopenharmony_ciinline GateRef StubBuilder::Argument(size_t index)
1544514f5e3Sopenharmony_ci{
1554514f5e3Sopenharmony_ci    return env_->GetArgument(index);
1564514f5e3Sopenharmony_ci}
1574514f5e3Sopenharmony_ci
1584514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int1Argument(size_t index)
1594514f5e3Sopenharmony_ci{
1604514f5e3Sopenharmony_ci    return Argument(index);
1614514f5e3Sopenharmony_ci}
1624514f5e3Sopenharmony_ci
1634514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Argument(size_t index)
1644514f5e3Sopenharmony_ci{
1654514f5e3Sopenharmony_ci    return Argument(index);
1664514f5e3Sopenharmony_ci}
1674514f5e3Sopenharmony_ci
1684514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Argument(size_t index)
1694514f5e3Sopenharmony_ci{
1704514f5e3Sopenharmony_ci    return Argument(index);
1714514f5e3Sopenharmony_ci}
1724514f5e3Sopenharmony_ci
1734514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedArgument(size_t index)
1744514f5e3Sopenharmony_ci{
1754514f5e3Sopenharmony_ci    return Argument(index);
1764514f5e3Sopenharmony_ci}
1774514f5e3Sopenharmony_ci
1784514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedPointerArgument(size_t index)
1794514f5e3Sopenharmony_ci{
1804514f5e3Sopenharmony_ci    return Argument(index);
1814514f5e3Sopenharmony_ci}
1824514f5e3Sopenharmony_ci
1834514f5e3Sopenharmony_ciinline GateRef StubBuilder::PtrArgument(size_t index)
1844514f5e3Sopenharmony_ci{
1854514f5e3Sopenharmony_ci    return Argument(index);
1864514f5e3Sopenharmony_ci}
1874514f5e3Sopenharmony_ci
1884514f5e3Sopenharmony_ciinline GateRef StubBuilder::Float32Argument(size_t index)
1894514f5e3Sopenharmony_ci{
1904514f5e3Sopenharmony_ci    return Argument(index);
1914514f5e3Sopenharmony_ci}
1924514f5e3Sopenharmony_ci
1934514f5e3Sopenharmony_ciinline GateRef StubBuilder::Float64Argument(size_t index)
1944514f5e3Sopenharmony_ci{
1954514f5e3Sopenharmony_ci    return Argument(index);
1964514f5e3Sopenharmony_ci}
1974514f5e3Sopenharmony_ci
1984514f5e3Sopenharmony_ciinline GateRef StubBuilder::Alloca(int size)
1994514f5e3Sopenharmony_ci{
2004514f5e3Sopenharmony_ci    return env_->GetBuilder()->Alloca(size);
2014514f5e3Sopenharmony_ci}
2024514f5e3Sopenharmony_ci
2034514f5e3Sopenharmony_ciinline GateRef StubBuilder::Return(GateRef value)
2044514f5e3Sopenharmony_ci{
2054514f5e3Sopenharmony_ci    auto control = env_->GetCurrentLabel()->GetControl();
2064514f5e3Sopenharmony_ci    auto depend = env_->GetCurrentLabel()->GetDepend();
2074514f5e3Sopenharmony_ci    return env_->GetBuilder()->Return(control, depend, value);
2084514f5e3Sopenharmony_ci}
2094514f5e3Sopenharmony_ci
2104514f5e3Sopenharmony_ciinline GateRef StubBuilder::Return()
2114514f5e3Sopenharmony_ci{
2124514f5e3Sopenharmony_ci    auto control = env_->GetCurrentLabel()->GetControl();
2134514f5e3Sopenharmony_ci    auto depend = env_->GetCurrentLabel()->GetDepend();
2144514f5e3Sopenharmony_ci    return env_->GetBuilder()->ReturnVoid(control, depend);
2154514f5e3Sopenharmony_ci}
2164514f5e3Sopenharmony_ci
2174514f5e3Sopenharmony_ciinline void StubBuilder::Bind(Label *label)
2184514f5e3Sopenharmony_ci{
2194514f5e3Sopenharmony_ci    env_->GetBuilder()->Bind(label);
2204514f5e3Sopenharmony_ci}
2214514f5e3Sopenharmony_ci
2224514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallRuntime(GateRef glue, int index, const std::vector<GateRef>& args)
2234514f5e3Sopenharmony_ci{
2244514f5e3Sopenharmony_ci    SavePcIfNeeded(glue);
2254514f5e3Sopenharmony_ci    const std::string name = RuntimeStubCSigns::GetRTName(index);
2264514f5e3Sopenharmony_ci    GateRef result = env_->GetBuilder()->CallRuntime(glue, index, Gate::InvalidGateRef, args,
2274514f5e3Sopenharmony_ci                                                     glue, name.c_str());
2284514f5e3Sopenharmony_ci    return result;
2294514f5e3Sopenharmony_ci}
2304514f5e3Sopenharmony_ci
2314514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallRuntime(GateRef glue, int index, GateRef argc, GateRef argv)
2324514f5e3Sopenharmony_ci{
2334514f5e3Sopenharmony_ci    SavePcIfNeeded(glue);
2344514f5e3Sopenharmony_ci    const std::string name = RuntimeStubCSigns::GetRTName(index);
2354514f5e3Sopenharmony_ci    GateRef result = env_->GetBuilder()->CallRuntimeVarargs(glue, index, argc, argv, name.c_str());
2364514f5e3Sopenharmony_ci    return result;
2374514f5e3Sopenharmony_ci}
2384514f5e3Sopenharmony_ci
2394514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallNGCRuntime(GateRef glue, int index,
2404514f5e3Sopenharmony_ci                                           const std::vector<GateRef>& args, GateRef hir)
2414514f5e3Sopenharmony_ci{
2424514f5e3Sopenharmony_ci    const std::string name = RuntimeStubCSigns::GetRTName(index);
2434514f5e3Sopenharmony_ci    GateRef result;
2444514f5e3Sopenharmony_ci    if (env_->GetCircuit()->IsOptimizedOrFastJit()) {
2454514f5e3Sopenharmony_ci        result = env_->GetBuilder()->CallNGCRuntime(glue, index, Gate::InvalidGateRef, args,
2464514f5e3Sopenharmony_ci                                                    hir, name.c_str());
2474514f5e3Sopenharmony_ci    } else {
2484514f5e3Sopenharmony_ci        result = env_->GetBuilder()->CallNGCRuntime(glue, index, Gate::InvalidGateRef, args,
2494514f5e3Sopenharmony_ci                                                    Circuit::NullGate(), name.c_str());
2504514f5e3Sopenharmony_ci    }
2514514f5e3Sopenharmony_ci    return result;
2524514f5e3Sopenharmony_ci}
2534514f5e3Sopenharmony_ci
2544514f5e3Sopenharmony_ciinline GateRef StubBuilder::FastCallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args, GateRef hir)
2554514f5e3Sopenharmony_ci{
2564514f5e3Sopenharmony_ci    GateRef result;
2574514f5e3Sopenharmony_ci    if (env_->GetCircuit()->IsOptimizedOrFastJit()) {
2584514f5e3Sopenharmony_ci        result = env_->GetBuilder()->FastCallOptimized(glue, code, Gate::InvalidGateRef, args, hir);
2594514f5e3Sopenharmony_ci    } else {
2604514f5e3Sopenharmony_ci        result = env_->GetBuilder()->FastCallOptimized(glue, code, Gate::InvalidGateRef, args, Circuit::NullGate());
2614514f5e3Sopenharmony_ci    }
2624514f5e3Sopenharmony_ci    return result;
2634514f5e3Sopenharmony_ci}
2644514f5e3Sopenharmony_ci
2654514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args, GateRef hir)
2664514f5e3Sopenharmony_ci{
2674514f5e3Sopenharmony_ci    GateRef result;
2684514f5e3Sopenharmony_ci    if (env_->GetCircuit()->IsOptimizedOrFastJit()) {
2694514f5e3Sopenharmony_ci        result = env_->GetBuilder()->CallOptimized(glue, code, Gate::InvalidGateRef, args, hir);
2704514f5e3Sopenharmony_ci    } else {
2714514f5e3Sopenharmony_ci        result = env_->GetBuilder()->CallOptimized(glue, code, Gate::InvalidGateRef, args, Circuit::NullGate());
2724514f5e3Sopenharmony_ci    }
2734514f5e3Sopenharmony_ci    return result;
2744514f5e3Sopenharmony_ci}
2754514f5e3Sopenharmony_ci
2764514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetAotCodeAddr(GateRef jsFunc)
2774514f5e3Sopenharmony_ci{
2784514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetCodeAddr(jsFunc);
2794514f5e3Sopenharmony_ci}
2804514f5e3Sopenharmony_ci
2814514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetBaselineCodeAddr(GateRef baselineCode)
2824514f5e3Sopenharmony_ci{
2834514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetBaselineCodeAddr(baselineCode);
2844514f5e3Sopenharmony_ci}
2854514f5e3Sopenharmony_ci
2864514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallStub(GateRef glue, int index, const std::initializer_list<GateRef>& args)
2874514f5e3Sopenharmony_ci{
2884514f5e3Sopenharmony_ci    SavePcIfNeeded(glue);
2894514f5e3Sopenharmony_ci    const std::string name = CommonStubCSigns::GetName(index);
2904514f5e3Sopenharmony_ci    GateRef result = env_->GetBuilder()->CallStub(glue, Circuit::NullGate(), index, args, name.c_str());
2914514f5e3Sopenharmony_ci    return result;
2924514f5e3Sopenharmony_ci}
2934514f5e3Sopenharmony_ci
2944514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallBuiltinRuntime(GateRef glue, const std::initializer_list<GateRef>& args, bool isNew)
2954514f5e3Sopenharmony_ci{
2964514f5e3Sopenharmony_ci    return env_->GetBuilder()->CallBuiltinRuntime(glue, Gate::InvalidGateRef, args, isNew);
2974514f5e3Sopenharmony_ci}
2984514f5e3Sopenharmony_ci
2994514f5e3Sopenharmony_ciinline GateRef StubBuilder::CallBuiltinRuntimeWithNewTarget(GateRef glue, const std::initializer_list<GateRef>& args)
3004514f5e3Sopenharmony_ci{
3014514f5e3Sopenharmony_ci    return env_->GetBuilder()->CallBuiltinRuntimeWithNewTarget(glue, Gate::InvalidGateRef, args);
3024514f5e3Sopenharmony_ci}
3034514f5e3Sopenharmony_ci
3044514f5e3Sopenharmony_ciinline void StubBuilder::DebugPrint(GateRef glue, std::initializer_list<GateRef> args)
3054514f5e3Sopenharmony_ci{
3064514f5e3Sopenharmony_ci    CallNGCRuntime(glue, RTSTUB_ID(DebugPrint), args);
3074514f5e3Sopenharmony_ci}
3084514f5e3Sopenharmony_ci
3094514f5e3Sopenharmony_ciinline void StubBuilder::FatalPrint(GateRef glue, std::initializer_list<GateRef> args)
3104514f5e3Sopenharmony_ci{
3114514f5e3Sopenharmony_ci    CallNGCRuntime(glue, RTSTUB_ID(FatalPrint), args);
3124514f5e3Sopenharmony_ci}
3134514f5e3Sopenharmony_ci
3144514f5e3Sopenharmony_civoid StubBuilder::SavePcIfNeeded(GateRef glue)
3154514f5e3Sopenharmony_ci{
3164514f5e3Sopenharmony_ci    if (env_->IsAsmInterp()) {
3174514f5e3Sopenharmony_ci        GateRef sp = Argument(static_cast<size_t>(InterpreterHandlerInputs::SP));
3184514f5e3Sopenharmony_ci        GateRef pc = Argument(static_cast<size_t>(InterpreterHandlerInputs::PC));
3194514f5e3Sopenharmony_ci        GateRef frame = PtrSub(sp,
3204514f5e3Sopenharmony_ci            IntPtr(AsmInterpretedFrame::GetSize(GetEnvironment()->IsArch32Bit())));
3214514f5e3Sopenharmony_ci        Store(VariableType::INT64(), glue, frame,
3224514f5e3Sopenharmony_ci            IntPtr(AsmInterpretedFrame::GetPcOffset(GetEnvironment()->IsArch32Bit())), pc);
3234514f5e3Sopenharmony_ci    }
3244514f5e3Sopenharmony_ci}
3254514f5e3Sopenharmony_ci
3264514f5e3Sopenharmony_civoid StubBuilder::SaveJumpSizeIfNeeded(GateRef glue, GateRef jumpSize)
3274514f5e3Sopenharmony_ci{
3284514f5e3Sopenharmony_ci    if (env_->IsAsmInterp() || env_->IsBaselineBuiltin()) {
3294514f5e3Sopenharmony_ci        GateRef sp = Argument(static_cast<size_t>(InterpreterHandlerInputs::SP));
3304514f5e3Sopenharmony_ci        GateRef frame = PtrSub(sp,
3314514f5e3Sopenharmony_ci            IntPtr(AsmInterpretedFrame::GetSize(GetEnvironment()->IsArch32Bit())));
3324514f5e3Sopenharmony_ci        Store(VariableType::INT64(), glue, frame,
3334514f5e3Sopenharmony_ci            IntPtr(AsmInterpretedFrame::GetCallSizeOffset(GetEnvironment()->IsArch32Bit())), jumpSize);
3344514f5e3Sopenharmony_ci    }
3354514f5e3Sopenharmony_ci}
3364514f5e3Sopenharmony_ci
3374514f5e3Sopenharmony_civoid StubBuilder::SetHotnessCounter(GateRef glue, GateRef method, GateRef value)
3384514f5e3Sopenharmony_ci{
3394514f5e3Sopenharmony_ci    auto env = GetEnvironment();
3404514f5e3Sopenharmony_ci    GateRef newValue = env->GetBuilder()->TruncInt64ToInt16(value);
3414514f5e3Sopenharmony_ci    Store(VariableType::INT16(), glue, method, IntPtr(Method::LITERAL_INFO_OFFSET), newValue);
3424514f5e3Sopenharmony_ci}
3434514f5e3Sopenharmony_ci
3444514f5e3Sopenharmony_civoid StubBuilder::SaveHotnessCounterIfNeeded(GateRef glue, GateRef sp, GateRef hotnessCounter, JSCallMode mode)
3454514f5e3Sopenharmony_ci{
3464514f5e3Sopenharmony_ci    if ((env_->IsAsmInterp() || env_->IsBaselineBuiltin())
3474514f5e3Sopenharmony_ci         && kungfu::AssemblerModule::IsJumpToCallCommonEntry(mode)) {
3484514f5e3Sopenharmony_ci        ASSERT(hotnessCounter != Circuit::NullGate());
3494514f5e3Sopenharmony_ci        GateRef frame = PtrSub(sp, IntPtr(AsmInterpretedFrame::GetSize(env_->IsArch32Bit())));
3504514f5e3Sopenharmony_ci        GateRef function = Load(VariableType::JS_POINTER(), frame,
3514514f5e3Sopenharmony_ci            IntPtr(AsmInterpretedFrame::GetFunctionOffset(env_->IsArch32Bit())));
3524514f5e3Sopenharmony_ci        GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
3534514f5e3Sopenharmony_ci        SetHotnessCounter(glue, method, hotnessCounter);
3544514f5e3Sopenharmony_ci    }
3554514f5e3Sopenharmony_ci}
3564514f5e3Sopenharmony_ci
3574514f5e3Sopenharmony_ci// memory
3584514f5e3Sopenharmony_ciinline GateRef StubBuilder::Load(VariableType type, GateRef base, GateRef offset)
3594514f5e3Sopenharmony_ci{
3604514f5e3Sopenharmony_ci    if (type == VariableType::NATIVE_POINTER()) {
3614514f5e3Sopenharmony_ci        type = env_->IsArch64Bit() ? VariableType::INT64() : VariableType::INT32();
3624514f5e3Sopenharmony_ci    }
3634514f5e3Sopenharmony_ci    return env_->GetBuilder()->Load(type, base, offset);
3644514f5e3Sopenharmony_ci}
3654514f5e3Sopenharmony_ci
3664514f5e3Sopenharmony_ciinline GateRef StubBuilder::Load(VariableType type, GateRef base)
3674514f5e3Sopenharmony_ci{
3684514f5e3Sopenharmony_ci    return Load(type, base, IntPtr(0));
3694514f5e3Sopenharmony_ci}
3704514f5e3Sopenharmony_ci
3714514f5e3Sopenharmony_ci// arithmetic
3724514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int16Add(GateRef x, GateRef y)
3734514f5e3Sopenharmony_ci{
3744514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int16Add(x, y);
3754514f5e3Sopenharmony_ci}
3764514f5e3Sopenharmony_ci
3774514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Add(GateRef x, GateRef y)
3784514f5e3Sopenharmony_ci{
3794514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Add(x, y);
3804514f5e3Sopenharmony_ci}
3814514f5e3Sopenharmony_ci
3824514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Add(GateRef x, GateRef y)
3834514f5e3Sopenharmony_ci{
3844514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Add(x, y);
3854514f5e3Sopenharmony_ci}
3864514f5e3Sopenharmony_ci
3874514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleAdd(GateRef x, GateRef y)
3884514f5e3Sopenharmony_ci{
3894514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleAdd(x, y);
3904514f5e3Sopenharmony_ci}
3914514f5e3Sopenharmony_ci
3924514f5e3Sopenharmony_ciinline GateRef StubBuilder::PtrMul(GateRef x, GateRef y)
3934514f5e3Sopenharmony_ci{
3944514f5e3Sopenharmony_ci    return env_->GetBuilder()->PtrMul(x, y);
3954514f5e3Sopenharmony_ci}
3964514f5e3Sopenharmony_ci
3974514f5e3Sopenharmony_ciinline GateRef StubBuilder::PtrAdd(GateRef x, GateRef y)
3984514f5e3Sopenharmony_ci{
3994514f5e3Sopenharmony_ci    return env_->GetBuilder()->PtrAdd(x, y);
4004514f5e3Sopenharmony_ci}
4014514f5e3Sopenharmony_ci
4024514f5e3Sopenharmony_ciinline GateRef StubBuilder::PtrSub(GateRef x, GateRef y)
4034514f5e3Sopenharmony_ci{
4044514f5e3Sopenharmony_ci    return env_->GetBuilder()->PtrSub(x, y);
4054514f5e3Sopenharmony_ci}
4064514f5e3Sopenharmony_ci
4074514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrAnd(GateRef x, GateRef y)
4084514f5e3Sopenharmony_ci{
4094514f5e3Sopenharmony_ci    return env_->Is32Bit() ? Int32And(x, y) : Int64And(x, y);
4104514f5e3Sopenharmony_ci}
4114514f5e3Sopenharmony_ci
4124514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrEqual(GateRef x, GateRef y)
4134514f5e3Sopenharmony_ci{
4144514f5e3Sopenharmony_ci    return env_->GetBuilder()->IntPtrEqual(x, y);
4154514f5e3Sopenharmony_ci}
4164514f5e3Sopenharmony_ci
4174514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int16Sub(GateRef x, GateRef y)
4184514f5e3Sopenharmony_ci{
4194514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int16Sub(x, y);
4204514f5e3Sopenharmony_ci}
4214514f5e3Sopenharmony_ci
4224514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Sub(GateRef x, GateRef y)
4234514f5e3Sopenharmony_ci{
4244514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Sub(x, y);
4254514f5e3Sopenharmony_ci}
4264514f5e3Sopenharmony_ci
4274514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Sub(GateRef x, GateRef y)
4284514f5e3Sopenharmony_ci{
4294514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Sub(x, y);
4304514f5e3Sopenharmony_ci}
4314514f5e3Sopenharmony_ci
4324514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleSub(GateRef x, GateRef y)
4334514f5e3Sopenharmony_ci{
4344514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleSub(x, y);
4354514f5e3Sopenharmony_ci}
4364514f5e3Sopenharmony_ci
4374514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Mul(GateRef x, GateRef y)
4384514f5e3Sopenharmony_ci{
4394514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Mul(x, y);
4404514f5e3Sopenharmony_ci}
4414514f5e3Sopenharmony_ci
4424514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Mul(GateRef x, GateRef y)
4434514f5e3Sopenharmony_ci{
4444514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Mul(x, y);
4454514f5e3Sopenharmony_ci}
4464514f5e3Sopenharmony_ci
4474514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleMul(GateRef x, GateRef y)
4484514f5e3Sopenharmony_ci{
4494514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleMul(x, y);
4504514f5e3Sopenharmony_ci}
4514514f5e3Sopenharmony_ci
4524514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleDiv(GateRef x, GateRef y)
4534514f5e3Sopenharmony_ci{
4544514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleDiv(x, y);
4554514f5e3Sopenharmony_ci}
4564514f5e3Sopenharmony_ci
4574514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Div(GateRef x, GateRef y)
4584514f5e3Sopenharmony_ci{
4594514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Div(x, y);
4604514f5e3Sopenharmony_ci}
4614514f5e3Sopenharmony_ci
4624514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Div(GateRef x, GateRef y)
4634514f5e3Sopenharmony_ci{
4644514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Div(x, y);
4654514f5e3Sopenharmony_ci}
4664514f5e3Sopenharmony_ci
4674514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrDiv(GateRef x, GateRef y)
4684514f5e3Sopenharmony_ci{
4694514f5e3Sopenharmony_ci    return env_->GetBuilder()->IntPtrDiv(x, y);
4704514f5e3Sopenharmony_ci}
4714514f5e3Sopenharmony_ci
4724514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Mod(GateRef x, GateRef y)
4734514f5e3Sopenharmony_ci{
4744514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Mod(x, y);
4754514f5e3Sopenharmony_ci}
4764514f5e3Sopenharmony_ci
4774514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleMod(GateRef x, GateRef y)
4784514f5e3Sopenharmony_ci{
4794514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleMod(x, y);
4804514f5e3Sopenharmony_ci}
4814514f5e3Sopenharmony_ci
4824514f5e3Sopenharmony_ci// bit operation
4834514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Or(GateRef x, GateRef y)
4844514f5e3Sopenharmony_ci{
4854514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Or(x, y);
4864514f5e3Sopenharmony_ci}
4874514f5e3Sopenharmony_ci
4884514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8And(GateRef x, GateRef y)
4894514f5e3Sopenharmony_ci{
4904514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int8And(x, y);
4914514f5e3Sopenharmony_ci}
4924514f5e3Sopenharmony_ci
4934514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8Xor(GateRef x, GateRef y)
4944514f5e3Sopenharmony_ci{
4954514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int8Xor(x, y);
4964514f5e3Sopenharmony_ci}
4974514f5e3Sopenharmony_ci
4984514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32And(GateRef x, GateRef y)
4994514f5e3Sopenharmony_ci{
5004514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32And(x, y);
5014514f5e3Sopenharmony_ci}
5024514f5e3Sopenharmony_ci
5034514f5e3Sopenharmony_ciinline GateRef StubBuilder::BitAnd(GateRef x, GateRef y)
5044514f5e3Sopenharmony_ci{
5054514f5e3Sopenharmony_ci    return env_->GetBuilder()->BitAnd(x, y);
5064514f5e3Sopenharmony_ci}
5074514f5e3Sopenharmony_ci
5084514f5e3Sopenharmony_ciinline GateRef StubBuilder::BitOr(GateRef x, GateRef y)
5094514f5e3Sopenharmony_ci{
5104514f5e3Sopenharmony_ci    return env_->GetBuilder()->BitOr(x, y);
5114514f5e3Sopenharmony_ci}
5124514f5e3Sopenharmony_ci
5134514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Not(GateRef x)
5144514f5e3Sopenharmony_ci{
5154514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Not(x);
5164514f5e3Sopenharmony_ci}
5174514f5e3Sopenharmony_ci
5184514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrNot(GateRef x)
5194514f5e3Sopenharmony_ci{
5204514f5e3Sopenharmony_ci    return env_->Is32Bit() ? Int32Not(x) : Int64Not(x);
5214514f5e3Sopenharmony_ci}
5224514f5e3Sopenharmony_ci
5234514f5e3Sopenharmony_ciinline GateRef StubBuilder::BoolNot(GateRef x)
5244514f5e3Sopenharmony_ci{
5254514f5e3Sopenharmony_ci    return env_->GetBuilder()->BoolNot(x);
5264514f5e3Sopenharmony_ci}
5274514f5e3Sopenharmony_ci
5284514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Or(GateRef x, GateRef y)
5294514f5e3Sopenharmony_ci{
5304514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Or(x, y);
5314514f5e3Sopenharmony_ci}
5324514f5e3Sopenharmony_ci
5334514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrOr(GateRef x, GateRef y)
5344514f5e3Sopenharmony_ci{
5354514f5e3Sopenharmony_ci    return env_->GetBuilder()->IntPtrOr(x, y);
5364514f5e3Sopenharmony_ci}
5374514f5e3Sopenharmony_ci
5384514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64And(GateRef x, GateRef y)
5394514f5e3Sopenharmony_ci{
5404514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64And(x, y);
5414514f5e3Sopenharmony_ci}
5424514f5e3Sopenharmony_ci
5434514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int16LSL(GateRef x, GateRef y)
5444514f5e3Sopenharmony_ci{
5454514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int16LSL(x, y);
5464514f5e3Sopenharmony_ci}
5474514f5e3Sopenharmony_ci
5484514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Xor(GateRef x, GateRef y)
5494514f5e3Sopenharmony_ci{
5504514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Xor(x, y);
5514514f5e3Sopenharmony_ci}
5524514f5e3Sopenharmony_ci
5534514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Xor(GateRef x, GateRef y)
5544514f5e3Sopenharmony_ci{
5554514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Xor(x, y);
5564514f5e3Sopenharmony_ci}
5574514f5e3Sopenharmony_ci
5584514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8LSR(GateRef x, GateRef y)
5594514f5e3Sopenharmony_ci{
5604514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int8LSR(x, y);
5614514f5e3Sopenharmony_ci}
5624514f5e3Sopenharmony_ci
5634514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Not(GateRef x)
5644514f5e3Sopenharmony_ci{
5654514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Not(x);
5664514f5e3Sopenharmony_ci}
5674514f5e3Sopenharmony_ci
5684514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32LSL(GateRef x, GateRef y)
5694514f5e3Sopenharmony_ci{
5704514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32LSL(x, y);
5714514f5e3Sopenharmony_ci}
5724514f5e3Sopenharmony_ci
5734514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64LSL(GateRef x, GateRef y)
5744514f5e3Sopenharmony_ci{
5754514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64LSL(x, y);
5764514f5e3Sopenharmony_ci}
5774514f5e3Sopenharmony_ci
5784514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrLSL(GateRef x, GateRef y)
5794514f5e3Sopenharmony_ci{
5804514f5e3Sopenharmony_ci    return env_->GetBuilder()->IntPtrLSL(x, y);
5814514f5e3Sopenharmony_ci}
5824514f5e3Sopenharmony_ci
5834514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32ASR(GateRef x, GateRef y)
5844514f5e3Sopenharmony_ci{
5854514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32ASR(x, y);
5864514f5e3Sopenharmony_ci}
5874514f5e3Sopenharmony_ci
5884514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32LSR(GateRef x, GateRef y)
5894514f5e3Sopenharmony_ci{
5904514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32LSR(x, y);
5914514f5e3Sopenharmony_ci}
5924514f5e3Sopenharmony_ci
5934514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64LSR(GateRef x, GateRef y)
5944514f5e3Sopenharmony_ci{
5954514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64LSR(x, y);
5964514f5e3Sopenharmony_ci}
5974514f5e3Sopenharmony_ci
5984514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrLSR(GateRef x, GateRef y)
5994514f5e3Sopenharmony_ci{
6004514f5e3Sopenharmony_ci    return env_->GetBuilder()->IntPtrLSR(x, y);
6014514f5e3Sopenharmony_ci}
6024514f5e3Sopenharmony_ci
6034514f5e3Sopenharmony_citemplate<OpCode Op, MachineType Type>
6044514f5e3Sopenharmony_ciinline GateRef StubBuilder::BinaryOp(GateRef x, GateRef y)
6054514f5e3Sopenharmony_ci{
6064514f5e3Sopenharmony_ci    return env_->GetBuilder()->BinaryOp<Op, Type>(x, y);
6074514f5e3Sopenharmony_ci}
6084514f5e3Sopenharmony_ci
6094514f5e3Sopenharmony_citemplate<OpCode Op, MachineType Type>
6104514f5e3Sopenharmony_ciinline GateRef StubBuilder::BinaryOpWithOverflow(GateRef x, GateRef y)
6114514f5e3Sopenharmony_ci{
6124514f5e3Sopenharmony_ci    return env_->GetBuilder()->BinaryOpWithOverflow<Op, Type>(x, y);
6134514f5e3Sopenharmony_ci}
6144514f5e3Sopenharmony_ci
6154514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsInt(GateRef x)
6164514f5e3Sopenharmony_ci{
6174514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsInt(x);
6184514f5e3Sopenharmony_ci}
6194514f5e3Sopenharmony_ci
6204514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsDouble(GateRef x)
6214514f5e3Sopenharmony_ci{
6224514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsDouble(x);
6234514f5e3Sopenharmony_ci}
6244514f5e3Sopenharmony_ci
6254514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsObject(GateRef x)
6264514f5e3Sopenharmony_ci{
6274514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsObject(x);
6284514f5e3Sopenharmony_ci}
6294514f5e3Sopenharmony_ci
6304514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsString(GateRef obj)
6314514f5e3Sopenharmony_ci{
6324514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsString(obj);
6334514f5e3Sopenharmony_ci}
6344514f5e3Sopenharmony_ci
6354514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsStringIterator(GateRef obj)
6364514f5e3Sopenharmony_ci{
6374514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsStringIterator(obj);
6384514f5e3Sopenharmony_ci}
6394514f5e3Sopenharmony_ci
6404514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsSharedObj(GateRef obj)
6414514f5e3Sopenharmony_ci{
6424514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsSharedObj(obj);
6434514f5e3Sopenharmony_ci}
6444514f5e3Sopenharmony_ci
6454514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsStringOrSymbol(GateRef obj)
6464514f5e3Sopenharmony_ci{
6474514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsStringOrSymbol(obj);
6484514f5e3Sopenharmony_ci}
6494514f5e3Sopenharmony_ci
6504514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsSymbol(GateRef obj)
6514514f5e3Sopenharmony_ci{
6524514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsSymbol(obj);
6534514f5e3Sopenharmony_ci}
6544514f5e3Sopenharmony_ci
6554514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsArrayBuffer(GateRef obj)
6564514f5e3Sopenharmony_ci{
6574514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
6584514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_ARRAY_BUFFER)));
6594514f5e3Sopenharmony_ci}
6604514f5e3Sopenharmony_ci
6614514f5e3Sopenharmony_ciinline GateRef StubBuilder::BothAreString(GateRef x, GateRef y)
6624514f5e3Sopenharmony_ci{
6634514f5e3Sopenharmony_ci    return env_->GetBuilder()->BothAreString(x, y);
6644514f5e3Sopenharmony_ci}
6654514f5e3Sopenharmony_ci
6664514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsNumber(GateRef x)
6674514f5e3Sopenharmony_ci{
6684514f5e3Sopenharmony_ci    return BoolNot(TaggedIsObject(x));
6694514f5e3Sopenharmony_ci}
6704514f5e3Sopenharmony_ci
6714514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsNumeric(GateRef x)
6724514f5e3Sopenharmony_ci{
6734514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsNumeric(x);
6744514f5e3Sopenharmony_ci}
6754514f5e3Sopenharmony_ci
6764514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsHole(GateRef x)
6774514f5e3Sopenharmony_ci{
6784514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsHole(x);
6794514f5e3Sopenharmony_ci}
6804514f5e3Sopenharmony_ci
6814514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsNotHole(GateRef x)
6824514f5e3Sopenharmony_ci{
6834514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsNotHole(x);
6844514f5e3Sopenharmony_ci}
6854514f5e3Sopenharmony_ci
6864514f5e3Sopenharmony_ciinline GateRef StubBuilder::ValueIsSpecialHole(GateRef x)
6874514f5e3Sopenharmony_ci{
6884514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsSpecialHole(x);
6894514f5e3Sopenharmony_ci}
6904514f5e3Sopenharmony_ci
6914514f5e3Sopenharmony_ciinline GateRef StubBuilder::ElementsKindIsIntOrHoleInt(GateRef kind)
6924514f5e3Sopenharmony_ci{
6934514f5e3Sopenharmony_ci    return env_->GetBuilder()->ElementsKindIsIntOrHoleInt(kind);
6944514f5e3Sopenharmony_ci}
6954514f5e3Sopenharmony_ci
6964514f5e3Sopenharmony_ciinline GateRef StubBuilder::ElementsKindIsNumOrHoleNum(GateRef kind)
6974514f5e3Sopenharmony_ci{
6984514f5e3Sopenharmony_ci    return env_->GetBuilder()->ElementsKindIsNumOrHoleNum(kind);
6994514f5e3Sopenharmony_ci}
7004514f5e3Sopenharmony_ci
7014514f5e3Sopenharmony_ciinline GateRef StubBuilder::ElementsKindIsHeapKind(GateRef kind)
7024514f5e3Sopenharmony_ci{
7034514f5e3Sopenharmony_ci    return env_->GetBuilder()->ElementsKindIsHeapKind(kind);
7044514f5e3Sopenharmony_ci}
7054514f5e3Sopenharmony_ci
7064514f5e3Sopenharmony_ciinline GateRef StubBuilder::ElementsKindHasHole(GateRef kind)
7074514f5e3Sopenharmony_ci{
7084514f5e3Sopenharmony_ci    return env_->GetBuilder()->ElementsKindHasHole(kind);
7094514f5e3Sopenharmony_ci}
7104514f5e3Sopenharmony_ci
7114514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsUndefined(GateRef x)
7124514f5e3Sopenharmony_ci{
7134514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsUndefined(x);
7144514f5e3Sopenharmony_ci}
7154514f5e3Sopenharmony_ci
7164514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsException(GateRef x)
7174514f5e3Sopenharmony_ci{
7184514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsException(x);
7194514f5e3Sopenharmony_ci}
7204514f5e3Sopenharmony_ci
7214514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsSpecial(GateRef x)
7224514f5e3Sopenharmony_ci{
7234514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsSpecial(x);
7244514f5e3Sopenharmony_ci}
7254514f5e3Sopenharmony_ci
7264514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsRegularObject(GateRef x)
7274514f5e3Sopenharmony_ci{
7284514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(x));
7294514f5e3Sopenharmony_ci    return Int32LessThan(objectType, Int32(static_cast<int32_t>(JSType::JS_API_ARRAY_LIST)));
7304514f5e3Sopenharmony_ci}
7314514f5e3Sopenharmony_ci
7324514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsHeapObject(GateRef x)
7334514f5e3Sopenharmony_ci{
7344514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsHeapObject(x);
7354514f5e3Sopenharmony_ci}
7364514f5e3Sopenharmony_ci
7374514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsGeneratorObject(GateRef x)
7384514f5e3Sopenharmony_ci{
7394514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsGeneratorObject(x);
7404514f5e3Sopenharmony_ci}
7414514f5e3Sopenharmony_ci
7424514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsJSArray(GateRef x)
7434514f5e3Sopenharmony_ci{
7444514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsJSArray(x);
7454514f5e3Sopenharmony_ci}
7464514f5e3Sopenharmony_ci
7474514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsTaggedArray(GateRef x)
7484514f5e3Sopenharmony_ci{
7494514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsTaggedArray(x);
7504514f5e3Sopenharmony_ci}
7514514f5e3Sopenharmony_ci
7524514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsAsyncGeneratorObject(GateRef x)
7534514f5e3Sopenharmony_ci{
7544514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsAsyncGeneratorObject(x);
7554514f5e3Sopenharmony_ci}
7564514f5e3Sopenharmony_ci
7574514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsJSGlobalObject(GateRef x)
7584514f5e3Sopenharmony_ci{
7594514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsJSGlobalObject(x);
7604514f5e3Sopenharmony_ci}
7614514f5e3Sopenharmony_ci
7624514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsWeak(GateRef x)
7634514f5e3Sopenharmony_ci{
7644514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsWeak(x);
7654514f5e3Sopenharmony_ci}
7664514f5e3Sopenharmony_ci
7674514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsPrototypeHandler(GateRef x)
7684514f5e3Sopenharmony_ci{
7694514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsPrototypeHandler(x);
7704514f5e3Sopenharmony_ci}
7714514f5e3Sopenharmony_ci
7724514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsStoreTSHandler(GateRef x)
7734514f5e3Sopenharmony_ci{
7744514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsStoreTSHandler(x);
7754514f5e3Sopenharmony_ci}
7764514f5e3Sopenharmony_ci
7774514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsTransWithProtoHandler(GateRef x)
7784514f5e3Sopenharmony_ci{
7794514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsTransWithProtoHandler(x);
7804514f5e3Sopenharmony_ci}
7814514f5e3Sopenharmony_ci
7824514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsTransitionHandler(GateRef x)
7834514f5e3Sopenharmony_ci{
7844514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsTransitionHandler(x);
7854514f5e3Sopenharmony_ci}
7864514f5e3Sopenharmony_ci
7874514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetNextPositionForHash(GateRef last, GateRef count, GateRef size)
7884514f5e3Sopenharmony_ci{
7894514f5e3Sopenharmony_ci    auto nextOffset = Int32LSR(Int32Mul(count, Int32Add(count, Int32(1))),
7904514f5e3Sopenharmony_ci                               Int32(1));
7914514f5e3Sopenharmony_ci    return Int32And(Int32Add(last, nextOffset), Int32Sub(size, Int32(1)));
7924514f5e3Sopenharmony_ci}
7934514f5e3Sopenharmony_ci
7944514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleIsNAN(GateRef x)
7954514f5e3Sopenharmony_ci{
7964514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleIsNAN(x);
7974514f5e3Sopenharmony_ci}
7984514f5e3Sopenharmony_ci
7994514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleIsINF(GateRef x)
8004514f5e3Sopenharmony_ci{
8014514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleIsINF(x);
8024514f5e3Sopenharmony_ci}
8034514f5e3Sopenharmony_ci
8044514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleIsNanOrInf(GateRef x)
8054514f5e3Sopenharmony_ci{
8064514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleIsNanOrInf(x);
8074514f5e3Sopenharmony_ci}
8084514f5e3Sopenharmony_ci
8094514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleAbs(GateRef x)
8104514f5e3Sopenharmony_ci{
8114514f5e3Sopenharmony_ci    return env_->GetBuilder()->FAbs(x);
8124514f5e3Sopenharmony_ci}
8134514f5e3Sopenharmony_ci
8144514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleIsInteger(GateRef x)
8154514f5e3Sopenharmony_ci{
8164514f5e3Sopenharmony_ci    GateRef notInteger = LogicOrBuilder(env_).Or(DoubleIsNAN(x)).Or(DoubleIsINF(x))
8174514f5e3Sopenharmony_ci        .Or(BoolNot(DoubleEqual(x, DoubleTrunc(x)))).Done();
8184514f5e3Sopenharmony_ci    return BoolNot(notInteger);
8194514f5e3Sopenharmony_ci}
8204514f5e3Sopenharmony_ci
8214514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleTrunc(GateRef x)
8224514f5e3Sopenharmony_ci{
8234514f5e3Sopenharmony_ci    if (env_->IsAArch64()) {
8244514f5e3Sopenharmony_ci        return env_->GetBuilder()->DoubleTrunc(x);
8254514f5e3Sopenharmony_ci    }
8264514f5e3Sopenharmony_ci
8274514f5e3Sopenharmony_ci    Label entry(env_);
8284514f5e3Sopenharmony_ci    env_->SubCfgEntry(&entry);
8294514f5e3Sopenharmony_ci
8304514f5e3Sopenharmony_ci    DEFVARIABLE(result, VariableType::FLOAT64(), x);
8314514f5e3Sopenharmony_ci    Label exit(env_);
8324514f5e3Sopenharmony_ci
8334514f5e3Sopenharmony_ci    constexpr int64_t DOUBLE_FRACTION_BITS = 52;
8344514f5e3Sopenharmony_ci    constexpr int64_t DOUBLE_EXP_MASK = 0x7ff;
8354514f5e3Sopenharmony_ci    constexpr int64_t DOUBLE_EXP_OFFSET = 0x3ff;
8364514f5e3Sopenharmony_ci    GateRef bits = CastDoubleToInt64(x);
8374514f5e3Sopenharmony_ci    GateRef exp = Int64Sub(Int64And(Int64LSR(bits, Int64(DOUBLE_FRACTION_BITS)), Int64(DOUBLE_EXP_MASK)),
8384514f5e3Sopenharmony_ci                           Int64(DOUBLE_EXP_OFFSET));
8394514f5e3Sopenharmony_ci
8404514f5e3Sopenharmony_ci    Label trunc(env_);
8414514f5e3Sopenharmony_ci    BRANCH(Int64GreaterThanOrEqual(exp, Int64(DOUBLE_FRACTION_BITS)), &exit, &trunc);
8424514f5e3Sopenharmony_ci    Bind(&trunc);
8434514f5e3Sopenharmony_ci    {
8444514f5e3Sopenharmony_ci        Label zero(env_);
8454514f5e3Sopenharmony_ci        Label nonZero(env_);
8464514f5e3Sopenharmony_ci        BRANCH(Int64LessThan(exp, Int64(0)), &zero, &nonZero);
8474514f5e3Sopenharmony_ci        Bind(&zero);
8484514f5e3Sopenharmony_ci        {
8494514f5e3Sopenharmony_ci            constexpr int64_t DOUBLE_SIGN_SHIFT = 63;
8504514f5e3Sopenharmony_ci            constexpr int64_t mask = static_cast<int64_t>(1) << DOUBLE_SIGN_SHIFT;
8514514f5e3Sopenharmony_ci            result = CastInt64ToFloat64(Int64And(bits, Int64(mask)));
8524514f5e3Sopenharmony_ci            Jump(&exit);
8534514f5e3Sopenharmony_ci        }
8544514f5e3Sopenharmony_ci        Bind(&nonZero);
8554514f5e3Sopenharmony_ci        {
8564514f5e3Sopenharmony_ci            constexpr int64_t DOUBLE_NON_FRACTION_BITS = 12;
8574514f5e3Sopenharmony_ci            constexpr int64_t NEG_ONE = -1;
8584514f5e3Sopenharmony_ci            GateRef mask = Int64LSR(Int64(NEG_ONE), Int64Add(exp, Int64(DOUBLE_NON_FRACTION_BITS)));
8594514f5e3Sopenharmony_ci            result = CastInt64ToFloat64(Int64And(bits, Int64Not(mask)));
8604514f5e3Sopenharmony_ci            Jump(&exit);
8614514f5e3Sopenharmony_ci        }
8624514f5e3Sopenharmony_ci    }
8634514f5e3Sopenharmony_ci
8644514f5e3Sopenharmony_ci    Bind(&exit);
8654514f5e3Sopenharmony_ci    auto ret = *result;
8664514f5e3Sopenharmony_ci    env_->SubCfgExit();
8674514f5e3Sopenharmony_ci    return ret;
8684514f5e3Sopenharmony_ci}
8694514f5e3Sopenharmony_ci
8704514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsNull(GateRef x)
8714514f5e3Sopenharmony_ci{
8724514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsNull(x);
8734514f5e3Sopenharmony_ci}
8744514f5e3Sopenharmony_ci
8754514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsUndefinedOrNull(GateRef x)
8764514f5e3Sopenharmony_ci{
8774514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsUndefinedOrNull(x);
8784514f5e3Sopenharmony_ci}
8794514f5e3Sopenharmony_ci
8804514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsUndefinedOrNullOrHole(GateRef x)
8814514f5e3Sopenharmony_ci{
8824514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsUndefinedOrNullOrHole(x);
8834514f5e3Sopenharmony_ci}
8844514f5e3Sopenharmony_ci
8854514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsTrue(GateRef x)
8864514f5e3Sopenharmony_ci{
8874514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsTrue(x);
8884514f5e3Sopenharmony_ci}
8894514f5e3Sopenharmony_ci
8904514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsFalse(GateRef x)
8914514f5e3Sopenharmony_ci{
8924514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsFalse(x);
8934514f5e3Sopenharmony_ci}
8944514f5e3Sopenharmony_ci
8954514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsBoolean(GateRef x)
8964514f5e3Sopenharmony_ci{
8974514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsBoolean(x);
8984514f5e3Sopenharmony_ci}
8994514f5e3Sopenharmony_ci
9004514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedGetInt(GateRef x)
9014514f5e3Sopenharmony_ci{
9024514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedGetInt(x);
9034514f5e3Sopenharmony_ci}
9044514f5e3Sopenharmony_ci
9054514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8ToTaggedInt(GateRef x)
9064514f5e3Sopenharmony_ci{
9074514f5e3Sopenharmony_ci    GateRef val = SExtInt8ToInt64(x);
9084514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToTaggedInt(val);
9094514f5e3Sopenharmony_ci}
9104514f5e3Sopenharmony_ci
9114514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int16ToTaggedInt(GateRef x)
9124514f5e3Sopenharmony_ci{
9134514f5e3Sopenharmony_ci    GateRef val = SExtInt16ToInt64(x);
9144514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToTaggedInt(val);
9154514f5e3Sopenharmony_ci}
9164514f5e3Sopenharmony_ci
9174514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntToTaggedPtr(GateRef x)
9184514f5e3Sopenharmony_ci{
9194514f5e3Sopenharmony_ci    GateRef val = SExtInt32ToInt64(x);
9204514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToTaggedIntPtr(val);
9214514f5e3Sopenharmony_ci}
9224514f5e3Sopenharmony_ci
9234514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntToTaggedInt(GateRef x)
9244514f5e3Sopenharmony_ci{
9254514f5e3Sopenharmony_ci    GateRef val = SExtInt32ToInt64(x);
9264514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToTaggedInt(val);
9274514f5e3Sopenharmony_ci}
9284514f5e3Sopenharmony_ci
9294514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64ToTaggedInt(GateRef x)
9304514f5e3Sopenharmony_ci{
9314514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToTaggedInt(x);
9324514f5e3Sopenharmony_ci}
9334514f5e3Sopenharmony_ci
9344514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64ToTaggedIntPtr(GateRef x)
9354514f5e3Sopenharmony_ci{
9364514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToTaggedIntPtr(x);
9374514f5e3Sopenharmony_ci}
9384514f5e3Sopenharmony_ci
9394514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleToTaggedDoublePtr(GateRef x)
9404514f5e3Sopenharmony_ci{
9414514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleToTaggedDoublePtr(x);
9424514f5e3Sopenharmony_ci}
9434514f5e3Sopenharmony_ci
9444514f5e3Sopenharmony_ciinline GateRef StubBuilder::BooleanToTaggedBooleanPtr(GateRef x)
9454514f5e3Sopenharmony_ci{
9464514f5e3Sopenharmony_ci    return env_->GetBuilder()->BooleanToTaggedBooleanPtr(x);
9474514f5e3Sopenharmony_ci}
9484514f5e3Sopenharmony_ci
9494514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedPtrToTaggedDoublePtr(GateRef x)
9504514f5e3Sopenharmony_ci{
9514514f5e3Sopenharmony_ci    return DoubleToTaggedDoublePtr(CastInt64ToFloat64(ChangeTaggedPointerToInt64(x)));
9524514f5e3Sopenharmony_ci}
9534514f5e3Sopenharmony_ci
9544514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedPtrToTaggedIntPtr(GateRef x)
9554514f5e3Sopenharmony_ci{
9564514f5e3Sopenharmony_ci    return IntToTaggedPtr(TruncInt64ToInt32(ChangeTaggedPointerToInt64(x)));
9574514f5e3Sopenharmony_ci}
9584514f5e3Sopenharmony_ci
9594514f5e3Sopenharmony_ciinline GateRef StubBuilder::CastDoubleToInt64(GateRef x)
9604514f5e3Sopenharmony_ci{
9614514f5e3Sopenharmony_ci    return env_->GetBuilder()->CastDoubleToInt64(x);
9624514f5e3Sopenharmony_ci}
9634514f5e3Sopenharmony_ci
9644514f5e3Sopenharmony_ciinline GateRef StubBuilder::CastFloat32ToInt32(GateRef x)
9654514f5e3Sopenharmony_ci{
9664514f5e3Sopenharmony_ci    return env_->GetBuilder()->CastFloat32ToInt32(x);
9674514f5e3Sopenharmony_ci}
9684514f5e3Sopenharmony_ci
9694514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedTrue()
9704514f5e3Sopenharmony_ci{
9714514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedTrue();
9724514f5e3Sopenharmony_ci}
9734514f5e3Sopenharmony_ci
9744514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedFalse()
9754514f5e3Sopenharmony_ci{
9764514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedFalse();
9774514f5e3Sopenharmony_ci}
9784514f5e3Sopenharmony_ci
9794514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedUndefined()
9804514f5e3Sopenharmony_ci{
9814514f5e3Sopenharmony_ci    return env_->GetBuilder()->UndefineConstant();
9824514f5e3Sopenharmony_ci}
9834514f5e3Sopenharmony_ci
9844514f5e3Sopenharmony_ci// compare operation
9854514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8Equal(GateRef x, GateRef y)
9864514f5e3Sopenharmony_ci{
9874514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int8Equal(x, y);
9884514f5e3Sopenharmony_ci}
9894514f5e3Sopenharmony_ci
9904514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int8GreaterThanOrEqual(GateRef x, GateRef y)
9914514f5e3Sopenharmony_ci{
9924514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int8GreaterThanOrEqual(x, y);
9934514f5e3Sopenharmony_ci}
9944514f5e3Sopenharmony_ci
9954514f5e3Sopenharmony_ciinline GateRef StubBuilder::Equal(GateRef x, GateRef y)
9964514f5e3Sopenharmony_ci{
9974514f5e3Sopenharmony_ci    return env_->GetBuilder()->Equal(x, y);
9984514f5e3Sopenharmony_ci}
9994514f5e3Sopenharmony_ci
10004514f5e3Sopenharmony_ciinline GateRef StubBuilder::NotEqual(GateRef x, GateRef y)
10014514f5e3Sopenharmony_ci{
10024514f5e3Sopenharmony_ci    return env_->GetBuilder()->NotEqual(x, y);
10034514f5e3Sopenharmony_ci}
10044514f5e3Sopenharmony_ci
10054514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32Equal(GateRef x, GateRef y)
10064514f5e3Sopenharmony_ci{
10074514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32Equal(x, y);
10084514f5e3Sopenharmony_ci}
10094514f5e3Sopenharmony_ci
10104514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32NotEqual(GateRef x, GateRef y)
10114514f5e3Sopenharmony_ci{
10124514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32NotEqual(x, y);
10134514f5e3Sopenharmony_ci}
10144514f5e3Sopenharmony_ci
10154514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64Equal(GateRef x, GateRef y)
10164514f5e3Sopenharmony_ci{
10174514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64Equal(x, y);
10184514f5e3Sopenharmony_ci}
10194514f5e3Sopenharmony_ci
10204514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleEqual(GateRef x, GateRef y)
10214514f5e3Sopenharmony_ci{
10224514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleEqual(x, y);
10234514f5e3Sopenharmony_ci}
10244514f5e3Sopenharmony_ci
10254514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleNotEqual(GateRef x, GateRef y)
10264514f5e3Sopenharmony_ci{
10274514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleNotEqual(x, y);
10284514f5e3Sopenharmony_ci}
10294514f5e3Sopenharmony_ci
10304514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleLessThan(GateRef x, GateRef y)
10314514f5e3Sopenharmony_ci{
10324514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleLessThan(x, y);
10334514f5e3Sopenharmony_ci}
10344514f5e3Sopenharmony_ci
10354514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleLessThanOrEqual(GateRef x, GateRef y)
10364514f5e3Sopenharmony_ci{
10374514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleLessThanOrEqual(x, y);
10384514f5e3Sopenharmony_ci}
10394514f5e3Sopenharmony_ci
10404514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleGreaterThan(GateRef x, GateRef y)
10414514f5e3Sopenharmony_ci{
10424514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleGreaterThan(x, y);
10434514f5e3Sopenharmony_ci}
10444514f5e3Sopenharmony_ci
10454514f5e3Sopenharmony_ciinline GateRef StubBuilder::DoubleGreaterThanOrEqual(GateRef x, GateRef y)
10464514f5e3Sopenharmony_ci{
10474514f5e3Sopenharmony_ci    return env_->GetBuilder()->DoubleGreaterThanOrEqual(x, y);
10484514f5e3Sopenharmony_ci}
10494514f5e3Sopenharmony_ci
10504514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64NotEqual(GateRef x, GateRef y)
10514514f5e3Sopenharmony_ci{
10524514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64NotEqual(x, y);
10534514f5e3Sopenharmony_ci}
10544514f5e3Sopenharmony_ci
10554514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32GreaterThan(GateRef x, GateRef y)
10564514f5e3Sopenharmony_ci{
10574514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32GreaterThan(x, y);
10584514f5e3Sopenharmony_ci}
10594514f5e3Sopenharmony_ci
10604514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32LessThan(GateRef x, GateRef y)
10614514f5e3Sopenharmony_ci{
10624514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32LessThan(x, y);
10634514f5e3Sopenharmony_ci}
10644514f5e3Sopenharmony_ci
10654514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32GreaterThanOrEqual(GateRef x, GateRef y)
10664514f5e3Sopenharmony_ci{
10674514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32GreaterThanOrEqual(x, y);
10684514f5e3Sopenharmony_ci}
10694514f5e3Sopenharmony_ci
10704514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32LessThanOrEqual(GateRef x, GateRef y)
10714514f5e3Sopenharmony_ci{
10724514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32LessThanOrEqual(x, y);
10734514f5e3Sopenharmony_ci}
10744514f5e3Sopenharmony_ci
10754514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32UnsignedGreaterThan(GateRef x, GateRef y)
10764514f5e3Sopenharmony_ci{
10774514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32UnsignedGreaterThan(x, y);
10784514f5e3Sopenharmony_ci}
10794514f5e3Sopenharmony_ci
10804514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32UnsignedLessThan(GateRef x, GateRef y)
10814514f5e3Sopenharmony_ci{
10824514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32UnsignedLessThan(x, y);
10834514f5e3Sopenharmony_ci}
10844514f5e3Sopenharmony_ci
10854514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32UnsignedGreaterThanOrEqual(GateRef x, GateRef y)
10864514f5e3Sopenharmony_ci{
10874514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32UnsignedGreaterThanOrEqual(x, y);
10884514f5e3Sopenharmony_ci}
10894514f5e3Sopenharmony_ci
10904514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int32UnsignedLessThanOrEqual(GateRef x, GateRef y)
10914514f5e3Sopenharmony_ci{
10924514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int32UnsignedLessThanOrEqual(x, y);
10934514f5e3Sopenharmony_ci}
10944514f5e3Sopenharmony_ci
10954514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64GreaterThan(GateRef x, GateRef y)
10964514f5e3Sopenharmony_ci{
10974514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64GreaterThan(x, y);
10984514f5e3Sopenharmony_ci}
10994514f5e3Sopenharmony_ci
11004514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64LessThan(GateRef x, GateRef y)
11014514f5e3Sopenharmony_ci{
11024514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64LessThan(x, y);
11034514f5e3Sopenharmony_ci}
11044514f5e3Sopenharmony_ci
11054514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64LessThanOrEqual(GateRef x, GateRef y)
11064514f5e3Sopenharmony_ci{
11074514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64LessThanOrEqual(x, y);
11084514f5e3Sopenharmony_ci}
11094514f5e3Sopenharmony_ci
11104514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64GreaterThanOrEqual(GateRef x, GateRef y)
11114514f5e3Sopenharmony_ci{
11124514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64GreaterThanOrEqual(x, y);
11134514f5e3Sopenharmony_ci}
11144514f5e3Sopenharmony_ci
11154514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64UnsignedLessThanOrEqual(GateRef x, GateRef y)
11164514f5e3Sopenharmony_ci{
11174514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64UnsignedLessThanOrEqual(x, y);
11184514f5e3Sopenharmony_ci}
11194514f5e3Sopenharmony_ci
11204514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64UnsignedGreaterThan(GateRef x, GateRef y)
11214514f5e3Sopenharmony_ci{
11224514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64UnsignedGreaterThan(x, y);
11234514f5e3Sopenharmony_ci}
11244514f5e3Sopenharmony_ci
11254514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64UnsignedGreaterThanOrEqual(GateRef x, GateRef y)
11264514f5e3Sopenharmony_ci{
11274514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64UnsignedGreaterThanOrEqual(x, y);
11284514f5e3Sopenharmony_ci}
11294514f5e3Sopenharmony_ci
11304514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrGreaterThan(GateRef x, GateRef y)
11314514f5e3Sopenharmony_ci{
11324514f5e3Sopenharmony_ci    return env_->GetBuilder()->IntPtrGreaterThan(x, y);
11334514f5e3Sopenharmony_ci}
11344514f5e3Sopenharmony_ci
11354514f5e3Sopenharmony_ci// cast operation
11364514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncInt16ToInt8(GateRef val)
11374514f5e3Sopenharmony_ci{
11384514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncInt16ToInt8(val);
11394514f5e3Sopenharmony_ci}
11404514f5e3Sopenharmony_ci
11414514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncInt32ToInt16(GateRef val)
11424514f5e3Sopenharmony_ci{
11434514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncInt32ToInt16(val);
11444514f5e3Sopenharmony_ci}
11454514f5e3Sopenharmony_ci
11464514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncInt32ToInt8(GateRef val)
11474514f5e3Sopenharmony_ci{
11484514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncInt32ToInt8(val);
11494514f5e3Sopenharmony_ci}
11504514f5e3Sopenharmony_ci
11514514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncFloatToInt64(GateRef val)
11524514f5e3Sopenharmony_ci{
11534514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncFloatToInt64(val);
11544514f5e3Sopenharmony_ci}
11554514f5e3Sopenharmony_ci
11564514f5e3Sopenharmony_ciinline void StubBuilder::CanNotConvertNotValidObject([[maybe_unused]] GateRef obj)
11574514f5e3Sopenharmony_ci{
11584514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(CanNotConvertNotValidObject), IsEcmaObject(obj));
11594514f5e3Sopenharmony_ci}
11604514f5e3Sopenharmony_ci
11614514f5e3Sopenharmony_ciinline void StubBuilder::IsNotPropertyKey([[maybe_unused]] GateRef flag)
11624514f5e3Sopenharmony_ci{
11634514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsNotPropertyKey), flag);
11644514f5e3Sopenharmony_ci}
11654514f5e3Sopenharmony_ci
11664514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeInt64ToIntPtr(GateRef val)
11674514f5e3Sopenharmony_ci{
11684514f5e3Sopenharmony_ci    if (env_->IsArch32Bit()) {
11694514f5e3Sopenharmony_ci        return TruncInt64ToInt32(val);
11704514f5e3Sopenharmony_ci    }
11714514f5e3Sopenharmony_ci    return val;
11724514f5e3Sopenharmony_ci}
11734514f5e3Sopenharmony_ci
11744514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt32ToPtr(GateRef val)
11754514f5e3Sopenharmony_ci{
11764514f5e3Sopenharmony_ci    if (env_->IsArch32Bit()) {
11774514f5e3Sopenharmony_ci        return val;
11784514f5e3Sopenharmony_ci    }
11794514f5e3Sopenharmony_ci    return ZExtInt32ToInt64(val);
11804514f5e3Sopenharmony_ci}
11814514f5e3Sopenharmony_ci
11824514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeIntPtrToInt32(GateRef val)
11834514f5e3Sopenharmony_ci{
11844514f5e3Sopenharmony_ci    if (env_->IsArch32Bit()) {
11854514f5e3Sopenharmony_ci        return val;
11864514f5e3Sopenharmony_ci    }
11874514f5e3Sopenharmony_ci    return TruncInt64ToInt32(val);
11884514f5e3Sopenharmony_ci}
11894514f5e3Sopenharmony_ci
11904514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSetterFromAccessor(GateRef accessor)
11914514f5e3Sopenharmony_ci{
11924514f5e3Sopenharmony_ci    GateRef setterOffset = IntPtr(AccessorData::SETTER_OFFSET);
11934514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), accessor, setterOffset);
11944514f5e3Sopenharmony_ci}
11954514f5e3Sopenharmony_ci
11964514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetElementsArray(GateRef object)
11974514f5e3Sopenharmony_ci{
11984514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetElementsArray(object);
11994514f5e3Sopenharmony_ci}
12004514f5e3Sopenharmony_ci
12014514f5e3Sopenharmony_ciinline void StubBuilder::SetElementsArray(VariableType type, GateRef glue, GateRef object, GateRef elementsArray,
12024514f5e3Sopenharmony_ci                                          MemoryAttribute mAttr)
12034514f5e3Sopenharmony_ci{
12044514f5e3Sopenharmony_ci    GateRef elementsOffset = IntPtr(JSObject::ELEMENTS_OFFSET);
12054514f5e3Sopenharmony_ci    Store(type, glue, object, elementsOffset, elementsArray, mAttr);
12064514f5e3Sopenharmony_ci}
12074514f5e3Sopenharmony_ci
12084514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertiesArray(GateRef object)
12094514f5e3Sopenharmony_ci{
12104514f5e3Sopenharmony_ci    GateRef propertiesOffset = IntPtr(JSObject::PROPERTIES_OFFSET);
12114514f5e3Sopenharmony_ci    return Load(VariableType::JS_POINTER(), object, propertiesOffset);
12124514f5e3Sopenharmony_ci}
12134514f5e3Sopenharmony_ci
12144514f5e3Sopenharmony_ci// SetProperties in js_object.h
12154514f5e3Sopenharmony_ciinline void StubBuilder::SetPropertiesArray(VariableType type, GateRef glue, GateRef object, GateRef propsArray,
12164514f5e3Sopenharmony_ci                                            MemoryAttribute mAttr)
12174514f5e3Sopenharmony_ci{
12184514f5e3Sopenharmony_ci    GateRef propertiesOffset = IntPtr(JSObject::PROPERTIES_OFFSET);
12194514f5e3Sopenharmony_ci    Store(type, glue, object, propertiesOffset, propsArray, mAttr);
12204514f5e3Sopenharmony_ci}
12214514f5e3Sopenharmony_ci
12224514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetHash(GateRef object)
12234514f5e3Sopenharmony_ci{
12244514f5e3Sopenharmony_ci    GateRef hashOffset = IntPtr(ECMAObject::HASH_OFFSET);
12254514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, hashOffset);
12264514f5e3Sopenharmony_ci}
12274514f5e3Sopenharmony_ci
12284514f5e3Sopenharmony_ciinline void StubBuilder::SetHash(GateRef glue, GateRef object, GateRef hash)
12294514f5e3Sopenharmony_ci{
12304514f5e3Sopenharmony_ci    GateRef hashOffset = IntPtr(ECMAObject::HASH_OFFSET);
12314514f5e3Sopenharmony_ci    Store(VariableType::INT64(), glue, object, hashOffset, hash, MemoryAttribute::NoBarrier());
12324514f5e3Sopenharmony_ci}
12334514f5e3Sopenharmony_ci
12344514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLengthOfTaggedArray(GateRef array)
12354514f5e3Sopenharmony_ci{
12364514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), array, IntPtr(TaggedArray::LENGTH_OFFSET));
12374514f5e3Sopenharmony_ci}
12384514f5e3Sopenharmony_ci
12394514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLengthOfJSTypedArray(GateRef array)
12404514f5e3Sopenharmony_ci{
12414514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), array, IntPtr(JSTypedArray::ARRAY_LENGTH_OFFSET));
12424514f5e3Sopenharmony_ci}
12434514f5e3Sopenharmony_ci
12444514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetExtractLengthOfTaggedArray(GateRef array)
12454514f5e3Sopenharmony_ci{
12464514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), array, IntPtr(TaggedArray::EXTRA_LENGTH_OFFSET));
12474514f5e3Sopenharmony_ci}
12484514f5e3Sopenharmony_ci
12494514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSHClass(GateRef obj)
12504514f5e3Sopenharmony_ci{
12514514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsJSHClass), TaggedIsHeapObject(obj));
12524514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsJSHClass(obj);
12534514f5e3Sopenharmony_ci    return res;
12544514f5e3Sopenharmony_ci}
12554514f5e3Sopenharmony_ci
12564514f5e3Sopenharmony_ci// object operation
12574514f5e3Sopenharmony_ciinline GateRef StubBuilder::LoadHClass(GateRef object)
12584514f5e3Sopenharmony_ci{
12594514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(LoadHClass), TaggedIsHeapObject(object));
12604514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->LoadHClass(object);
12614514f5e3Sopenharmony_ci    return res;
12624514f5e3Sopenharmony_ci}
12634514f5e3Sopenharmony_ci
12644514f5e3Sopenharmony_ciinline void StubBuilder::StoreHClass(GateRef glue, GateRef object, GateRef hClass)
12654514f5e3Sopenharmony_ci{
12664514f5e3Sopenharmony_ci    return env_->GetBuilder()->StoreHClass(glue, object, hClass);
12674514f5e3Sopenharmony_ci}
12684514f5e3Sopenharmony_ci
12694514f5e3Sopenharmony_ciinline void StubBuilder::StoreHClassWithoutBarrier(GateRef glue, GateRef object, GateRef hClass)
12704514f5e3Sopenharmony_ci{
12714514f5e3Sopenharmony_ci    return env_->GetBuilder()->StoreHClassWithoutBarrier(glue, object, hClass);
12724514f5e3Sopenharmony_ci}
12734514f5e3Sopenharmony_ci
12744514f5e3Sopenharmony_ciinline void StubBuilder::StoreBuiltinHClass(GateRef glue, GateRef object, GateRef hClass)
12754514f5e3Sopenharmony_ci{
12764514f5e3Sopenharmony_ci    return env_->GetBuilder()->StoreHClassWithoutBarrier(glue, object, hClass);
12774514f5e3Sopenharmony_ci}
12784514f5e3Sopenharmony_ci
12794514f5e3Sopenharmony_ciinline void StubBuilder::StorePrototype(GateRef glue, GateRef hclass, GateRef prototype)
12804514f5e3Sopenharmony_ci{
12814514f5e3Sopenharmony_ci    return env_->GetBuilder()->StorePrototype(glue, hclass, prototype);
12824514f5e3Sopenharmony_ci}
12834514f5e3Sopenharmony_ci
12844514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetObjectType(GateRef hClass)
12854514f5e3Sopenharmony_ci{
12864514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetObjectType(hClass);
12874514f5e3Sopenharmony_ci}
12884514f5e3Sopenharmony_ci
12894514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDictionaryMode(GateRef object)
12904514f5e3Sopenharmony_ci{
12914514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsDictionaryMode), TaggedIsHeapObject(object));
12924514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsDictionaryMode(object);
12934514f5e3Sopenharmony_ci    return res;
12944514f5e3Sopenharmony_ci}
12954514f5e3Sopenharmony_ci
12964514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDictionaryModeByHClass(GateRef hClass)
12974514f5e3Sopenharmony_ci{
12984514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsDictionaryModeByHClass(hClass);
12994514f5e3Sopenharmony_ci}
13004514f5e3Sopenharmony_ci
13014514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDictionaryElement(GateRef hClass)
13024514f5e3Sopenharmony_ci{
13034514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsDictionaryElement(hClass);
13044514f5e3Sopenharmony_ci}
13054514f5e3Sopenharmony_ci
13064514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsClassConstructorFromBitField(GateRef bitfield)
13074514f5e3Sopenharmony_ci{
13084514f5e3Sopenharmony_ci    // decode
13094514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsClassConstructorWithBitField(bitfield);
13104514f5e3Sopenharmony_ci}
13114514f5e3Sopenharmony_ci
13124514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsClassConstructor(GateRef object)
13134514f5e3Sopenharmony_ci{
13144514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsClassConstructor), TaggedIsHeapObject(object));
13154514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsClassConstructor(object);
13164514f5e3Sopenharmony_ci    return res;
13174514f5e3Sopenharmony_ci}
13184514f5e3Sopenharmony_ci
13194514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsClassPrototype(GateRef object)
13204514f5e3Sopenharmony_ci{
13214514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsClassPrototype), TaggedIsHeapObject(object));
13224514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsClassPrototype(object);
13234514f5e3Sopenharmony_ci    return res;
13244514f5e3Sopenharmony_ci}
13254514f5e3Sopenharmony_ci
13264514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsExtensible(GateRef object)
13274514f5e3Sopenharmony_ci{
13284514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsExtensible), TaggedIsHeapObject(object));
13294514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsExtensible(object);
13304514f5e3Sopenharmony_ci    return res;
13314514f5e3Sopenharmony_ci}
13324514f5e3Sopenharmony_ci
13334514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSendableFunctionModule(GateRef module)
13344514f5e3Sopenharmony_ci{
13354514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsSendableFunctionModule), IsSourceTextModule(module));
13364514f5e3Sopenharmony_ci    GateRef bitfieldOffset = Int32(SourceTextModule::BIT_FIELD_OFFSET);
13374514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), module, bitfieldOffset);
13384514f5e3Sopenharmony_ci    return Equal(Int32And(Int32LSR(bitfield,
13394514f5e3Sopenharmony_ci        Int32(SourceTextModule::SharedTypeBits::START_BIT)),
13404514f5e3Sopenharmony_ci        Int32((1LU << SourceTextModule::SharedTypeBits::SIZE) - 1)),
13414514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(SharedTypes::SENDABLE_FUNCTION_MODULE)));
13424514f5e3Sopenharmony_ci}
13434514f5e3Sopenharmony_ci
13444514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedObjectIsEcmaObject(GateRef obj)
13454514f5e3Sopenharmony_ci{
13464514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsEcmaObject), TaggedIsHeapObject(obj));
13474514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->TaggedObjectIsEcmaObject(obj);
13484514f5e3Sopenharmony_ci    return res;
13494514f5e3Sopenharmony_ci}
13504514f5e3Sopenharmony_ci
13514514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsEcmaObject(GateRef obj)
13524514f5e3Sopenharmony_ci{
13534514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsEcmaObject(obj);
13544514f5e3Sopenharmony_ci}
13554514f5e3Sopenharmony_ci
13564514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSObject(GateRef obj)
13574514f5e3Sopenharmony_ci{
13584514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsJSObject), TaggedIsHeapObject(obj));
13594514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsJSObject(obj);
13604514f5e3Sopenharmony_ci    return res;
13614514f5e3Sopenharmony_ci}
13624514f5e3Sopenharmony_ci
13634514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSFunctionBase(GateRef obj)
13644514f5e3Sopenharmony_ci{
13654514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
13664514f5e3Sopenharmony_ci    GateRef greater = Int32GreaterThanOrEqual(objectType,
13674514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::JS_FUNCTION_BASE)));
13684514f5e3Sopenharmony_ci    GateRef less = Int32LessThanOrEqual(objectType,
13694514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::JS_BOUND_FUNCTION)));
13704514f5e3Sopenharmony_ci    return BitAnd(greater, less);
13714514f5e3Sopenharmony_ci}
13724514f5e3Sopenharmony_ci
13734514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsConstructor(GateRef object)
13744514f5e3Sopenharmony_ci{
13754514f5e3Sopenharmony_ci    GateRef hClass = LoadHClass(object);
13764514f5e3Sopenharmony_ci    GateRef bitfieldOffset = IntPtr(JSHClass::BIT_FIELD_OFFSET);
13774514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass, bitfieldOffset);
13784514f5e3Sopenharmony_ci    // decode
13794514f5e3Sopenharmony_ci    return Int32NotEqual(
13804514f5e3Sopenharmony_ci        Int32And(Int32LSR(bitfield, Int32(JSHClass::ConstructorBit::START_BIT)),
13814514f5e3Sopenharmony_ci                 Int32((1LU << JSHClass::ConstructorBit::SIZE) - 1)),
13824514f5e3Sopenharmony_ci        Int32(0));
13834514f5e3Sopenharmony_ci}
13844514f5e3Sopenharmony_ci
13854514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsBase(GateRef func)
13864514f5e3Sopenharmony_ci{
13874514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsBase(func);
13884514f5e3Sopenharmony_ci}
13894514f5e3Sopenharmony_ci
13904514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDerived(GateRef func)
13914514f5e3Sopenharmony_ci{
13924514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsDerived(func);
13934514f5e3Sopenharmony_ci}
13944514f5e3Sopenharmony_ci
13954514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSymbol(GateRef obj)
13964514f5e3Sopenharmony_ci{
13974514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
13984514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::SYMBOL)));
13994514f5e3Sopenharmony_ci}
14004514f5e3Sopenharmony_ci
14014514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDataView(GateRef obj)
14024514f5e3Sopenharmony_ci{
14034514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14044514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_DATA_VIEW)));
14054514f5e3Sopenharmony_ci}
14064514f5e3Sopenharmony_ci
14074514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsString(GateRef obj)
14084514f5e3Sopenharmony_ci{
14094514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsJSObject), TaggedIsHeapObject(obj));
14104514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->TaggedObjectIsString(obj);
14114514f5e3Sopenharmony_ci    return res;
14124514f5e3Sopenharmony_ci}
14134514f5e3Sopenharmony_ci
14144514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsLineString(GateRef obj)
14154514f5e3Sopenharmony_ci{
14164514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14174514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::LINE_STRING)));
14184514f5e3Sopenharmony_ci}
14194514f5e3Sopenharmony_ci
14204514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSlicedString(GateRef obj)
14214514f5e3Sopenharmony_ci{
14224514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14234514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::SLICED_STRING)));
14244514f5e3Sopenharmony_ci}
14254514f5e3Sopenharmony_ci
14264514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsConstantString(GateRef obj)
14274514f5e3Sopenharmony_ci{
14284514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14294514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::CONSTANT_STRING)));
14304514f5e3Sopenharmony_ci}
14314514f5e3Sopenharmony_ci
14324514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsLiteralString(GateRef obj)
14334514f5e3Sopenharmony_ci{
14344514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsLiteralString(obj);
14354514f5e3Sopenharmony_ci}
14364514f5e3Sopenharmony_ci
14374514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsTreeString(GateRef obj)
14384514f5e3Sopenharmony_ci{
14394514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsTreeString(obj);
14404514f5e3Sopenharmony_ci}
14414514f5e3Sopenharmony_ci
14424514f5e3Sopenharmony_ciinline GateRef StubBuilder::TreeStringIsFlat(GateRef string)
14434514f5e3Sopenharmony_ci{
14444514f5e3Sopenharmony_ci    return env_->GetBuilder()->TreeStringIsFlat(string);
14454514f5e3Sopenharmony_ci}
14464514f5e3Sopenharmony_ci
14474514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedObjectIsBigInt(GateRef obj)
14484514f5e3Sopenharmony_ci{
14494514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14504514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::BIGINT)));
14514514f5e3Sopenharmony_ci}
14524514f5e3Sopenharmony_ci
14534514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJsProxy(GateRef obj)
14544514f5e3Sopenharmony_ci{
14554514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14564514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_PROXY)));
14574514f5e3Sopenharmony_ci}
14584514f5e3Sopenharmony_ci
14594514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSShared(GateRef obj)
14604514f5e3Sopenharmony_ci{
14614514f5e3Sopenharmony_ci    return TaggedIsSharedObj(obj);
14624514f5e3Sopenharmony_ci}
14634514f5e3Sopenharmony_ci
14644514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsProfileTypeInfoCell0(GateRef obj)
14654514f5e3Sopenharmony_ci{
14664514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14674514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::PROFILE_TYPE_INFO_CELL_0)));
14684514f5e3Sopenharmony_ci}
14694514f5e3Sopenharmony_ci
14704514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSGlobalObject(GateRef obj)
14714514f5e3Sopenharmony_ci{
14724514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14734514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_GLOBAL_OBJECT)));
14744514f5e3Sopenharmony_ci}
14754514f5e3Sopenharmony_ci
14764514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsNativeModuleFailureInfo(GateRef obj)
14774514f5e3Sopenharmony_ci{
14784514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14794514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::NATIVE_MODULE_FAILURE_INFO)));
14804514f5e3Sopenharmony_ci}
14814514f5e3Sopenharmony_ci
14824514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsModuleNamespace(GateRef obj)
14834514f5e3Sopenharmony_ci{
14844514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14854514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_MODULE_NAMESPACE)));
14864514f5e3Sopenharmony_ci}
14874514f5e3Sopenharmony_ci
14884514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSourceTextModule(GateRef obj)
14894514f5e3Sopenharmony_ci{
14904514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14914514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::SOURCE_TEXT_MODULE_RECORD)));
14924514f5e3Sopenharmony_ci}
14934514f5e3Sopenharmony_ci
14944514f5e3Sopenharmony_ciinline GateRef StubBuilder::ObjIsSpecialContainer(GateRef obj)
14954514f5e3Sopenharmony_ci{
14964514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
14974514f5e3Sopenharmony_ci    return BitAnd(
14984514f5e3Sopenharmony_ci        Int32GreaterThanOrEqual(objectType, Int32(static_cast<int32_t>(JSType::JS_API_ARRAY_LIST))),
14994514f5e3Sopenharmony_ci        Int32LessThanOrEqual(objectType, Int32(static_cast<int32_t>(JSType::JS_API_QUEUE))));
15004514f5e3Sopenharmony_ci}
15014514f5e3Sopenharmony_ci
15024514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSPrimitiveRef(GateRef obj)
15034514f5e3Sopenharmony_ci{
15044514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15054514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_PRIMITIVE_REF)));
15064514f5e3Sopenharmony_ci}
15074514f5e3Sopenharmony_ci
15084514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJsArray(GateRef obj)
15094514f5e3Sopenharmony_ci{
15104514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15114514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_ARRAY)));
15124514f5e3Sopenharmony_ci}
15134514f5e3Sopenharmony_ci
15144514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJsSArray(GateRef obj)
15154514f5e3Sopenharmony_ci{
15164514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15174514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_SHARED_ARRAY)));
15184514f5e3Sopenharmony_ci}
15194514f5e3Sopenharmony_ci
15204514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsByteArray(GateRef obj)
15214514f5e3Sopenharmony_ci{
15224514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15234514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::BYTE_ARRAY)));
15244514f5e3Sopenharmony_ci}
15254514f5e3Sopenharmony_ci
15264514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIVector(GateRef obj)
15274514f5e3Sopenharmony_ci{
15284514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15294514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_VECTOR)));
15304514f5e3Sopenharmony_ci}
15314514f5e3Sopenharmony_ci
15324514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIStack(GateRef obj)
15334514f5e3Sopenharmony_ci{
15344514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15354514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_STACK)));
15364514f5e3Sopenharmony_ci}
15374514f5e3Sopenharmony_ci
15384514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIPlainArray(GateRef obj)
15394514f5e3Sopenharmony_ci{
15404514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15414514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_PLAIN_ARRAY)));
15424514f5e3Sopenharmony_ci}
15434514f5e3Sopenharmony_ci
15444514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIQueue(GateRef obj)
15454514f5e3Sopenharmony_ci{
15464514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15474514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_QUEUE)));
15484514f5e3Sopenharmony_ci}
15494514f5e3Sopenharmony_ci
15504514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIDeque(GateRef obj)
15514514f5e3Sopenharmony_ci{
15524514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15534514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_DEQUE)));
15544514f5e3Sopenharmony_ci}
15554514f5e3Sopenharmony_ci
15564514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPILightWeightMap(GateRef obj)
15574514f5e3Sopenharmony_ci{
15584514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15594514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_LIGHT_WEIGHT_MAP)));
15604514f5e3Sopenharmony_ci}
15614514f5e3Sopenharmony_ci
15624514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPILightWeightSet(GateRef obj)
15634514f5e3Sopenharmony_ci{
15644514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15654514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_LIGHT_WEIGHT_SET)));
15664514f5e3Sopenharmony_ci}
15674514f5e3Sopenharmony_ci
15684514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsLinkedNode(GateRef obj)
15694514f5e3Sopenharmony_ci{
15704514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15714514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::LINKED_NODE)));
15724514f5e3Sopenharmony_ci}
15734514f5e3Sopenharmony_ci
15744514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIHashMap(GateRef obj)
15754514f5e3Sopenharmony_ci{
15764514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15774514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_HASH_MAP)));
15784514f5e3Sopenharmony_ci}
15794514f5e3Sopenharmony_ci
15804514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIHashSet(GateRef obj)
15814514f5e3Sopenharmony_ci{
15824514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15834514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_HASH_SET)));
15844514f5e3Sopenharmony_ci}
15854514f5e3Sopenharmony_ci
15864514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPILinkedList(GateRef obj)
15874514f5e3Sopenharmony_ci{
15884514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15894514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_LINKED_LIST)));
15904514f5e3Sopenharmony_ci}
15914514f5e3Sopenharmony_ci
15924514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIList(GateRef obj)
15934514f5e3Sopenharmony_ci{
15944514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
15954514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_LIST)));
15964514f5e3Sopenharmony_ci}
15974514f5e3Sopenharmony_ci
15984514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSAPIArrayList(GateRef obj)
15994514f5e3Sopenharmony_ci{
16004514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
16014514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_API_ARRAY_LIST)));
16024514f5e3Sopenharmony_ci}
16034514f5e3Sopenharmony_ci
16044514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSCollator(GateRef obj)
16054514f5e3Sopenharmony_ci{
16064514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
16074514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_COLLATOR)));
16084514f5e3Sopenharmony_ci}
16094514f5e3Sopenharmony_ci
16104514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSObjectType(GateRef obj, JSType jsType)
16114514f5e3Sopenharmony_ci{
16124514f5e3Sopenharmony_ci    return LogicAndBuilder(env_)
16134514f5e3Sopenharmony_ci        .And(TaggedIsHeapObject(obj))
16144514f5e3Sopenharmony_ci        .And(Int32Equal(GetObjectType(LoadHClass(obj)), Int32(static_cast<int32_t>(jsType))))
16154514f5e3Sopenharmony_ci        .Done();
16164514f5e3Sopenharmony_ci}
16174514f5e3Sopenharmony_ci
16184514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSRegExp(GateRef obj)
16194514f5e3Sopenharmony_ci{
16204514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
16214514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_REG_EXP)));
16224514f5e3Sopenharmony_ci}
16234514f5e3Sopenharmony_ci
16244514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTarget(GateRef proxyObj)
16254514f5e3Sopenharmony_ci{
16264514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSProxy::TARGET_OFFSET);
16274514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), proxyObj, offset);
16284514f5e3Sopenharmony_ci}
16294514f5e3Sopenharmony_ci
16304514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJsCOWArray(GateRef obj)
16314514f5e3Sopenharmony_ci{
16324514f5e3Sopenharmony_ci    // Elements of JSArray are shared and properties are not yet.
16334514f5e3Sopenharmony_ci    GateRef elements = GetElementsArray(obj);
16344514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(elements));
16354514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsCOWArray(objectType);
16364514f5e3Sopenharmony_ci}
16374514f5e3Sopenharmony_ci
16384514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsCOWArray(GateRef obj)
16394514f5e3Sopenharmony_ci{
16404514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
16414514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsCOWArray(objectType);
16424514f5e3Sopenharmony_ci}
16434514f5e3Sopenharmony_ci
16444514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsMutantTaggedArray(GateRef elements)
16454514f5e3Sopenharmony_ci{
16464514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(elements));
16474514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsMutantTaggedArray(objectType);
16484514f5e3Sopenharmony_ci}
16494514f5e3Sopenharmony_ci
16504514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsWritable(GateRef attr)
16514514f5e3Sopenharmony_ci{
16524514f5e3Sopenharmony_ci    return Int32NotEqual(
16534514f5e3Sopenharmony_ci        Int32And(
16544514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::WritableField::START_BIT))),
16554514f5e3Sopenharmony_ci            Int32((1LLU << PropertyAttributes::WritableField::SIZE) - 1)),
16564514f5e3Sopenharmony_ci        Int32(0));
16574514f5e3Sopenharmony_ci}
16584514f5e3Sopenharmony_ci
16594514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDefaultAttribute(GateRef attr)
16604514f5e3Sopenharmony_ci{
16614514f5e3Sopenharmony_ci    return Int32NotEqual(
16624514f5e3Sopenharmony_ci        Int32And(
16634514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::DefaultAttributesField::START_BIT))),
16644514f5e3Sopenharmony_ci            Int32((1LLU << PropertyAttributes::DefaultAttributesField::SIZE) - 1)),
16654514f5e3Sopenharmony_ci        Int32(0));
16664514f5e3Sopenharmony_ci}
16674514f5e3Sopenharmony_ci
16684514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsConfigable(GateRef attr)
16694514f5e3Sopenharmony_ci{
16704514f5e3Sopenharmony_ci    return Int32NotEqual(
16714514f5e3Sopenharmony_ci        Int32And(
16724514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::ConfigurableField::START_BIT))),
16734514f5e3Sopenharmony_ci            Int32((1LLU << PropertyAttributes::ConfigurableField::SIZE) - 1)),
16744514f5e3Sopenharmony_ci        Int32(0));
16754514f5e3Sopenharmony_ci}
16764514f5e3Sopenharmony_ci
16774514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsAccessor(GateRef attr)
16784514f5e3Sopenharmony_ci{
16794514f5e3Sopenharmony_ci    return Int32NotEqual(
16804514f5e3Sopenharmony_ci        Int32And(
16814514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::IsAccessorField::START_BIT))),
16824514f5e3Sopenharmony_ci            Int32((1LLU << PropertyAttributes::IsAccessorField::SIZE) - 1)),
16834514f5e3Sopenharmony_ci        Int32(0));
16844514f5e3Sopenharmony_ci}
16854514f5e3Sopenharmony_ci
16864514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsEnumerable(GateRef attr)
16874514f5e3Sopenharmony_ci{
16884514f5e3Sopenharmony_ci    return Int32NotEqual(
16894514f5e3Sopenharmony_ci        Int32And(
16904514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::EnumerableField::START_BIT))),
16914514f5e3Sopenharmony_ci            Int32((1LLU << PropertyAttributes::EnumerableField::SIZE) - 1)),
16924514f5e3Sopenharmony_ci        Int32(0));
16934514f5e3Sopenharmony_ci}
16944514f5e3Sopenharmony_ci
16954514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsInlinedProperty(GateRef attr)
16964514f5e3Sopenharmony_ci{
16974514f5e3Sopenharmony_ci    return Int32NotEqual(
16984514f5e3Sopenharmony_ci        Int32And(
16994514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::IsInlinedPropsField::START_BIT))),
17004514f5e3Sopenharmony_ci            Int32((1LLU << PropertyAttributes::IsInlinedPropsField::SIZE) - 1)),
17014514f5e3Sopenharmony_ci        Int32(0));
17024514f5e3Sopenharmony_ci}
17034514f5e3Sopenharmony_ci
17044514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetProtoCell(GateRef object)
17054514f5e3Sopenharmony_ci{
17064514f5e3Sopenharmony_ci    GateRef protoCellOffset = IntPtr(PrototypeHandler::PROTO_CELL_OFFSET);
17074514f5e3Sopenharmony_ci    return Load(VariableType::JS_POINTER(), object, protoCellOffset);
17084514f5e3Sopenharmony_ci}
17094514f5e3Sopenharmony_ci
17104514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPrototypeHandlerHolder(GateRef object)
17114514f5e3Sopenharmony_ci{
17124514f5e3Sopenharmony_ci    GateRef holderOffset = IntPtr(PrototypeHandler::HOLDER_OFFSET);
17134514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, holderOffset);
17144514f5e3Sopenharmony_ci}
17154514f5e3Sopenharmony_ci
17164514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPrototypeHandlerHandlerInfo(GateRef object)
17174514f5e3Sopenharmony_ci{
17184514f5e3Sopenharmony_ci    GateRef handlerInfoOffset = IntPtr(PrototypeHandler::HANDLER_INFO_OFFSET);
17194514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, handlerInfoOffset);
17204514f5e3Sopenharmony_ci}
17214514f5e3Sopenharmony_ci
17224514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetStoreTSHandlerHolder(GateRef object)
17234514f5e3Sopenharmony_ci{
17244514f5e3Sopenharmony_ci    GateRef holderOffset = IntPtr(StoreTSHandler::HOLDER_OFFSET);
17254514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, holderOffset);
17264514f5e3Sopenharmony_ci}
17274514f5e3Sopenharmony_ci
17284514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetStoreTSHandlerHandlerInfo(GateRef object)
17294514f5e3Sopenharmony_ci{
17304514f5e3Sopenharmony_ci    GateRef handlerInfoOffset = IntPtr(StoreTSHandler::HANDLER_INFO_OFFSET);
17314514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, handlerInfoOffset);
17324514f5e3Sopenharmony_ci}
17334514f5e3Sopenharmony_ci
17344514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetHasChanged(GateRef object)
17354514f5e3Sopenharmony_ci{
17364514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetHasChanged(object);
17374514f5e3Sopenharmony_ci}
17384514f5e3Sopenharmony_ci
17394514f5e3Sopenharmony_ciinline GateRef StubBuilder::HclassIsPrototypeHandler(GateRef hClass)
17404514f5e3Sopenharmony_ci{
17414514f5e3Sopenharmony_ci    return Int32Equal(GetObjectType(hClass),
17424514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::PROTOTYPE_HANDLER)));
17434514f5e3Sopenharmony_ci}
17444514f5e3Sopenharmony_ci
17454514f5e3Sopenharmony_ciinline GateRef StubBuilder::HclassIsTransitionHandler(GateRef hClass)
17464514f5e3Sopenharmony_ci{
17474514f5e3Sopenharmony_ci    return Int32Equal(GetObjectType(hClass),
17484514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::TRANSITION_HANDLER)));
17494514f5e3Sopenharmony_ci}
17504514f5e3Sopenharmony_ci
17514514f5e3Sopenharmony_ciinline GateRef StubBuilder::HclassIsPropertyBox(GateRef hClass)
17524514f5e3Sopenharmony_ci{
17534514f5e3Sopenharmony_ci    return Int32Equal(GetObjectType(hClass),
17544514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::PROPERTY_BOX)));
17554514f5e3Sopenharmony_ci}
17564514f5e3Sopenharmony_ci
17574514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedIsProtoChangeMarker(GateRef obj)
17584514f5e3Sopenharmony_ci{
17594514f5e3Sopenharmony_ci    return env_->GetBuilder()->TaggedIsProtoChangeMarker(obj);
17604514f5e3Sopenharmony_ci}
17614514f5e3Sopenharmony_ci
17624514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetEmptyArray(GateRef glue)
17634514f5e3Sopenharmony_ci{
17644514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetEmptyArray(glue);
17654514f5e3Sopenharmony_ci}
17664514f5e3Sopenharmony_ci
17674514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLengthFromForInIterator(GateRef iter)
17684514f5e3Sopenharmony_ci{
17694514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetLengthFromForInIterator(iter);
17704514f5e3Sopenharmony_ci}
17714514f5e3Sopenharmony_ci
17724514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetIndexFromForInIterator(GateRef iter)
17734514f5e3Sopenharmony_ci{
17744514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetIndexFromForInIterator(iter);
17754514f5e3Sopenharmony_ci}
17764514f5e3Sopenharmony_ci
17774514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetKeysFromForInIterator(GateRef iter)
17784514f5e3Sopenharmony_ci{
17794514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetKeysFromForInIterator(iter);
17804514f5e3Sopenharmony_ci}
17814514f5e3Sopenharmony_ci
17824514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetObjectFromForInIterator(GateRef iter)
17834514f5e3Sopenharmony_ci{
17844514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetObjectFromForInIterator(iter);
17854514f5e3Sopenharmony_ci}
17864514f5e3Sopenharmony_ci
17874514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetCachedHclassFromForInIterator(GateRef iter)
17884514f5e3Sopenharmony_ci{
17894514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetCachedHclassFromForInIterator(iter);
17904514f5e3Sopenharmony_ci}
17914514f5e3Sopenharmony_ci
17924514f5e3Sopenharmony_ciinline void StubBuilder::SetLengthOfForInIterator(GateRef glue, GateRef iter, GateRef length)
17934514f5e3Sopenharmony_ci{
17944514f5e3Sopenharmony_ci    env_->GetBuilder()->SetLengthOfForInIterator(glue, iter, length);
17954514f5e3Sopenharmony_ci}
17964514f5e3Sopenharmony_ci
17974514f5e3Sopenharmony_ciinline void StubBuilder::SetIndexOfForInIterator(GateRef glue, GateRef iter, GateRef index)
17984514f5e3Sopenharmony_ci{
17994514f5e3Sopenharmony_ci    env_->GetBuilder()->SetIndexOfForInIterator(glue, iter, index);
18004514f5e3Sopenharmony_ci}
18014514f5e3Sopenharmony_ci
18024514f5e3Sopenharmony_ciinline void StubBuilder::SetKeysOfForInIterator(GateRef glue, GateRef iter, GateRef keys)
18034514f5e3Sopenharmony_ci{
18044514f5e3Sopenharmony_ci    env_->GetBuilder()->SetKeysOfForInIterator(glue, iter, keys);
18054514f5e3Sopenharmony_ci}
18064514f5e3Sopenharmony_ci
18074514f5e3Sopenharmony_ciinline void StubBuilder::SetObjectOfForInIterator(GateRef glue, GateRef iter, GateRef object)
18084514f5e3Sopenharmony_ci{
18094514f5e3Sopenharmony_ci    env_->GetBuilder()->SetObjectOfForInIterator(glue, iter, object);
18104514f5e3Sopenharmony_ci}
18114514f5e3Sopenharmony_ci
18124514f5e3Sopenharmony_ciinline void StubBuilder::SetCachedHclassOfForInIterator(GateRef glue, GateRef iter, GateRef hclass)
18134514f5e3Sopenharmony_ci{
18144514f5e3Sopenharmony_ci    env_->GetBuilder()->SetCachedHclassOfForInIterator(glue, iter, hclass);
18154514f5e3Sopenharmony_ci}
18164514f5e3Sopenharmony_ci
18174514f5e3Sopenharmony_ciinline void StubBuilder::IncreaseInteratorIndex(GateRef glue, GateRef iter, GateRef index)
18184514f5e3Sopenharmony_ci{
18194514f5e3Sopenharmony_ci    env_->GetBuilder()->IncreaseInteratorIndex(glue, iter, index);
18204514f5e3Sopenharmony_ci}
18214514f5e3Sopenharmony_ci
18224514f5e3Sopenharmony_ciinline void StubBuilder::SetNextIndexOfArrayIterator(GateRef glue, GateRef iter, GateRef nextIndex)
18234514f5e3Sopenharmony_ci{
18244514f5e3Sopenharmony_ci    env_->GetBuilder()->SetNextIndexOfArrayIterator(glue, iter, nextIndex);
18254514f5e3Sopenharmony_ci}
18264514f5e3Sopenharmony_ci
18274514f5e3Sopenharmony_ciinline void StubBuilder::SetIteratedArrayOfArrayIterator(GateRef glue, GateRef iter, GateRef iteratedArray)
18284514f5e3Sopenharmony_ci{
18294514f5e3Sopenharmony_ci    env_->GetBuilder()->SetIteratedArrayOfArrayIterator(glue, iter, iteratedArray);
18304514f5e3Sopenharmony_ci}
18314514f5e3Sopenharmony_ci
18324514f5e3Sopenharmony_ciinline void StubBuilder::SetBitFieldOfArrayIterator(GateRef glue, GateRef iter, GateRef kind)
18334514f5e3Sopenharmony_ci{
18344514f5e3Sopenharmony_ci    env_->GetBuilder()->SetBitFieldOfArrayIterator(glue, iter, kind);
18354514f5e3Sopenharmony_ci}
18364514f5e3Sopenharmony_ci
18374514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsField(GateRef attr)
18384514f5e3Sopenharmony_ci{
18394514f5e3Sopenharmony_ci    return Int32Equal(
18404514f5e3Sopenharmony_ci        Int32And(
18414514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
18424514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
18434514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::FIELD));
18444514f5e3Sopenharmony_ci}
18454514f5e3Sopenharmony_ci
18464514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsNonSharedStoreField(GateRef attr)
18474514f5e3Sopenharmony_ci{
18484514f5e3Sopenharmony_ci    return Int32Equal(
18494514f5e3Sopenharmony_ci        Int32And(
18504514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::SWholeKindBit::START_BIT))),
18514514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::SWholeKindBit::SIZE) - 1)),
18524514f5e3Sopenharmony_ci        Int32(HandlerBase::StoreHandlerKind::S_FIELD));
18534514f5e3Sopenharmony_ci}
18544514f5e3Sopenharmony_ci
18554514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsStoreShared(GateRef attr)
18564514f5e3Sopenharmony_ci{
18574514f5e3Sopenharmony_ci    return Int32NotEqual(
18584514f5e3Sopenharmony_ci        Int32And(
18594514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::SSharedBit::START_BIT))),
18604514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::SSharedBit::SIZE) - 1)),
18614514f5e3Sopenharmony_ci        Int32(0));
18624514f5e3Sopenharmony_ci}
18634514f5e3Sopenharmony_ci
18644514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsElement(GateRef attr)
18654514f5e3Sopenharmony_ci{
18664514f5e3Sopenharmony_ci    return Int32Equal(
18674514f5e3Sopenharmony_ci        Int32And(
18684514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
18694514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
18704514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::ELEMENT));
18714514f5e3Sopenharmony_ci}
18724514f5e3Sopenharmony_ci
18734514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsStringElement(GateRef attr)
18744514f5e3Sopenharmony_ci{
18754514f5e3Sopenharmony_ci    return Int32Equal(
18764514f5e3Sopenharmony_ci        Int32And(
18774514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
18784514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
18794514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::STRING));
18804514f5e3Sopenharmony_ci}
18814514f5e3Sopenharmony_ci
18824514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsNumber(GateRef attr)
18834514f5e3Sopenharmony_ci{
18844514f5e3Sopenharmony_ci    return Int32Equal(
18854514f5e3Sopenharmony_ci        Int32And(
18864514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
18874514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
18884514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::NUMBER));
18894514f5e3Sopenharmony_ci}
18904514f5e3Sopenharmony_ci
18914514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsStringLength(GateRef attr)
18924514f5e3Sopenharmony_ci{
18934514f5e3Sopenharmony_ci    return Int32Equal(
18944514f5e3Sopenharmony_ci        Int32And(
18954514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
18964514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
18974514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::STRING_LENGTH));
18984514f5e3Sopenharmony_ci}
18994514f5e3Sopenharmony_ci
19004514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsTypedArrayElement(GateRef attr)
19014514f5e3Sopenharmony_ci{
19024514f5e3Sopenharmony_ci    return Int32Equal(
19034514f5e3Sopenharmony_ci        Int32And(
19044514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
19054514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
19064514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::TYPED_ARRAY));
19074514f5e3Sopenharmony_ci}
19084514f5e3Sopenharmony_ci
19094514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsNonExist(GateRef attr)
19104514f5e3Sopenharmony_ci{
19114514f5e3Sopenharmony_ci    return Int32Equal(
19124514f5e3Sopenharmony_ci        Int32And(
19134514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::KindBit::START_BIT))),
19144514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::KindBit::SIZE) - 1)),
19154514f5e3Sopenharmony_ci        Int32(HandlerBase::HandlerKind::NON_EXIST));
19164514f5e3Sopenharmony_ci}
19174514f5e3Sopenharmony_ci
19184514f5e3Sopenharmony_ciinline GateRef StubBuilder::HandlerBaseIsAccessor(GateRef attr)
19194514f5e3Sopenharmony_ci{
19204514f5e3Sopenharmony_ci    return Int32NotEqual(
19214514f5e3Sopenharmony_ci        Int32And(
19224514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::AccessorBit::START_BIT))),
19234514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::AccessorBit::SIZE) - 1)),
19244514f5e3Sopenharmony_ci        Int32(0));
19254514f5e3Sopenharmony_ci}
19264514f5e3Sopenharmony_ci
19274514f5e3Sopenharmony_ciinline GateRef StubBuilder::HandlerBaseIsJSArray(GateRef attr)
19284514f5e3Sopenharmony_ci{
19294514f5e3Sopenharmony_ci    return Int32NotEqual(
19304514f5e3Sopenharmony_ci        Int32And(
19314514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::IsJSArrayBit::START_BIT))),
19324514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::IsJSArrayBit::SIZE) - 1)),
19334514f5e3Sopenharmony_ci        Int32(0));
19344514f5e3Sopenharmony_ci}
19354514f5e3Sopenharmony_ci
19364514f5e3Sopenharmony_ciinline GateRef StubBuilder::HandlerBaseIsInlinedProperty(GateRef attr)
19374514f5e3Sopenharmony_ci{
19384514f5e3Sopenharmony_ci    return Int32NotEqual(
19394514f5e3Sopenharmony_ci        Int32And(
19404514f5e3Sopenharmony_ci            TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::InlinedPropsBit::START_BIT))),
19414514f5e3Sopenharmony_ci            Int32((1LLU << HandlerBase::InlinedPropsBit::SIZE) - 1)),
19424514f5e3Sopenharmony_ci        Int32(0));
19434514f5e3Sopenharmony_ci}
19444514f5e3Sopenharmony_ci
19454514f5e3Sopenharmony_ciinline GateRef StubBuilder::HandlerBaseGetOffset(GateRef attr)
19464514f5e3Sopenharmony_ci{
19474514f5e3Sopenharmony_ci    return Int32And(
19484514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::OffsetBit::START_BIT))),
19494514f5e3Sopenharmony_ci        Int32((1LLU << HandlerBase::OffsetBit::SIZE) - 1));
19504514f5e3Sopenharmony_ci}
19514514f5e3Sopenharmony_ci
19524514f5e3Sopenharmony_ci
19534514f5e3Sopenharmony_ciinline GateRef StubBuilder::HandlerBaseGetAttrIndex(GateRef attr)
19544514f5e3Sopenharmony_ci{
19554514f5e3Sopenharmony_ci    return Int32And(
19564514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::AttrIndexBit::START_BIT))),
19574514f5e3Sopenharmony_ci        Int32((1LLU << HandlerBase::AttrIndexBit::SIZE) - 1));
19584514f5e3Sopenharmony_ci}
19594514f5e3Sopenharmony_ci
19604514f5e3Sopenharmony_ciinline GateRef StubBuilder::HandlerBaseGetRep(GateRef attr)
19614514f5e3Sopenharmony_ci{
19624514f5e3Sopenharmony_ci    return Int32And(
19634514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::RepresentationBit::START_BIT))),
19644514f5e3Sopenharmony_ci        Int32((1LLU << HandlerBase::RepresentationBit::SIZE) - 1));
19654514f5e3Sopenharmony_ci}
19664514f5e3Sopenharmony_ci
19674514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsInvalidPropertyBox(GateRef obj)
19684514f5e3Sopenharmony_ci{
19694514f5e3Sopenharmony_ci    GateRef valueOffset = IntPtr(PropertyBox::VALUE_OFFSET);
19704514f5e3Sopenharmony_ci    GateRef value = Load(VariableType::JS_ANY(), obj, valueOffset);
19714514f5e3Sopenharmony_ci    return TaggedIsHole(value);
19724514f5e3Sopenharmony_ci}
19734514f5e3Sopenharmony_ci
19744514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsAccessorPropertyBox(GateRef obj)
19754514f5e3Sopenharmony_ci{
19764514f5e3Sopenharmony_ci    GateRef valueOffset = IntPtr(PropertyBox::VALUE_OFFSET);
19774514f5e3Sopenharmony_ci    GateRef value = Load(VariableType::JS_ANY(), obj, valueOffset);
19784514f5e3Sopenharmony_ci    return TaggedIsAccessor(value);
19794514f5e3Sopenharmony_ci}
19804514f5e3Sopenharmony_ci
19814514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetValueFromPropertyBox(GateRef obj)
19824514f5e3Sopenharmony_ci{
19834514f5e3Sopenharmony_ci    GateRef valueOffset = IntPtr(PropertyBox::VALUE_OFFSET);
19844514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), obj, valueOffset);
19854514f5e3Sopenharmony_ci}
19864514f5e3Sopenharmony_ci
19874514f5e3Sopenharmony_ciinline void StubBuilder::SetValueToPropertyBox(GateRef glue, GateRef obj, GateRef value)
19884514f5e3Sopenharmony_ci{
19894514f5e3Sopenharmony_ci    GateRef valueOffset = IntPtr(PropertyBox::VALUE_OFFSET);
19904514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, obj, valueOffset, value);
19914514f5e3Sopenharmony_ci}
19924514f5e3Sopenharmony_ci
19934514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTransitionHClass(GateRef obj)
19944514f5e3Sopenharmony_ci{
19954514f5e3Sopenharmony_ci    GateRef transitionHClassOffset = IntPtr(TransitionHandler::TRANSITION_HCLASS_OFFSET);
19964514f5e3Sopenharmony_ci    return Load(VariableType::JS_POINTER(), obj, transitionHClassOffset);
19974514f5e3Sopenharmony_ci}
19984514f5e3Sopenharmony_ci
19994514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTransitionHandlerInfo(GateRef obj)
20004514f5e3Sopenharmony_ci{
20014514f5e3Sopenharmony_ci    GateRef handlerInfoOffset = IntPtr(TransitionHandler::HANDLER_INFO_OFFSET);
20024514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), obj, handlerInfoOffset);
20034514f5e3Sopenharmony_ci}
20044514f5e3Sopenharmony_ci
20054514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTransWithProtoHClass(GateRef obj)
20064514f5e3Sopenharmony_ci{
20074514f5e3Sopenharmony_ci    GateRef transitionHClassOffset = IntPtr(TransWithProtoHandler::TRANSITION_HCLASS_OFFSET);
20084514f5e3Sopenharmony_ci    return Load(VariableType::JS_POINTER(), obj, transitionHClassOffset);
20094514f5e3Sopenharmony_ci}
20104514f5e3Sopenharmony_ci
20114514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTransWithProtoHandlerInfo(GateRef obj)
20124514f5e3Sopenharmony_ci{
20134514f5e3Sopenharmony_ci    GateRef handlerInfoOffset = IntPtr(TransWithProtoHandler::HANDLER_INFO_OFFSET);
20144514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), obj, handlerInfoOffset);
20154514f5e3Sopenharmony_ci}
20164514f5e3Sopenharmony_ci
20174514f5e3Sopenharmony_ciinline GateRef StubBuilder::PropAttrGetOffset(GateRef attr)
20184514f5e3Sopenharmony_ci{
20194514f5e3Sopenharmony_ci    return Int32And(
20204514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::OffsetField::START_BIT))),
20214514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::OffsetField::SIZE) - 1));
20224514f5e3Sopenharmony_ci}
20234514f5e3Sopenharmony_ci
20244514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSortedIndex(GateRef attr)
20254514f5e3Sopenharmony_ci{
20264514f5e3Sopenharmony_ci    return TruncInt64ToInt32(Int64And(
20274514f5e3Sopenharmony_ci        Int64LSR(attr, Int64(PropertyAttributes::SortedIndexField::START_BIT)),
20284514f5e3Sopenharmony_ci        Int64((1LLU << PropertyAttributes::SortedIndexField::SIZE) - 1)));
20294514f5e3Sopenharmony_ci}
20304514f5e3Sopenharmony_ci
20314514f5e3Sopenharmony_ci// SetDictionaryOrder func in property_attribute.h
20324514f5e3Sopenharmony_ciinline GateRef StubBuilder::SetDictionaryOrderFieldInPropAttr(GateRef attr, GateRef value)
20334514f5e3Sopenharmony_ci{
20344514f5e3Sopenharmony_ci    GateRef mask = Int64LSL(
20354514f5e3Sopenharmony_ci        Int64((1LLU << PropertyAttributes::DictionaryOrderField::SIZE) - 1),
20364514f5e3Sopenharmony_ci        Int64(PropertyAttributes::DictionaryOrderField::START_BIT));
20374514f5e3Sopenharmony_ci    GateRef newVal = Int64Or(Int64And(attr, Int64Not(mask)),
20384514f5e3Sopenharmony_ci        Int64LSL(value, Int64(PropertyAttributes::DictionaryOrderField::START_BIT)));
20394514f5e3Sopenharmony_ci    return newVal;
20404514f5e3Sopenharmony_ci}
20414514f5e3Sopenharmony_ci
20424514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPrototypeFromHClass(GateRef hClass)
20434514f5e3Sopenharmony_ci{
20444514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetPrototypeFromHClass(hClass);
20454514f5e3Sopenharmony_ci}
20464514f5e3Sopenharmony_ci
20474514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetEnumCacheFromHClass(GateRef hClass)
20484514f5e3Sopenharmony_ci{
20494514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetEnumCacheFromHClass(hClass);
20504514f5e3Sopenharmony_ci}
20514514f5e3Sopenharmony_ci
20524514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetProtoChangeMarkerFromHClass(GateRef hClass)
20534514f5e3Sopenharmony_ci{
20544514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetProtoChangeMarkerFromHClass(hClass);
20554514f5e3Sopenharmony_ci}
20564514f5e3Sopenharmony_ci
20574514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLayoutFromHClass(GateRef hClass)
20584514f5e3Sopenharmony_ci{
20594514f5e3Sopenharmony_ci    GateRef attrOffset = IntPtr(JSHClass::LAYOUT_OFFSET);
20604514f5e3Sopenharmony_ci    return Load(VariableType::JS_POINTER(), hClass, attrOffset);
20614514f5e3Sopenharmony_ci}
20624514f5e3Sopenharmony_ci
20634514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetBitFieldFromHClass(GateRef hClass)
20644514f5e3Sopenharmony_ci{
20654514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::BIT_FIELD_OFFSET);
20664514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), hClass, offset);
20674514f5e3Sopenharmony_ci}
20684514f5e3Sopenharmony_ci
20694514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLengthFromString(GateRef value)
20704514f5e3Sopenharmony_ci{
20714514f5e3Sopenharmony_ci    GateRef len = Load(VariableType::INT32(), value, IntPtr(EcmaString::MIX_LENGTH_OFFSET));
20724514f5e3Sopenharmony_ci    return Int32LSR(len, Int32(EcmaString::STRING_LENGTH_SHIFT_COUNT));
20734514f5e3Sopenharmony_ci}
20744514f5e3Sopenharmony_ci
20754514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetFirstFromTreeString(GateRef string)
20764514f5e3Sopenharmony_ci{
20774514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetFirstFromTreeString(string);
20784514f5e3Sopenharmony_ci}
20794514f5e3Sopenharmony_ci
20804514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSecondFromTreeString(GateRef string)
20814514f5e3Sopenharmony_ci{
20824514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetSecondFromTreeString(string);
20834514f5e3Sopenharmony_ci}
20844514f5e3Sopenharmony_ci
20854514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetIsAllTaggedPropFromHClass(GateRef hclass)
20864514f5e3Sopenharmony_ci{
20874514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hclass, IntPtr(JSHClass::BIT_FIELD1_OFFSET));
20884514f5e3Sopenharmony_ci    return Int32And(Int32LSR(bitfield,
20894514f5e3Sopenharmony_ci        Int32(JSHClass::IsAllTaggedPropBit::START_BIT)),
20904514f5e3Sopenharmony_ci        Int32((1LLU << JSHClass::IsAllTaggedPropBit::SIZE) - 1));
20914514f5e3Sopenharmony_ci}
20924514f5e3Sopenharmony_ci
20934514f5e3Sopenharmony_ciinline void StubBuilder::SetBitFieldToHClass(GateRef glue, GateRef hClass, GateRef bitfield)
20944514f5e3Sopenharmony_ci{
20954514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::BIT_FIELD_OFFSET);
20964514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, hClass, offset, bitfield);
20974514f5e3Sopenharmony_ci}
20984514f5e3Sopenharmony_ci
20994514f5e3Sopenharmony_ciinline void StubBuilder::SetIsAllTaggedProp(GateRef glue, GateRef hclass, GateRef hasRep)
21004514f5e3Sopenharmony_ci{
21014514f5e3Sopenharmony_ci    GateRef bitfield1 = Load(VariableType::INT32(), hclass, IntPtr(JSHClass::BIT_FIELD1_OFFSET));
21024514f5e3Sopenharmony_ci    GateRef mask = Int32LSL(
21034514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::IsAllTaggedPropBit::SIZE) - 1),
21044514f5e3Sopenharmony_ci        Int32(JSHClass::IsAllTaggedPropBit::START_BIT));
21054514f5e3Sopenharmony_ci    GateRef newVal = Int32Or(Int32And(bitfield1, Int32Not(mask)),
21064514f5e3Sopenharmony_ci        Int32LSL(hasRep, Int32(JSHClass::IsAllTaggedPropBit::START_BIT)));
21074514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, hclass, IntPtr(JSHClass::BIT_FIELD1_OFFSET), newVal);
21084514f5e3Sopenharmony_ci}
21094514f5e3Sopenharmony_ci
21104514f5e3Sopenharmony_ciinline void StubBuilder::SetPrototypeToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef proto)
21114514f5e3Sopenharmony_ci{
21124514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::PROTOTYPE_OFFSET);
21134514f5e3Sopenharmony_ci    Store(type, glue, hClass, offset, proto);
21144514f5e3Sopenharmony_ci}
21154514f5e3Sopenharmony_ci
21164514f5e3Sopenharmony_ciinline void StubBuilder::SetProtoChangeDetailsToHClass(VariableType type,
21174514f5e3Sopenharmony_ci    GateRef glue, GateRef hClass, GateRef protoChange)
21184514f5e3Sopenharmony_ci{
21194514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::PROTO_CHANGE_DETAILS_OFFSET);
21204514f5e3Sopenharmony_ci    Store(type, glue, hClass, offset, protoChange);
21214514f5e3Sopenharmony_ci}
21224514f5e3Sopenharmony_ci
21234514f5e3Sopenharmony_ciinline void StubBuilder::SetLayoutToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef attr,
21244514f5e3Sopenharmony_ci                                           MemoryAttribute mAttr)
21254514f5e3Sopenharmony_ci{
21264514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::LAYOUT_OFFSET);
21274514f5e3Sopenharmony_ci    Store(type, glue, hClass, offset, attr, mAttr);
21284514f5e3Sopenharmony_ci}
21294514f5e3Sopenharmony_ci
21304514f5e3Sopenharmony_ciinline void StubBuilder::SetEnumCacheToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef key)
21314514f5e3Sopenharmony_ci{
21324514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::ENUM_CACHE_OFFSET);
21334514f5e3Sopenharmony_ci    Store(type, glue, hClass, offset, key);
21344514f5e3Sopenharmony_ci}
21354514f5e3Sopenharmony_ci
21364514f5e3Sopenharmony_ciinline void StubBuilder::SetTransitionsToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef transition)
21374514f5e3Sopenharmony_ci{
21384514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::TRANSTIONS_OFFSET);
21394514f5e3Sopenharmony_ci    Store(type, glue, hClass, offset, transition);
21404514f5e3Sopenharmony_ci}
21414514f5e3Sopenharmony_ci
21424514f5e3Sopenharmony_ciinline void StubBuilder::SetParentToHClass(VariableType type, GateRef glue, GateRef hClass, GateRef parent)
21434514f5e3Sopenharmony_ci{
21444514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSHClass::PARENT_OFFSET);
21454514f5e3Sopenharmony_ci    Store(type, glue, hClass, offset, parent);
21464514f5e3Sopenharmony_ci}
21474514f5e3Sopenharmony_ci
21484514f5e3Sopenharmony_ciinline void StubBuilder::SetIsProtoTypeToHClass(GateRef glue, GateRef hClass, GateRef value)
21494514f5e3Sopenharmony_ci{
21504514f5e3Sopenharmony_ci    GateRef oldValue = ZExtInt1ToInt32(value);
21514514f5e3Sopenharmony_ci    GateRef bitfield = GetBitFieldFromHClass(hClass);
21524514f5e3Sopenharmony_ci    GateRef mask = Int32LSL(
21534514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::IsPrototypeBit::SIZE) - 1),
21544514f5e3Sopenharmony_ci        Int32(JSHClass::IsPrototypeBit::START_BIT));
21554514f5e3Sopenharmony_ci    GateRef newVal = Int32Or(Int32And(bitfield, Int32Not(mask)),
21564514f5e3Sopenharmony_ci        Int32LSL(oldValue, Int32(JSHClass::IsPrototypeBit::START_BIT)));
21574514f5e3Sopenharmony_ci    SetBitFieldToHClass(glue, hClass, newVal);
21584514f5e3Sopenharmony_ci}
21594514f5e3Sopenharmony_ci
21604514f5e3Sopenharmony_ciinline void StubBuilder::SetIsTS(GateRef glue, GateRef hClass, GateRef value)
21614514f5e3Sopenharmony_ci{
21624514f5e3Sopenharmony_ci    GateRef oldValue = ZExtInt1ToInt32(value);
21634514f5e3Sopenharmony_ci    GateRef bitfield = GetBitFieldFromHClass(hClass);
21644514f5e3Sopenharmony_ci    GateRef mask = Int32LSL(
21654514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::IsTSBit::SIZE) - 1),
21664514f5e3Sopenharmony_ci        Int32(JSHClass::IsTSBit::START_BIT));
21674514f5e3Sopenharmony_ci    GateRef newVal = Int32Or(Int32And(bitfield, Int32Not(mask)),
21684514f5e3Sopenharmony_ci        Int32LSL(oldValue, Int32(JSHClass::IsTSBit::START_BIT)));
21694514f5e3Sopenharmony_ci    SetBitFieldToHClass(glue, hClass, newVal);
21704514f5e3Sopenharmony_ci}
21714514f5e3Sopenharmony_ci
21724514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsProtoTypeHClass(GateRef hClass)
21734514f5e3Sopenharmony_ci{
21744514f5e3Sopenharmony_ci    GateRef bitfield = GetBitFieldFromHClass(hClass);
21754514f5e3Sopenharmony_ci    return TruncInt32ToInt1(Int32And(Int32LSR(bitfield,
21764514f5e3Sopenharmony_ci        Int32(JSHClass::IsPrototypeBit::START_BIT)),
21774514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::IsPrototypeBit::SIZE) - 1)));
21784514f5e3Sopenharmony_ci}
21794514f5e3Sopenharmony_ci
21804514f5e3Sopenharmony_ciinline void StubBuilder::SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass, GateRef value,
21814514f5e3Sopenharmony_ci                                                 GateRef attrOffset, VariableType type, MemoryAttribute mAttr)
21824514f5e3Sopenharmony_ci{
21834514f5e3Sopenharmony_ci    ASM_ASSERT_WITH_GLUE(GET_MESSAGE_STRING_ID(IsNotDictionaryMode), BoolNot(IsDictionaryModeByHClass(hClass)), glue);
21844514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass,
21854514f5e3Sopenharmony_ci                            IntPtr(JSHClass::BIT_FIELD1_OFFSET));
21864514f5e3Sopenharmony_ci    GateRef inlinedPropsStart = Int32And(Int32LSR(bitfield,
21874514f5e3Sopenharmony_ci        Int32(JSHClass::InlinedPropsStartBits::START_BIT)),
21884514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::InlinedPropsStartBits::SIZE) - 1));
21894514f5e3Sopenharmony_ci    GateRef propOffset = Int32Mul(
21904514f5e3Sopenharmony_ci        Int32Add(inlinedPropsStart, attrOffset), Int32(JSTaggedValue::TaggedTypeSize()));
21914514f5e3Sopenharmony_ci
21924514f5e3Sopenharmony_ci    // NOTE: need to translate MarkingBarrier
21934514f5e3Sopenharmony_ci    Store(type, glue, obj, ZExtInt32ToPtr(propOffset), value, mAttr);
21944514f5e3Sopenharmony_ci    EXITENTRY();
21954514f5e3Sopenharmony_ci}
21964514f5e3Sopenharmony_ci
21974514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertyInlinedProps(GateRef obj, GateRef hClass,
21984514f5e3Sopenharmony_ci    GateRef index)
21994514f5e3Sopenharmony_ci{
22004514f5e3Sopenharmony_ci    GateRef inlinedPropsStart = GetInlinedPropsStartFromHClass(hClass);
22014514f5e3Sopenharmony_ci    GateRef propOffset = Int32Mul(
22024514f5e3Sopenharmony_ci        Int32Add(inlinedPropsStart, index), Int32(JSTaggedValue::TaggedTypeSize()));
22034514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), obj, ZExtInt32ToInt64(propOffset));
22044514f5e3Sopenharmony_ci}
22054514f5e3Sopenharmony_ci
22064514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetInlinedPropOffsetFromHClass(GateRef hclass, GateRef index)
22074514f5e3Sopenharmony_ci{
22084514f5e3Sopenharmony_ci    GateRef inlinedPropsStart = GetInlinedPropsStartFromHClass(hclass);
22094514f5e3Sopenharmony_ci    GateRef propOffset = Int32Mul(
22104514f5e3Sopenharmony_ci        Int32Add(inlinedPropsStart, index), Int32(JSTaggedValue::TaggedTypeSize()));
22114514f5e3Sopenharmony_ci    return ZExtInt32ToInt64(propOffset);
22124514f5e3Sopenharmony_ci}
22134514f5e3Sopenharmony_ci
22144514f5e3Sopenharmony_ciinline void StubBuilder::IncNumberOfProps(GateRef glue, GateRef hClass)
22154514f5e3Sopenharmony_ci{
22164514f5e3Sopenharmony_ci    GateRef propNums = GetNumberOfPropsFromHClass(hClass);
22174514f5e3Sopenharmony_ci    SetNumberOfPropsToHClass(glue, hClass, Int32Add(propNums, Int32(1)));
22184514f5e3Sopenharmony_ci}
22194514f5e3Sopenharmony_ci
22204514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetNumberOfPropsFromHClass(GateRef hClass)
22214514f5e3Sopenharmony_ci{
22224514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD1_OFFSET));
22234514f5e3Sopenharmony_ci    return Int32And(Int32LSR(bitfield,
22244514f5e3Sopenharmony_ci        Int32(JSHClass::NumberOfPropsBits::START_BIT)),
22254514f5e3Sopenharmony_ci        Int32((1LLU << JSHClass::NumberOfPropsBits::SIZE) - 1));
22264514f5e3Sopenharmony_ci}
22274514f5e3Sopenharmony_ci
22284514f5e3Sopenharmony_ciinline GateRef StubBuilder::HasDeleteProperty(GateRef hClass)
22294514f5e3Sopenharmony_ci{
22304514f5e3Sopenharmony_ci    return env_->GetBuilder()->HasDeleteProperty(hClass);
22314514f5e3Sopenharmony_ci}
22324514f5e3Sopenharmony_ci
22334514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsTSHClass(GateRef hClass)
22344514f5e3Sopenharmony_ci{
22354514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD_OFFSET));
22364514f5e3Sopenharmony_ci    return Int32NotEqual(Int32And(Int32LSR(bitfield,
22374514f5e3Sopenharmony_ci        Int32(JSHClass::IsTSBit::START_BIT)),
22384514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::IsTSBit::SIZE) - 1)),
22394514f5e3Sopenharmony_ci        Int32(0));
22404514f5e3Sopenharmony_ci}
22414514f5e3Sopenharmony_ci
22424514f5e3Sopenharmony_ciinline void StubBuilder::SetNumberOfPropsToHClass(GateRef glue, GateRef hClass, GateRef value)
22434514f5e3Sopenharmony_ci{
22444514f5e3Sopenharmony_ci    GateRef bitfield1 = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD1_OFFSET));
22454514f5e3Sopenharmony_ci    GateRef oldWithMask = Int32And(bitfield1,
22464514f5e3Sopenharmony_ci        Int32(~static_cast<uint32_t>(JSHClass::NumberOfPropsBits::Mask())));
22474514f5e3Sopenharmony_ci    GateRef newValue = Int32LSR(value, Int32(JSHClass::NumberOfPropsBits::START_BIT));
22484514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, hClass, IntPtr(JSHClass::BIT_FIELD1_OFFSET),
22494514f5e3Sopenharmony_ci        Int32Or(oldWithMask, newValue));
22504514f5e3Sopenharmony_ci}
22514514f5e3Sopenharmony_ci
22524514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetInlinedPropertiesFromHClass(GateRef hClass)
22534514f5e3Sopenharmony_ci{
22544514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD1_OFFSET));
22554514f5e3Sopenharmony_ci    GateRef objectSizeInWords = Int32And(Int32LSR(bitfield,
22564514f5e3Sopenharmony_ci        Int32(JSHClass::ObjectSizeInWordsBits::START_BIT)),
22574514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::ObjectSizeInWordsBits::SIZE) - 1));
22584514f5e3Sopenharmony_ci    GateRef inlinedPropsStart = Int32And(Int32LSR(bitfield,
22594514f5e3Sopenharmony_ci        Int32(JSHClass::InlinedPropsStartBits::START_BIT)),
22604514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::InlinedPropsStartBits::SIZE) - 1));
22614514f5e3Sopenharmony_ci    return Int32Sub(objectSizeInWords, inlinedPropsStart);
22624514f5e3Sopenharmony_ci}
22634514f5e3Sopenharmony_ci
22644514f5e3Sopenharmony_ciinline void StubBuilder::SetElementsKindToTrackInfo(GateRef glue, GateRef trackInfo, GateRef elementsKind)
22654514f5e3Sopenharmony_ci{
22664514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), trackInfo, IntPtr(TrackInfo::BIT_FIELD_OFFSET));
22674514f5e3Sopenharmony_ci    GateRef oldWithMask = Int32And(bitfield,
22684514f5e3Sopenharmony_ci        Int32(~static_cast<uint32_t>(TrackInfo::ElementsKindBits::Mask())));
22694514f5e3Sopenharmony_ci    GateRef newValue = Int32LSR(elementsKind, Int32(TrackInfo::ElementsKindBits::START_BIT));
22704514f5e3Sopenharmony_ci    GateRef newBitfield = Int32Or(oldWithMask, newValue);
22714514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, trackInfo, IntPtr(TrackInfo::BIT_FIELD_OFFSET), newBitfield);
22724514f5e3Sopenharmony_ci}
22734514f5e3Sopenharmony_ci
22744514f5e3Sopenharmony_ciinline void StubBuilder::SetSpaceFlagToTrackInfo(GateRef glue, GateRef trackInfo, GateRef spaceFlag)
22754514f5e3Sopenharmony_ci{
22764514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), trackInfo, IntPtr(TrackInfo::BIT_FIELD_OFFSET));
22774514f5e3Sopenharmony_ci    GateRef oldWithMask = Int32And(bitfield,
22784514f5e3Sopenharmony_ci        Int32(~static_cast<uint32_t>(TrackInfo::SpaceFlagBits::Mask())));
22794514f5e3Sopenharmony_ci    GateRef newValue = Int32LSL(spaceFlag, Int32(TrackInfo::SpaceFlagBits::START_BIT));
22804514f5e3Sopenharmony_ci    GateRef newBitfield = Int32Or(oldWithMask, newValue);
22814514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, trackInfo, IntPtr(TrackInfo::BIT_FIELD_OFFSET), newBitfield);
22824514f5e3Sopenharmony_ci}
22834514f5e3Sopenharmony_ci
22844514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetElementsKindFromHClass(GateRef hClass)
22854514f5e3Sopenharmony_ci{
22864514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetElementsKindByHClass(hClass);
22874514f5e3Sopenharmony_ci}
22884514f5e3Sopenharmony_ci
22894514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetObjectSizeFromHClass(GateRef hClass)
22904514f5e3Sopenharmony_ci{
22914514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetObjectSizeFromHClass(hClass);
22924514f5e3Sopenharmony_ci}
22934514f5e3Sopenharmony_ci
22944514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetInlinedPropsStartFromHClass(GateRef hClass)
22954514f5e3Sopenharmony_ci{
22964514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD1_OFFSET));
22974514f5e3Sopenharmony_ci    return Int32And(Int32LSR(bitfield,
22984514f5e3Sopenharmony_ci        Int32(JSHClass::InlinedPropsStartBits::START_BIT)),
22994514f5e3Sopenharmony_ci        Int32((1LU << JSHClass::InlinedPropsStartBits::SIZE) - 1));
23004514f5e3Sopenharmony_ci}
23014514f5e3Sopenharmony_ci
23024514f5e3Sopenharmony_ciinline void StubBuilder::SetValueToTaggedArrayWithAttr(
23034514f5e3Sopenharmony_ci    GateRef glue, GateRef array, GateRef index, GateRef key, GateRef val, GateRef attr)
23044514f5e3Sopenharmony_ci{
23054514f5e3Sopenharmony_ci    GateRef offset = PtrMul(ZExtInt32ToPtr(index), IntPtr(JSTaggedValue::TaggedTypeSize()));
23064514f5e3Sopenharmony_ci    GateRef dataOffset = PtrAdd(offset, IntPtr(TaggedArray::DATA_OFFSET));
23074514f5e3Sopenharmony_ci    SetValueWithAttr(glue, array, dataOffset, key, val, attr);
23084514f5e3Sopenharmony_ci}
23094514f5e3Sopenharmony_ci
23104514f5e3Sopenharmony_ciinline void StubBuilder::SetValueToTaggedArrayWithRep(
23114514f5e3Sopenharmony_ci    GateRef glue, GateRef array, GateRef index, GateRef val, GateRef rep, Label *repChange)
23124514f5e3Sopenharmony_ci{
23134514f5e3Sopenharmony_ci    GateRef offset = PtrMul(ZExtInt32ToPtr(index), IntPtr(JSTaggedValue::TaggedTypeSize()));
23144514f5e3Sopenharmony_ci    GateRef dataOffset = PtrAdd(offset, IntPtr(TaggedArray::DATA_OFFSET));
23154514f5e3Sopenharmony_ci    SetValueWithRep(glue, array, dataOffset, val, rep, repChange);
23164514f5e3Sopenharmony_ci}
23174514f5e3Sopenharmony_ci
23184514f5e3Sopenharmony_ciinline void StubBuilder::SetValueToTaggedArray(VariableType valType, GateRef glue, GateRef array,
23194514f5e3Sopenharmony_ci                                               GateRef index, GateRef val, MemoryAttribute mAttr)
23204514f5e3Sopenharmony_ci{
23214514f5e3Sopenharmony_ci    // NOTE: need to translate MarkingBarrier
23224514f5e3Sopenharmony_ci    GateRef offset = PtrMul(ZExtInt32ToPtr(index), IntPtr(JSTaggedValue::TaggedTypeSize()));
23234514f5e3Sopenharmony_ci    GateRef dataOffset = PtrAdd(offset, IntPtr(TaggedArray::DATA_OFFSET));
23244514f5e3Sopenharmony_ci    Store(valType, glue, array, dataOffset, val, mAttr);
23254514f5e3Sopenharmony_ci}
23264514f5e3Sopenharmony_ci
23274514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetValueFromTaggedArray(GateRef array, GateRef index)
23284514f5e3Sopenharmony_ci{
23294514f5e3Sopenharmony_ci    GateRef offset = PtrMul(ZExtInt32ToPtr(index), IntPtr(JSTaggedValue::TaggedTypeSize()));
23304514f5e3Sopenharmony_ci    GateRef dataOffset = PtrAdd(offset, IntPtr(TaggedArray::DATA_OFFSET));
23314514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), array, dataOffset);
23324514f5e3Sopenharmony_ci}
23334514f5e3Sopenharmony_ci
23344514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetDataPtrInTaggedArray(GateRef array)
23354514f5e3Sopenharmony_ci{
23364514f5e3Sopenharmony_ci    return PtrAdd(array, IntPtr(TaggedArray::DATA_OFFSET));
23374514f5e3Sopenharmony_ci}
23384514f5e3Sopenharmony_ci
23394514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetUnsharedConstpoolIndex(GateRef constpool)
23404514f5e3Sopenharmony_ci{
23414514f5e3Sopenharmony_ci    GateRef constPoolSize = GetLengthOfTaggedArray(constpool);
23424514f5e3Sopenharmony_ci    GateRef unshareIdx = Int32Sub(constPoolSize, Int32(ConstantPool::UNSHARED_CONSTPOOL_INDEX));
23434514f5e3Sopenharmony_ci    return GetValueFromTaggedArray(constpool, unshareIdx);
23444514f5e3Sopenharmony_ci}
23454514f5e3Sopenharmony_ci
23464514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetUnsharedConstpoolFromGlue(GateRef glue, GateRef constpool)
23474514f5e3Sopenharmony_ci{
23484514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetUnsharedConstpoolFromGlue(glue, constpool);
23494514f5e3Sopenharmony_ci}
23504514f5e3Sopenharmony_ci
23514514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetUnsharedConstpool(GateRef arrayAddr, GateRef index)
23524514f5e3Sopenharmony_ci{
23534514f5e3Sopenharmony_ci    GateRef dataOffset =
23544514f5e3Sopenharmony_ci        PtrAdd(arrayAddr, PtrMul(IntPtr(JSTaggedValue::TaggedTypeSize()), ZExtInt32ToPtr(TaggedGetInt(index))));
23554514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), dataOffset);
23564514f5e3Sopenharmony_ci}
23574514f5e3Sopenharmony_ci
23584514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetValueFromMutantTaggedArray(GateRef elements, GateRef index)
23594514f5e3Sopenharmony_ci{
23604514f5e3Sopenharmony_ci    GateRef offset = PtrMul(ZExtInt32ToPtr(index), IntPtr(sizeof(int64_t)));
23614514f5e3Sopenharmony_ci    GateRef dataOffset = PtrAdd(offset, IntPtr(TaggedArray::DATA_OFFSET));
23624514f5e3Sopenharmony_ci    return Load(VariableType::INT64(), elements, dataOffset);
23634514f5e3Sopenharmony_ci}
23644514f5e3Sopenharmony_ci
23654514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSpecialIndexedObj(GateRef jsType)
23664514f5e3Sopenharmony_ci{
23674514f5e3Sopenharmony_ci    return Int32GreaterThan(jsType, Int32(static_cast<int32_t>(JSType::JS_ARRAY)));
23684514f5e3Sopenharmony_ci}
23694514f5e3Sopenharmony_ci
23704514f5e3Sopenharmony_ciinline void StubBuilder::CheckUpdateSharedType(bool isDicMode, Variable *result, GateRef glue, GateRef receiver,
23714514f5e3Sopenharmony_ci    GateRef attr, GateRef value, Label *executeSetProp, Label *exit)
23724514f5e3Sopenharmony_ci{
23734514f5e3Sopenharmony_ci    auto *env = GetEnvironment();
23744514f5e3Sopenharmony_ci    Label isJSShared(env);
23754514f5e3Sopenharmony_ci    BRANCH(IsJSShared(receiver), &isJSShared, executeSetProp);
23764514f5e3Sopenharmony_ci    Bind(&isJSShared);
23774514f5e3Sopenharmony_ci    {
23784514f5e3Sopenharmony_ci        Label typeMismatch(env);
23794514f5e3Sopenharmony_ci        GateRef fieldType = isDicMode ? GetDictSharedFieldTypeInPropAttr(attr) : GetSharedFieldTypeInPropAttr(attr);
23804514f5e3Sopenharmony_ci        MatchFieldType(glue, fieldType, value, executeSetProp, &typeMismatch);
23814514f5e3Sopenharmony_ci        Bind(&typeMismatch);
23824514f5e3Sopenharmony_ci        {
23834514f5e3Sopenharmony_ci            GateRef taggedId = Int32(GET_MESSAGE_STRING_ID(SetTypeMismatchedSharedProperty));
23844514f5e3Sopenharmony_ci            CallRuntime(glue, RTSTUB_ID(ThrowTypeError), {IntToTaggedInt(taggedId)});
23854514f5e3Sopenharmony_ci            *result = Exception();
23864514f5e3Sopenharmony_ci            Jump(exit);
23874514f5e3Sopenharmony_ci        }
23884514f5e3Sopenharmony_ci    }
23894514f5e3Sopenharmony_ci}
23904514f5e3Sopenharmony_ci
23914514f5e3Sopenharmony_ciinline void StubBuilder::CheckUpdateSharedType(bool isDicMode, Variable *result, GateRef glue, GateRef receiver,
23924514f5e3Sopenharmony_ci    GateRef attr, GateRef value, Label *executeSetProp, Label *exit, GateRef SCheckModelIsCHECK)
23934514f5e3Sopenharmony_ci{
23944514f5e3Sopenharmony_ci    auto *env = GetEnvironment();
23954514f5e3Sopenharmony_ci    Label isJSShared(env);
23964514f5e3Sopenharmony_ci    BRANCH(LogicAndBuilder(env).And(SCheckModelIsCHECK).And(IsJSShared(receiver)).Done(),
23974514f5e3Sopenharmony_ci        &isJSShared, executeSetProp);
23984514f5e3Sopenharmony_ci    Bind(&isJSShared);
23994514f5e3Sopenharmony_ci    {
24004514f5e3Sopenharmony_ci        Label typeMismatch(env);
24014514f5e3Sopenharmony_ci        GateRef fieldType = isDicMode ? GetDictSharedFieldTypeInPropAttr(attr) : GetSharedFieldTypeInPropAttr(attr);
24024514f5e3Sopenharmony_ci        MatchFieldType(glue, fieldType, value, executeSetProp, &typeMismatch);
24034514f5e3Sopenharmony_ci        Bind(&typeMismatch);
24044514f5e3Sopenharmony_ci        {
24054514f5e3Sopenharmony_ci            GateRef taggedId = Int32(GET_MESSAGE_STRING_ID(SetTypeMismatchedSharedProperty));
24064514f5e3Sopenharmony_ci            CallRuntime(glue, RTSTUB_ID(ThrowTypeError), {IntToTaggedInt(taggedId)});
24074514f5e3Sopenharmony_ci            *result = Exception();
24084514f5e3Sopenharmony_ci            Jump(exit);
24094514f5e3Sopenharmony_ci        }
24104514f5e3Sopenharmony_ci    }
24114514f5e3Sopenharmony_ci}
24124514f5e3Sopenharmony_ci
24134514f5e3Sopenharmony_ciinline void StubBuilder::MatchFieldType(Variable *result, GateRef glue, GateRef fieldType, GateRef value,
24144514f5e3Sopenharmony_ci                                        Label *executeSetProp, Label *exit)
24154514f5e3Sopenharmony_ci{
24164514f5e3Sopenharmony_ci    auto *env = GetEnvironment();
24174514f5e3Sopenharmony_ci    Label typeMismatch(env);
24184514f5e3Sopenharmony_ci    MatchFieldType(glue, fieldType, value, executeSetProp, &typeMismatch);
24194514f5e3Sopenharmony_ci    Bind(&typeMismatch);
24204514f5e3Sopenharmony_ci    {
24214514f5e3Sopenharmony_ci        GateRef taggedId = Int32(GET_MESSAGE_STRING_ID(SetTypeMismatchedSharedProperty));
24224514f5e3Sopenharmony_ci        CallRuntime(glue, RTSTUB_ID(ThrowTypeError), {IntToTaggedInt(taggedId)});
24234514f5e3Sopenharmony_ci        *result = Exception();
24244514f5e3Sopenharmony_ci        Jump(exit);
24254514f5e3Sopenharmony_ci    }
24264514f5e3Sopenharmony_ci}
24274514f5e3Sopenharmony_ci
24284514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetFieldTypeFromHandler(GateRef attr)
24294514f5e3Sopenharmony_ci{
24304514f5e3Sopenharmony_ci    return Int32And(
24314514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(HandlerBase::SFieldTypeBit::START_BIT))),
24324514f5e3Sopenharmony_ci        Int32((1LLU << HandlerBase::SFieldTypeBit::SIZE) - 1));
24334514f5e3Sopenharmony_ci}
24344514f5e3Sopenharmony_ci
24354514f5e3Sopenharmony_ciinline GateRef StubBuilder::ClearSharedStoreKind(GateRef handlerInfo)
24364514f5e3Sopenharmony_ci{
24374514f5e3Sopenharmony_ci    return Int64And(handlerInfo, Int64Not(Int64(HandlerBase::SSharedBit::Mask())));
24384514f5e3Sopenharmony_ci}
24394514f5e3Sopenharmony_ci
24404514f5e3Sopenharmony_ciinline GateRef StubBuilder::UpdateSOutOfBoundsForHandler(GateRef handlerInfo)
24414514f5e3Sopenharmony_ci{
24424514f5e3Sopenharmony_ci    return Int64Or(handlerInfo, Int64(HandlerBase::SOutOfBoundsBit::Mask()));
24434514f5e3Sopenharmony_ci}
24444514f5e3Sopenharmony_ci
24454514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSpecialContainer(GateRef jsType)
24464514f5e3Sopenharmony_ci{
24474514f5e3Sopenharmony_ci    // arraylist and vector has fast pass now
24484514f5e3Sopenharmony_ci    return BitOr(
24494514f5e3Sopenharmony_ci        Int32Equal(jsType, Int32(static_cast<int32_t>(JSType::JS_API_ARRAY_LIST))),
24504514f5e3Sopenharmony_ci        Int32Equal(jsType, Int32(static_cast<int32_t>(JSType::JS_API_VECTOR))));
24514514f5e3Sopenharmony_ci}
24524514f5e3Sopenharmony_ci
24534514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSharedArray(GateRef jsType)
24544514f5e3Sopenharmony_ci{
24554514f5e3Sopenharmony_ci    return Int32Equal(jsType, Int32(static_cast<int32_t>(JSType::JS_SHARED_ARRAY)));
24564514f5e3Sopenharmony_ci}
24574514f5e3Sopenharmony_ci
24584514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsFastTypeArray(GateRef jsType)
24594514f5e3Sopenharmony_ci{
24604514f5e3Sopenharmony_ci    return BitAnd(
24614514f5e3Sopenharmony_ci        Int32GreaterThan(jsType, Int32(static_cast<int32_t>(JSType::JS_TYPED_ARRAY_FIRST))),
24624514f5e3Sopenharmony_ci        Int32LessThanOrEqual(jsType, Int32(static_cast<int32_t>(JSType::JS_FLOAT64_ARRAY))));
24634514f5e3Sopenharmony_ci}
24644514f5e3Sopenharmony_ci
24654514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsAccessorInternal(GateRef value)
24664514f5e3Sopenharmony_ci{
24674514f5e3Sopenharmony_ci    return Int32Equal(GetObjectType(LoadHClass(value)),
24684514f5e3Sopenharmony_ci                      Int32(static_cast<int32_t>(JSType::INTERNAL_ACCESSOR)));
24694514f5e3Sopenharmony_ci}
24704514f5e3Sopenharmony_ci
24714514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropAttrFromLayoutInfo(GateRef layout, GateRef entry)
24724514f5e3Sopenharmony_ci{
24734514f5e3Sopenharmony_ci    GateRef index = Int32Add(Int32LSL(entry, Int32(LayoutInfo::ELEMENTS_INDEX_LOG2)),
24744514f5e3Sopenharmony_ci        Int32(LayoutInfo::ATTR_INDEX_OFFSET));
24754514f5e3Sopenharmony_ci    return GetInt64OfTInt(GetValueFromTaggedArray(layout, index));
24764514f5e3Sopenharmony_ci}
24774514f5e3Sopenharmony_ci
24784514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetIhcFromAOTLiteralInfo(GateRef info)
24794514f5e3Sopenharmony_ci{
24804514f5e3Sopenharmony_ci    auto len = GetLengthOfTaggedArray(info);
24814514f5e3Sopenharmony_ci    GateRef aotIhcIndex = Int32Sub(len, Int32(AOTLiteralInfo::AOT_IHC_INDEX));
24824514f5e3Sopenharmony_ci    GateRef ihcOffset = Int32Mul(aotIhcIndex, Int32(JSTaggedValue::TaggedTypeSize()));
24834514f5e3Sopenharmony_ci    GateRef dataOffset = PtrAdd(ihcOffset, IntPtr(TaggedArray::DATA_OFFSET));
24844514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), info, dataOffset);
24854514f5e3Sopenharmony_ci}
24864514f5e3Sopenharmony_ci
24874514f5e3Sopenharmony_ciinline void StubBuilder::UpdateFieldType(GateRef glue, GateRef hclass, GateRef attr)
24884514f5e3Sopenharmony_ci{
24894514f5e3Sopenharmony_ci    CallNGCRuntime(glue, RTSTUB_ID(UpdateFieldType), { hclass, attr });
24904514f5e3Sopenharmony_ci}
24914514f5e3Sopenharmony_ci
24924514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertyMetaDataFromAttr(GateRef attr)
24934514f5e3Sopenharmony_ci{
24944514f5e3Sopenharmony_ci    return Int32And(
24954514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::PropertyMetaDataField::START_BIT))),
24964514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::PropertyMetaDataField::SIZE) - 1));
24974514f5e3Sopenharmony_ci}
24984514f5e3Sopenharmony_ci
24994514f5e3Sopenharmony_ciinline GateRef StubBuilder::TranslateToRep(GateRef value)
25004514f5e3Sopenharmony_ci{
25014514f5e3Sopenharmony_ci    auto env = GetEnvironment();
25024514f5e3Sopenharmony_ci    Label entryPass(env);
25034514f5e3Sopenharmony_ci    env->SubCfgEntry(&entryPass);
25044514f5e3Sopenharmony_ci    Label intLabel(env);
25054514f5e3Sopenharmony_ci    Label nonIntLabel(env);
25064514f5e3Sopenharmony_ci    Label doubleLabel(env);
25074514f5e3Sopenharmony_ci    Label exit(env);
25084514f5e3Sopenharmony_ci    DEFVARIABLE(result, VariableType::INT32(), Int32(static_cast<int32_t>(Representation::TAGGED)));
25094514f5e3Sopenharmony_ci    Branch(TaggedIsInt(value), &intLabel, &nonIntLabel);
25104514f5e3Sopenharmony_ci    Bind(&intLabel);
25114514f5e3Sopenharmony_ci    {
25124514f5e3Sopenharmony_ci        result = Int32(static_cast<int32_t>(Representation::INT));
25134514f5e3Sopenharmony_ci        Jump(&exit);
25144514f5e3Sopenharmony_ci    }
25154514f5e3Sopenharmony_ci    Bind(&nonIntLabel);
25164514f5e3Sopenharmony_ci    {
25174514f5e3Sopenharmony_ci        Branch(TaggedIsDouble(value), &doubleLabel, &exit);
25184514f5e3Sopenharmony_ci    }
25194514f5e3Sopenharmony_ci    Bind(&doubleLabel);
25204514f5e3Sopenharmony_ci    {
25214514f5e3Sopenharmony_ci        result = Int32(static_cast<int32_t>(Representation::DOUBLE));
25224514f5e3Sopenharmony_ci        Jump(&exit);
25234514f5e3Sopenharmony_ci    }
25244514f5e3Sopenharmony_ci    Bind(&exit);
25254514f5e3Sopenharmony_ci    auto ret = *result;
25264514f5e3Sopenharmony_ci    env->SubCfgExit();
25274514f5e3Sopenharmony_ci    return ret;
25284514f5e3Sopenharmony_ci}
25294514f5e3Sopenharmony_ci
25304514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetKeyFromLayoutInfo(GateRef layout, GateRef entry)
25314514f5e3Sopenharmony_ci{
25324514f5e3Sopenharmony_ci    GateRef index = Int32LSL(entry, Int32(LayoutInfo::ELEMENTS_INDEX_LOG2));
25334514f5e3Sopenharmony_ci    return GetValueFromTaggedArray(layout, index);
25344514f5e3Sopenharmony_ci}
25354514f5e3Sopenharmony_ci
25364514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertiesAddrFromLayoutInfo(GateRef layout)
25374514f5e3Sopenharmony_ci{
25384514f5e3Sopenharmony_ci    return PtrAdd(layout, IntPtr(TaggedArray::DATA_OFFSET));
25394514f5e3Sopenharmony_ci}
25404514f5e3Sopenharmony_ci
25414514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetInt64OfTInt(GateRef x)
25424514f5e3Sopenharmony_ci{
25434514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetInt64OfTInt(x);
25444514f5e3Sopenharmony_ci}
25454514f5e3Sopenharmony_ci
25464514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetInt32OfTInt(GateRef x)
25474514f5e3Sopenharmony_ci{
25484514f5e3Sopenharmony_ci    return TruncInt64ToInt32(GetInt64OfTInt(x));
25494514f5e3Sopenharmony_ci}
25504514f5e3Sopenharmony_ci
25514514f5e3Sopenharmony_ciinline GateRef StubBuilder::TaggedCastToIntPtr(GateRef x)
25524514f5e3Sopenharmony_ci{
25534514f5e3Sopenharmony_ci    return env_->Is32Bit() ? TruncInt64ToInt32(GetInt64OfTInt(x)) : GetInt64OfTInt(x);
25544514f5e3Sopenharmony_ci}
25554514f5e3Sopenharmony_ci
25564514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetDoubleOfTInt(GateRef x)
25574514f5e3Sopenharmony_ci{
25584514f5e3Sopenharmony_ci    return ChangeInt32ToFloat64(GetInt32OfTInt(x));
25594514f5e3Sopenharmony_ci}
25604514f5e3Sopenharmony_ci
25614514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetDoubleOfTDouble(GateRef x)
25624514f5e3Sopenharmony_ci{
25634514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetDoubleOfTDouble(x);
25644514f5e3Sopenharmony_ci}
25654514f5e3Sopenharmony_ci
25664514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetInt32OfTNumber(GateRef x)
25674514f5e3Sopenharmony_ci{
25684514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetInt32OfTNumber(x);
25694514f5e3Sopenharmony_ci}
25704514f5e3Sopenharmony_ci
25714514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetDoubleOfTNumber(GateRef x)
25724514f5e3Sopenharmony_ci{
25734514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetDoubleOfTNumber(x);
25744514f5e3Sopenharmony_ci}
25754514f5e3Sopenharmony_ci
25764514f5e3Sopenharmony_ciinline GateRef StubBuilder::LoadObjectFromWeakRef(GateRef x)
25774514f5e3Sopenharmony_ci{
25784514f5e3Sopenharmony_ci    return env_->GetBuilder()->LoadObjectFromWeakRef(x);
25794514f5e3Sopenharmony_ci}
25804514f5e3Sopenharmony_ci
25814514f5e3Sopenharmony_ciinline GateRef StubBuilder::ExtFloat32ToDouble(GateRef x)
25824514f5e3Sopenharmony_ci{
25834514f5e3Sopenharmony_ci    return env_->GetBuilder()->ExtFloat32ToDouble(x);
25844514f5e3Sopenharmony_ci}
25854514f5e3Sopenharmony_ci
25864514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeInt32ToFloat32(GateRef x)
25874514f5e3Sopenharmony_ci{
25884514f5e3Sopenharmony_ci    return env_->GetBuilder()->ChangeInt32ToFloat32(x);
25894514f5e3Sopenharmony_ci}
25904514f5e3Sopenharmony_ci
25914514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeInt32ToFloat64(GateRef x)
25924514f5e3Sopenharmony_ci{
25934514f5e3Sopenharmony_ci    return env_->GetBuilder()->ChangeInt32ToFloat64(x);
25944514f5e3Sopenharmony_ci}
25954514f5e3Sopenharmony_ci
25964514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeUInt32ToFloat64(GateRef x)
25974514f5e3Sopenharmony_ci{
25984514f5e3Sopenharmony_ci    return env_->GetBuilder()->ChangeUInt32ToFloat64(x);
25994514f5e3Sopenharmony_ci}
26004514f5e3Sopenharmony_ci
26014514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeFloat64ToInt32(GateRef x)
26024514f5e3Sopenharmony_ci{
26034514f5e3Sopenharmony_ci    return env_->GetBuilder()->ChangeFloat64ToInt32(x);
26044514f5e3Sopenharmony_ci}
26054514f5e3Sopenharmony_ci
26064514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncDoubleToFloat32(GateRef x)
26074514f5e3Sopenharmony_ci{
26084514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncDoubleToFloat32(x);
26094514f5e3Sopenharmony_ci}
26104514f5e3Sopenharmony_ci
26114514f5e3Sopenharmony_ciinline GateRef StubBuilder::ChangeTaggedPointerToInt64(GateRef x)
26124514f5e3Sopenharmony_ci{
26134514f5e3Sopenharmony_ci    return env_->GetBuilder()->ChangeTaggedPointerToInt64(x);
26144514f5e3Sopenharmony_ci}
26154514f5e3Sopenharmony_ci
26164514f5e3Sopenharmony_ciinline GateRef StubBuilder::Int64ToTaggedPtr(GateRef x)
26174514f5e3Sopenharmony_ci{
26184514f5e3Sopenharmony_ci    return env_->GetBuilder()->Int64ToTaggedPtr(x);
26194514f5e3Sopenharmony_ci}
26204514f5e3Sopenharmony_ci
26214514f5e3Sopenharmony_ciinline GateRef StubBuilder::CastInt32ToFloat32(GateRef x)
26224514f5e3Sopenharmony_ci{
26234514f5e3Sopenharmony_ci    return env_->GetBuilder()->CastInt32ToFloat32(x);
26244514f5e3Sopenharmony_ci}
26254514f5e3Sopenharmony_ci
26264514f5e3Sopenharmony_ciinline GateRef StubBuilder::CastInt64ToFloat64(GateRef x)
26274514f5e3Sopenharmony_ci{
26284514f5e3Sopenharmony_ci    return env_->GetBuilder()->CastInt64ToFloat64(x);
26294514f5e3Sopenharmony_ci}
26304514f5e3Sopenharmony_ci
26314514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt32ToInt64(GateRef x)
26324514f5e3Sopenharmony_ci{
26334514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt32ToInt64(x);
26344514f5e3Sopenharmony_ci}
26354514f5e3Sopenharmony_ci
26364514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt16ToInt64(GateRef x)
26374514f5e3Sopenharmony_ci{
26384514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt16ToInt64(x);
26394514f5e3Sopenharmony_ci}
26404514f5e3Sopenharmony_ci
26414514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt8ToInt64(GateRef x)
26424514f5e3Sopenharmony_ci{
26434514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt8ToInt64(x);
26444514f5e3Sopenharmony_ci}
26454514f5e3Sopenharmony_ci
26464514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt8ToInt32(GateRef x)
26474514f5e3Sopenharmony_ci{
26484514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt8ToInt32(x);
26494514f5e3Sopenharmony_ci}
26504514f5e3Sopenharmony_ci
26514514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt16ToInt32(GateRef x)
26524514f5e3Sopenharmony_ci{
26534514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt16ToInt32(x);
26544514f5e3Sopenharmony_ci}
26554514f5e3Sopenharmony_ci
26564514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt1ToInt64(GateRef x)
26574514f5e3Sopenharmony_ci{
26584514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt1ToInt64(x);
26594514f5e3Sopenharmony_ci}
26604514f5e3Sopenharmony_ci
26614514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt1ToInt32(GateRef x)
26624514f5e3Sopenharmony_ci{
26634514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt1ToInt32(x);
26644514f5e3Sopenharmony_ci}
26654514f5e3Sopenharmony_ci
26664514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt8ToInt16(GateRef x)
26674514f5e3Sopenharmony_ci{
26684514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt8ToInt16(x);
26694514f5e3Sopenharmony_ci}
26704514f5e3Sopenharmony_ci
26714514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt32ToInt64(GateRef x)
26724514f5e3Sopenharmony_ci{
26734514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt32ToInt64(x);
26744514f5e3Sopenharmony_ci}
26754514f5e3Sopenharmony_ci
26764514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt1ToInt64(GateRef x)
26774514f5e3Sopenharmony_ci{
26784514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt1ToInt64(x);
26794514f5e3Sopenharmony_ci}
26804514f5e3Sopenharmony_ci
26814514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt1ToInt32(GateRef x)
26824514f5e3Sopenharmony_ci{
26834514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt1ToInt32(x);
26844514f5e3Sopenharmony_ci}
26854514f5e3Sopenharmony_ci
26864514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt8ToInt32(GateRef x)
26874514f5e3Sopenharmony_ci{
26884514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt8ToInt32(x);
26894514f5e3Sopenharmony_ci}
26904514f5e3Sopenharmony_ci
26914514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt8ToInt64(GateRef x)
26924514f5e3Sopenharmony_ci{
26934514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt8ToInt64(x);
26944514f5e3Sopenharmony_ci}
26954514f5e3Sopenharmony_ci
26964514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt8ToPtr(GateRef x)
26974514f5e3Sopenharmony_ci{
26984514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt8ToPtr(x);
26994514f5e3Sopenharmony_ci}
27004514f5e3Sopenharmony_ci
27014514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt16ToPtr(GateRef x)
27024514f5e3Sopenharmony_ci{
27034514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt16ToPtr(x);
27044514f5e3Sopenharmony_ci}
27054514f5e3Sopenharmony_ci
27064514f5e3Sopenharmony_ciinline GateRef StubBuilder::SExtInt32ToPtr(GateRef x)
27074514f5e3Sopenharmony_ci{
27084514f5e3Sopenharmony_ci    return env_->GetBuilder()->SExtInt32ToPtr(x);
27094514f5e3Sopenharmony_ci}
27104514f5e3Sopenharmony_ci
27114514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt16ToInt32(GateRef x)
27124514f5e3Sopenharmony_ci{
27134514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt16ToInt32(x);
27144514f5e3Sopenharmony_ci}
27154514f5e3Sopenharmony_ci
27164514f5e3Sopenharmony_ciinline GateRef StubBuilder::ZExtInt16ToInt64(GateRef x)
27174514f5e3Sopenharmony_ci{
27184514f5e3Sopenharmony_ci    return env_->GetBuilder()->ZExtInt16ToInt64(x);
27194514f5e3Sopenharmony_ci}
27204514f5e3Sopenharmony_ci
27214514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncInt64ToInt32(GateRef x)
27224514f5e3Sopenharmony_ci{
27234514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncInt64ToInt32(x);
27244514f5e3Sopenharmony_ci}
27254514f5e3Sopenharmony_ci
27264514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncPtrToInt32(GateRef x)
27274514f5e3Sopenharmony_ci{
27284514f5e3Sopenharmony_ci    if (env_->Is32Bit()) {
27294514f5e3Sopenharmony_ci        return x;
27304514f5e3Sopenharmony_ci    }
27314514f5e3Sopenharmony_ci    return TruncInt64ToInt32(x);
27324514f5e3Sopenharmony_ci}
27334514f5e3Sopenharmony_ci
27344514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncInt64ToInt1(GateRef x)
27354514f5e3Sopenharmony_ci{
27364514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncInt64ToInt1(x);
27374514f5e3Sopenharmony_ci}
27384514f5e3Sopenharmony_ci
27394514f5e3Sopenharmony_ciinline GateRef StubBuilder::TruncInt32ToInt1(GateRef x)
27404514f5e3Sopenharmony_ci{
27414514f5e3Sopenharmony_ci    return env_->GetBuilder()->TruncInt32ToInt1(x);
27424514f5e3Sopenharmony_ci}
27434514f5e3Sopenharmony_ci
27444514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetObjectFromConstPool(GateRef constpool, GateRef index)
27454514f5e3Sopenharmony_ci{
27464514f5e3Sopenharmony_ci    return GetValueFromTaggedArray(constpool, index);
27474514f5e3Sopenharmony_ci}
27484514f5e3Sopenharmony_ci
27494514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetGlobalConstantAddr(GateRef index)
27504514f5e3Sopenharmony_ci{
27514514f5e3Sopenharmony_ci    return Int64Mul(Int64(sizeof(JSTaggedValue)), index);
27524514f5e3Sopenharmony_ci}
27534514f5e3Sopenharmony_ci
27544514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetGlobalConstantOffset(ConstantIndex index)
27554514f5e3Sopenharmony_ci{
27564514f5e3Sopenharmony_ci    if (env_->Is32Bit()) {
27574514f5e3Sopenharmony_ci        return Int32Mul(Int32(sizeof(JSTaggedValue)), Int32(static_cast<int>(index)));
27584514f5e3Sopenharmony_ci    } else {
27594514f5e3Sopenharmony_ci        return Int64Mul(Int64(sizeof(JSTaggedValue)), Int64(static_cast<int>(index)));
27604514f5e3Sopenharmony_ci    }
27614514f5e3Sopenharmony_ci}
27624514f5e3Sopenharmony_ci
27634514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsCallableFromBitField(GateRef bitfield)
27644514f5e3Sopenharmony_ci{
27654514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsCallableFromBitField(bitfield);
27664514f5e3Sopenharmony_ci}
27674514f5e3Sopenharmony_ci
27684514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsCallable(GateRef obj)
27694514f5e3Sopenharmony_ci{
27704514f5e3Sopenharmony_ci    ASM_ASSERT(GET_MESSAGE_STRING_ID(IsCallable), TaggedIsHeapObject(obj));
27714514f5e3Sopenharmony_ci    GateRef res = env_->GetBuilder()->IsCallable(obj);
27724514f5e3Sopenharmony_ci    return res;
27734514f5e3Sopenharmony_ci}
27744514f5e3Sopenharmony_ci
27754514f5e3Sopenharmony_ci// GetOffset func in property_attribute.h
27764514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetOffsetFieldInPropAttr(GateRef attr)
27774514f5e3Sopenharmony_ci{
27784514f5e3Sopenharmony_ci    return Int32And(
27794514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::OffsetField::START_BIT))),
27804514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::OffsetField::SIZE) - 1));
27814514f5e3Sopenharmony_ci}
27824514f5e3Sopenharmony_ci
27834514f5e3Sopenharmony_ci// SetOffset func in property_attribute.h
27844514f5e3Sopenharmony_ciinline GateRef StubBuilder::SetOffsetFieldInPropAttr(GateRef attr, GateRef value)
27854514f5e3Sopenharmony_ci{
27864514f5e3Sopenharmony_ci    GateRef mask = Int64LSL(
27874514f5e3Sopenharmony_ci        Int64((1LLU << PropertyAttributes::OffsetField::SIZE) - 1),
27884514f5e3Sopenharmony_ci        Int64(PropertyAttributes::OffsetField::START_BIT));
27894514f5e3Sopenharmony_ci    GateRef newVal = Int64Or(Int64And(attr, Int64Not(mask)),
27904514f5e3Sopenharmony_ci        Int64LSL(ZExtInt32ToInt64(value), Int64(PropertyAttributes::OffsetField::START_BIT)));
27914514f5e3Sopenharmony_ci    return newVal;
27924514f5e3Sopenharmony_ci}
27934514f5e3Sopenharmony_ci
27944514f5e3Sopenharmony_ci// SetIsInlinedProps func in property_attribute.h
27954514f5e3Sopenharmony_ciinline GateRef StubBuilder::SetIsInlinePropsFieldInPropAttr(GateRef attr, GateRef value)
27964514f5e3Sopenharmony_ci{
27974514f5e3Sopenharmony_ci    GateRef mask = Int64LSL(
27984514f5e3Sopenharmony_ci        Int64((1LU << PropertyAttributes::IsInlinedPropsField::SIZE) - 1),
27994514f5e3Sopenharmony_ci        Int64(PropertyAttributes::IsInlinedPropsField::START_BIT));
28004514f5e3Sopenharmony_ci    GateRef newVal = Int64Or(Int64And(attr, Int64Not(mask)),
28014514f5e3Sopenharmony_ci        Int64LSL(ZExtInt32ToInt64(value), Int64(PropertyAttributes::IsInlinedPropsField::START_BIT)));
28024514f5e3Sopenharmony_ci    return newVal;
28034514f5e3Sopenharmony_ci}
28044514f5e3Sopenharmony_ci
28054514f5e3Sopenharmony_ci
28064514f5e3Sopenharmony_ciinline GateRef StubBuilder::SetTrackTypeInPropAttr(GateRef attr, GateRef type)
28074514f5e3Sopenharmony_ci{
28084514f5e3Sopenharmony_ci    GateRef mask = Int64LSL(
28094514f5e3Sopenharmony_ci        Int64((1LU << PropertyAttributes::TrackTypeField::SIZE) - 1),
28104514f5e3Sopenharmony_ci        Int64(PropertyAttributes::TrackTypeField::START_BIT));
28114514f5e3Sopenharmony_ci    GateRef newVal = Int64Or(Int64And(attr, Int64Not(mask)),
28124514f5e3Sopenharmony_ci        Int64LSL(ZExtInt32ToInt64(type), Int64(PropertyAttributes::TrackTypeField::START_BIT)));
28134514f5e3Sopenharmony_ci    return newVal;
28144514f5e3Sopenharmony_ci}
28154514f5e3Sopenharmony_ci
28164514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSharedFieldTypeInPropAttr(GateRef attr)
28174514f5e3Sopenharmony_ci{
28184514f5e3Sopenharmony_ci    return Int32And(
28194514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::SharedFieldTypeField::START_BIT))),
28204514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::SharedFieldTypeField::SIZE) - 1));
28214514f5e3Sopenharmony_ci}
28224514f5e3Sopenharmony_ci
28234514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTrackTypeInPropAttr(GateRef attr)
28244514f5e3Sopenharmony_ci{
28254514f5e3Sopenharmony_ci    return Int32And(
28264514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::TrackTypeField::START_BIT))),
28274514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::TrackTypeField::SIZE) - 1));
28284514f5e3Sopenharmony_ci}
28294514f5e3Sopenharmony_ci
28304514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetDictSharedFieldTypeInPropAttr(GateRef attr)
28314514f5e3Sopenharmony_ci{
28324514f5e3Sopenharmony_ci    return Int32And(
28334514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::DictSharedFieldTypeField::START_BIT))),
28344514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::DictSharedFieldTypeField::SIZE) - 1));
28354514f5e3Sopenharmony_ci}
28364514f5e3Sopenharmony_ci
28374514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetRepInPropAttr(GateRef attr)
28384514f5e3Sopenharmony_ci{
28394514f5e3Sopenharmony_ci    return Int32And(
28404514f5e3Sopenharmony_ci        TruncInt64ToInt32(Int64LSR(attr, Int64(PropertyAttributes::RepresentationField::START_BIT))),
28414514f5e3Sopenharmony_ci        Int32((1LLU << PropertyAttributes::RepresentationField::SIZE) - 1));
28424514f5e3Sopenharmony_ci}
28434514f5e3Sopenharmony_ci
28444514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsIntRepInPropAttr(GateRef rep)
28454514f5e3Sopenharmony_ci{
28464514f5e3Sopenharmony_ci    return Int32Equal(rep, Int32(static_cast<int32_t>(Representation::INT)));
28474514f5e3Sopenharmony_ci}
28484514f5e3Sopenharmony_ci
28494514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsDoubleRepInPropAttr(GateRef rep)
28504514f5e3Sopenharmony_ci{
28514514f5e3Sopenharmony_ci    return Int32Equal(rep, Int32(static_cast<int32_t>(Representation::DOUBLE)));
28524514f5e3Sopenharmony_ci}
28534514f5e3Sopenharmony_ci
28544514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsTaggedRepInPropAttr(GateRef attr)
28554514f5e3Sopenharmony_ci{
28564514f5e3Sopenharmony_ci    GateRef rep = GetRepInPropAttr(attr);
28574514f5e3Sopenharmony_ci    return BitAnd(BoolNot(IsDoubleRepInPropAttr(rep)), BoolNot(IsIntRepInPropAttr(rep)));
28584514f5e3Sopenharmony_ci}
28594514f5e3Sopenharmony_ci
28604514f5e3Sopenharmony_ciinline GateRef StubBuilder::SetTaggedRepInPropAttr(GateRef attr)
28614514f5e3Sopenharmony_ci{
28624514f5e3Sopenharmony_ci    GateRef mask = Int64LSL(
28634514f5e3Sopenharmony_ci        Int64((1LU << PropertyAttributes::RepresentationField::SIZE) - 1),
28644514f5e3Sopenharmony_ci        Int64(PropertyAttributes::RepresentationField::START_BIT));
28654514f5e3Sopenharmony_ci    GateRef targetType = Int32(static_cast<uint32_t>(Representation::TAGGED));
28664514f5e3Sopenharmony_ci    GateRef newVal = Int64Or(Int64And(attr, Int64Not(mask)),
28674514f5e3Sopenharmony_ci        Int64LSL(ZExtInt32ToInt64(targetType), Int64(PropertyAttributes::RepresentationField::START_BIT)));
28684514f5e3Sopenharmony_ci    return newVal;
28694514f5e3Sopenharmony_ci}
28704514f5e3Sopenharmony_ci
28714514f5e3Sopenharmony_citemplate<class T>
28724514f5e3Sopenharmony_civoid StubBuilder::SetHClassBit(GateRef glue, GateRef hClass, GateRef value)
28734514f5e3Sopenharmony_ci{
28744514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), hClass, IntPtr(JSHClass::BIT_FIELD_OFFSET));
28754514f5e3Sopenharmony_ci    GateRef mask = Int32LSL(
28764514f5e3Sopenharmony_ci        Int32((1LU << T::SIZE) - 1),
28774514f5e3Sopenharmony_ci        Int32(T::START_BIT));
28784514f5e3Sopenharmony_ci    GateRef newVal = Int32Or(Int32And(bitfield, Int32Not(mask)),
28794514f5e3Sopenharmony_ci        Int32LSL(value, Int32(T::START_BIT)));
28804514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, hClass, IntPtr(JSHClass::BIT_FIELD_OFFSET), newVal);
28814514f5e3Sopenharmony_ci}
28824514f5e3Sopenharmony_ci
28834514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrEuqal(GateRef x, GateRef y)
28844514f5e3Sopenharmony_ci{
28854514f5e3Sopenharmony_ci    return env_->Is32Bit() ? Int32Equal(x, y) : Int64Equal(x, y);
28864514f5e3Sopenharmony_ci}
28874514f5e3Sopenharmony_ci
28884514f5e3Sopenharmony_ciinline GateRef StubBuilder::IntPtrNotEqual(GateRef x, GateRef y)
28894514f5e3Sopenharmony_ci{
28904514f5e3Sopenharmony_ci    return env_->Is32Bit() ? Int32NotEqual(x, y) : Int64NotEqual(x, y);
28914514f5e3Sopenharmony_ci}
28924514f5e3Sopenharmony_ci
28934514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetBitMask(GateRef bitoffset)
28944514f5e3Sopenharmony_ci{
28954514f5e3Sopenharmony_ci    // BIT_PER_WORD_MASK
28964514f5e3Sopenharmony_ci    GateRef bitPerWordMask = Int32(GCBitset::BIT_PER_WORD_MASK);
28974514f5e3Sopenharmony_ci    // IndexInWord(bitOffset) = bitOffset & BIT_PER_WORD_MASK
28984514f5e3Sopenharmony_ci    GateRef indexInWord = Int32And(bitoffset, bitPerWordMask);
28994514f5e3Sopenharmony_ci    // Mask(indeInWord) = 1 << index
29004514f5e3Sopenharmony_ci    return Int32LSL(Int32(1), indexInWord);
29014514f5e3Sopenharmony_ci}
29024514f5e3Sopenharmony_ci
29034514f5e3Sopenharmony_ciinline GateRef StubBuilder::ObjectAddressToRange(GateRef x)
29044514f5e3Sopenharmony_ci{
29054514f5e3Sopenharmony_ci    // This function may cause GateRef x is not an object. GC may not mark this x object.
29064514f5e3Sopenharmony_ci    return IntPtrAnd(TaggedCastToIntPtr(x), IntPtr(~panda::ecmascript::DEFAULT_REGION_MASK));
29074514f5e3Sopenharmony_ci}
29084514f5e3Sopenharmony_ci
29094514f5e3Sopenharmony_ciinline GateRef StubBuilder::RegionInSpace(GateRef region, RegionSpaceFlag space)
29104514f5e3Sopenharmony_ci{
29114514f5e3Sopenharmony_ci    auto offset = Region::PackedData::GetFlagsOffset(env_->Is32Bit());
29124514f5e3Sopenharmony_ci    GateRef x = Load(VariableType::NATIVE_POINTER(), PtrAdd(IntPtr(offset), region),
29134514f5e3Sopenharmony_ci        IntPtr(0));
29144514f5e3Sopenharmony_ci    if (env_->Is32Bit()) {
29154514f5e3Sopenharmony_ci        return Int32Equal(Int32And(x,
29164514f5e3Sopenharmony_ci            Int32(RegionSpaceFlag::VALID_SPACE_MASK)), Int32(space));
29174514f5e3Sopenharmony_ci    } else {
29184514f5e3Sopenharmony_ci        return Int64Equal(Int64And(x,
29194514f5e3Sopenharmony_ci            Int64(RegionSpaceFlag::VALID_SPACE_MASK)), Int64(space));
29204514f5e3Sopenharmony_ci    }
29214514f5e3Sopenharmony_ci}
29224514f5e3Sopenharmony_ci
29234514f5e3Sopenharmony_ciinline GateRef StubBuilder::InEdenGeneration(GateRef region)
29244514f5e3Sopenharmony_ci{
29254514f5e3Sopenharmony_ci    return RegionInSpace(region, RegionSpaceFlag::IN_EDEN_SPACE);
29264514f5e3Sopenharmony_ci}
29274514f5e3Sopenharmony_ci
29284514f5e3Sopenharmony_ciinline GateRef StubBuilder::InYoungGeneration(GateRef region)
29294514f5e3Sopenharmony_ci{
29304514f5e3Sopenharmony_ci    return RegionInSpace(region, RegionSpaceFlag::IN_YOUNG_SPACE);
29314514f5e3Sopenharmony_ci}
29324514f5e3Sopenharmony_ci
29334514f5e3Sopenharmony_ciinline GateRef StubBuilder::RegionInSpace(GateRef region, RegionSpaceFlag spaceBegin, RegionSpaceFlag spaceEnd)
29344514f5e3Sopenharmony_ci{
29354514f5e3Sopenharmony_ci    auto offset = Region::PackedData::GetFlagsOffset(env_->Is32Bit());
29364514f5e3Sopenharmony_ci    GateRef x = Load(VariableType::NATIVE_POINTER(), PtrAdd(IntPtr(offset), region),
29374514f5e3Sopenharmony_ci        IntPtr(0));
29384514f5e3Sopenharmony_ci    if (env_->Is32Bit()) {
29394514f5e3Sopenharmony_ci        GateRef spaceType = Int32And(x, Int32(RegionSpaceFlag::VALID_SPACE_MASK));
29404514f5e3Sopenharmony_ci        GateRef greater = Int32GreaterThanOrEqual(spaceType, Int32(spaceBegin));
29414514f5e3Sopenharmony_ci        GateRef less = Int32LessThanOrEqual(spaceType, Int32(spaceEnd));
29424514f5e3Sopenharmony_ci        return BitAnd(greater, less);
29434514f5e3Sopenharmony_ci    } else {
29444514f5e3Sopenharmony_ci        GateRef spaceType = Int64And(x, Int64(RegionSpaceFlag::VALID_SPACE_MASK));
29454514f5e3Sopenharmony_ci        GateRef greater = Int64GreaterThanOrEqual(spaceType, Int64(spaceBegin));
29464514f5e3Sopenharmony_ci        GateRef less = Int64LessThanOrEqual(spaceType, Int64(spaceEnd));
29474514f5e3Sopenharmony_ci        return BitAnd(greater, less);
29484514f5e3Sopenharmony_ci    }
29494514f5e3Sopenharmony_ci}
29504514f5e3Sopenharmony_ci
29514514f5e3Sopenharmony_ciinline GateRef StubBuilder::InGeneralYoungGeneration(GateRef region)
29524514f5e3Sopenharmony_ci{
29534514f5e3Sopenharmony_ci    return RegionInSpace(region, RegionSpaceFlag::GENERAL_YOUNG_BEGIN, RegionSpaceFlag::GENERAL_YOUNG_END);
29544514f5e3Sopenharmony_ci}
29554514f5e3Sopenharmony_ci
29564514f5e3Sopenharmony_ciinline GateRef StubBuilder::InGeneralOldGeneration(GateRef region)
29574514f5e3Sopenharmony_ci{
29584514f5e3Sopenharmony_ci    return RegionInSpace(region, RegionSpaceFlag::GENERAL_OLD_BEGIN, RegionSpaceFlag::GENERAL_OLD_END);
29594514f5e3Sopenharmony_ci}
29604514f5e3Sopenharmony_ci
29614514f5e3Sopenharmony_ciinline GateRef StubBuilder::InSharedHeap(GateRef region)
29624514f5e3Sopenharmony_ci{
29634514f5e3Sopenharmony_ci    auto offset = Region::PackedData::GetFlagsOffset(env_->Is32Bit());
29644514f5e3Sopenharmony_ci    GateRef x = Load(VariableType::NATIVE_POINTER(), PtrAdd(IntPtr(offset), region),
29654514f5e3Sopenharmony_ci        IntPtr(0));
29664514f5e3Sopenharmony_ci    if (env_->Is32Bit()) {
29674514f5e3Sopenharmony_ci        GateRef spaceType = Int32And(x, Int32(RegionSpaceFlag::VALID_SPACE_MASK));
29684514f5e3Sopenharmony_ci        GateRef greater = Int32GreaterThanOrEqual(spaceType, Int32(RegionSpaceFlag::SHARED_SPACE_BEGIN));
29694514f5e3Sopenharmony_ci        GateRef less = Int32LessThanOrEqual(spaceType, Int32(RegionSpaceFlag::SHARED_SPACE_END));
29704514f5e3Sopenharmony_ci        return BitAnd(greater, less);
29714514f5e3Sopenharmony_ci    } else {
29724514f5e3Sopenharmony_ci        GateRef spaceType = Int64And(x, Int64(RegionSpaceFlag::VALID_SPACE_MASK));
29734514f5e3Sopenharmony_ci        GateRef greater = Int64GreaterThanOrEqual(spaceType, Int64(RegionSpaceFlag::SHARED_SPACE_BEGIN));
29744514f5e3Sopenharmony_ci        GateRef less = Int64LessThanOrEqual(spaceType, Int64(RegionSpaceFlag::SHARED_SPACE_END));
29754514f5e3Sopenharmony_ci        return BitAnd(greater, less);
29764514f5e3Sopenharmony_ci    }
29774514f5e3Sopenharmony_ci}
29784514f5e3Sopenharmony_ci
29794514f5e3Sopenharmony_ciinline GateRef StubBuilder::InSharedSweepableSpace(GateRef region)
29804514f5e3Sopenharmony_ci{
29814514f5e3Sopenharmony_ci    auto offset = Region::PackedData::GetFlagsOffset(env_->Is32Bit());
29824514f5e3Sopenharmony_ci    GateRef x = Load(VariableType::NATIVE_POINTER(), PtrAdd(IntPtr(offset), region),
29834514f5e3Sopenharmony_ci        IntPtr(0));
29844514f5e3Sopenharmony_ci    if (env_->Is32Bit()) {
29854514f5e3Sopenharmony_ci        GateRef spaceType = Int32And(x, Int32(RegionSpaceFlag::VALID_SPACE_MASK));
29864514f5e3Sopenharmony_ci        GateRef greater = Int32GreaterThanOrEqual(spaceType, Int32(RegionSpaceFlag::SHARED_SWEEPABLE_SPACE_BEGIN));
29874514f5e3Sopenharmony_ci        GateRef less = Int32LessThanOrEqual(spaceType, Int32(RegionSpaceFlag::SHARED_SWEEPABLE_SPACE_END));
29884514f5e3Sopenharmony_ci        return BitAnd(greater, less);
29894514f5e3Sopenharmony_ci    } else {
29904514f5e3Sopenharmony_ci        GateRef spaceType = Int64And(x, Int64(RegionSpaceFlag::VALID_SPACE_MASK));
29914514f5e3Sopenharmony_ci        GateRef greater = Int64GreaterThanOrEqual(spaceType, Int64(RegionSpaceFlag::SHARED_SWEEPABLE_SPACE_BEGIN));
29924514f5e3Sopenharmony_ci        GateRef less = Int64LessThanOrEqual(spaceType, Int64(RegionSpaceFlag::SHARED_SWEEPABLE_SPACE_END));
29934514f5e3Sopenharmony_ci        return BitAnd(greater, less);
29944514f5e3Sopenharmony_ci    }
29954514f5e3Sopenharmony_ci}
29964514f5e3Sopenharmony_ci
29974514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetParentEnv(GateRef object)
29984514f5e3Sopenharmony_ci{
29994514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetParentEnv(object);
30004514f5e3Sopenharmony_ci}
30014514f5e3Sopenharmony_ci
30024514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSendableParentEnv(GateRef object)
30034514f5e3Sopenharmony_ci{
30044514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetSendableParentEnv(object);
30054514f5e3Sopenharmony_ci}
30064514f5e3Sopenharmony_ci
30074514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertiesFromLexicalEnv(GateRef object, GateRef index)
30084514f5e3Sopenharmony_ci{
30094514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetPropertiesFromLexicalEnv(object, index);
30104514f5e3Sopenharmony_ci}
30114514f5e3Sopenharmony_ci
30124514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertiesFromSendableEnv(GateRef object, GateRef index)
30134514f5e3Sopenharmony_ci{
30144514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetPropertiesFromSendableEnv(object, index);
30154514f5e3Sopenharmony_ci}
30164514f5e3Sopenharmony_ci
30174514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetKeyFromLexivalEnv(GateRef lexicalEnv, GateRef levelIndex, GateRef slotIndex)
30184514f5e3Sopenharmony_ci{
30194514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetKeyFromLexivalEnv(lexicalEnv, levelIndex, slotIndex);
30204514f5e3Sopenharmony_ci}
30214514f5e3Sopenharmony_ci
30224514f5e3Sopenharmony_ciinline void StubBuilder::SetPropertiesToSendableEnv(GateRef glue, GateRef object, GateRef index, GateRef value)
30234514f5e3Sopenharmony_ci{
30244514f5e3Sopenharmony_ci    GateRef valueIndex = Int32Add(index, Int32(SendableEnv::SENDABLE_RESERVED_ENV_LENGTH));
30254514f5e3Sopenharmony_ci    SetValueToTaggedArray(VariableType::JS_ANY(), glue, object, valueIndex, value);
30264514f5e3Sopenharmony_ci}
30274514f5e3Sopenharmony_ci
30284514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSendableEnvFromModule(GateRef module)
30294514f5e3Sopenharmony_ci{
30304514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetSendableEnvFromModule(module);
30314514f5e3Sopenharmony_ci}
30324514f5e3Sopenharmony_ci
30334514f5e3Sopenharmony_ciinline void StubBuilder::SetSendableEnvToModule(GateRef glue, GateRef module, GateRef value, MemoryAttribute mAttr)
30344514f5e3Sopenharmony_ci{
30354514f5e3Sopenharmony_ci    GateRef offset = IntPtr(SourceTextModule::SENDABLE_ENV_OFFSET);
30364514f5e3Sopenharmony_ci    mAttr.SetShare(MemoryAttribute::SHARED);
30374514f5e3Sopenharmony_ci    Store(VariableType::JS_POINTER(), glue, module, offset, value, mAttr);
30384514f5e3Sopenharmony_ci}
30394514f5e3Sopenharmony_ci
30404514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetHomeObjectFromJSFunction(GateRef object)
30414514f5e3Sopenharmony_ci{
30424514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::HOME_OBJECT_OFFSET);
30434514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, offset);
30444514f5e3Sopenharmony_ci}
30454514f5e3Sopenharmony_ci
30464514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetMethodFromJSFunctionOrProxy(GateRef object)
30474514f5e3Sopenharmony_ci{
30484514f5e3Sopenharmony_ci    auto env = GetEnvironment();
30494514f5e3Sopenharmony_ci    Label subentry(env);
30504514f5e3Sopenharmony_ci    env->SubCfgEntry(&subentry);
30514514f5e3Sopenharmony_ci
30524514f5e3Sopenharmony_ci    GateRef methodOffset;
30534514f5e3Sopenharmony_ci    Label funcIsJSFunctionBase(env);
30544514f5e3Sopenharmony_ci    Label funcIsJSProxy(env);
30554514f5e3Sopenharmony_ci    Label getMethod(env);
30564514f5e3Sopenharmony_ci    BRANCH(IsJSFunctionBase(object), &funcIsJSFunctionBase, &funcIsJSProxy);
30574514f5e3Sopenharmony_ci    Bind(&funcIsJSFunctionBase);
30584514f5e3Sopenharmony_ci    {
30594514f5e3Sopenharmony_ci        methodOffset = IntPtr(JSFunctionBase::METHOD_OFFSET);
30604514f5e3Sopenharmony_ci        Jump(&getMethod);
30614514f5e3Sopenharmony_ci    }
30624514f5e3Sopenharmony_ci    Bind(&funcIsJSProxy);
30634514f5e3Sopenharmony_ci    {
30644514f5e3Sopenharmony_ci        methodOffset = IntPtr(JSProxy::METHOD_OFFSET);
30654514f5e3Sopenharmony_ci        Jump(&getMethod);
30664514f5e3Sopenharmony_ci    }
30674514f5e3Sopenharmony_ci    Bind(&getMethod);
30684514f5e3Sopenharmony_ci    GateRef method = Load(VariableType::JS_ANY(), object, methodOffset);
30694514f5e3Sopenharmony_ci    env->SubCfgExit();
30704514f5e3Sopenharmony_ci    return method;
30714514f5e3Sopenharmony_ci}
30724514f5e3Sopenharmony_ci
30734514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetCallFieldFromMethod(GateRef method)
30744514f5e3Sopenharmony_ci{
30754514f5e3Sopenharmony_ci    GateRef callFieldOffset = IntPtr(Method::CALL_FIELD_OFFSET);
30764514f5e3Sopenharmony_ci    return Load(VariableType::INT64(), method, callFieldOffset);
30774514f5e3Sopenharmony_ci}
30784514f5e3Sopenharmony_ci
30794514f5e3Sopenharmony_ciinline void StubBuilder::SetLexicalEnvToFunction(GateRef glue, GateRef object, GateRef lexicalEnv,
30804514f5e3Sopenharmony_ci                                                 MemoryAttribute mAttr)
30814514f5e3Sopenharmony_ci{
30824514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::LEXICAL_ENV_OFFSET);
30834514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, object, offset, lexicalEnv, mAttr);
30844514f5e3Sopenharmony_ci}
30854514f5e3Sopenharmony_ci
30864514f5e3Sopenharmony_ciinline void StubBuilder::SetProtoTransRootHClassToFunction(GateRef glue, GateRef object, GateRef hclass,
30874514f5e3Sopenharmony_ci                                                           MemoryAttribute mAttr)
30884514f5e3Sopenharmony_ci{
30894514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::PROTO_TRANS_ROOT_HCLASS_OFFSET);
30904514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, object, offset, hclass, mAttr);
30914514f5e3Sopenharmony_ci}
30924514f5e3Sopenharmony_ci
30934514f5e3Sopenharmony_ciinline void StubBuilder::SetProtoOrHClassToFunction(GateRef glue, GateRef function, GateRef value,
30944514f5e3Sopenharmony_ci                                                    MemoryAttribute mAttr)
30954514f5e3Sopenharmony_ci{
30964514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::PROTO_OR_DYNCLASS_OFFSET);
30974514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, function, offset, value, mAttr);
30984514f5e3Sopenharmony_ci}
30994514f5e3Sopenharmony_ci
31004514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetProtoOrHClass(GateRef function)
31014514f5e3Sopenharmony_ci{
31024514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::PROTO_OR_DYNCLASS_OFFSET);
31034514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), function, offset);
31044514f5e3Sopenharmony_ci}
31054514f5e3Sopenharmony_ci
31064514f5e3Sopenharmony_ciinline void StubBuilder::SetTypedArrayName(GateRef glue, GateRef typedArray, GateRef name,
31074514f5e3Sopenharmony_ci                                           MemoryAttribute mAttr)
31084514f5e3Sopenharmony_ci{
31094514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSTypedArray::TYPED_ARRAY_NAME_OFFSET);
31104514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, typedArray, offset, name, mAttr);
31114514f5e3Sopenharmony_ci}
31124514f5e3Sopenharmony_ci
31134514f5e3Sopenharmony_ciinline void StubBuilder::SetContentType(GateRef glue, GateRef typedArray, GateRef type)
31144514f5e3Sopenharmony_ci{
31154514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSTypedArray::CONTENT_TYPE_OFFSET);
31164514f5e3Sopenharmony_ci    Store(VariableType::INT8(), glue, typedArray, offset, type, MemoryAttribute::NoBarrier());
31174514f5e3Sopenharmony_ci}
31184514f5e3Sopenharmony_ci
31194514f5e3Sopenharmony_ciinline void StubBuilder::SetViewedArrayBufferOrByteArray(GateRef glue, GateRef typedArray, GateRef data,
31204514f5e3Sopenharmony_ci    MemoryAttribute mAttr)
31214514f5e3Sopenharmony_ci{
31224514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSTypedArray::VIEWED_ARRAY_BUFFER_OFFSET);
31234514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, typedArray, offset, data, mAttr);
31244514f5e3Sopenharmony_ci}
31254514f5e3Sopenharmony_ci
31264514f5e3Sopenharmony_ciinline void StubBuilder::SetByteLength(GateRef glue, GateRef typedArray, GateRef byteLength)
31274514f5e3Sopenharmony_ci{
31284514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSTypedArray::BYTE_LENGTH_OFFSET);
31294514f5e3Sopenharmony_ci    Store(VariableType::INT8(), glue, typedArray, offset, byteLength, MemoryAttribute::NoBarrier());
31304514f5e3Sopenharmony_ci}
31314514f5e3Sopenharmony_ci
31324514f5e3Sopenharmony_ciinline void StubBuilder::SetByteOffset(GateRef glue, GateRef typedArray, GateRef byteOffset)
31334514f5e3Sopenharmony_ci{
31344514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSTypedArray::BYTE_OFFSET_OFFSET);
31354514f5e3Sopenharmony_ci    Store(VariableType::INT8(), glue, typedArray, offset, byteOffset, MemoryAttribute::NoBarrier());
31364514f5e3Sopenharmony_ci}
31374514f5e3Sopenharmony_ci
31384514f5e3Sopenharmony_ciinline void StubBuilder::SetTypedArrayLength(GateRef glue, GateRef typedArray, GateRef arrayLength)
31394514f5e3Sopenharmony_ci{
31404514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSTypedArray::ARRAY_LENGTH_OFFSET);
31414514f5e3Sopenharmony_ci    Store(VariableType::INT8(), glue, typedArray, offset, arrayLength, MemoryAttribute::NoBarrier());
31424514f5e3Sopenharmony_ci}
31434514f5e3Sopenharmony_ci
31444514f5e3Sopenharmony_ciinline void StubBuilder::SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value,
31454514f5e3Sopenharmony_ci                                                 MemoryAttribute mAttr)
31464514f5e3Sopenharmony_ci{
31474514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::HOME_OBJECT_OFFSET);
31484514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, function, offset, value, mAttr);
31494514f5e3Sopenharmony_ci}
31504514f5e3Sopenharmony_ci
31514514f5e3Sopenharmony_ciinline void StubBuilder::SetModuleToFunction(GateRef glue, GateRef function, GateRef value,
31524514f5e3Sopenharmony_ci                                             MemoryAttribute mAttr)
31534514f5e3Sopenharmony_ci{
31544514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::ECMA_MODULE_OFFSET);
31554514f5e3Sopenharmony_ci    Store(VariableType::JS_POINTER(), glue, function, offset, value, mAttr);
31564514f5e3Sopenharmony_ci}
31574514f5e3Sopenharmony_ci
31584514f5e3Sopenharmony_ciinline void StubBuilder::SetWorkNodePointerToFunction(GateRef glue, GateRef function, GateRef value,
31594514f5e3Sopenharmony_ci                                                      MemoryAttribute mAttr)
31604514f5e3Sopenharmony_ci{
31614514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::WORK_NODE_POINTER_OFFSET);
31624514f5e3Sopenharmony_ci    Store(VariableType::NATIVE_POINTER(), glue, function, offset, value, mAttr);
31634514f5e3Sopenharmony_ci}
31644514f5e3Sopenharmony_ci
31654514f5e3Sopenharmony_ciinline void StubBuilder::SetMethodToFunction(GateRef glue, GateRef function, GateRef value,
31664514f5e3Sopenharmony_ci                                             MemoryAttribute mAttr)
31674514f5e3Sopenharmony_ci{
31684514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunctionBase::METHOD_OFFSET);
31694514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, function, offset, value, mAttr);
31704514f5e3Sopenharmony_ci}
31714514f5e3Sopenharmony_ci
31724514f5e3Sopenharmony_ciinline void StubBuilder::SetCodeEntryToFunctionFromMethod(GateRef glue, GateRef function, GateRef method)
31734514f5e3Sopenharmony_ci{
31744514f5e3Sopenharmony_ci    GateRef codeEntryOffset = IntPtr(Method::CODEENTRY_LITERAL_OFFSET);
31754514f5e3Sopenharmony_ci    GateRef codeEntry = Load(VariableType::NATIVE_POINTER(), method, codeEntryOffset);
31764514f5e3Sopenharmony_ci    GateRef funcOffset = IntPtr(JSFunctionBase::CODE_ENTRY_OFFSET);
31774514f5e3Sopenharmony_ci    Store(VariableType::NATIVE_POINTER(), glue, function, funcOffset, codeEntry);
31784514f5e3Sopenharmony_ci}
31794514f5e3Sopenharmony_ci
31804514f5e3Sopenharmony_ciinline void StubBuilder::SetCodeEntryToFunctionFromFuncEntry(GateRef glue, GateRef function, GateRef codeEntry)
31814514f5e3Sopenharmony_ci{
31824514f5e3Sopenharmony_ci    GateRef funcOffset = IntPtr(JSFunctionBase::CODE_ENTRY_OFFSET);
31834514f5e3Sopenharmony_ci    Store(VariableType::NATIVE_POINTER(), glue, function, funcOffset, codeEntry);
31844514f5e3Sopenharmony_ci}
31854514f5e3Sopenharmony_ci
31864514f5e3Sopenharmony_ciinline void StubBuilder::SetLengthToFunction(GateRef glue, GateRef function, GateRef value)
31874514f5e3Sopenharmony_ci{
31884514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunctionBase::LENGTH_OFFSET);
31894514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, function, offset, value, MemoryAttribute::NoBarrier());
31904514f5e3Sopenharmony_ci}
31914514f5e3Sopenharmony_ci
31924514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLengthFromFunction(GateRef function)
31934514f5e3Sopenharmony_ci{
31944514f5e3Sopenharmony_ci    return Load(VariableType::JS_NOT_POINTER(), function, IntPtr(JSFunctionBase::LENGTH_OFFSET));
31954514f5e3Sopenharmony_ci}
31964514f5e3Sopenharmony_ci
31974514f5e3Sopenharmony_ciinline void StubBuilder::SetRawProfileTypeInfoToFunction(GateRef glue, GateRef function, GateRef value,
31984514f5e3Sopenharmony_ci                                                         MemoryAttribute mAttr)
31994514f5e3Sopenharmony_ci{
32004514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::RAW_PROFILE_TYPE_INFO_OFFSET);
32014514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, function, offset, value, mAttr);
32024514f5e3Sopenharmony_ci}
32034514f5e3Sopenharmony_ci
32044514f5e3Sopenharmony_ciinline void StubBuilder::SetValueToProfileTypeInfoCell(GateRef glue, GateRef profileTypeInfoCell, GateRef value)
32054514f5e3Sopenharmony_ci{
32064514f5e3Sopenharmony_ci    GateRef offset = IntPtr(ProfileTypeInfoCell::VALUE_OFFSET);
32074514f5e3Sopenharmony_ci    Store(VariableType::JS_POINTER(), glue, profileTypeInfoCell, offset, value);
32084514f5e3Sopenharmony_ci}
32094514f5e3Sopenharmony_ci
32104514f5e3Sopenharmony_ciinline void StubBuilder::UpdateProfileTypeInfoCellType(GateRef glue, GateRef profileTypeInfoCell)
32114514f5e3Sopenharmony_ci{
32124514f5e3Sopenharmony_ci    auto env = GetEnvironment();
32134514f5e3Sopenharmony_ci    Label subEntry(env);
32144514f5e3Sopenharmony_ci    env->SubCfgEntry(&subEntry);
32154514f5e3Sopenharmony_ci
32164514f5e3Sopenharmony_ci    // ProfileTypeInfoCell0 -> Cell1 -> CellN
32174514f5e3Sopenharmony_ci    Label isProfileTypeInfoCell0(env);
32184514f5e3Sopenharmony_ci    Label notProfileTypeInfoCell0(env);
32194514f5e3Sopenharmony_ci    Label isProfileTypeInfoCell1(env);
32204514f5e3Sopenharmony_ci    Label endProfileTypeInfoCellType(env);
32214514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(profileTypeInfoCell));
32224514f5e3Sopenharmony_ci    BRANCH(Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::PROFILE_TYPE_INFO_CELL_0))),
32234514f5e3Sopenharmony_ci           &isProfileTypeInfoCell0, &notProfileTypeInfoCell0);
32244514f5e3Sopenharmony_ci    Bind(&isProfileTypeInfoCell0);
32254514f5e3Sopenharmony_ci    {
32264514f5e3Sopenharmony_ci        auto profileTypeInfoCell1Class = GetGlobalConstantValue(VariableType::JS_POINTER(), glue,
32274514f5e3Sopenharmony_ci                                                                ConstantIndex::PROFILE_TYPE_INFO_CELL_1_CLASS_INDEX);
32284514f5e3Sopenharmony_ci        StoreHClassWithoutBarrier(glue, profileTypeInfoCell, profileTypeInfoCell1Class);
32294514f5e3Sopenharmony_ci        Jump(&endProfileTypeInfoCellType);
32304514f5e3Sopenharmony_ci    }
32314514f5e3Sopenharmony_ci    Bind(&notProfileTypeInfoCell0);
32324514f5e3Sopenharmony_ci    BRANCH(Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::PROFILE_TYPE_INFO_CELL_1))),
32334514f5e3Sopenharmony_ci           &isProfileTypeInfoCell1, &endProfileTypeInfoCellType);
32344514f5e3Sopenharmony_ci    Bind(&isProfileTypeInfoCell1);
32354514f5e3Sopenharmony_ci    {
32364514f5e3Sopenharmony_ci        auto profileTypeInfoCellNClass = GetGlobalConstantValue(VariableType::JS_POINTER(), glue,
32374514f5e3Sopenharmony_ci                                                                ConstantIndex::PROFILE_TYPE_INFO_CELL_N_CLASS_INDEX);
32384514f5e3Sopenharmony_ci        StoreHClassWithoutBarrier(glue, profileTypeInfoCell, profileTypeInfoCellNClass);
32394514f5e3Sopenharmony_ci        Jump(&endProfileTypeInfoCellType);
32404514f5e3Sopenharmony_ci    }
32414514f5e3Sopenharmony_ci    Bind(&endProfileTypeInfoCellType);
32424514f5e3Sopenharmony_ci    env->SubCfgExit();
32434514f5e3Sopenharmony_ci}
32444514f5e3Sopenharmony_ci
32454514f5e3Sopenharmony_ciinline void StubBuilder::SetJSObjectTaggedField(GateRef glue, GateRef object, size_t offset, GateRef value)
32464514f5e3Sopenharmony_ci{
32474514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, object, IntPtr(offset), value);
32484514f5e3Sopenharmony_ci}
32494514f5e3Sopenharmony_ci
32504514f5e3Sopenharmony_ciinline void StubBuilder::SetCompiledCodeFlagToFunction(GateRef glue, GateRef function, GateRef value)
32514514f5e3Sopenharmony_ci{
32524514f5e3Sopenharmony_ci    GateRef bitFieldOffset = IntPtr(JSFunctionBase::BIT_FIELD_OFFSET);
32534514f5e3Sopenharmony_ci    GateRef oldVal = Load(VariableType::INT32(), function, bitFieldOffset);
32544514f5e3Sopenharmony_ci
32554514f5e3Sopenharmony_ci    GateRef mask = Int32(JSFunctionBase::COMPILED_CODE_FASTCALL_BITS << JSFunctionBase::IsCompiledCodeBit::START_BIT);
32564514f5e3Sopenharmony_ci    GateRef newVal = Int32Or(Int32And(oldVal, Int32Not(mask)), value);
32574514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, function, bitFieldOffset, newVal);
32584514f5e3Sopenharmony_ci}
32594514f5e3Sopenharmony_ci
32604514f5e3Sopenharmony_ciinline void StubBuilder::SetCompiledFuncEntry(GateRef glue, GateRef jsFunc, GateRef codeEntry, GateRef isFastCall)
32614514f5e3Sopenharmony_ci{
32624514f5e3Sopenharmony_ci    SetCodeEntryToFunctionFromFuncEntry(glue, jsFunc, codeEntry);
32634514f5e3Sopenharmony_ci    GateRef compiledCodeFastCallBits = Int32Add(Int32(1),
32644514f5e3Sopenharmony_ci                                                Int32LSL(isFastCall, Int32(JSFunctionBase::IsFastCallBit::START_BIT)));
32654514f5e3Sopenharmony_ci    SetCompiledCodeFlagToFunction(glue, jsFunc, compiledCodeFastCallBits);
32664514f5e3Sopenharmony_ci}
32674514f5e3Sopenharmony_ci
32684514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetIsFastCall(GateRef machineCode)
32694514f5e3Sopenharmony_ci{
32704514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), machineCode, IntPtr(MachineCode::BIT_FIELD_OFFSET));
32714514f5e3Sopenharmony_ci    return Int32And(Int32LSR(bitfield, Int32(MachineCode::IsFastCallBits::START_BIT)),
32724514f5e3Sopenharmony_ci                    Int32((1LU << MachineCode::IsFastCallBits::SIZE) - 1));
32734514f5e3Sopenharmony_ci}
32744514f5e3Sopenharmony_ci
32754514f5e3Sopenharmony_ciinline void StubBuilder::SetTaskConcurrentFuncFlagToFunction(GateRef glue, GateRef function, GateRef value)
32764514f5e3Sopenharmony_ci{
32774514f5e3Sopenharmony_ci    GateRef bitFieldOffset = IntPtr(JSFunctionBase::BIT_FIELD_OFFSET);
32784514f5e3Sopenharmony_ci    GateRef oldVal = Load(VariableType::INT32(), function, bitFieldOffset);
32794514f5e3Sopenharmony_ci    GateRef mask = Int32LSL(
32804514f5e3Sopenharmony_ci        Int32((1LU << JSFunctionBase::TaskConcurrentFuncFlagBit::SIZE) - 1),
32814514f5e3Sopenharmony_ci        Int32(JSFunctionBase::TaskConcurrentFuncFlagBit::START_BIT));
32824514f5e3Sopenharmony_ci    GateRef newVal = Int32Or(Int32And(oldVal, Int32Not(mask)),
32834514f5e3Sopenharmony_ci        Int32LSL(ZExtInt1ToInt32(value), Int32(JSFunctionBase::TaskConcurrentFuncFlagBit::START_BIT)));
32844514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, function, bitFieldOffset, newVal);
32854514f5e3Sopenharmony_ci}
32864514f5e3Sopenharmony_ci
32874514f5e3Sopenharmony_ciinline void StubBuilder::SetBitFieldToFunction(GateRef glue, GateRef function, GateRef value)
32884514f5e3Sopenharmony_ci{
32894514f5e3Sopenharmony_ci    GateRef bitFieldOffset = IntPtr(JSFunctionBase::BIT_FIELD_OFFSET);
32904514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, function, bitFieldOffset, value);
32914514f5e3Sopenharmony_ci}
32924514f5e3Sopenharmony_ci
32934514f5e3Sopenharmony_ciinline void StubBuilder::SetMachineCodeToFunction(GateRef glue, GateRef function, GateRef value, MemoryAttribute mAttr)
32944514f5e3Sopenharmony_ci{
32954514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSFunction::MACHINECODE_OFFSET);
32964514f5e3Sopenharmony_ci    Store(VariableType::JS_ANY(), glue, function, offset, value, mAttr);
32974514f5e3Sopenharmony_ci}
32984514f5e3Sopenharmony_ci
32994514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetGlobalObject(GateRef glue)
33004514f5e3Sopenharmony_ci{
33014514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSThread::GlueData::GetGlobalObjOffset(env_->Is32Bit()));
33024514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), glue, offset);
33034514f5e3Sopenharmony_ci}
33044514f5e3Sopenharmony_ci
33054514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetMethodFromFunction(GateRef function)
33064514f5e3Sopenharmony_ci{
33074514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetMethodFromFunction(function);
33084514f5e3Sopenharmony_ci}
33094514f5e3Sopenharmony_ci
33104514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetModuleFromFunction(GateRef function)
33114514f5e3Sopenharmony_ci{
33124514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetModuleFromFunction(function);
33134514f5e3Sopenharmony_ci}
33144514f5e3Sopenharmony_ci
33154514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetHomeObjectFromFunction(GateRef function)
33164514f5e3Sopenharmony_ci{
33174514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetHomeObjectFromFunction(function);
33184514f5e3Sopenharmony_ci}
33194514f5e3Sopenharmony_ci
33204514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetEntryIndexOfGlobalDictionary(GateRef entry)
33214514f5e3Sopenharmony_ci{
33224514f5e3Sopenharmony_ci    return Int32Add(Int32(OrderTaggedHashTable<GlobalDictionary>::TABLE_HEADER_SIZE),
33234514f5e3Sopenharmony_ci        Int32Mul(entry, Int32(GlobalDictionary::ENTRY_SIZE)));
33244514f5e3Sopenharmony_ci}
33254514f5e3Sopenharmony_ci
33264514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetBoxFromGlobalDictionary(GateRef object, GateRef entry)
33274514f5e3Sopenharmony_ci{
33284514f5e3Sopenharmony_ci    GateRef index = GetEntryIndexOfGlobalDictionary(entry);
33294514f5e3Sopenharmony_ci    GateRef offset = PtrAdd(ZExtInt32ToPtr(index),
33304514f5e3Sopenharmony_ci        IntPtr(GlobalDictionary::ENTRY_VALUE_INDEX));
33314514f5e3Sopenharmony_ci    return GetValueFromTaggedArray(object, offset);
33324514f5e3Sopenharmony_ci}
33334514f5e3Sopenharmony_ci
33344514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetValueFromGlobalDictionary(GateRef object, GateRef entry)
33354514f5e3Sopenharmony_ci{
33364514f5e3Sopenharmony_ci    GateRef box = GetBoxFromGlobalDictionary(object, entry);
33374514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), box, IntPtr(PropertyBox::VALUE_OFFSET));
33384514f5e3Sopenharmony_ci}
33394514f5e3Sopenharmony_ci
33404514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertiesFromJSObject(GateRef object)
33414514f5e3Sopenharmony_ci{
33424514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSObject::PROPERTIES_OFFSET);
33434514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), object, offset);
33444514f5e3Sopenharmony_ci}
33454514f5e3Sopenharmony_ci
33464514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSFunction(GateRef obj)
33474514f5e3Sopenharmony_ci{
33484514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
33494514f5e3Sopenharmony_ci    GateRef greater = Int32GreaterThanOrEqual(objectType,
33504514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::JS_FUNCTION_FIRST)));
33514514f5e3Sopenharmony_ci    GateRef less = Int32LessThanOrEqual(objectType,
33524514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::JS_FUNCTION_LAST)));
33534514f5e3Sopenharmony_ci    return BitAnd(greater, less);
33544514f5e3Sopenharmony_ci}
33554514f5e3Sopenharmony_ci
33564514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsBoundFunction(GateRef obj)
33574514f5e3Sopenharmony_ci{
33584514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
33594514f5e3Sopenharmony_ci    return Int32Equal(objectType, Int32(static_cast<int32_t>(JSType::JS_BOUND_FUNCTION)));
33604514f5e3Sopenharmony_ci}
33614514f5e3Sopenharmony_ci
33624514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsJSOrBoundFunction(GateRef obj)
33634514f5e3Sopenharmony_ci{
33644514f5e3Sopenharmony_ci    GateRef objectType = GetObjectType(LoadHClass(obj));
33654514f5e3Sopenharmony_ci    GateRef greater = Int32GreaterThanOrEqual(objectType,
33664514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::JS_FUNCTION_FIRST)));
33674514f5e3Sopenharmony_ci    GateRef less = Int32LessThanOrEqual(objectType,
33684514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(JSType::JS_BOUND_FUNCTION)));
33694514f5e3Sopenharmony_ci    return BitAnd(greater, less);
33704514f5e3Sopenharmony_ci}
33714514f5e3Sopenharmony_ci
33724514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsAOTLiteralInfo(GateRef info)
33734514f5e3Sopenharmony_ci{
33744514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsAOTLiteralInfo(info);
33754514f5e3Sopenharmony_ci}
33764514f5e3Sopenharmony_ci
33774514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsAotWithCallField(GateRef method)
33784514f5e3Sopenharmony_ci{
33794514f5e3Sopenharmony_ci    GateRef callFieldOffset = IntPtr(Method::CALL_FIELD_OFFSET);
33804514f5e3Sopenharmony_ci    GateRef callfield = Load(VariableType::INT64(), method, callFieldOffset);
33814514f5e3Sopenharmony_ci    return Int64NotEqual(
33824514f5e3Sopenharmony_ci        Int64And(
33834514f5e3Sopenharmony_ci            Int64LSR(callfield, Int64(Method::IsAotCodeBit::START_BIT)),
33844514f5e3Sopenharmony_ci            Int64((1LU << Method::IsAotCodeBit::SIZE) - 1)),
33854514f5e3Sopenharmony_ci        Int64(0));
33864514f5e3Sopenharmony_ci}
33874514f5e3Sopenharmony_ci
33884514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsFastCall(GateRef method)
33894514f5e3Sopenharmony_ci{
33904514f5e3Sopenharmony_ci    GateRef callFieldOffset = IntPtr(Method::CALL_FIELD_OFFSET);
33914514f5e3Sopenharmony_ci    GateRef callfield = Load(VariableType::INT64(), method, callFieldOffset);
33924514f5e3Sopenharmony_ci    return Int64NotEqual(
33934514f5e3Sopenharmony_ci        Int64And(
33944514f5e3Sopenharmony_ci            Int64LSR(callfield, Int64(Method::IsFastCallBit::START_BIT)),
33954514f5e3Sopenharmony_ci            Int64((1LU << Method::IsFastCallBit::SIZE) - 1)),
33964514f5e3Sopenharmony_ci        Int64(0));
33974514f5e3Sopenharmony_ci}
33984514f5e3Sopenharmony_ci
33994514f5e3Sopenharmony_ciinline GateRef StubBuilder::HasPrototype(GateRef kind)
34004514f5e3Sopenharmony_ci{
34014514f5e3Sopenharmony_ci    return LogicAndBuilder(env_)
34024514f5e3Sopenharmony_ci        .And(Int32NotEqual(kind, Int32(static_cast<int32_t>(FunctionKind::BUILTIN_PROXY_CONSTRUCTOR))))
34034514f5e3Sopenharmony_ci        .And(Int32GreaterThanOrEqual(kind, Int32(static_cast<int32_t>(FunctionKind::BASE_CONSTRUCTOR))))
34044514f5e3Sopenharmony_ci        .And(Int32LessThanOrEqual(kind, Int32(static_cast<int32_t>(FunctionKind::ASYNC_GENERATOR_FUNCTION))))
34054514f5e3Sopenharmony_ci        .Done();
34064514f5e3Sopenharmony_ci}
34074514f5e3Sopenharmony_ci
34084514f5e3Sopenharmony_ciinline GateRef StubBuilder::HasAccessor(GateRef kind)
34094514f5e3Sopenharmony_ci{
34104514f5e3Sopenharmony_ci    GateRef greater = Int32GreaterThanOrEqual(kind,
34114514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(FunctionKind::NORMAL_FUNCTION)));
34124514f5e3Sopenharmony_ci    GateRef less = Int32LessThanOrEqual(kind,
34134514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(FunctionKind::ASYNC_FUNCTION)));
34144514f5e3Sopenharmony_ci    return BitAnd(greater, less);
34154514f5e3Sopenharmony_ci}
34164514f5e3Sopenharmony_ci
34174514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsClassConstructorKind(GateRef kind)
34184514f5e3Sopenharmony_ci{
34194514f5e3Sopenharmony_ci    GateRef left = Int32Equal(kind, Int32(static_cast<int32_t>(FunctionKind::CLASS_CONSTRUCTOR)));
34204514f5e3Sopenharmony_ci    GateRef right = Int32Equal(kind, Int32(static_cast<int32_t>(FunctionKind::DERIVED_CONSTRUCTOR)));
34214514f5e3Sopenharmony_ci    return BitOr(left, right);
34224514f5e3Sopenharmony_ci}
34234514f5e3Sopenharmony_ci
34244514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsGeneratorKind(GateRef kind)
34254514f5e3Sopenharmony_ci{
34264514f5e3Sopenharmony_ci    GateRef left = Int32Equal(kind, Int32(static_cast<int32_t>(FunctionKind::ASYNC_GENERATOR_FUNCTION)));
34274514f5e3Sopenharmony_ci    GateRef right = Int32Equal(kind, Int32(static_cast<int32_t>(FunctionKind::GENERATOR_FUNCTION)));
34284514f5e3Sopenharmony_ci    return BitOr(left, right);
34294514f5e3Sopenharmony_ci}
34304514f5e3Sopenharmony_ci
34314514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsBaseKind(GateRef kind)
34324514f5e3Sopenharmony_ci{
34334514f5e3Sopenharmony_ci    GateRef val = Int32Equal(kind, Int32(static_cast<int32_t>(FunctionKind::BASE_CONSTRUCTOR)));
34344514f5e3Sopenharmony_ci    return BitOr(val, IsGeneratorKind(kind));
34354514f5e3Sopenharmony_ci}
34364514f5e3Sopenharmony_ci
34374514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsBaseConstructorKind(GateRef kind)
34384514f5e3Sopenharmony_ci{
34394514f5e3Sopenharmony_ci    return Int32Equal(kind, Int32(static_cast<int32_t>(FunctionKind::BASE_CONSTRUCTOR)));
34404514f5e3Sopenharmony_ci}
34414514f5e3Sopenharmony_ci
34424514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsSendableFunction(GateRef method)
34434514f5e3Sopenharmony_ci{
34444514f5e3Sopenharmony_ci    GateRef fieldOffset = IntPtr(Method::EXTRA_LITERAL_INFO_OFFSET);
34454514f5e3Sopenharmony_ci    GateRef literalField = Load(VariableType::INT64(), method, fieldOffset);
34464514f5e3Sopenharmony_ci    return Int64NotEqual(
34474514f5e3Sopenharmony_ci        Int64And(
34484514f5e3Sopenharmony_ci            Int64LSR(literalField, Int64(Method::IsSharedBit::START_BIT)),
34494514f5e3Sopenharmony_ci            Int64((1LU << Method::IsSharedBit::SIZE) - 1)),
34504514f5e3Sopenharmony_ci        Int64(0));
34514514f5e3Sopenharmony_ci}
34524514f5e3Sopenharmony_ci
34534514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsNativeMethod(GateRef method)
34544514f5e3Sopenharmony_ci{
34554514f5e3Sopenharmony_ci    GateRef callFieldOffset = IntPtr(Method::CALL_FIELD_OFFSET);
34564514f5e3Sopenharmony_ci    GateRef callfield = Load(VariableType::INT64(), method, callFieldOffset);
34574514f5e3Sopenharmony_ci    return Int64NotEqual(
34584514f5e3Sopenharmony_ci        Int64And(
34594514f5e3Sopenharmony_ci            Int64LSR(callfield, Int64(MethodLiteral::IsNativeBit::START_BIT)),
34604514f5e3Sopenharmony_ci            Int64((1LU << MethodLiteral::IsNativeBit::SIZE) - 1)),
34614514f5e3Sopenharmony_ci        Int64(0));
34624514f5e3Sopenharmony_ci}
34634514f5e3Sopenharmony_ci
34644514f5e3Sopenharmony_ciinline GateRef StubBuilder::JudgeAotAndFastCall(GateRef jsFunc, CircuitBuilder::JudgeMethodType type)
34654514f5e3Sopenharmony_ci{
34664514f5e3Sopenharmony_ci    return env_->GetBuilder()->JudgeAotAndFastCall(jsFunc, type);
34674514f5e3Sopenharmony_ci}
34684514f5e3Sopenharmony_ci
34694514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetExpectedNumOfArgs(GateRef method)
34704514f5e3Sopenharmony_ci{
34714514f5e3Sopenharmony_ci    GateRef callFieldOffset = IntPtr(Method::CALL_FIELD_OFFSET);
34724514f5e3Sopenharmony_ci    GateRef callfield = Load(VariableType::INT64(), method, callFieldOffset);
34734514f5e3Sopenharmony_ci    return TruncInt64ToInt32(Int64And(
34744514f5e3Sopenharmony_ci        Int64LSR(callfield, Int64(MethodLiteral::NumArgsBits::START_BIT)),
34754514f5e3Sopenharmony_ci        Int64((1LU << MethodLiteral::NumArgsBits::SIZE) - 1)));
34764514f5e3Sopenharmony_ci}
34774514f5e3Sopenharmony_ci
34784514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetMethodFromJSProxy(GateRef proxy)
34794514f5e3Sopenharmony_ci{
34804514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSProxy::METHOD_OFFSET);
34814514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), proxy, offset);
34824514f5e3Sopenharmony_ci}
34834514f5e3Sopenharmony_ci
34844514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetHandlerFromJSProxy(GateRef proxy)
34854514f5e3Sopenharmony_ci{
34864514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSProxy::HANDLER_OFFSET);
34874514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), proxy, offset);
34884514f5e3Sopenharmony_ci}
34894514f5e3Sopenharmony_ci
34904514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetTargetFromJSProxy(GateRef proxy)
34914514f5e3Sopenharmony_ci{
34924514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSProxy::TARGET_OFFSET);
34934514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), proxy, offset);
34944514f5e3Sopenharmony_ci}
34954514f5e3Sopenharmony_ci
34964514f5e3Sopenharmony_ciinline GateRef StubBuilder::ComputeTaggedArraySize(GateRef length)
34974514f5e3Sopenharmony_ci{
34984514f5e3Sopenharmony_ci    return PtrAdd(IntPtr(TaggedArray::DATA_OFFSET),
34994514f5e3Sopenharmony_ci        PtrMul(IntPtr(JSTaggedValue::TaggedTypeSize()), length));
35004514f5e3Sopenharmony_ci}
35014514f5e3Sopenharmony_ci
35024514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetGlobalConstantValue(VariableType type, GateRef glue, ConstantIndex index)
35034514f5e3Sopenharmony_ci{
35044514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetGlobalConstantValue(type, glue, index);
35054514f5e3Sopenharmony_ci}
35064514f5e3Sopenharmony_ci
35074514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSingleCharTable(GateRef glue)
35084514f5e3Sopenharmony_ci{
35094514f5e3Sopenharmony_ci    return GetGlobalConstantValue(
35104514f5e3Sopenharmony_ci        VariableType::JS_POINTER(), glue, ConstantIndex::SINGLE_CHAR_TABLE_INDEX);
35114514f5e3Sopenharmony_ci}
35124514f5e3Sopenharmony_ci
35134514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsEnableElementsKind(GateRef glue)
35144514f5e3Sopenharmony_ci{
35154514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSThread::GlueData::GetIsEnableElementsKindOffset(env_->Is32Bit()));
35164514f5e3Sopenharmony_ci    return Load(VariableType::BOOL(), glue, offset);
35174514f5e3Sopenharmony_ci}
35184514f5e3Sopenharmony_ci
35194514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetGlobalEnvValue(VariableType type, GateRef env, size_t index)
35204514f5e3Sopenharmony_ci{
35214514f5e3Sopenharmony_ci    auto valueIndex = IntPtr(GlobalEnv::HEADER_SIZE + JSTaggedValue::TaggedTypeSize() * index);
35224514f5e3Sopenharmony_ci    return Load(type, env, valueIndex);
35234514f5e3Sopenharmony_ci}
35244514f5e3Sopenharmony_ci
35254514f5e3Sopenharmony_ciinline GateRef StubBuilder::HasPendingException(GateRef glue)
35264514f5e3Sopenharmony_ci{
35274514f5e3Sopenharmony_ci    GateRef exceptionOffset = IntPtr(JSThread::GlueData::GetExceptionOffset(env_->IsArch32Bit()));
35284514f5e3Sopenharmony_ci    GateRef exception = Load(VariableType::JS_ANY(), glue, exceptionOffset);
35294514f5e3Sopenharmony_ci    return TaggedIsNotHole(exception);
35304514f5e3Sopenharmony_ci}
35314514f5e3Sopenharmony_ci
35324514f5e3Sopenharmony_ciinline GateRef StubBuilder::DispatchBuiltins(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args)
35334514f5e3Sopenharmony_ci{
35344514f5e3Sopenharmony_ci    GateRef target = PtrMul(ZExtInt32ToPtr(builtinsId), IntPtrSize());
35354514f5e3Sopenharmony_ci    return env_->GetBuilder()->CallBuiltin(glue, target, args);
35364514f5e3Sopenharmony_ci}
35374514f5e3Sopenharmony_ci
35384514f5e3Sopenharmony_ciinline GateRef StubBuilder::DispatchBuiltinsWithArgv(GateRef glue, GateRef builtinsId, const std::vector<GateRef>& args)
35394514f5e3Sopenharmony_ci{
35404514f5e3Sopenharmony_ci    GateRef target = PtrMul(ZExtInt32ToPtr(builtinsId), IntPtrSize());
35414514f5e3Sopenharmony_ci    return env_->GetBuilder()->CallBuiltinWithArgv(glue, target, args);
35424514f5e3Sopenharmony_ci}
35434514f5e3Sopenharmony_ci
35444514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetBuiltinId(GateRef method)
35454514f5e3Sopenharmony_ci{
35464514f5e3Sopenharmony_ci    GateRef extraLiteralInfoOffset = IntPtr(Method::EXTRA_LITERAL_INFO_OFFSET);
35474514f5e3Sopenharmony_ci    GateRef extraLiteralInfo = Load(VariableType::INT64(), method, extraLiteralInfoOffset);
35484514f5e3Sopenharmony_ci    return TruncInt64ToInt32(Int64And(
35494514f5e3Sopenharmony_ci        Int64LSR(extraLiteralInfo, Int64(MethodLiteral::BuiltinIdBits::START_BIT)),
35504514f5e3Sopenharmony_ci        Int64((1LU << MethodLiteral::BuiltinIdBits::SIZE) - 1)));
35514514f5e3Sopenharmony_ci}
35524514f5e3Sopenharmony_ci
35534514f5e3Sopenharmony_ciinline GateRef StubBuilder::ComputeSizeUtf8(GateRef length)
35544514f5e3Sopenharmony_ci{
35554514f5e3Sopenharmony_ci    return PtrAdd(IntPtr(LineEcmaString::DATA_OFFSET), length);
35564514f5e3Sopenharmony_ci}
35574514f5e3Sopenharmony_ci
35584514f5e3Sopenharmony_ciinline GateRef StubBuilder::ComputeSizeUtf16(GateRef length)
35594514f5e3Sopenharmony_ci{
35604514f5e3Sopenharmony_ci    return PtrAdd(IntPtr(LineEcmaString::DATA_OFFSET), PtrMul(length, IntPtr(sizeof(uint16_t))));
35614514f5e3Sopenharmony_ci}
35624514f5e3Sopenharmony_ci
35634514f5e3Sopenharmony_ciinline GateRef StubBuilder::AlignUp(GateRef x, GateRef alignment)
35644514f5e3Sopenharmony_ci{
35654514f5e3Sopenharmony_ci    GateRef x1 = PtrAdd(x, PtrSub(alignment, IntPtr(1)));
35664514f5e3Sopenharmony_ci    return IntPtrAnd(x1, IntPtrNot(PtrSub(alignment, IntPtr(1))));
35674514f5e3Sopenharmony_ci}
35684514f5e3Sopenharmony_ci
35694514f5e3Sopenharmony_ciinline void StubBuilder::SetLength(GateRef glue, GateRef str, GateRef length, bool compressed)
35704514f5e3Sopenharmony_ci{
35714514f5e3Sopenharmony_ci    GateRef len = Int32LSL(length, Int32(EcmaString::STRING_LENGTH_SHIFT_COUNT));
35724514f5e3Sopenharmony_ci    GateRef mixLength;
35734514f5e3Sopenharmony_ci    if (compressed) {
35744514f5e3Sopenharmony_ci        mixLength = Int32Or(len, Int32(EcmaString::STRING_COMPRESSED));
35754514f5e3Sopenharmony_ci    } else {
35764514f5e3Sopenharmony_ci        mixLength = Int32Or(len, Int32(EcmaString::STRING_UNCOMPRESSED));
35774514f5e3Sopenharmony_ci    }
35784514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, str, IntPtr(EcmaString::MIX_LENGTH_OFFSET), mixLength);
35794514f5e3Sopenharmony_ci}
35804514f5e3Sopenharmony_ci
35814514f5e3Sopenharmony_ciinline void StubBuilder::SetLength(GateRef glue, GateRef str, GateRef length, GateRef isCompressed)
35824514f5e3Sopenharmony_ci{
35834514f5e3Sopenharmony_ci    GateRef len = Int32LSL(length, Int32(EcmaString::STRING_LENGTH_SHIFT_COUNT));
35844514f5e3Sopenharmony_ci    GateRef mixLength = Int32Or(len, isCompressed);
35854514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, str, IntPtr(EcmaString::MIX_LENGTH_OFFSET), mixLength);
35864514f5e3Sopenharmony_ci}
35874514f5e3Sopenharmony_ci
35884514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsIntegerString(GateRef string)
35894514f5e3Sopenharmony_ci{
35904514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsIntegerString(string);
35914514f5e3Sopenharmony_ci}
35924514f5e3Sopenharmony_ci
35934514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetRawHashFromString(GateRef value)
35944514f5e3Sopenharmony_ci{
35954514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetRawHashFromString(value);
35964514f5e3Sopenharmony_ci}
35974514f5e3Sopenharmony_ci
35984514f5e3Sopenharmony_ciinline void StubBuilder::SetRawHashcode(GateRef glue, GateRef str, GateRef rawHashcode, GateRef isInteger)
35994514f5e3Sopenharmony_ci{
36004514f5e3Sopenharmony_ci    env_->GetBuilder()->SetRawHashcode(glue, str, rawHashcode, isInteger);
36014514f5e3Sopenharmony_ci}
36024514f5e3Sopenharmony_ci
36034514f5e3Sopenharmony_ciinline GateRef StubBuilder::TryGetHashcodeFromString(GateRef string)
36044514f5e3Sopenharmony_ci{
36054514f5e3Sopenharmony_ci    return env_->GetBuilder()->TryGetHashcodeFromString(string);
36064514f5e3Sopenharmony_ci}
36074514f5e3Sopenharmony_ci
36084514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetMixHashcode(GateRef string)
36094514f5e3Sopenharmony_ci{
36104514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), string, IntPtr(EcmaString::MIX_HASHCODE_OFFSET));
36114514f5e3Sopenharmony_ci}
36124514f5e3Sopenharmony_ci
36134514f5e3Sopenharmony_ciinline void StubBuilder::SetElementsKindToJSHClass(GateRef glue, GateRef jsHclass, GateRef elementsKind)
36144514f5e3Sopenharmony_ci{
36154514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), jsHclass, IntPtr(JSHClass::BIT_FIELD_OFFSET));
36164514f5e3Sopenharmony_ci    GateRef encodeValue = Int32LSL(elementsKind, Int32(JSHClass::ElementsKindBits::START_BIT));
36174514f5e3Sopenharmony_ci    GateRef mask = Int32(((1LU << JSHClass::ElementsKindBits::SIZE) - 1) << JSHClass::ElementsKindBits::START_BIT);
36184514f5e3Sopenharmony_ci    bitfield = Int32Or(Int32And(bitfield, Int32Not(mask)), encodeValue);
36194514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, jsHclass, IntPtr(JSHClass::BIT_FIELD_OFFSET), bitfield);
36204514f5e3Sopenharmony_ci}
36214514f5e3Sopenharmony_ci
36224514f5e3Sopenharmony_ciinline void StubBuilder::SetExtensibleToBitfield(GateRef glue, GateRef obj, bool isExtensible)
36234514f5e3Sopenharmony_ci{
36244514f5e3Sopenharmony_ci    GateRef jsHclass = LoadHClass(obj);
36254514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), jsHclass, IntPtr(JSHClass::BIT_FIELD_OFFSET));
36264514f5e3Sopenharmony_ci    GateRef boolVal = Boolean(isExtensible);
36274514f5e3Sopenharmony_ci    GateRef boolToInt32 = ZExtInt1ToInt32(boolVal);
36284514f5e3Sopenharmony_ci    GateRef encodeValue = Int32LSL(boolToInt32, Int32(JSHClass::ExtensibleBit::START_BIT));
36294514f5e3Sopenharmony_ci    GateRef mask = Int32(((1LU << JSHClass::ExtensibleBit::SIZE) - 1) << JSHClass::ExtensibleBit::START_BIT);
36304514f5e3Sopenharmony_ci    bitfield = Int32Or(Int32And(bitfield, Int32Not(mask)), encodeValue);
36314514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, jsHclass, IntPtr(JSHClass::BIT_FIELD_OFFSET), bitfield);
36324514f5e3Sopenharmony_ci}
36334514f5e3Sopenharmony_ci
36344514f5e3Sopenharmony_ciinline void StubBuilder::SetCallableToBitfield(GateRef glue, GateRef obj, bool isCallable)
36354514f5e3Sopenharmony_ci{
36364514f5e3Sopenharmony_ci    GateRef jsHclass = LoadHClass(obj);
36374514f5e3Sopenharmony_ci    GateRef bitfield = Load(VariableType::INT32(), jsHclass, IntPtr(JSHClass::BIT_FIELD_OFFSET));
36384514f5e3Sopenharmony_ci    GateRef boolVal = Boolean(isCallable);
36394514f5e3Sopenharmony_ci    GateRef boolToInt32 = ZExtInt1ToInt32(boolVal);
36404514f5e3Sopenharmony_ci    GateRef encodeValue = Int32LSL(boolToInt32, Int32(JSHClass::CallableBit::START_BIT));
36414514f5e3Sopenharmony_ci    GateRef mask = Int32(((1LU << JSHClass::CallableBit::SIZE) - 1) << JSHClass::CallableBit::START_BIT);
36424514f5e3Sopenharmony_ci    bitfield = Int32Or(Int32And(bitfield, Int32Not(mask)), encodeValue);
36434514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, jsHclass, IntPtr(JSHClass::BIT_FIELD_OFFSET), bitfield);
36444514f5e3Sopenharmony_ci}
36454514f5e3Sopenharmony_ci
36464514f5e3Sopenharmony_ciinline void StubBuilder::Comment(GateRef glue, const std::string &str)
36474514f5e3Sopenharmony_ci{
36484514f5e3Sopenharmony_ci    CallNGCRuntime(glue, RTSTUB_ID(Comment), { StringPtr(str) });
36494514f5e3Sopenharmony_ci}
36504514f5e3Sopenharmony_ci
36514514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsStableElements(GateRef hClass)
36524514f5e3Sopenharmony_ci{
36534514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsStableElements(hClass);
36544514f5e3Sopenharmony_ci}
36554514f5e3Sopenharmony_ci
36564514f5e3Sopenharmony_ciinline GateRef StubBuilder::HasConstructorByHClass(GateRef hClass)
36574514f5e3Sopenharmony_ci{
36584514f5e3Sopenharmony_ci    return env_->GetBuilder()->HasConstructorByHClass(hClass);
36594514f5e3Sopenharmony_ci}
36604514f5e3Sopenharmony_ci
36614514f5e3Sopenharmony_ciinline GateRef StubBuilder::HasConstructor(GateRef object)
36624514f5e3Sopenharmony_ci{
36634514f5e3Sopenharmony_ci    return env_->GetBuilder()->HasConstructor(object);
36644514f5e3Sopenharmony_ci}
36654514f5e3Sopenharmony_ci
36664514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsStableArguments(GateRef hClass)
36674514f5e3Sopenharmony_ci{
36684514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsStableArguments(hClass);
36694514f5e3Sopenharmony_ci}
36704514f5e3Sopenharmony_ci
36714514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsStableArray(GateRef hClass)
36724514f5e3Sopenharmony_ci{
36734514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsStableArray(hClass);
36744514f5e3Sopenharmony_ci}
36754514f5e3Sopenharmony_ci
36764514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsTypedArray(GateRef obj)
36774514f5e3Sopenharmony_ci{
36784514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsTypedArray(obj);
36794514f5e3Sopenharmony_ci}
36804514f5e3Sopenharmony_ci
36814514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetProfileTypeInfo(GateRef jsFunc)
36824514f5e3Sopenharmony_ci{
36834514f5e3Sopenharmony_ci    GateRef raw = Load(VariableType::JS_POINTER(), jsFunc, IntPtr(JSFunction::RAW_PROFILE_TYPE_INFO_OFFSET));
36844514f5e3Sopenharmony_ci    return Load(VariableType::JS_POINTER(), raw, IntPtr(ProfileTypeInfoCell::VALUE_OFFSET));
36854514f5e3Sopenharmony_ci}
36864514f5e3Sopenharmony_ci
36874514f5e3Sopenharmony_ciinline void StubBuilder::CheckDetectorName(GateRef glue, GateRef key, Label *fallthrough, Label *slow)
36884514f5e3Sopenharmony_ci{
36894514f5e3Sopenharmony_ci    GateRef glueGlobalEnvOffset = IntPtr(JSThread::GlueData::GetGlueGlobalEnvOffset(env_->Is32Bit()));
36904514f5e3Sopenharmony_ci    GateRef glueGlobalEnv = Load(VariableType::NATIVE_POINTER(), glue, glueGlobalEnvOffset);
36914514f5e3Sopenharmony_ci    GateRef keyAddr = ChangeTaggedPointerToInt64(key);
36924514f5e3Sopenharmony_ci    GateRef firstDetectorName = GetGlobalEnvValue(
36934514f5e3Sopenharmony_ci        VariableType::INT64(), glueGlobalEnv, GlobalEnv::FIRST_DETECTOR_SYMBOL_INDEX);
36944514f5e3Sopenharmony_ci    GateRef lastDetectorName = GetGlobalEnvValue(
36954514f5e3Sopenharmony_ci        VariableType::INT64(), glueGlobalEnv, GlobalEnv::LAST_DETECTOR_SYMBOL_INDEX);
36964514f5e3Sopenharmony_ci    GateRef isDetectorName = BitAnd(Int64UnsignedLessThanOrEqual(firstDetectorName, keyAddr),
36974514f5e3Sopenharmony_ci                                    Int64UnsignedLessThanOrEqual(keyAddr, lastDetectorName));
36984514f5e3Sopenharmony_ci    Label checkCommonDetector(env_);
36994514f5e3Sopenharmony_ci    BRANCH(isDetectorName, slow, &checkCommonDetector);
37004514f5e3Sopenharmony_ci    Bind(&checkCommonDetector);
37014514f5e3Sopenharmony_ci    auto gFlagsStr = GetGlobalConstantValue(
37024514f5e3Sopenharmony_ci        VariableType::JS_POINTER(), glue, ConstantIndex::FLAGS_INDEX);
37034514f5e3Sopenharmony_ci    GateRef isFlagsStr = Equal(key, gFlagsStr);
37044514f5e3Sopenharmony_ci    BRANCH(isFlagsStr, slow, fallthrough);
37054514f5e3Sopenharmony_ci}
37064514f5e3Sopenharmony_ci
37074514f5e3Sopenharmony_ciinline GateRef StubBuilder::LoadPfHeaderFromConstPool(GateRef jsFunc)
37084514f5e3Sopenharmony_ci{
37094514f5e3Sopenharmony_ci    GateRef method = Load(VariableType::JS_ANY(), jsFunc, IntPtr(JSFunctionBase::METHOD_OFFSET));
37104514f5e3Sopenharmony_ci    GateRef constPool = Load(VariableType::JS_ANY(), method, IntPtr(Method::CONSTANT_POOL_OFFSET));
37114514f5e3Sopenharmony_ci    auto length = GetLengthOfTaggedArray(constPool);
37124514f5e3Sopenharmony_ci    auto index = Int32Sub(length, Int32(ConstantPool::JS_PANDA_FILE_INDEX));
37134514f5e3Sopenharmony_ci    auto jsPandaFile = GetValueFromTaggedArray(constPool, index);
37144514f5e3Sopenharmony_ci    auto jsPfAddr = ChangeInt64ToIntPtr(ChangeTaggedPointerToInt64(jsPandaFile));
37154514f5e3Sopenharmony_ci    auto pfAddr = Load(VariableType::NATIVE_POINTER(), jsPfAddr, Int32(JSPandaFile::PF_OFFSET));
37164514f5e3Sopenharmony_ci    auto pfHeader = Load(VariableType::NATIVE_POINTER(), pfAddr, Int32(0));
37174514f5e3Sopenharmony_ci    return pfHeader;
37184514f5e3Sopenharmony_ci}
37194514f5e3Sopenharmony_ci
37204514f5e3Sopenharmony_ciinline GateRef StubBuilder::LoadHCIndexInfosFromConstPool(GateRef jsFunc)
37214514f5e3Sopenharmony_ci{
37224514f5e3Sopenharmony_ci    GateRef method = Load(VariableType::JS_ANY(), jsFunc, IntPtr(JSFunctionBase::METHOD_OFFSET));
37234514f5e3Sopenharmony_ci    GateRef constPool = Load(VariableType::JS_ANY(), method, IntPtr(Method::CONSTANT_POOL_OFFSET));
37244514f5e3Sopenharmony_ci    auto length = GetLengthOfTaggedArray(constPool);
37254514f5e3Sopenharmony_ci    auto index = Int32Sub(length, Int32(ConstantPool::CONSTANT_INDEX_INFO_INDEX));
37264514f5e3Sopenharmony_ci    return GetValueFromTaggedArray(constPool, index);
37274514f5e3Sopenharmony_ci}
37284514f5e3Sopenharmony_ci
37294514f5e3Sopenharmony_ciinline GateRef StubBuilder::LoadHCIndexFromConstPool(
37304514f5e3Sopenharmony_ci    GateRef cachedArray, GateRef cachedLength, GateRef traceId, Label *miss)
37314514f5e3Sopenharmony_ci{
37324514f5e3Sopenharmony_ci    auto env = GetEnvironment();
37334514f5e3Sopenharmony_ci    Label subEntry(env);
37344514f5e3Sopenharmony_ci    env->SubCfgEntry(&subEntry);
37354514f5e3Sopenharmony_ci
37364514f5e3Sopenharmony_ci    DEFVARIABLE(bcOffset, VariableType::INT32(), Int32(0));
37374514f5e3Sopenharmony_ci    DEFVARIABLE(constantIndex, VariableType::INT32(),
37384514f5e3Sopenharmony_ci        Int32(static_cast<int32_t>(ConstantIndex::ELEMENT_HOLE_TAGGED_HCLASS_INDEX)));
37394514f5e3Sopenharmony_ci    DEFVARIABLE(i, VariableType::INT32(), Int32(0));
37404514f5e3Sopenharmony_ci
37414514f5e3Sopenharmony_ci    Label loopHead(env);
37424514f5e3Sopenharmony_ci    Label loopEnd(env);
37434514f5e3Sopenharmony_ci    Label afterLoop(env);
37444514f5e3Sopenharmony_ci    Label matchSuccess(env);
37454514f5e3Sopenharmony_ci    Label afterUpdate(env);
37464514f5e3Sopenharmony_ci    BRANCH(Int32LessThan(*i, cachedLength), &loopHead, miss);
37474514f5e3Sopenharmony_ci    LoopBegin(&loopHead);
37484514f5e3Sopenharmony_ci    bcOffset = GetInt32OfTInt(GetValueFromTaggedArray(cachedArray, *i));
37494514f5e3Sopenharmony_ci    BRANCH(Int32Equal(*bcOffset, traceId), &matchSuccess, &afterUpdate);
37504514f5e3Sopenharmony_ci    Bind(&matchSuccess);
37514514f5e3Sopenharmony_ci    constantIndex = GetInt32OfTInt(GetValueFromTaggedArray(cachedArray, Int32Add(*i, Int32(1))));
37524514f5e3Sopenharmony_ci    Jump(&afterLoop);
37534514f5e3Sopenharmony_ci    Bind(&afterUpdate);
37544514f5e3Sopenharmony_ci    i = Int32Add(*i, Int32(2)); // 2 : skip traceId and constantIndex
37554514f5e3Sopenharmony_ci    BRANCH(Int32LessThan(*i, cachedLength), &loopEnd, miss);
37564514f5e3Sopenharmony_ci    Bind(&loopEnd);
37574514f5e3Sopenharmony_ci    LoopEnd(&loopHead);
37584514f5e3Sopenharmony_ci    Bind(&afterLoop);
37594514f5e3Sopenharmony_ci    auto ret = *constantIndex;
37604514f5e3Sopenharmony_ci
37614514f5e3Sopenharmony_ci    env->SubCfgExit();
37624514f5e3Sopenharmony_ci    return ret;
37634514f5e3Sopenharmony_ci}
37644514f5e3Sopenharmony_ci
37654514f5e3Sopenharmony_ciinline GateRef StubBuilder::RemoveTaggedWeakTag(GateRef weak)
37664514f5e3Sopenharmony_ci{
37674514f5e3Sopenharmony_ci    return Int64ToTaggedPtr(IntPtrAnd(ChangeTaggedPointerToInt64(weak), IntPtr(~JSTaggedValue::TAG_WEAK)));
37684514f5e3Sopenharmony_ci}
37694514f5e3Sopenharmony_ci
37704514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetAttrIndex(GateRef index)
37714514f5e3Sopenharmony_ci{
37724514f5e3Sopenharmony_ci    return Int32Add(Int32LSL(index, Int32(LayoutInfo::ELEMENTS_INDEX_LOG2)), Int32(LayoutInfo::ATTR_INDEX_OFFSET));
37734514f5e3Sopenharmony_ci}
37744514f5e3Sopenharmony_ci
37754514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetKeyIndex(GateRef index)
37764514f5e3Sopenharmony_ci{
37774514f5e3Sopenharmony_ci    return Int32LSL(index, Int32(LayoutInfo::ELEMENTS_INDEX_LOG2));
37784514f5e3Sopenharmony_ci}
37794514f5e3Sopenharmony_ci
37804514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetAttr(GateRef layoutInfo, GateRef index)
37814514f5e3Sopenharmony_ci{
37824514f5e3Sopenharmony_ci    GateRef fixedIdx = GetAttrIndex(index);
37834514f5e3Sopenharmony_ci    return GetInt64OfTInt(GetValueFromTaggedArray(layoutInfo, fixedIdx));
37844514f5e3Sopenharmony_ci}
37854514f5e3Sopenharmony_ci
37864514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetKey(GateRef layoutInfo, GateRef index)
37874514f5e3Sopenharmony_ci{
37884514f5e3Sopenharmony_ci    GateRef fixedIdx = GetKeyIndex(index);
37894514f5e3Sopenharmony_ci    return GetValueFromTaggedArray(layoutInfo, fixedIdx);
37904514f5e3Sopenharmony_ci}
37914514f5e3Sopenharmony_ci
37924514f5e3Sopenharmony_ciinline GateRef StubBuilder::IsMarkerCellValid(GateRef cell)
37934514f5e3Sopenharmony_ci{
37944514f5e3Sopenharmony_ci    return env_->GetBuilder()->IsMarkerCellValid(cell);
37954514f5e3Sopenharmony_ci}
37964514f5e3Sopenharmony_ci
37974514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetAccessorHasChanged(GateRef obj)
37984514f5e3Sopenharmony_ci{
37994514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetAccessorHasChanged(obj);
38004514f5e3Sopenharmony_ci}
38014514f5e3Sopenharmony_ci
38024514f5e3Sopenharmony_ciinline GateRef StubBuilder::ComputeTaggedTypedArraySize(GateRef elementSize, GateRef length)
38034514f5e3Sopenharmony_ci{
38044514f5e3Sopenharmony_ci    return PtrAdd(IntPtr(ByteArray::DATA_OFFSET), PtrMul(elementSize, length));
38054514f5e3Sopenharmony_ci}
38064514f5e3Sopenharmony_ci
38074514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetViewedArrayBuffer(GateRef dataView)
38084514f5e3Sopenharmony_ci{
38094514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), dataView,
38104514f5e3Sopenharmony_ci                IntPtr(JSDataView::VIEW_ARRAY_BUFFER_OFFSET));
38114514f5e3Sopenharmony_ci}
38124514f5e3Sopenharmony_ci
38134514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetByteOffset(GateRef dataView)
38144514f5e3Sopenharmony_ci{
38154514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), dataView,
38164514f5e3Sopenharmony_ci                IntPtr(JSDataView::BYTE_OFFSET_OFFSET));
38174514f5e3Sopenharmony_ci}
38184514f5e3Sopenharmony_ci
38194514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetByteLength(GateRef dataView)
38204514f5e3Sopenharmony_ci{
38214514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), dataView,
38224514f5e3Sopenharmony_ci                IntPtr(JSDataView::BYTE_LENGTH_OFFSET));
38234514f5e3Sopenharmony_ci}
38244514f5e3Sopenharmony_ci
38254514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetArrayBufferData(GateRef buffer)
38264514f5e3Sopenharmony_ci{
38274514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSArrayBuffer::DATA_OFFSET);
38284514f5e3Sopenharmony_ci    return Load(VariableType::JS_ANY(), buffer, offset);
38294514f5e3Sopenharmony_ci}
38304514f5e3Sopenharmony_ci
38314514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetArrayBufferByteLength(GateRef buffer)
38324514f5e3Sopenharmony_ci{
38334514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSArrayBuffer::BYTE_LENGTH_OFFSET);
38344514f5e3Sopenharmony_ci    return Load(VariableType::INT32(), buffer, offset);
38354514f5e3Sopenharmony_ci}
38364514f5e3Sopenharmony_ci
38374514f5e3Sopenharmony_ciinline void StubBuilder::SetArrayBufferByteLength(GateRef glue, GateRef buffer, GateRef length)
38384514f5e3Sopenharmony_ci{
38394514f5e3Sopenharmony_ci    GateRef offset = IntPtr(JSArrayBuffer::BYTE_LENGTH_OFFSET);
38404514f5e3Sopenharmony_ci    Store(VariableType::INT32(), glue, buffer, offset, length);
38414514f5e3Sopenharmony_ci}
38424514f5e3Sopenharmony_ci
38434514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLastLeaveFrame(GateRef glue)
38444514f5e3Sopenharmony_ci{
38454514f5e3Sopenharmony_ci    bool isArch32 = GetEnvironment()->Is32Bit();
38464514f5e3Sopenharmony_ci    GateRef spOffset = IntPtr(JSThread::GlueData::GetLeaveFrameOffset(isArch32));
38474514f5e3Sopenharmony_ci    return Load(VariableType::NATIVE_POINTER(), glue, spOffset);
38484514f5e3Sopenharmony_ci}
38494514f5e3Sopenharmony_ci
38504514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPropertiesCache(GateRef glue)
38514514f5e3Sopenharmony_ci{
38524514f5e3Sopenharmony_ci    GateRef currentContextOffset = IntPtr(JSThread::GlueData::GetCurrentContextOffset(env_->Is32Bit()));
38534514f5e3Sopenharmony_ci    GateRef currentContext = Load(VariableType::NATIVE_POINTER(), glue, currentContextOffset);
38544514f5e3Sopenharmony_ci    return Load(VariableType::NATIVE_POINTER(), currentContext, IntPtr(0));
38554514f5e3Sopenharmony_ci}
38564514f5e3Sopenharmony_ci
38574514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSortedKey(GateRef layoutInfo, GateRef index)
38584514f5e3Sopenharmony_ci{
38594514f5e3Sopenharmony_ci    GateRef fixedIdx = GetSortedIndex(layoutInfo, index);
38604514f5e3Sopenharmony_ci    return GetKey(layoutInfo, fixedIdx);
38614514f5e3Sopenharmony_ci}
38624514f5e3Sopenharmony_ci
38634514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetSortedIndex(GateRef layoutInfo, GateRef index)
38644514f5e3Sopenharmony_ci{
38654514f5e3Sopenharmony_ci    return GetSortedIndex(GetAttr(layoutInfo, index));
38664514f5e3Sopenharmony_ci}
38674514f5e3Sopenharmony_ci
38684514f5e3Sopenharmony_ciinline void StubBuilder::SetToPropertiesCache(GateRef glue, GateRef cache, GateRef cls, GateRef key, GateRef result,
38694514f5e3Sopenharmony_ci                                              GateRef hir)
38704514f5e3Sopenharmony_ci{
38714514f5e3Sopenharmony_ci    GateRef hash = HashFromHclassAndKey(glue, cls, key, hir);
38724514f5e3Sopenharmony_ci    GateRef prop =
38734514f5e3Sopenharmony_ci        PtrAdd(cache, PtrMul(ZExtInt32ToPtr(hash), IntPtr(PropertiesCache::PropertyKey::GetPropertyKeySize())));
38744514f5e3Sopenharmony_ci    StoreWithoutBarrier(VariableType::JS_POINTER(), prop, IntPtr(PropertiesCache::PropertyKey::GetHclassOffset()), cls);
38754514f5e3Sopenharmony_ci    StoreWithoutBarrier(VariableType::JS_ANY(), prop, IntPtr(PropertiesCache::PropertyKey::GetKeyOffset()), key);
38764514f5e3Sopenharmony_ci    StoreWithoutBarrier(VariableType::INT32(), prop, IntPtr(PropertiesCache::PropertyKey::GetResultsOffset()), result);
38774514f5e3Sopenharmony_ci}
38784514f5e3Sopenharmony_ci
38794514f5e3Sopenharmony_ciinline void StubBuilder::StoreWithoutBarrier(VariableType type, GateRef base, GateRef offset, GateRef value)
38804514f5e3Sopenharmony_ci{
38814514f5e3Sopenharmony_ci    GateRef addr = PtrAdd(base, offset);
38824514f5e3Sopenharmony_ci    env_->GetBuilder()->StoreWithoutBarrier(type, addr, value);
38834514f5e3Sopenharmony_ci}
38844514f5e3Sopenharmony_ci
38854514f5e3Sopenharmony_ciinline GateRef StubBuilder::HashFromHclassAndKey(GateRef glue, GateRef cls, GateRef key, GateRef hir)
38864514f5e3Sopenharmony_ci{
38874514f5e3Sopenharmony_ci    GateRef clsHash = Int32LSR(ChangeIntPtrToInt32(TaggedCastToIntPtr(cls)), Int32(3));  // skip 8bytes
38884514f5e3Sopenharmony_ci    GateRef keyHash = GetKeyHashCode(glue, key, hir);
38894514f5e3Sopenharmony_ci    return Int32And(Int32Xor(clsHash, keyHash), Int32(PropertiesCache::CACHE_LENGTH_MASK));
38904514f5e3Sopenharmony_ci}
38914514f5e3Sopenharmony_ci
38924514f5e3Sopenharmony_ciinline GateRef StubBuilder::OrdinaryNewJSObjectCreate(GateRef glue, GateRef proto)
38934514f5e3Sopenharmony_ci{
38944514f5e3Sopenharmony_ci    return env_->GetBuilder()->OrdinaryNewJSObjectCreate(glue, proto);
38954514f5e3Sopenharmony_ci}
38964514f5e3Sopenharmony_ci
38974514f5e3Sopenharmony_ciinline GateRef StubBuilder::NewJSPrimitiveRef(GateRef glue, size_t index, GateRef obj)
38984514f5e3Sopenharmony_ci{
38994514f5e3Sopenharmony_ci    return env_->GetBuilder()->NewJSPrimitiveRef(glue, index, obj);
39004514f5e3Sopenharmony_ci}
39014514f5e3Sopenharmony_ci
39024514f5e3Sopenharmony_ciinline GateRef StubBuilder::ToObject(GateRef glue, GateRef obj)
39034514f5e3Sopenharmony_ci{
39044514f5e3Sopenharmony_ci    return env_->GetBuilder()->ToObject(glue, obj);
39054514f5e3Sopenharmony_ci}
39064514f5e3Sopenharmony_ci
39074514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetPrototype(GateRef glue, GateRef object)
39084514f5e3Sopenharmony_ci{
39094514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetPrototype(glue, object);
39104514f5e3Sopenharmony_ci}
39114514f5e3Sopenharmony_ci
39124514f5e3Sopenharmony_ciinline GateRef StubBuilder::GetLengthOfJSArray(GateRef array)
39134514f5e3Sopenharmony_ci{
39144514f5e3Sopenharmony_ci    return env_->GetBuilder()->GetLengthOfJSArray(array);
39154514f5e3Sopenharmony_ci}
39164514f5e3Sopenharmony_ci} //  namespace panda::ecmascript::kungfu
39174514f5e3Sopenharmony_ci#endif // ECMASCRIPT_COMPILER_STUB_INL_H
3918