1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // Called from C. Returns the Go type *m.
10 func gc_m_ptr(ret *interface{}) {
14 // Called from C. Returns the Go type *g.
15 func gc_g_ptr(ret *interface{}) {
19 // Called from C. Returns the Go type *itab.
20 func gc_itab_ptr(ret *interface{}) {
24 func gc_unixnanotime(now *int64) {
25 sec, nsec := timenow()
26 *now = sec*1e9 + int64(nsec)
30 gogc(2) // force GC and do eager sweep
31 systemstack(scavenge_m)
34 var poolcleanup func()
36 func registerPoolCleanup(f func()) {
42 if poolcleanup != nil {
46 for _, p := range &allp {
50 // clear tinyalloc pool
51 if c := p.mcache; c != nil {
55 // disconnect cached list before dropping it on the floor,
56 // so that a dangling ref to one entry does not pin all of them.
58 for sg = c.sudogcache; sg != nil; sg = sgnext {
66 for i := range p.deferpool {
67 // disconnect cached list before dropping it on the floor,
68 // so that a dangling ref to one entry does not pin all of them.
70 for d = p.deferpool[i]; d != nil; d = dlink {
81 getg().issystem = true
83 for gosweepone() != ^uintptr(0) {
89 // This can happen if a GC runs between
90 // gosweepone returning ^0 above
91 // and the lock being acquired.
96 goparkunlock(&gclock, "GC sweep wait")
100 // NOTE: Really dst *unsafe.Pointer, src unsafe.Pointer,
101 // but if we do that, Go inserts a write barrier on *dst = src.
103 func writebarrierptr(dst *uintptr, src uintptr) {
108 func writebarrierstring(dst *[2]uintptr, src [2]uintptr) {
114 func writebarrierslice(dst *[3]uintptr, src [3]uintptr) {
121 func writebarrieriface(dst *[2]uintptr, src [2]uintptr) {
127 func writebarrierfat2(dst *[2]uintptr, _ *byte, src [2]uintptr) {
133 func writebarrierfat3(dst *[3]uintptr, _ *byte, src [3]uintptr) {
140 func writebarrierfat4(dst *[4]uintptr, _ *byte, src [4]uintptr) {
148 func writebarrierfat(typ *_type, dst, src unsafe.Pointer) {
149 memmove(dst, src, typ.size)