Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
707213e
Factor out unimplemented function translation.
nevkontakte Feb 19, 2023
0ee97fe
Remove a special case for methods with array-pointer receivers.
nevkontakte Mar 11, 2023
06e8925
Refactor method translation code.
nevkontakte Jul 20, 2024
6770879
Remove uglify-es from package.json.
nevkontakte Jul 31, 2024
22c65b8
Use Node's native source map support instead of a third-party module.
nevkontakte Jul 31, 2024
0390b03
Merge pull request #1336 from nevkontakte/drop-deps
nevkontakte Aug 1, 2024
d5771cc
Assign identity to all function literals and use them as funcRefs.
nevkontakte Jul 20, 2024
4ebc56c
Temporarily disable reflect tests that depend on caller function names.
nevkontakte Aug 3, 2024
1ebb325
Merge pull request #1335 from nevkontakte/gng7
nevkontakte Aug 3, 2024
3b94762
Encapsulating DCE
grantnelson-wf Aug 22, 2024
525b19b
Adding instance tracking to the DCE
grantnelson-wf Aug 23, 2024
f565ca5
Adding compiler tests for DCE
grantnelson-wf Sep 24, 2024
2d1000c
Merge branch 'dceIntegrationTests' of github.com:Workiva/gopherjs int…
grantnelson-wf Sep 26, 2024
6fe8b6e
Update for integration tests
grantnelson-wf Sep 27, 2024
b9976d5
Updating to match some future changes
grantnelson-wf Oct 1, 2024
56cec36
Merge pull request #1339 from Workiva/encapDCE2
nevkontakte Oct 2, 2024
df51690
Merge branch 'master' of github.com:gopherjs/gopherjs into dceIntegra…
grantnelson-wf Oct 2, 2024
a0ea4da
Merge branch 'dceIntegrationTests' of github.com:Workiva/gopherjs int…
grantnelson-wf Oct 2, 2024
2539cd5
making requested changes to compiler tests
grantnelson-wf Oct 9, 2024
a07a61f
Adding more functions to InstanceMap
grantnelson-wf Oct 11, 2024
9146446
fixing godoc link
grantnelson-wf Oct 14, 2024
0994e88
Merge pull request #1345 from Workiva/moreInstanceMap
flimzy Oct 14, 2024
4dc2318
Merge pull request #1343 from Workiva/dceIntegrationTests
nevkontakte Oct 16, 2024
e4ddafe
Merge branch 'master' of github.com:Workiva/gopherjs into dce4Instances
grantnelson-wf Oct 17, 2024
4d87a0b
Fixing grammar in readme
grantnelson-wf Oct 17, 2024
542b30f
Merge branch 'master' of github.com:gopherjs/gopherjs into dce4Instances
grantnelson-wf Oct 17, 2024
46f06c2
Fixing grammar in readme
grantnelson-wf Oct 17, 2024
04193e9
Move analysis package into internal
grantnelson-wf Oct 22, 2024
948c73a
Update function info blocking to use instances
grantnelson-wf Oct 22, 2024
40b7fe4
Fixed requested changes
grantnelson-wf Oct 23, 2024
dddb56a
Merge pull request #1347 from Workiva/blocking4FuncInst
flimzy Oct 23, 2024
76cecb9
Merge branch 'master' of github.com:gopherjs/gopherjs into dce4Instances
grantnelson-wf Oct 23, 2024
ea51571
Fixing GoDoc links and range checking on len
grantnelson-wf Oct 24, 2024
8a27348
Merge pull request #1340 from Workiva/dce4Instances
flimzy Oct 24, 2024
3a364dc
Fixed issue in len with string concatenation in argument
grantnelson-wf Oct 28, 2024
ebb16a4
Merge pull request #1348 from Workiva/parenLen
flimzy Oct 28, 2024
54b13af
Improving return with defers blocking
grantnelson-wf Oct 31, 2024
fe49d93
made defer more debuggable and some other fixes
grantnelson-wf Nov 14, 2024
6e01eab
fixed calling a defer across packages
grantnelson-wf Nov 14, 2024
3c9b135
Merge pull request #1349 from Workiva/blockingDeferReturns
nevkontakte Nov 17, 2024
010220a
fixing some issues in analysis around generics
grantnelson-wf Nov 21, 2024
65c5c0b
updating decl naming
grantnelson-wf Nov 19, 2024
ea5dd71
merged #1351
grantnelson-wf Nov 21, 2024
96b85d9
Serialization updates
grantnelson-wf Dec 3, 2024
a3e015c
Merge pull request #1351 from Workiva/fixAnalysisGen
grantnelson-wf Dec 9, 2024
f77e16c
Merge branch 'master' of github.com:gopherjs/gopherjs into setDeclNames
grantnelson-wf Dec 9, 2024
1fa608f
Added Helper calls to info_test
grantnelson-wf Dec 9, 2024
11bf21d
Using srcModTime instead of time.Now
grantnelson-wf Dec 12, 2024
45e3712
Setting the buildTime back to time.Now
grantnelson-wf Dec 12, 2024
f0695e0
fixing grammar
grantnelson-wf Dec 17, 2024
428efba
Merge pull request #1354 from Workiva/archiveSerial
grantnelson-wf Dec 17, 2024
e6cfbef
Merge branch 'master' of github.com:gopherjs/gopherjs into setDeclNames
grantnelson-wf Dec 17, 2024
289ebba
Merge pull request #1350 from Workiva/setDeclNames
grantnelson-wf Dec 19, 2024
75ff10c
Skipping tests with expired certificate
grantnelson-wf Feb 10, 2025
8e75705
Merge pull request #1360 from Workiva/cryptoAgain
grantnelson-wf Feb 10, 2025
a594ec1
separating parse and compile
grantnelson-wf Feb 10, 2025
2a9b9a4
Fixing spelling mistake
grantnelson-wf Feb 14, 2025
82034ad
using Sources instead of ParsedPackage
grantnelson-wf Feb 20, 2025
ba2ea8d
clarifying naming and comments
grantnelson-wf Feb 24, 2025
a3f0ab4
Merge pull request #1361 from Workiva/delayCompile2
grantnelson-wf Feb 26, 2025
2bb5c74
Merge branch 'master' of github.com:gopherjs/gopherjs into sourceInst…
grantnelson-wf Feb 26, 2025
5740abf
made requested changes from prior ticket and did some cleanup
grantnelson-wf Feb 26, 2025
c8b8905
moved linkname to its own package
grantnelson-wf Feb 27, 2025
bd9aac3
Merge pull request #1362 from Workiva/sourceInsteadOfParsedPackage
grantnelson-wf Mar 4, 2025
887f51e
Updated to cross package analysis
grantnelson-wf Mar 5, 2025
5685251
Merge pull request #1364 from Workiva/breakupCompile3
grantnelson-wf Mar 24, 2025
bfb3fd5
chore(deps): Replace outdated goembed repo with a fixed version.
IngwiePhoenix Apr 8, 2025
18c9a00
fix: Fixes #1352 by using a forked version of goembed
IngwiePhoenix Apr 8, 2025
ad87dd6
Merge pull request #1367 from IngwiePhoenix/master
nevkontakte Apr 21, 2025
138e9e0
Update spf13/cobra, spf13/pflag, and evanw/esbuild to resolve direct …
May 12, 2025
c95887b
Merge pull request #1369 from LRGoldenPony/CVEDependencyUpdates
flimzy May 13, 2025
3e9afa2
Adding type parameters from a function into the nested types inside o…
grantnelson-wf May 12, 2025
208d830
Merge pull request #1370 from Workiva/nestedTypes
grantnelson-wf May 22, 2025
f5ca11f
Handling deep nested types
grantnelson-wf May 28, 2025
d4d3cf7
Updated subst to v0.33.0
grantnelson-wf May 29, 2025
5bcfc68
Updating DCE to support nested types
grantnelson-wf Jun 5, 2025
1ff0ea5
Adding selectors to index handling
grantnelson-wf Jun 10, 2025
8781080
Merge pull request #1374 from Workiva/nestedTypes2
grantnelson-wf Jun 16, 2025
bda00ea
Merge branch 'master' of github.com:gopherjs/gopherjs into dceUpdate
grantnelson-wf Jun 16, 2025
120c98d
Merge pull request #1375 from Workiva/dceUpdate
grantnelson-wf Jun 16, 2025
b2ab7b5
Merge branch 'master' of github.com:gopherjs/gopherjs into indexedSel
grantnelson-wf Jun 16, 2025
1e45615
Merge pull request #1376 from Workiva/indexedSel
grantnelson-wf Jun 16, 2025
6c9aa83
Grouping by declaration kinds and adding $finishSetup
grantnelson-wf Jul 23, 2025
d466fe3
Merge pull request #1380 from Workiva/typeOrderWip
grantnelson-wf Jul 28, 2025
e7ccb4d
Bump brace-expansion from 1.1.11 to 1.1.12 in /node-syscall
dependabot[bot] Jul 28, 2025
e7546c0
Merge pull request #1381 from gopherjs/dependabot/npm_and_yarn/node-s…
nevkontakte Jul 28, 2025
96a2970
Fixing collecting instances with inverted dependencies
grantnelson-wf Jul 30, 2025
a87964c
Merge pull request #1384 from Workiva/collectImplicitInstances
grantnelson-wf Aug 1, 2025
784cea3
Removing old style +build constraints
grantnelson-wf Aug 13, 2025
eded33e
Formatting imports
grantnelson-wf Aug 13, 2025
437f326
Updating tests and overrides
grantnelson-wf Aug 13, 2025
5229e7f
Merge pull request #1386 from Workiva/update119Overrides
grantnelson-wf Aug 15, 2025
9eb1c70
enable generics and remove overrides for generics
grantnelson-wf Aug 15, 2025
99b9ba6
add complex integration test
grantnelson-wf Aug 15, 2025
1568908
Merge pull request #1387 from Workiva/enableGenerics1
grantnelson-wf Aug 18, 2025
05dd05a
Merge branch 'master' of github.com:gopherjs/gopherjs into go120Update2
grantnelson-wf Aug 18, 2025
bca215b
Fixing merge conflicts
grantnelson-wf Aug 18, 2025
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
Prev Previous commit
Next Next commit
Fixed requested changes
  • Loading branch information
