fix(go): 第二轮细查再修正 12 处版本与机制细节

- 02:reentersyscall 在 1.25 的顺序是 save -> 改 _Gsyscall -> 复制 syscalltick、解绑、置 _Psyscall;1.26 起整个解绑取消,P 保持 _Prunning
- 03:pallocSum 的 bit63 是"整片完全空闲"哨兵(三个数都等于 2^21 时只置这一位),不是闲置位
- 04:STW① 的 gcBgMarkStartWorkers 在停世界之前执行(mgc.go:817 -> :834)
- 07:sync.Map 三代关系:1.23 及以前 read/dirty;1.24 起 HashTrieMap 可选(GOEXPERIMENT=synchashtriemap);1.25 起默认;1.26 删旧实现
- 10:Mutex 实现搬到 internal/sync 是 1.24(不是 1.26);WaitGroup waiter 只占低 31 位,bit31 是 synctest bubble 标志;wg.Go 的"panic 不调 Done"是 1.26 行为,1.25 要求 f 不能 panic
- 11:Ticker 不可达可回收始于 1.23(原文把 1.22 及以前写成"1.23 及以前",与同页自相矛盾);cancelCtx.err 是 atomic.Value
- 14:GMP 调度器是 Go 1.1 引入(P / per-P runq / work-stealing),1.5 只是 GOMAXPROCS 默认改为核数

校验:check-pages 15 页通过;114 个 go 代码块 -> 16/16 完整程序实跑通过、5 个伪代码片段预期解析失败;KPI 9.7 万字。
This commit is contained in:
2026-10-21 15:54:40 +08:00
parent 33d6090c8d
commit a0f412f3e8
9 changed files with 85 additions and 34 deletions

View File

@@ -236,10 +236,10 @@ func gcWriteBarrier(slot *unsafe.Pointer, ptr unsafe.Pointer) {
│ 分配量达到阈值 / 手动 runtime.GC() / 两分钟没 GC
▼
_GCmark ← STW ①:mark setup
│ 0. 停世界之前就先做:gcBgMarkStartWorkers 按 GOMAXPROCS 起后台 mark worker(建好即 gopark 待命)
│ 1. 停止所有用户协程(stop the world)
│ 2. 打开写屏障:writeBarrier.enabled = true,等所有 P 完成切换
│ 3. gcBgMarkStartWorkers:按 GOMAXPROCS 起后台 mark worker(先 gopark 待命)
│ 4. 恢复用户协程——STW 到此结束,根还没开始扫
│ 3. 恢复用户协程——STW 到此结束,根还没开始扫
▼
并发标记(不 STW;世界重启之后才跑根标记任务:各 goroutine 栈、全局变量、runtime 结构,
再把灰色推到灰队列;用户协程与 mark worker 同时跑,靠混合写屏障保正确性)