Skip to content

Assume all functions without body are blocking. #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/analysis/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ func (info *Info) newFuncInfo(n ast.Node) *FuncInfo {
// Register the function in the appropriate map.
switch n := n.(type) {
case *ast.FuncDecl:
if n.Body == nil {
// Function body comes from elsewhere (for example, from a go:linkname
// directive), conservatively assume that it may be blocking.
// TODO(nevkontakte): It is possible to improve accuracy of this detection.
// Since GopherJS supports inly "import-style" go:linkname, at this stage
// the compiler already determined whether the implementation function is
// blocking, and we could check that.
funcInfo.Blocking[n] = true
}
info.FuncDeclInfos[info.Defs[n.Name].(*types.Func)] = funcInfo
case *ast.FuncLit:
info.FuncLitInfos[n] = funcInfo
Expand Down