Skip to content

Commit fb6f637

Browse files
committed
Renamed maybeLivePtr to maybeTraceablePtr.
1 parent 2f6ef56 commit fb6f637

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

src/runtime/mgc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,8 @@ func gcUntrackSyncObjects() {
11881188

11891189
forEachGRace(func(gp *g) {
11901190
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
1191-
sg.elem.untrack()
1192-
sg.c.untrack()
1191+
sg.elem.setUnraceable()
1192+
sg.c.setUnraceable()
11931193
}
11941194
})
11951195
}
@@ -1203,8 +1203,8 @@ func gcRestoreSyncObjects() {
12031203

12041204
forEachGRace(func(gp *g) {
12051205
for sg := gp.waiting; sg != nil; sg = sg.waitlink {
1206-
sg.elem.track()
1207-
sg.c.track()
1206+
sg.elem.setTraceable()
1207+
sg.c.setTraceable()
12081208
}
12091209
})
12101210
}

src/runtime/runtime2.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,18 @@ type gobuf struct {
319319
bp uintptr // for framepointer-enabled architectures
320320
}
321321

322-
// maybeLivePtr is a special pointer that is conditionally trackable
322+
// maybeTraceablePtr is a special pointer that is conditionally trackable
323323
// by the GC. It consists of an address as a uintptr (vu) and a pointer
324324
// to a data element (vp).
325325
//
326-
// maybeLivePtr values can be in one of three states:
326+
// maybeTraceablePtr values can be in one of three states:
327327
// 1. Unset: vu == 0 && vp == nil
328328
// 2. Untracked: vu != 0 && vp == nil
329329
// 3. Tracked: vu != 0 && vp != nil
330330
//
331331
// Do not set fields manually. Use methods instead.
332332
// Extend this type with additional methods if needed.
333-
type maybeLivePtr struct {
333+
type maybeTraceablePtr struct {
334334
vp unsafe.Pointer // For liveness only.
335335
vu uintptr // Source of truth.
336336
}
@@ -339,56 +339,56 @@ type maybeLivePtr struct {
339339
// This is used to hide the pointer from the GC.
340340
//
341341
//go:nosplit
342-
func (p *maybeLivePtr) untrack() {
342+
func (p *maybeTraceablePtr) setUnraceable() {
343343
p.vp = nil
344344
}
345345

346-
// track resets the pointer to the stored address.
346+
// setTraceable resets the pointer to the stored address.
347347
// This is used to make the pointer visible to the GC.
348348
//
349349
//go:nosplit
350-
func (p *maybeLivePtr) track() {
350+
func (p *maybeTraceablePtr) setTraceable() {
351351
p.vp = unsafe.Pointer(p.vu)
352352
}
353353

354354
// set sets the pointer to the data element and updates the address.
355355
//
356356
//go:nosplit
357-
func (p *maybeLivePtr) set(v unsafe.Pointer) {
357+
func (p *maybeTraceablePtr) set(v unsafe.Pointer) {
358358
p.vp = v
359359
p.vu = uintptr(v)
360360
}
361361

362362
// get retrieves the pointer to the data element.
363363
//
364364
//go:nosplit
365-
func (p *maybeLivePtr) get() unsafe.Pointer {
365+
func (p *maybeTraceablePtr) get() unsafe.Pointer {
366366
return unsafe.Pointer(p.vu)
367367
}
368368

369369
// uintptr returns the uintptr address of the pointer.
370370
//
371371
//go:nosplit
372-
func (p *maybeLivePtr) uintptr() uintptr {
372+
func (p *maybeTraceablePtr) uintptr() uintptr {
373373
return p.vu
374374
}
375375

376-
// maybeLiveChan extends conditionally trackable pointers (maybeLivePtr)
376+
// maybeTraceableChan extends conditionally trackable pointers (maybeTraceablePtr)
377377
// to track hchan pointers.
378378
//
379379
// Do not set fields manually. Use methods instead.
380-
type maybeLiveChan struct {
381-
maybeLivePtr
380+
type maybeTraceableChan struct {
381+
maybeTraceablePtr
382382
}
383383

384384
//go:nosplit
385-
func (p *maybeLiveChan) set(c *hchan) {
386-
p.maybeLivePtr.set(unsafe.Pointer(c))
385+
func (p *maybeTraceableChan) set(c *hchan) {
386+
p.maybeTraceablePtr.set(unsafe.Pointer(c))
387387
}
388388

389389
//go:nosplit
390-
func (p *maybeLiveChan) get() *hchan {
391-
return (*hchan)(p.maybeLivePtr.get())
390+
func (p *maybeTraceableChan) get() *hchan {
391+
return (*hchan)(p.maybeTraceablePtr.get())
392392
}
393393

394394
// sudog (pseudo-g) represents a g in a wait list, such as for sending/receiving
@@ -411,7 +411,7 @@ type sudog struct {
411411
next *sudog
412412
prev *sudog
413413

414-
elem maybeLivePtr // data element (may point to stack)
414+
elem maybeTraceablePtr // data element (may point to stack)
415415

416416
// The following fields are never accessed concurrently.
417417
// For channels, waitlink is only accessed by g.
@@ -439,10 +439,10 @@ type sudog struct {
439439
// in the second entry in the list.)
440440
waiters uint16
441441

442-
parent *sudog // semaRoot binary tree
443-
waitlink *sudog // g.waiting list or semaRoot
444-
waittail *sudog // semaRoot
445-
c maybeLiveChan // channel
442+
parent *sudog // semaRoot binary tree
443+
waitlink *sudog // g.waiting list or semaRoot
444+
waittail *sudog // semaRoot
445+
c maybeTraceableChan // channel
446446
}
447447

448448
type libcall struct {

src/runtime/sema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (root *semaRoot) queue(addr *uint32, s *sudog, lifo bool, syncSema bool) {
310310
// When dealing with sync semaphores, hide the elem field from the GC
311311
// to prevent it from prematurely marking the semaphore when running
312312
// goroutine leak detection.
313-
s.elem.untrack()
313+
s.elem.setUnraceable()
314314
}
315315
s.next = nil
316316
s.prev = nil
@@ -609,7 +609,7 @@ func notifyListWait(l *notifyList, t uint32) {
609609
// the condvar address from the blocked goroutine when
610610
// checking for goroutine leaks.
611611
s.elem.set(unsafe.Pointer(l))
612-
s.elem.untrack()
612+
s.elem.setUnraceable()
613613
s.g.waiting = s
614614
}
615615
s.ticket = t

0 commit comments

Comments
 (0)