grantnelson-wf committed Oct 23, 2024
commit 40b7fe49418b386d991ce377a3bbecdc09d30210
10 changes: 5 additions & 5 deletions compiler/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
}

bodyOutput := string(fc.CatchOutput(1, func() {
if fc.HasBlocking() {
if fc.IsBlocking() {
fc.pkgCtx.Scopes[body] = fc.pkgCtx.Scopes[typ]
fc.handleEscapingVars(body)
}
Expand Down Expand Up @@ -283,14 +283,14 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
if fc.HasDefer {
fc.localVars = append(fc.localVars, "$deferred")
suffix = " }" + suffix
if fc.HasBlocking() {
if fc.IsBlocking() {
suffix = " }" + suffix
}
}

localVarDefs := "" // Function-local var declaration at the top.

if fc.HasBlocking() {
if fc.IsBlocking() {
localVars := append([]string{}, fc.localVars...)
// There are several special variables involved in handling blocking functions:
// $r is sometimes used as a temporary variable to store blocking call result.
Expand All @@ -314,7 +314,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
if fc.HasDefer {
prefix = prefix + " var $err = null; try {"
deferSuffix := " } catch(err) { $err = err;"
if fc.HasBlocking() {
if fc.IsBlocking() {
deferSuffix += " $s = -1;"
}
if fc.resultNames == nil && fc.sig.HasResults() {
Expand All @@ -324,7 +324,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
if fc.resultNames != nil {
deferSuffix += fmt.Sprintf(" if (!$curGoroutine.asleep) { return %s; }", fc.translateResults(fc.resultNames))
}
if fc.HasBlocking() {
if fc.IsBlocking() {
deferSuffix += " if($curGoroutine.asleep) {"
}
suffix = deferSuffix + suffix
Expand Down
64 changes: 35 additions & 29 deletions compiler/internal/analysis/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (info *Info) newFuncInfoInstances(fd *ast.FuncDecl) []*FuncInfo {
// IsBlocking returns true if the function may contain blocking calls or operations.
func (info *Info) IsBlocking(inst typeparams.Instance) bool {
if funInfo := info.FuncInfo(inst); funInfo != nil {
return funInfo.HasBlocking()
return funInfo.IsBlocking()
}
panic(fmt.Errorf(`info did not have function declaration instance for %q`, inst))
}
Expand Down Expand Up @@ -193,7 +193,7 @@ func AnalyzePkg(files []*ast.File, fileSet *token.FileSet, typesInfo *types.Info
for _, caller := range info.allInfos {
// Check calls to named functions and function-typed variables.
caller.localInstCallees.Iterate(func(callee typeparams.Instance, callSites []astPath) {
if info.FuncInfo(callee).HasBlocking() {
if info.FuncInfo(callee).IsBlocking() {
for _, callSite := range callSites {
caller.markBlocking(callSite)
}
Expand All @@ -204,7 +204,7 @@ func AnalyzePkg(files []*ast.File, fileSet *token.FileSet, typesInfo *types.Info

// Check direct calls to function literals.
for callee, callSites := range caller.literalFuncCallees {
if info.FuncLitInfo(callee).HasBlocking() {
if info.FuncLitInfo(callee).IsBlocking() {
for _, callSite := range callSites {
caller.markBlocking(callSite)
}
Expand Down Expand Up @@ -267,11 +267,11 @@ type FuncInfo struct {
visitorStack astPath
}

// HasBlocking indicates if this function may block goroutine execution.
// IsBlocking indicates if this function may block goroutine execution.
//
// For example, a channel operation in a function or a call to another
// possibly blocking function may block the function.
func (fi *FuncInfo) HasBlocking() bool {
func (fi *FuncInfo) IsBlocking() bool {
return fi == nil || len(fi.Blocking) != 0
}

Expand Down Expand Up @@ -397,19 +397,22 @@ func (fi *FuncInfo) visitCallExpr(n *ast.CallExpr) ast.Visitor {
switch f := astutil.RemoveParens(n.Fun).(type) {
case *ast.Ident:
fi.callToNamedFunc(fi.instanceForIdent(f))
return fi
case *ast.SelectorExpr:
if sel := fi.pkgInfo.Selections[f]; sel != nil {
if typesutil.IsJsObject(sel.Recv()) {
// js.Object methods are known to be non-blocking, but we still must
// check its arguments.
} else {
// selection is a method call like `foo.Bar()`, where `foo` might
// be generic and needs to be substituted with the type argument.
fi.callToNamedFunc(fi.instanceFoSelection(sel))
return fi
}
} else {
fi.callToNamedFunc(fi.instanceForIdent(f.Sel))
// selection is a method call like `foo.Bar()`, where `foo` might
// be generic and needs to be substituted with the type argument.
fi.callToNamedFunc(fi.instanceForSelection(sel))
return fi
}

fi.callToNamedFunc(fi.instanceForIdent(f.Sel))
return fi
case *ast.FuncLit:
// Collect info about the function literal itself.
ast.Walk(fi, n.Fun)
Expand All @@ -427,40 +430,43 @@ func (fi *FuncInfo) visitCallExpr(n *ast.CallExpr) ast.Visitor {
// This is a type conversion to an instance of a generic type,
// not a call. Type assertion itself is not blocking, but we will
// visit the input expression.
} else if astutil.IsTypeExpr(f.Index, fi.pkgInfo.Info) {
return fi
}
if astutil.IsTypeExpr(f.Index, fi.pkgInfo.Info) {
// This is a call of an instantiation of a generic function,
// e.g. `foo[int]` in `func foo[T any]() { ... }; func main() { foo[int]() }`
fi.callToNamedFunc(fi.instanceForIdent(f.X.(*ast.Ident)))
} else {
// The called function is gotten with an index or key from a map, array, or slice.
// e.g. `m := map[string]func(){}; m["key"]()`, `s := []func(); s[0]()`.
// Since we can't predict if the returned function will be blocking
// or not, we have to be conservative and assume that function might be blocking.
fi.markBlocking(fi.visitorStack)
return fi
}
// The called function is gotten with an index or key from a map, array, or slice.
// e.g. `m := map[string]func(){}; m["key"]()`, `s := []func(); s[0]()`.
// Since we can't predict if the returned function will be blocking
// or not, we have to be conservative and assume that function might be blocking.
fi.markBlocking(fi.visitorStack)
return fi
case *ast.IndexListExpr:
// Collect info about the instantiated type or function.
if astutil.IsTypeExpr(f, fi.pkgInfo.Info) {
// This is a type conversion to an instance of a generic type,
// not a call. Type assertion itself is not blocking, but we will
// visit the input expression.
} else {
// This is a call of an instantiation of a generic function,
// e.g. `foo[int, bool]` in `func foo[T1, T2 any]() { ... }; func main() { foo[int, bool]() }`
fi.callToNamedFunc(fi.instanceForIdent(f.X.(*ast.Ident)))
return fi
}
// This is a call of an instantiation of a generic function,
// e.g. `foo[int, bool]` in `func foo[T1, T2 any]() { ... }; func main() { foo[int, bool]() }`
fi.callToNamedFunc(fi.instanceForIdent(f.X.(*ast.Ident)))
return fi
default:
if astutil.IsTypeExpr(f, fi.pkgInfo.Info) {
// This is a type conversion, not a call. Type assertion itself is not
// blocking, but we will visit the input expression.
} else {
// The function is returned by a non-trivial expression. We have to be
// conservative and assume that function might be blocking.
fi.markBlocking(fi.visitorStack)
return fi
}
// The function is returned by a non-trivial expression. We have to be
// conservative and assume that function might be blocking.
fi.markBlocking(fi.visitorStack)
return fi
}

return fi
}

func (fi *FuncInfo) instanceForIdent(fnId *ast.Ident) typeparams.Instance {
Expand All @@ -471,7 +477,7 @@ func (fi *FuncInfo) instanceForIdent(fnId *ast.Ident) typeparams.Instance {
}
}

func (fi *FuncInfo) instanceFoSelection(sel *types.Selection) typeparams.Instance {
func (fi *FuncInfo) instanceForSelection(sel *types.Selection) typeparams.Instance {
if _, ok := sel.Obj().Type().(*types.Signature); ok {
// Substitute the selection to ensure that the receiver has the correct
// type arguments propagated down from the caller.
Expand Down
4 changes: 2 additions & 2 deletions compiler/internal/analysis/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ func (bt *blockingTest) isFuncLitBlocking(lineNo int) bool {
if fnLit == nil {
bt.f.T.Fatalf(`FuncLit found on line %d not found in the AST.`, lineNo)
}
return bt.pkgInfo.FuncLitInfo(fnLit).HasBlocking()
return bt.pkgInfo.FuncLitInfo(fnLit).IsBlocking()
}

func (bt *blockingTest) assertBlockingInst(instanceStr string) {
Expand All @@ -1230,7 +1230,7 @@ func (bt *blockingTest) isFuncInstBlocking(instanceStr string) bool {
instances := bt.pkgInfo.funcInstInfos.Keys()
for _, inst := range instances {
if inst.TypeString() == instanceStr {
return bt.pkgInfo.FuncInfo(inst).HasBlocking()
return bt.pkgInfo.FuncInfo(inst).IsBlocking()
}
}
bt.f.T.Logf(`Function instances found in package info:`)
Expand Down
4 changes: 2 additions & 2 deletions compiler/internal/typeparams/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func (iset *InstanceSet) ByObj() map[types.Object][]Instance {
return result
}

// ForObj returns instances for a given object type belong to. Order is not specified.
// This returns the same values as `ByObj()[obj]`.
// ForObj returns the instances that belong to the given object type.
// Order is not specified. This returns the same values as `ByObj()[obj]`.
func (iset *InstanceSet) ForObj(obj types.Object) []Instance {
result := []Instance{}
for _, inst := range iset.values {
Expand Down
Loading