aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/mcentral.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/mcentral.go')
-rw-r--r--libgo/go/runtime/mcentral.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/libgo/go/runtime/mcentral.go b/libgo/go/runtime/mcentral.go
index a60eb9f..cd59010 100644
--- a/libgo/go/runtime/mcentral.go
+++ b/libgo/go/runtime/mcentral.go
@@ -251,16 +251,16 @@ func (c *mcentral) freeSpan(s *mspan, preserve bool, wasempty bool) bool {
func (c *mcentral) grow() *mspan {
npages := uintptr(class_to_allocnpages[c.spanclass.sizeclass()])
size := uintptr(class_to_size[c.spanclass.sizeclass()])
- n := (npages << _PageShift) / size
s := mheap_.alloc(npages, c.spanclass, false, true)
if s == nil {
return nil
}
- p := s.base()
- s.limit = p + size*n
-
+ // Use division by multiplication and shifts to quickly compute:
+ // n := (npages << _PageShift) / size
+ n := (npages << _PageShift) >> s.divShift * uintptr(s.divMul) >> s.divShift2
+ s.limit = s.base() + size*n
heapBitsForAddr(s.base()).initSpan(s)
return s
}