})
newg.stackguard0 = newg.stack.lo + _StackGuard
newg.stackguard1 = ^uintptr(0)
- newg.stackAlloc = uintptr(stacksize)
}
return newg
}
throw("gfput: bad status (not Gdead)")
}
- stksize := gp.stackAlloc
+ stksize := gp.stack.hi - gp.stack.lo
if stksize != _FixedStack {
// non-standard stack size - free it.
- stackfree(gp.stack, gp.stackAlloc)
+ stackfree(gp.stack)
gp.stack.lo = 0
gp.stack.hi = 0
gp.stackguard0 = 0
gp.stack = stackalloc(_FixedStack)
})
gp.stackguard0 = gp.stack.lo + _StackGuard
- gp.stackAlloc = _FixedStack
} else {
if raceenabled {
- racemalloc(unsafe.Pointer(gp.stack.lo), gp.stackAlloc)
+ racemalloc(unsafe.Pointer(gp.stack.lo), gp.stack.hi-gp.stack.lo)
}
if msanenabled {
- msanmalloc(unsafe.Pointer(gp.stack.lo), gp.stackAlloc)
+ msanmalloc(unsafe.Pointer(gp.stack.lo), gp.stack.hi-gp.stack.lo)
}
}
}
stack stack
stackguard0 uintptr
stackguard1 uintptr
- stackAlloc uintptr
stktopsp uintptr
}
old.stack = g.m.gsignal.stack
old.stackguard0 = g.m.gsignal.stackguard0
old.stackguard1 = g.m.gsignal.stackguard1
- old.stackAlloc = g.m.gsignal.stackAlloc
old.stktopsp = g.m.gsignal.stktopsp
}
stsp := uintptr(unsafe.Pointer(st.ss_sp))
g.m.gsignal.stack.hi = stsp + st.ss_size
g.m.gsignal.stackguard0 = stsp + _StackGuard
g.m.gsignal.stackguard1 = stsp + _StackGuard
- g.m.gsignal.stackAlloc = st.ss_size
}
// restoreGsignalStack restores the gsignal stack to the value it had
gp.stack = st.stack
gp.stackguard0 = st.stackguard0
gp.stackguard1 = st.stackguard1
- gp.stackAlloc = st.stackAlloc
gp.stktopsp = st.stktopsp
}
// resources and must not split the stack.
//
//go:systemstack
-func stackfree(stk stack, n uintptr) {
+func stackfree(stk stack) {
gp := getg()
v := unsafe.Pointer(stk.lo)
+ n := stk.hi - stk.lo
if n&(n-1) != 0 {
throw("stack not a power of 2")
}
fillstack(new, 0xfd)
}
if stackDebug >= 1 {
- print("copystack gp=", gp, " [", hex(old.lo), " ", hex(old.hi-used), " ", hex(old.hi), "]/", gp.stackAlloc, " -> [", hex(new.lo), " ", hex(new.hi-used), " ", hex(new.hi), "]/", newsize, "\n")
+ print("copystack gp=", gp, " [", hex(old.lo), " ", hex(old.hi-used), " ", hex(old.hi), "]", " -> [", hex(new.lo), " ", hex(new.hi-used), " ", hex(new.hi), "]/", newsize, "\n")
}
// Compute adjustment.
gp.stack = new
gp.stackguard0 = new.lo + _StackGuard // NOTE: might clobber a preempt request
gp.sched.sp = new.hi - used
- oldsize := gp.stackAlloc
- gp.stackAlloc = newsize
gp.stktopsp += adjinfo.delta
// Adjust pointers in the new stack.
if stackPoisonCopy != 0 {
fillstack(old, 0xfc)
}
- stackfree(old, oldsize)
+ stackfree(old)
}
// round x up to a power of 2.
}
// Allocate a bigger segment and move the stack.
- oldsize := int(gp.stackAlloc)
+ oldsize := gp.stack.hi - gp.stack.lo
newsize := oldsize * 2
- if uintptr(newsize) > maxstacksize {
+ if newsize > maxstacksize {
print("runtime: goroutine stack exceeds ", maxstacksize, "-byte limit\n")
throw("stack overflow")
}
// The concurrent GC will not scan the stack while we are doing the copy since
// the gp is in a Gcopystack status.
- copystack(gp, uintptr(newsize), true)
+ copystack(gp, newsize, true)
if stackDebug >= 1 {
print("stack grow done\n")
}
if gp.stack.lo != 0 {
// Free whole stack - it will get reallocated
// if G is used again.
- stackfree(gp.stack, gp.stackAlloc)
+ stackfree(gp.stack)
gp.stack.lo = 0
gp.stack.hi = 0
}
return
}
- oldsize := gp.stackAlloc
+ oldsize := gp.stack.hi - gp.stack.lo
newsize := oldsize / 2
// Don't shrink the allocation below the minimum-sized stack
// allocation.