diff options
| author | Russ Cox <rsc@golang.org> | 2025-10-29 13:37:52 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-10-30 09:55:06 -0700 |
| commit | d32b1f02c3e869b6ddf73d2113477b1fd77d42c8 (patch) | |
| tree | 074df75ed82ee3790fd4a4232a07754ad2693a3b /src/runtime/runtime1.go | |
| parent | cbbd385cb863e4a0969de9846fdd80227ed91ad0 (diff) | |
| download | go-d32b1f02c3e869b6ddf73d2113477b1fd77d42c8.tar.xz | |
runtime: delete timediv
Now that the compiler handles constant 64-bit divisions
without function calls on 32-bit systems, we no longer need
to maintain and test a bad custom implementation of 64-bit division.
Change-Id: If28807ad4f86507267ae69bc8f0b09ec18e98b66
Reviewed-on: https://go-review.googlesource.com/c/go/+/716463
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/runtime/runtime1.go')
| -rw-r--r-- | src/runtime/runtime1.go | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go index 3ec5c44ebd..43e4c14236 100644 --- a/src/runtime/runtime1.go +++ b/src/runtime/runtime1.go @@ -212,10 +212,6 @@ func check() { throw("bad unsafe.Sizeof y1") } - if timediv(12345*1000000000+54321, 1000000000, &e) != 12345 || e != 54321 { - throw("bad timediv") - } - var z uint32 z = 1 if !atomic.Cas(&z, 1, 2) { @@ -593,35 +589,6 @@ func setTraceback(level string) { atomic.Store(&traceback_cache, t) } -// Poor mans 64-bit division. -// This is a very special function, do not use it if you are not sure what you are doing. -// int64 division is lowered into _divv() call on 386, which does not fit into nosplit functions. -// Handles overflow in a time-specific manner. -// This keeps us within no-split stack limits on 32-bit processors. -// -//go:nosplit -func timediv(v int64, div int32, rem *int32) int32 { - res := int32(0) - for bit := 30; bit >= 0; bit-- { - if v >= int64(div)<<uint(bit) { - v = v - (int64(div) << uint(bit)) - // Before this for loop, res was 0, thus all these - // power of 2 increments are now just bitsets. - res |= 1 << uint(bit) - } - } - if v >= int64(div) { - if rem != nil { - *rem = 0 - } - return 0x7fffffff - } - if rem != nil { - *rem = int32(v) - } - return res -} - // Helpers for Go. Must be NOSPLIT, must only call NOSPLIT functions, and must not block. //go:nosplit |
