aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/stack.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/runtime/stack.go b/src/runtime/stack.go
index 55e97e77af..c92accf188 100644
--- a/src/runtime/stack.go
+++ b/src/runtime/stack.go
@@ -12,6 +12,7 @@ import (
"internal/runtime/atomic"
"internal/runtime/gc"
"internal/runtime/sys"
+ "math/bits"
"unsafe"
)
@@ -181,12 +182,10 @@ func stackinit() {
// stacklog2 returns ⌊log_2(n)⌋.
func stacklog2(n uintptr) int {
- log2 := 0
- for n > 1 {
- n >>= 1
- log2++
+ if n == 0 {
+ return 0
}
- return log2
+ return bits.Len64(uint64(n))
}
// Allocates a stack from the free pool. Must be called with