goescape

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package goescape analyzes Go storage lifetimes before LLVM lowering. The location graph and solver adapt Go 1.27.3's cmd/compile/internal/escape/{graph,solve,leaks}.go to a frontend-independent representation. SSA construction and backend placement are separate layers.

Index

Constants

View Source
const MaxCacheBytes = 64 << 20
View Source
const Version = 22

Version participates in package fingerprints, including compiler API users that do not supply a development compiler hash. Bump when semantic contracts or placement proofs change incompatibly with previously emitted archives.

Variables

This section is empty.

Functions

func ValidSummary

func ValidSummary(fn *ssa.Function, s Summary) bool

ValidSummary checks the dimensions of a body-independent imported contract. In particular, an unbuilt dependency may not have SSA Params yet.

Types

type Cache

type Cache struct {
	Namespace string
	// BodyKey optionally identifies the exact source/transforms of fn. It must
	// change whenever its SSA operations or operands change. Empty keys use the
	// complete SSA dump. Types, layout policies and dependencies remain hashed.
	BodyKey func(fn *ssa.Function) string
	Load    func(key string) ([]byte, error)
	Store   func(key string, data []byte) error
	Event   func(hit bool)
}

Cache is optional local build-cache storage. I/O errors and invalid records fall back to analysis. Callbacks run on the coordinator, never backend workers.

type Config

type Config struct {
	// Cache optionally persists complete, validated facts for this program.
	Cache *Cache

	// Inspect must reject bodies replaced by linkname, source patches, native
	// declarations or intrinsics unless the replacement itself is being analyzed.
	Inspect func(*ssa.Function) bool
	// External provides a validated summary for an uninspectable function.
	// Missing contracts conservatively publish every argument.
	External func(*ssa.Function) (Summary, bool)
	// ExternalKey identifies the validated component that compiled an opaque
	// dependency. It keeps callers' component keys stable when only bodies
	// have been replaced by exported contracts.
	ExternalKey func(*ssa.Function) string
	// IndirectInterface describes the actual interface data representation.
	// The default uses two-word Go function values, as LLGo does.
	IndirectInterface func(types.Type) bool
	// ForceHeap runs before solving, so pointers inside forced-heap storage
	// also escape. An empty reason permits ordinary lifetime analysis.
	ForceHeap func(ssa.Instruction, types.Type) string
	// StackLayout describes newly introduced stack storage. Zero size needs
	// no reservation; alignment must be a positive power of two.
	StackLayout func(ssa.Instruction, types.Type) (size, alignment uint64)
	// LocalStackLayout accounts for newly required root slots of storage
	// already local in Go SSA. The original object bytes are not new storage.
	LocalStackLayout func(ssa.Instruction, types.Type) (size, alignment uint64)
	// MaxStackBytes bounds new storage per function, before final call effects.
	// Zero leaves the target's existing per-object policy unchanged.
	MaxStackBytes uint64
}

Config supplies the backend's representation and resolved call contracts. Callbacks run synchronously during Analyze. Results do not retain them.

type Decision

type Decision struct {
	Heap   bool
	Reason string
	// ReadOnly permits a proven byte/string conversion to borrow its input.
	ReadOnly bool
}

type Effect

type Effect uint16

Effect describes a minimum indirection depth. Zero means absent; a positive value encodes depth+1. Keeping this encoding makes the zero Summary useful as the initial element of the recursive-group fixed point.

type Parameter

type Parameter struct {
	Heap, Mutator, Callee Effect
	Results               []Effect
}

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is immutable after Analyze returns and may be read by backend workers.

func Analyze

func Analyze(roots []*ssa.Function, config Config) *Result

Analyze follows inspectable static callees and nested functions from roots. Each call SCC reaches a monotone summary fixed point before its callers.

func (*Result) CaptureByValue

func (r *Result) CaptureByValue(v *ssa.FreeVar) bool

CaptureByValue reports whether lowering must store the captured value rather than its variable's address. The shared SSA itself is never rewritten.

func (*Result) ComponentKey

func (r *Result) ComponentKey(fn *ssa.Function) string

func (*Result) Decision

func (r *Result) Decision(site ssa.Instruction) Decision

func (*Result) LookupDecision

func (r *Result) LookupDecision(site ssa.Instruction) (Decision, bool)

LookupDecision distinguishes analyzed objects from bodies that were excluded because their symbols use another ABI or have a replacement implementation.

func (*Result) StackBytes

func (r *Result) StackBytes(fn *ssa.Function) uint64

StackBytes is a conservative reservation for the function's promoted Go objects. Lowering helpers can reserve additional storage from the same budget.

func (*Result) Summary

func (r *Result) Summary(fn *ssa.Function) (Summary, bool)

func (*Result) WriteReport

func (r *Result) WriteReport(w io.Writer, level func(*ssa.Function) int) error

WriteReport prints deterministic frontend storage decisions. level selects functions and verbosity: zero disables output, one prints placements, and higher values include reasons. LLVM may subsequently remove more storage.

type Summary

type Summary struct {
	Parameters []Parameter
}

Summary parameters are receivers/ordinary parameters followed by free vars. Exported copies may be serialized; Analyze validates imported dimensions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL