Skip to content

Commit

Permalink
Merge pull request #241 from goplus/reset
Browse files Browse the repository at this point in the history
ResetIcall/ResetAllIcall
  • Loading branch information
visualfc authored Apr 28, 2023
2 parents 1d6c597 + 4b8fbd2 commit b822879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (ctx *Context) RunPkg(mainPkg *ssa.Package, input string, args []string) (e
if err != nil {
return 2, err
}
defer interp.UnsafeReleaseIcall()
defer interp.ResetIcall()
return ctx.RunInterp(interp, input, args)
}

Expand Down
11 changes: 9 additions & 2 deletions interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,12 @@ func (i *Interp) RunInit() (err error) {
return
}

// icall allocate stat
// ResetAllIcall is reset all reflectx icall, all interp methods invalid.
func ResetAllIcall() {
reflectx.ResetAll()
}

// IcallStat return reflectx icall allocate stat
func IcallStat() (capacity int, allocate int, aviable int) {
return reflectx.IcallStat()
}
Expand All @@ -1311,10 +1316,12 @@ func (i *Interp) IcallAlloc() int {
return i.record.rctx.IcallAlloc()
}

func (i *Interp) UnsafeReleaseIcall() {
// ResetIcall is reset reflectx icall, all methods invalid.
func (i *Interp) ResetIcall() {
i.record.rctx.Reset()
}

// UnsafeRelease is unsafe release interp. interp all invalid.
func (i *Interp) UnsafeRelease() {
i.record.Release()
for _, v := range i.funcs {
Expand Down

0 comments on commit b822879

Please sign in to comment.