cmd/5l, runtime: make ARM integer division profiler-friendly

The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.

CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.

Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.

Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.

Combined, these make the torture test from issue 6681 pass.

Fixes #6681.

R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
This commit is contained in:
Russ Cox 2013-10-30 18:50:34 +00:00
parent 95ae85fb82
commit b0db472ea2
5 changed files with 61 additions and 62 deletions

View file

@ -8,6 +8,7 @@ import (
"bytes"
"fmt"
"hash/crc32"
"math/big"
"os/exec"
"regexp"
"runtime"
@ -123,6 +124,10 @@ func testCPUProfile(t *testing.T, need []string, f func()) {
}
})
if len(need) == 0 {
return
}
var total uintptr
for i, name := range need {
total += have[i]
@ -237,6 +242,26 @@ func TestGoroutineSwitch(t *testing.T) {
}
}
// Test that profiling of division operations is okay, especially on ARM. See issue 6681.
func TestMathBigDivide(t *testing.T) {
testCPUProfile(t, nil, func() {
t := time.After(5 * time.Second)
pi := new(big.Int)
for {
for i := 0; i < 100; i++ {
n := big.NewInt(2646693125139304345)
d := big.NewInt(842468587426513207)
pi.Div(n, d)
}
select {
case <-t:
return
default:
}
}
})
}
// Operating systems that are expected to fail the tests. See issue 6047.
var badOS = map[string]bool{
"darwin": true,