Lines Matching full:gp
447 gp := getg()
489 if stackNoCache != 0 || gp.m.p == 0 || gp.m.preemptoff != "" {
494 c := gp.m.p.ptr().mcache
745 func adjustctxt(gp *g, adjinfo *adjustinfo) {
746 adjustpointer(adjinfo, unsafe.Pointer(&gp.sched.ctxt))
751 bp := gp.sched.bp
758 oldfp := gp.sched.bp
759 adjustpointer(adjinfo, unsafe.Pointer(&gp.sched.bp))
764 if oldfp == gp.sched.sp-goarch.PtrSize {
765 memmove(unsafe.Pointer(gp.sched.bp), unsafe.Pointer(oldfp), goarch.PtrSize)
766 adjustpointer(adjinfo, unsafe.Pointer(gp.sched.bp))
771 func adjustdefers(gp *g, adjinfo *adjustinfo) {
775 adjustpointer(adjinfo, unsafe.Pointer(&gp._defer))
776 for d := gp._defer; d != nil; d = d.link {
783 func adjustpanics(gp *g, adjinfo *adjustinfo) {
786 adjustpointer(adjinfo, unsafe.Pointer(&gp._panic))
789 func adjustsudogs(gp *g, adjinfo *adjustinfo) {
792 for s := gp.waiting; s != nil; s = s.waitlink {
803 func findsghi(gp *g, stk stack) uintptr {
805 for sg := gp.waiting; sg != nil; sg = sg.waitlink {
814 // syncadjustsudogs adjusts gp's sudogs and copies the part of gp's
817 func syncadjustsudogs(gp *g, used uintptr, adjinfo *adjustinfo) uintptr {
818 if gp.waiting == nil {
824 for sg := gp.waiting; sg != nil; sg = sg.waitlink {
841 adjustsudogs(gp, adjinfo)
856 for sg := gp.waiting; sg != nil; sg = sg.waitlink {
866 // Copies gp's stack to a new stack of a different size.
867 // Caller must have changed gp status to Gcopystack.
868 func copystack(gp *g, newsize uintptr) {
869 if gp.syscallsp != 0 {
872 old := gp.stack
876 used := old.hi - gp.sched.sp
889 …print("copystack gp=", gp, " [", hex(old.lo), " ", hex(old.hi-used), " ", hex(old.hi), "]", " -> […
899 if !gp.activeStackChans {
900 if newsize < old.hi-old.lo && gp.parkingOnChan.Load() {
907 adjustsudogs(gp, &adjinfo)
909 // sudogs may be pointing in to the stack and gp has
911 // be writing to gp's stack. Find the highest such
916 adjinfo.sghi = findsghi(gp, old)
920 ncopy -= syncadjustsudogs(gp, used, &adjinfo)
929 adjustctxt(gp, &adjinfo)
930 adjustdefers(gp, &adjinfo)
931 adjustpanics(gp, &adjinfo)
937 gp.stack = new
938 gp.stackguard0 = new.lo + stackGuard // NOTE: might clobber a preempt request
939 gp.sched.sp = new.hi - used
940 gp.stktopsp += adjinfo.delta
944 for u.init(gp, 0); u.valid(); u.next() {
978 // TODO: double check all gp. shouldn't be getg().
989 gp := thisg.m.curg
994 gp.syscallsp = morebuf.sp
995 gp.syscallpc = morebuf.pc
997 f := findfunc(gp.sched.pc)
1000 pcoff = gp.sched.pc - f.entry()
1003 " sp=", hex(gp.sched.sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n",
1005 …"\tsched={pc:", hex(gp.sched.pc), " sp:", hex(gp.sched.sp), " lr:", hex(gp.sched.lr), " ctxt:", gp…
1008 traceback(morebuf.pc, morebuf.sp, morebuf.lr, gp)
1019 // is about to try to preempt gp. Read it just once and use that same
1021 stackguard0 := atomic.Loaduintptr(&gp.stackguard0)
1039 // gp->preempt is set, so it will be preempted next time.
1040 gp.stackguard0 = gp.stack.lo + stackGuard
1041 gogo(&gp.sched) // never return
1045 if gp.stack.lo == 0 {
1048 sp := gp.sched.sp
1053 if stackDebug >= 1 || sp < gp.stack.lo {
1054 …print("runtime: newstack sp=", hex(sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n…
1056 …"\tsched={pc:", hex(gp.sched.pc), " sp:", hex(gp.sched.sp), " lr:", hex(gp.sched.lr), " ctxt:", gp…
1058 if sp < gp.stack.lo {
1059 print("runtime: gp=", gp, ", goid=", gp.goid, ", gp->status=", hex(readgstatus(gp)), "\n ")
1060 print("runtime: split stack overflow: ", hex(sp), " < ", hex(gp.stack.lo), "\n")
1065 if gp == thisg.m.g0 {
1072 if gp.preemptShrink {
1075 gp.preemptShrink = false
1076 shrinkstack(gp)
1079 if gp.preemptStop {
1080 preemptPark(gp) // never returns
1084 gopreempt_m(gp) // never return
1088 oldsize := gp.stack.hi - gp.stack.lo
1094 if f := findfunc(gp.sched.pc); f.valid() {
1097 used := gp.stack.hi - gp.sched.sp
1116 print("runtime: sp=", hex(sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n")
1122 casgstatus(gp, _Grunning, _Gcopystack)
1125 // the gp is in a Gcopystack status.
1126 copystack(gp, newsize)
1130 casgstatus(gp, _Gcopystack, _Grunning)
1131 gogo(&gp.sched)
1152 // gp's stack. Shrinking the stack is only safe when we have precise
1154 // _Gscan bit for gp or must be running gp itself.
1155 func isShrinkStackSafe(gp *g) bool {
1160 if gp.syscallsp != 0 {
1166 if gp.asyncSafePoint {
1171 // gp.activeStackChans being set.
1172 if gp.parkingOnChan.Load() {
1176 // gp is in _Gwaiting solely to make itself available to the GC.
1179 // of the G's stack. Note: it's safe to access gp.waitreason here.
1182 // which prevents gp.waitreason from changing.
1183 if traceEnabled() && readgstatus(gp)&^_Gscan == _Gwaiting && gp.waitreason.isWaitingForGC() {
1189 // Maybe shrink the stack being used by gp.
1191 // gp must be stopped and we must own its stack. It may be in
1193 func shrinkstack(gp *g) {
1194 if gp.stack.lo == 0 {
1197 if s := readgstatus(gp); s&_Gscan == 0 {
1201 if !(gp == getg().m.curg && getg() != getg().m.curg && s == _Grunning) {
1206 if !isShrinkStackSafe(gp) {
1212 if gp == getg().m.curg && gp.m.libcallsp != 0 {
1219 f := findfunc(gp.startpc)
1226 oldsize := gp.stack.hi - gp.stack.lo
1234 // shrink the stack if gp is using less than a quarter of its
1238 avail := gp.stack.hi - gp.stack.lo
1239 if used := gp.stack.hi - gp.sched.sp + stackNosplit; used >= avail/4 {
1247 copystack(gp, newsize)