github.com/cloudwego/frugal@v0.1.15/internal/atm/ssa/funcdata.go (about) 1 /* 2 * Copyright 2022 ByteDance Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package ssa 18 19 import ( 20 `fmt` 21 `strings` 22 23 `github.com/cloudwego/frugal/internal/rt` 24 ) 25 26 type FuncData struct { 27 Code []byte 28 Layout *FuncLayout 29 Liveness map[Pos]SlotSet 30 StackMap map[uintptr]*rt.StackMap 31 } 32 33 type FuncLayout struct { 34 Ins []IrNode 35 Start map[int]int 36 Block map[int]*BasicBlock 37 } 38 39 func (self *FuncLayout) String() string { 40 ni := len(self.Ins) 41 ns := len(self.Start) 42 ss := make([]string, 0, ni + ns) 43 44 /* print every instruction */ 45 for i, ins := range self.Ins { 46 if bb, ok := self.Block[i]; !ok { 47 ss = append(ss, fmt.Sprintf("%06x | %s", i, ins)) 48 } else { 49 ss = append(ss, fmt.Sprintf("%06x | bb_%d:", i, bb.Id), fmt.Sprintf("%06x | %s", i, ins)) 50 } 51 } 52 53 /* join them together */ 54 return fmt.Sprintf( 55 "FuncLayout {\n%s\n}", 56 strings.Join(ss, "\n"), 57 ) 58 }