1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_COMPILER_FUNC_ENTRY_DES_H
17 #define ECMASCRIPT_COMPILER_FUNC_ENTRY_DES_H
18 
19 #include "ecmascript/common.h"
20 #include "ecmascript/compiler/aot_file/executed_memory_allocator.h"
21 #include "ecmascript/compiler/bc_call_signature.h"
22 #include "ecmascript/compiler/call_signature.h"
23 #include "ecmascript/deoptimizer/calleeReg.h"
24 
25 namespace panda::ecmascript {
26 struct FuncEntryDes {
27     using CallSignature = kungfu::CallSignature;
28 
29     uint64_t codeAddr_ {};
30     CallSignature::TargetKind kind_;
31     bool isMainFunc_ {};
32     bool isFastCall_ {};
33     uint32_t indexInKindOrMethodId_ {};
34     uint32_t moduleIndex_ {};
35     uint32_t abcIndexInAi_ {INVALID_INDEX};
36     int fpDeltaPrevFrameSp_ {};
37     uint32_t funcSize_ {};
38     uint32_t calleeRegisterNum_ {};
39     int32_t CalleeReg2Offset_[2 * kungfu::MAX_CALLEE_SAVE_REIGISTER_NUM];
IsStubpanda::ecmascript::FuncEntryDes40     bool IsStub() const
41     {
42         return CallSignature::TargetKind::STUB_BEGIN <= kind_ && kind_ < CallSignature::TargetKind::STUB_END;
43     }
IsBCStubpanda::ecmascript::FuncEntryDes44     bool IsBCStub() const
45     {
46         return CallSignature::TargetKind::BCHANDLER_BEGIN <= kind_ &&
47                kind_ < CallSignature::TargetKind::BCHANDLER_END;
48     }
IsBCHandlerStubpanda::ecmascript::FuncEntryDes49     bool IsBCHandlerStub() const
50     {
51         return (kind_ == CallSignature::TargetKind::BYTECODE_HANDLER);
52     }
IsBuiltinsStubpanda::ecmascript::FuncEntryDes53     bool IsBuiltinsStub() const
54     {
55         return (kind_ == CallSignature::TargetKind::BUILTINS_STUB ||
56                 kind_ == CallSignature::TargetKind::BUILTINS_WITH_ARGV_STUB);
57     }
58 
IsCommonStubpanda::ecmascript::FuncEntryDes59     bool IsCommonStub() const
60     {
61         return (kind_ == CallSignature::TargetKind::COMMON_STUB);
62     }
63 
IsBaselineStubpanda::ecmascript::FuncEntryDes64     bool IsBaselineStub() const
65     {
66         return (kind_ == CallSignature::TargetKind::BASELINE_STUB);
67     }
IsGeneralRTStubpanda::ecmascript::FuncEntryDes68     bool IsGeneralRTStub() const
69     {
70         return (kind_ >= CallSignature::TargetKind::RUNTIME_STUB && kind_ <= CallSignature::TargetKind::DEOPT_STUB);
71     }
72 };
73 }  // namespace panda::ecmascript
74 #endif  // ECMASCRIPT_COMPILER_FUNC_ENTRY_DES_H
75 
76