• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-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 #include "code_info.h"
17 #include "utils/bit_memory_region-inl.h"
18 
19 namespace panda::compiler {
20 
Dump(std::ostream & stream) const21 void CodeInfo::Dump(std::ostream &stream) const
22 {
23     stream << "CodeInfo: vregs_num=" << GetHeader().GetVRegsCount() << ", frame_size=" << GetHeader().GetFrameSize()
24            << std::endl;
25     EnumerateTables([this, &stream](size_t index, auto member) {
26         if (HasTable(index)) {
27             const auto &table = this->*member;
28             table.Dump(stream);
29         }
30     });
31 }
32 
Dump(std::ostream & stream,const StackMap & stack_map,Arch arch) const33 void CodeInfo::Dump(std::ostream &stream, const StackMap &stack_map, Arch arch) const
34 {
35     stream << "Stackmap #" << stack_map.GetRow() << ": npc=0x" << std::hex << stack_map.GetNativePcUnpacked(arch)
36            << ", bpc=0x" << std::hex << stack_map.GetBytecodePc();
37     if (stack_map.HasInlineInfoIndex()) {
38         stream << ", inline_depth=" << GetInlineDepth(stack_map) + 1;
39     }
40     if (stack_map.HasRootsRegMaskIndex() || stack_map.HasRootsStackMaskIndex()) {
41         stream << ", roots=[";
42         const char *sep = "";
43         if (stack_map.HasRootsRegMaskIndex()) {
44             stream << "r:0x" << std::hex << GetRootsRegMask(stack_map);
45             sep = ",";
46         }
47         if (stack_map.HasRootsStackMaskIndex()) {
48             auto region = GetRootsStackMask(stack_map);
49             stream << sep << "s:" << region;
50         }
51         stream << "]";
52     }
53     if (stack_map.HasVRegMaskIndex()) {
54         stream << ", vregs=" << GetVRegMask(stack_map);
55     }
56 }
57 
DumpInlineInfo(std::ostream & stream,const StackMap & stack_map,int depth) const58 void CodeInfo::DumpInlineInfo(std::ostream &stream, const StackMap &stack_map, int depth) const
59 {
60     auto ii = GetInlineInfo(stack_map, depth);
61     stream << "InlineInfo #" << depth << ": bpc=0x" << std::hex << ii.GetBytecodePc() << std::dec
62            << ", vregs_num: " << ii.GetVRegsCount();
63 }
64 
65 }  // namespace panda::compiler
66