@@ -733,12 +733,10 @@ func gcStart(trigger gcTrigger) {
733
733
mode = gcForceMode
734
734
} else if debug .gcstoptheworld == 2 {
735
735
mode = gcForceBlockMode
736
- } else if goexperiment .GoroutineLeakFinderGC {
737
- if work .goroutineLeakFinder .pending .Load () ||
738
- debug .gcgoroutineleaks > 0 {
739
- // Fully stop the world if running deadlock detection.
740
- mode = gcForceBlockMode
741
- }
736
+ } else if work .goroutineLeakFinder .pending .Load () || debug .gcgoroutineleaks > 0 {
737
+ // If goroutine leak detection has been enabled (via GODEBUG=gcgoroutineleaks=1),
738
+ // or via profiling, fully stop the world.
739
+ mode = gcForceBlockMode
742
740
}
743
741
744
742
// Ok, we're doing it! Stop everybody else
@@ -1035,7 +1033,8 @@ top:
1035
1033
}
1036
1034
}
1037
1035
})
1038
- if restart {
1036
+ switch {
1037
+ case restart :
1039
1038
gcDebugMarkDone .restartedDueTo27993 = true
1040
1039
1041
1040
getg ().m .preemptoff = ""
@@ -1049,25 +1048,22 @@ top:
1049
1048
})
1050
1049
semrelease (& worldsema )
1051
1050
goto top
1052
- } else if goexperiment .GoroutineLeakFinderGC {
1053
- // If we are detecting goroutine leaks, do so now.
1054
- if work .goroutineLeakFinder .enabled && ! work .goroutineLeakFinder .done {
1055
- // Detect goroutine leaks. If the returned value is true, then
1056
- // detection was performed during this cycle. Otherwise, more mark work is needed,
1057
- // or live goroutines were found.
1058
- work .goroutineLeakFinder .done = findGoleaks ()
1059
-
1060
- getg ().m .preemptoff = ""
1061
- systemstack (func () {
1062
- // Accumulate the time we were stopped before we had to start again.
1063
- work .cpuStats .accumulateGCPauseTime (nanotime ()- stw .finishedStopping , work .maxprocs )
1051
+ case work .goroutineLeakFinder .enabled && ! work .goroutineLeakFinder .done :
1052
+ // Detect goroutine leaks. If the returned value is true, then detection was
1053
+ // performed during this cycle. Otherwise, more runnable goroutines were discovered,
1054
+ // requiring additional mark work.
1055
+ work .goroutineLeakFinder .done = findGoleaks ()
1064
1056
1065
- now := startTheWorldWithSema (0 , stw )
1066
- work .pauseNS += now - stw .startedStopping
1067
- })
1068
- semrelease (& worldsema )
1069
- goto top
1070
- }
1057
+ getg ().m .preemptoff = ""
1058
+ systemstack (func () {
1059
+ // Accumulate the time we were stopped before we had to start again.
1060
+ work .cpuStats .accumulateGCPauseTime (nanotime ()- stw .finishedStopping , work .maxprocs )
1061
+
1062
+ now := startTheWorldWithSema (0 , stw )
1063
+ work .pauseNS += now - stw .startedStopping
1064
+ })
1065
+ semrelease (& worldsema )
1066
+ goto top
1071
1067
}
1072
1068
1073
1069
gcComputeStartingStackSize ()
0 commit comments