gosta

package
v0.0.0-...-6b2c996 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddState

func AddState(self *SmallFSM, gfsm *GFSM, op Op, chanID ChanID, gid int, sid int)

func Execute

func Execute(rt *Runtime, sp *StaticProgram, limit int)

func LinkState

func LinkState(from *State, to *State, chanID ChanID, op Op)

Types

type Action

type Action struct {
	StepID int // 一步可能有多个动作
	Score  int // 打分值

	Onwhich int // 在哪个Goroutine上操作
	ToState SID // 到哪个State

	Onwhich2 int //ACTION_MATCH情况下,RECV的
	ToState2 SID //ACTION_MATCH情况下,RECV的

	Type        ActionType   // 哪种动作
	ChanID      int          // SEND/RECV时,用于改变Chan
	Goroutines  []*Goroutine // GO时,用于绑定Goroutine初值
	Goroutines2 []*Goroutine // 对于ACTION_MATCH, RECV的GO列表
}

type ActionStack

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

func (*ActionStack) Empty

func (s *ActionStack) Empty() bool

func (*ActionStack) Get

func (s *ActionStack) Get(n int) Action

func (*ActionStack) Pop

func (s *ActionStack) Pop()

func (*ActionStack) Push

func (s *ActionStack) Push(i Action)

func (*ActionStack) Size

func (s *ActionStack) Size() int

func (*ActionStack) Top

func (s *ActionStack) Top() Action

type ActionType

type ActionType int
const (
	ACTION_MAIN ActionType = iota //初始化Main函数
	ACTION_SEND
	ACTION_RECV
	ACTION_EPSILON
	ACTION_MATCH
	ACTION_ILLEGAL

	ACTION_SINGLE_SEND
	ACTION_SINGLE_RECV
)

type BuildHelper

type BuildHelper struct {
	Pack *ssa.Package

	ChanEnv map[string]int

	Channels []Channel

	FuncEnv map[string]int  //函数名-下标映射表 walk前添加
	Funcs   []*ssa.Function //函数列表,walk前添加
	GFSMs   []*GFSM         //自动机列表,walk结束后添加

	GoroutineCounter int // 运行时Goroutine序号

	//构建过程中暂时使用
	CurFuncname  string
	StateCounter int // 自动机的状态计数器,每个自动机从0开始
	CurMachine   int

	GlobalStateCounter int // 全局的状态计数器,用于实验统计
}

type ChanID

type ChanID int // Channel id

type Channel

type Channel struct {
	ID   ChanID
	Cap  int
	Type string
}

func GetChan

func GetChan(self StaticProgram, cid ChanID) *Channel

type Edge

type Edge struct {
	From, To SID
	Op       Op
	ChanID   ChanID
}

type GFSM

type GFSM struct {
	ID     GID // 在StaticProgram中自动机的下标
	States []*State
}

协程自动机

type GID

type GID int // GFSM id
const (
	NO_MACHINE GID = -1 // 对于RGoroutine,从未初始化的意思
)

type Goroutine

type Goroutine struct {
	Num      int      // Goroutine序号
	Machine  GID      // 是从哪个函数中spawn出来的
	Bindings []ChanID // channel的id,和StaticProgram里的Channels下标一致

}

协程 自动机的Go调用 & Goroutine运行时状态

func AddGoroutine

func AddGoroutine(self *SmallFSM) *Goroutine

type IntStack

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

func (*IntStack) Empty

func (s *IntStack) Empty() bool

begin empty

func (*IntStack) Get

func (s *IntStack) Get(n int) int

begin get

func (*IntStack) Pop

func (s *IntStack) Pop()

begin pop

func (*IntStack) Push

func (s *IntStack) Push(i int)

begin push

func (*IntStack) Size

func (s *IntStack) Size() int

begin size

func (*IntStack) Top

func (s *IntStack) Top() int

begin top

type NodeType

type NodeType int
const (
	NODE_START NodeType = iota
	NODE_END
	NODE_MIDDLE
)

type Op

type Op int
const (
	OP_SEND Op = iota
	OP_RECV
	OP_EPSILON // 空边
)

type RChannel

type RChannel struct {
	Cap int
	Now int //容量,发现它不需要用栈,用正常加减就可以了
}

type RGoroutine

type RGoroutine struct {
	Machine  GID
	Bindings []ChanID
	Current  SIDStack //状态栈
}

type Runtime

type Runtime struct {
	Goroutines []RGoroutine
	Live       map[int]int

	Channels []RChannel
	Logs     ActionStack //日志栈

	LogCounter int //当前日志编号

	Result int // 抽象执行过程中,产生协程死锁的数量
	Paths  int // 抽象执行过程中,实际分析的路径数
}

func MakeRuntime

func MakeRuntime(sp *StaticProgram, totalScore int) *Runtime

type SID

type SID struct {
	GID GID
	ID  int
}

type SIDStack

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

func (*SIDStack) Empty

func (s *SIDStack) Empty() bool

func (*SIDStack) Get

func (s *SIDStack) Get(n int) SID

func (*SIDStack) Pop

func (s *SIDStack) Pop()

func (*SIDStack) Push

func (s *SIDStack) Push(i SID)

func (*SIDStack) Size

func (s *SIDStack) Size() int

func (*SIDStack) Top

func (s *SIDStack) Top() SID

type SmallFSM

type SmallFSM struct {
	First *State
	Last  *State
	Outs  []int
}

构建时,一个BasicBlock对应的自动机

func MakeSmallFSM

func MakeSmallFSM(gfsm *GFSM, gid int, sid int) *SmallFSM

type State

type State struct {
	ID      SID          // GFSM中状态的下标
	Gos     []*Goroutine // 在这里即将调用的Goroutine,在运行到这里时,会复制
	In, Out []*Edge
	Type    NodeType
}

协程自动机中的状态

type StaticProgram

type StaticProgram struct {
	GFSMs    []*GFSM   //所有协程自动机
	Channels []Channel //所有管道,一次运行中,只有一套管道

	GoroutineCount int // 运行时可能的总协程数
	AllStateCount  int // 静态程序的总状态数
}

静态构建的目标,动态运行的初始

func BuildFSMs

func BuildFSMs(fileName string) *StaticProgram

Jump to

Keyboard shortcuts

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