1
2
3
4
5
6
7 package main
8
9 import "unsafe"
10
11 func init() {
12 register("FramePointerAdjust", FramePointerAdjust)
13 }
14
15 func FramePointerAdjust() { framePointerAdjust1(0) }
16
17
18 func framePointerAdjust1(x int) {
19 argp := uintptr(unsafe.Pointer(&x))
20 fp := *getFP()
21 if !(argp-0x100 <= fp && fp <= argp+0x100) {
22 print("saved FP=", fp, " &x=", argp, "\n")
23 panic("FAIL")
24 }
25
26
27 grow(10000)
28
29
30 argp = uintptr(unsafe.Pointer(&x))
31 fp = *getFP()
32 if !(argp-0x100 <= fp && fp <= argp+0x100) {
33 print("saved FP=", fp, " &x=", argp, "\n")
34 panic("FAIL")
35 }
36 }
37
38 func grow(n int) {
39 if n > 0 {
40 grow(n - 1)
41 }
42 }
43
44 func getFP() *uintptr
45
View as plain text