upfront

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChAliasingInfo = &channelAliasingInfo{}
View Source
var (
	ChannelNames = make(map[token.Pos]string)
)

Functions

func Andersen

func Andersen(prog *ssa.Program, mains []*ssa.Package, include IncludeType) *pointer.Result

func CollectNames

func CollectNames(pkgs []*packages.Package)

func GetPtsToSets

func GetPtsToSets(prog *ssa.Program, mains []*ssa.Package) *pointer.Result

func TotalAndersen

func TotalAndersen(prog *ssa.Program, mains []*ssa.Package) *pointer.Result

func Transform

func Transform(c *astutil.Cursor) bool

func UnrollLoops

func UnrollLoops(pkgs []*packages.Package) []*packages.Package

Loop unroller will recursively trasnform the AST, by turning for statements of the form: for init; guard; iter { S } ==> init; { S; iter }; ...; { S; iter }

---------n times-------------

where, given "i" as an iteration index, "i" is not mutated in the body of the loop, and: init - Is an initialization of the form: ---- i := c1 ---- var i := c1, for some constant c1 guard - Is a boolean expression of the form ---- i {<, <=, >=, >} c2 ---- c2 {<, <=, >=, >} i, for some constant c2 iter - Is an interation operation of the form ---- i{++, --} (equivalent with i = i {+, -} 1) ---- i = i {+, -} c3 ---- i = c3 {+, i} i, for some constant c3 And "n" is determined by |c2 - c1| / |c3|

Types

type Access

type Access interface {
	// contains filtered or unexported methods
}

func SplitLabel

func SplitLabel(label *pointer.Label) (ssa.Value, []Access)

type ArrayAccess

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

type ChanNameCollector

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

func (*ChanNameCollector) Visit

func (v *ChanNameCollector) Visit(n ast.Node) ast.Visitor

type ChannelOp

type ChannelOp struct {
	Buffer  ssa.Value
	Send    []ssa.Instruction
	Receive []ssa.Instruction
	Close   []ssa.Instruction
	Make    ssa.Instruction
}

ChannelOp aggregates all possible instructions associated with a MakeChan instruction in the source.

func (*ChannelOp) BufferLabel

func (op *ChannelOp) BufferLabel() string

BufferLabel formats the buffer size to a string.

func (*ChannelOp) String

func (op *ChannelOp) String() (opStr string)

type CtrLocPriorities

type CtrLocPriorities struct {
	FunPriorities   map[*ssa.Function]int
	BlockPriorities map[*ssa.Function][]int
}

func GetCtrLocPriorities

func GetCtrLocPriorities(allFuns map[*ssa.Function]struct{}, scc graph.SCCDecomposition[*ssa.Function]) CtrLocPriorities

Uses the SCC decomposition of the callgraph to assign priorities to ssa.Functions. Functions are assigned priorities in depth-first order. We prioritize "deeper" functions before others. We cannot retrieve allFuns ourselves because importing cfg causes an import cycle.

type FieldAccess

type FieldAccess struct {
	Field string
	// contains filtered or unexported fields
}

type GoCollection

type GoCollection interface {
	HasCycle(*Goro) bool

	FunToGoro(*ssa.Function) *Goro
	FunHasCycle(*ssa.Function) bool
}

type GoCycles

type GoCycles map[*Goro][]*Goro

func (GoCycles) FunHasCycle

func (goros GoCycles) FunHasCycle(f *ssa.Function) bool

func (GoCycles) FunToGoro

func (goros GoCycles) FunToGoro(f *ssa.Function) *Goro

func (GoCycles) HasCycle

func (goro GoCycles) HasCycle(g *Goro) bool

type GoTopology

type GoTopology []*Goro

func CollectGoros

func CollectGoros(result *pointer.Result) (goros GoTopology)

Status: mildly tested

func (GoTopology) Cycles

func (goros GoTopology) Cycles() GoCycles

Calculate cycles in the call graph.

func (GoTopology) FunHasCycle

func (goros GoTopology) FunHasCycle(f *ssa.Function) bool

func (GoTopology) FunToGoro

func (goros GoTopology) FunToGoro(f *ssa.Function) *Goro

func (GoTopology) HasCycle

func (goros GoTopology) HasCycle(g *Goro) bool

func (GoTopology) LogCycles

func (goros GoTopology) LogCycles()

type Goro

type Goro struct {
	Entry             *ssa.Function
	ChannelOperations map[ssa.Value]*ChannelOp
	SpawnedGoroutines []*Goro
	CrossPackageCalls []*Goro
}

Goro describes the structure of the transitive closure of a goroutine.

func (*Goro) ProcessFunction

func (g *Goro) ProcessFunction(fun *ssa.Function, results map[ssa.Value]pointer.Pointer)

ProcessFunction connects channel allocation sites with channel operations in the given function by using the results of the points-to analysis, and adds them to the receiver Goroutine.

func (*Goro) String

func (g *Goro) String() (goroStr string)

type IncludeType

type IncludeType struct {
	All       bool
	Chan      bool
	Interface bool
	Function  bool
	Map       bool
	// Array     bool
	Slice   bool
	Pointer bool
}

Configuration structure determines for values of which types to include queries in the Andersen analysis. Only pointer-like values appear in this list

type TargetType

type TargetType int

func (TargetType) String

func (t TargetType) String() string

type WrittenFields

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

func ComputeWrittenFields

func ComputeWrittenFields(pt *pointer.Result, callDAG graph.SCCDecomposition[*ssa.Function]) WrittenFields

func (WrittenFields) FieldInfo

func (w WrittenFields) FieldInfo(typ *T.Struct, funs map[*ssa.Function]struct{}) (
	isWritten func(fieldIndex int) bool,
)

func (WrittenFields) IsFieldWrittenFromFunction

func (w WrittenFields) IsFieldWrittenFromFunction(fun *ssa.Function, typ *T.Struct, fieldIndex int) bool

func (WrittenFields) MapCombinedInfo

func (w WrittenFields) MapCombinedInfo(funs map[*ssa.Function]struct{}) (
	isUpdated func(v ssa.Value) bool,
)

func (WrittenFields) PointerCombinedInfo

func (w WrittenFields) PointerCombinedInfo(funs map[*ssa.Function]struct{}) (
	isUpdated func(v ssa.Value) bool,
)

func (WrittenFields) SliceCombinedInfo

func (w WrittenFields) SliceCombinedInfo(funs map[*ssa.Function]struct{}) (
	isUpdated func(v ssa.Value) bool,
)

func (WrittenFields) String

func (w WrittenFields) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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