github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/liveness/plive.go (about)

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Garbage collector liveness bitmap generation.
     6  
     7  // The command line flag -live causes this code to print debug information.
     8  // The levels are:
     9  //
    10  //	-live (aka -live=1): print liveness lists as code warnings at safe points
    11  //	-live=2: print an assembly listing with liveness annotations
    12  //
    13  // Each level includes the earlier output as well.
    14  
    15  package liveness
    16  
    17  import (
    18  	"github.com/shogo82148/std/cmd/compile/internal/abi"
    19  	"github.com/shogo82148/std/cmd/compile/internal/ir"
    20  	"github.com/shogo82148/std/cmd/compile/internal/objw"
    21  	"github.com/shogo82148/std/cmd/compile/internal/ssa"
    22  )
    23  
    24  // Map maps from *ssa.Value to StackMapIndex.
    25  // Also keeps track of unsafe ssa.Values and ssa.Blocks.
    26  // (unsafe = can't be interrupted during GC.)
    27  type Map struct {
    28  	Vals         map[ssa.ID]objw.StackMapIndex
    29  	UnsafeVals   map[ssa.ID]bool
    30  	UnsafeBlocks map[ssa.ID]bool
    31  	// The set of live, pointer-containing variables at the DeferReturn
    32  	// call (only set when open-coded defers are used).
    33  	DeferReturn objw.StackMapIndex
    34  }
    35  
    36  func (m Map) Get(v *ssa.Value) objw.StackMapIndex
    37  
    38  func (m Map) GetUnsafe(v *ssa.Value) bool
    39  
    40  func (m Map) GetUnsafeBlock(b *ssa.Block) bool
    41  
    42  // IsUnsafe indicates that all points in this function are
    43  // unsafe-points.
    44  func IsUnsafe(f *ssa.Func) bool
    45  
    46  // Entry pointer for Compute analysis. Solves for the Compute of
    47  // pointer variables in the function and emits a runtime data
    48  // structure read by the garbage collector.
    49  // Returns a map from GC safe points to their corresponding stack map index,
    50  // and a map that contains all input parameters that may be partially live.
    51  func Compute(curfn *ir.Func, f *ssa.Func, stkptrsize int64, pp *objw.Progs) (Map, map[*ir.Name]bool)
    52  
    53  // WriteFuncMap writes the pointer bitmaps for bodyless function fn's
    54  // inputs and outputs as the value of symbol <fn>.args_stackmap.
    55  // If fn has outputs, two bitmaps are written, otherwise just one.
    56  func WriteFuncMap(fn *ir.Func, abiInfo *abi.ABIParamResultInfo)