]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: simplify code
authorDmitry Vyukov <dvyukov@google.com>
Tue, 27 Jan 2015 19:55:03 +0000 (22:55 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 27 Jan 2015 20:26:07 +0000 (20:26 +0000)
The %61 hack was added when runtime was is in C.
Now the Go compiler does the optimization.

Change-Id: I79c3302ec4b931eaaaaffe75e7101c92bf287fc7
Reviewed-on: https://go-review.googlesource.com/3289
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/proc1.go

index 1950403329fb6eb7d75b4791f21f5d158a16112f..39e80945784860f6309c4115ec1be8ca88878281 100644 (file)
@@ -1429,10 +1429,7 @@ top:
        // Check the global runnable queue once in a while to ensure fairness.
        // Otherwise two goroutines can completely occupy the local runqueue
        // by constantly respawning each other.
-       tick := _g_.m.p.schedtick
-       // This is a fancy way to say tick%61==0,
-       // it uses 2 MUL instructions instead of a single DIV and so is faster on modern processors.
-       if uint64(tick)-((uint64(tick)*0x4325c53f)>>36)*61 == 0 && sched.runqsize > 0 {
+       if _g_.m.p.schedtick%61 == 0 && sched.runqsize > 0 {
                lock(&sched.lock)
                gp = globrunqget(_g_.m.p, 1)
                unlock(&sched.lock)