• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_ARK_STACKMAP_H
17 #define ECMASCRIPT_ARK_STACKMAP_H
18 
19 #include "ecmascript/stackmap/llvm_stackmap_type.h"
20 
21 namespace panda::ecmascript::kungfu {
22 struct ARKConst {
23     OffsetType offset;
24 };
25 
26 struct StackMapSecHead {
27     uint32_t totalSize;
28     uint32_t callsiteNum;
29     uint32_t callsitStart;
30     uint32_t callsitEnd;
31 };
32 struct CallsiteHead {
33     uint32_t calliteOffset {0}; // relative text start addr
34     uint32_t stackmapOffset {0}; // relative stackmap start addr
35     uint32_t arkStackMapNum {0};
36     uint32_t deoptOffset {0};
37     uint32_t deoptNum {0};
38 };
39 
40 /* <deoptId, kind, value> */
41 struct ARKDeopt {
42     OffsetType Id; // deoptid
43     LocationTy::Kind kind;
44     std::variant<OffsetType, DwarfRegAndOffsetType, LargeInt> value;
45 };
46 
47 struct ARKCallsite {
48     CallsiteHead head;
49     CallSiteInfo stackmaps;
50     std::vector<kungfu::ARKDeopt> callsite2Deopt;
51     bool operator < (const ARKCallsite & x) const
52     {
53         return head.calliteOffset < x.head.calliteOffset;
54     }
55     uint32_t CalHeadSize() const;
56     uint32_t CalStackMapSize() const;
57 };
58 
59 struct ARKCallsiteAOTFileInfo {
60     StackMapSecHead secHead;
61     std::vector<ARKCallsite> callsites;
62 };
63 using ArkStackMap = CallSiteInfo;
64 using CalleeRegAndOffsetVec = std::vector<DwarfRegAndOffsetType>;
65 /*
66 totalSize  callsiteNum callsitStart  callsitEnd
67 -----head1--------
68 -----head2--------
69       |
70       |
71 -----head[N]------
72 
73 -----stackmap1----
74 -----stackmap2----
75       |
76       |
77 -----stackmap2[N]-
78 
79 -----deopt1-----
80 -<deoptid, LocationTy::Kind, LocationTy
81 -          CONSTANT,  <OffsetType OffsetOrSmallConstant>
82 -          INDIRECT   <loc.DwarfRegNum, loc.OffsetOrSmallConstant>
83 -          CONSTANTNDEX <LargeInt>
84 */
85 } // namespace panda::ecmascript::kungfu
86 #endif  // ECMASCRIPT_ARK_STACKMAP_H