domain

package
v0.0.0-...-0fc56a9 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoroutineCounter *utils.Counter
View Source
var GuardedAccessCounter *utils.Counter
View Source
var PosIDCounter *utils.Counter

Functions

This section is empty.

Types

type BlockState

type BlockState struct {
	GuardedAccesses   []*GuardedAccess
	Lockset           *Lockset
	DeferredFunctions *stacks.CallCommonStack
}

func CreateBlockState

func CreateBlockState(ga []*GuardedAccess, ls *Lockset, df *stacks.CallCommonStack) *BlockState

func GetEmptyBlockState

func GetEmptyBlockState() *BlockState

func (*BlockState) AddFunctionCallState

func (existingBlock *BlockState) AddFunctionCallState(newBlock *BlockState, shouldMergeLockset bool)

AddFunctionCallState is used to add the state of a function call to the blocks total state when iterating through it. shouldMergeLockset is used depending if the call was using a goroutine or not.

func (*BlockState) Copy

func (existingBlock *BlockState) Copy() *BlockState

func (*BlockState) MergeChildBlock

func (existingBlock *BlockState) MergeChildBlock(newBlock *BlockState)

MergeChildBlock merges child block with it's parent in append-like fashion. A -> B Will Merge B unto A

func (*BlockState) MergeSiblingBlock

func (existingBlock *BlockState) MergeSiblingBlock(newBlock *BlockState)

MergeSiblingBlock merges sibling blocks in merge-like fashion. A -> B

-> C

Will Merge B and C

type Context

type Context struct {
	GoroutineID int
	Clock       VectorClock
	StackTrace  *stacks.IntStackWithMap
}

Flow context

func NewEmptyContext

func NewEmptyContext() *Context

func NewGoroutineExecutionState

func NewGoroutineExecutionState(state *Context) *Context

func (*Context) Copy

func (gs *Context) Copy() *Context

func (*Context) CopyWithoutMap

func (gs *Context) CopyWithoutMap() *Context

func (*Context) Increment

func (gs *Context) Increment()

func (*Context) MayConcurrent

func (gs *Context) MayConcurrent(state *Context) bool

type DeferFunction

type DeferFunction struct {
	Function   *ssa.CallCommon
	BlockIndex int
}

type FlowData

type FlowData struct {
	PosToRemove int
	ID          int // ID depends on the flow, which means it's unique.
	State       *Context
	Lockset     *Lockset
}

func (*FlowData) Copy

func (ga *FlowData) Copy() *FlowData

type FunctionState

type FunctionState struct {
	GuardedAccesses []*GuardedAccess
	Lockset         *Lockset
}

func CreateFunctionState

func CreateFunctionState(ga []*GuardedAccess, ls *Lockset) *FunctionState

func GetFunctionState

func GetFunctionState() *FunctionState

func (*FunctionState) AddContextToFunction

func (fs *FunctionState) AddContextToFunction(context *Context)

AddContextToFunction adds flow specific context data

func (*FunctionState) Copy

func (fs *FunctionState) Copy() *FunctionState

func (*FunctionState) RemoveContextFromFunction

func (fs *FunctionState) RemoveContextFromFunction()

RemoveContextFromFunction strips any context related data from the guarded access fields. It nullifies id, goroutine id, clock and removes from the guarded access the prefix that matches the context path. This way, other flows can take the guarded access and add relevant data.

type GuardedAccess

type GuardedAccess struct {
	*PosData
	*FlowData
}

func AddGuardedAccess

func AddGuardedAccess(pos token.Pos, value ssa.Value, kind OpKind, lockset *Lockset, context *Context) *GuardedAccess

func (*GuardedAccess) Copy

func (ga *GuardedAccess) Copy() *GuardedAccess

func (*GuardedAccess) Intersects

func (ga *GuardedAccess) Intersects(gaToCompare *GuardedAccess) bool

func (*GuardedAccess) IsConflicting

func (ga *GuardedAccess) IsConflicting(gaToCompare *GuardedAccess) bool

func (*GuardedAccess) ShallowCopy

func (ga *GuardedAccess) ShallowCopy() *GuardedAccess

type Lockset

type Lockset struct {
	Locks   locksLastUse
	Unlocks locksLastUse
}

func NewLockset

func NewLockset() *Lockset

func (*Lockset) Copy

func (ls *Lockset) Copy() *Lockset

func (*Lockset) MergeSiblingLockset

func (ls *Lockset) MergeSiblingLockset(locksetToMerge *Lockset)

MergeSiblingLockset is called when merging different paths of the control flow graph. The mutex status should be merged and not appended. Because Locks is a must set, for a lock to appear in the result, an intersect between the branches' lockset is performed to make sure the lock appears in all branches. Unlock is a may set, so a union is applied since it's sufficient to have an unlock at least in one of the branches.

func (*Lockset) UpdateWithNewLockSet

func (ls *Lockset) UpdateWithNewLockSet(newLocks, newUnlocks locksLastUse)

The three following methods handle updating the lockset the same way. By recording each lock state (locked/unlocked) at the current point. It means that if a mutex was unlocked at some point but later was locked again, then it's latest status is locked, and the unlock status is removed. The difference between each algorithm is the context used.

UpdateWithNewLockSet updates the lockset and expects newLocks, newUnlocks to contain the most up to date status of the mutex and update accordingly.

func (*Lockset) UpdateWithPrevLockset

func (ls *Lockset) UpdateWithPrevLockset(prevLS *Lockset)

UpdateWithPrevLockset works the same as UpdateWithNewLockSet but expects prevLS to contain an earlier version of the status of the locks.

type OpKind

type OpKind int
const (
	GuardAccessRead OpKind = iota
	GuardAccessWrite
)

func (OpKind) String

func (op OpKind) String() string

type PosData

type PosData struct {
	PosID  int // guarded accesses of the same function share the same PosID. It's used to mark the same guarded access in different flows.
	Pos    token.Pos
	OpKind OpKind
	Value  ssa.Value
}

type VectorClock

type VectorClock map[int]int

func (VectorClock) Copy

func (vc VectorClock) Copy() VectorClock

func (VectorClock) Get

func (vc VectorClock) Get(id int) int

Get returns clock for provided goroutine ID. If no such goroutine or clock is not initialized, then returns a zero value.

func (VectorClock) MergeClocks

func (vc VectorClock) MergeClocks(clockToMerge VectorClock)

Jump to

Keyboard shortcuts

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