]> Cypherpunks repositories - gostls13.git/commitdiff
test: fix and re-enable nosplit.go
authorCherry Zhang <cherryyz@google.com>
Thu, 5 Oct 2017 20:14:14 +0000 (16:14 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 31 Oct 2017 19:12:11 +0000 (19:12 +0000)
The test was skipped because it did not work on AMD64 with
frame pointer enabled, and accidentally skipped on other
architectures. Now frame pointer is the default on AMD64.
Update the test to work with frame pointer. Now the test
is skipped only when frame pointer is NOT enabled on AMD64.

Fixes #18317.

Change-Id: I724cb6874e562f16e67ce5f389a1d032a2003115
Reviewed-on: https://go-review.googlesource.com/68610
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
test/nosplit.go

index 989d8ccba77725b8df9cd183c5f36c89fa05d4bc..e6cecebde36dea2e8e070ea9274f11dc8af20c6f 100644 (file)
@@ -115,15 +115,15 @@ main 132
 main 136
 
 # A nosplit leaf can use the whole 128-CallSize bytes available on entry.
-# (CallSize is 32 on ppc64)
+# (CallSize is 32 on ppc64, 8 on amd64 for frame pointer.)
 main 96 nosplit
 main 100 nosplit; REJECT ppc64 ppc64le
 main 104 nosplit; REJECT ppc64 ppc64le
 main 108 nosplit; REJECT ppc64 ppc64le
 main 112 nosplit; REJECT ppc64 ppc64le
 main 116 nosplit; REJECT ppc64 ppc64le
-main 120 nosplit; REJECT ppc64 ppc64le
-main 124 nosplit; REJECT ppc64 ppc64le
+main 120 nosplit; REJECT ppc64 ppc64le amd64
+main 124 nosplit; REJECT ppc64 ppc64le amd64
 main 128 nosplit; REJECT
 main 132 nosplit; REJECT
 main 136 nosplit; REJECT
@@ -132,13 +132,14 @@ main 136 nosplit; REJECT
 # having room for the saved caller PC and the called frame.
 # Because ARM doesn't save LR in the leaf, it gets an extra 4 bytes.
 # Because arm64 doesn't save LR in the leaf, it gets an extra 8 bytes.
-# ppc64 doesn't save LR in the leaf, but CallSize is 32, so it gets 24 fewer bytes than amd64.
+# ppc64 doesn't save LR in the leaf, but CallSize is 32, so it gets 24 bytes.
+# Because AMD64 uses frame pointer, it has 8 fewer bytes.
 main 96 nosplit call f; f 0 nosplit
 main 100 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le
 main 104 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le
 main 108 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le
-main 112 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le
-main 116 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le
+main 112 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le amd64
+main 116 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le amd64
 main 120 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le amd64
 main 124 nosplit call f; f 0 nosplit; REJECT ppc64 ppc64le amd64 386
 main 128 nosplit call f; f 0 nosplit; REJECT
@@ -148,11 +149,11 @@ main 136 nosplit call f; f 0 nosplit; REJECT
 # Calling a splitting function from a nosplit function requires
 # having room for the saved caller PC of the call but also the
 # saved caller PC for the call to morestack.
-# RISC architectures differ in the same way as before.
+# Architectures differ in the same way as before.
 main 96 nosplit call f; f 0 call f
 main 100 nosplit call f; f 0 call f; REJECT ppc64 ppc64le
-main 104 nosplit call f; f 0 call f; REJECT ppc64 ppc64le
-main 108 nosplit call f; f 0 call f; REJECT ppc64 ppc64le
+main 104 nosplit call f; f 0 call f; REJECT ppc64 ppc64le amd64
+main 108 nosplit call f; f 0 call f; REJECT ppc64 ppc64le amd64
 main 112 nosplit call f; f 0 call f; REJECT ppc64 ppc64le amd64
 main 116 nosplit call f; f 0 call f; REJECT ppc64 ppc64le amd64
 main 120 nosplit call f; f 0 call f; REJECT ppc64 ppc64le amd64 386
@@ -164,8 +165,8 @@ main 136 nosplit call f; f 0 call f; REJECT
 # Indirect calls are assumed to be splitting functions.
 main 96 nosplit callind
 main 100 nosplit callind; REJECT ppc64 ppc64le
-main 104 nosplit callind; REJECT ppc64 ppc64le
-main 108 nosplit callind; REJECT ppc64 ppc64le
+main 104 nosplit callind; REJECT ppc64 ppc64le amd64
+main 108 nosplit callind; REJECT ppc64 ppc64le amd64
 main 112 nosplit callind; REJECT ppc64 ppc64le amd64
 main 116 nosplit callind; REJECT ppc64 ppc64le amd64
 main 120 nosplit callind; REJECT ppc64 ppc64le amd64 386
@@ -198,18 +199,14 @@ func main() {
                goarch = runtime.GOARCH
        }
 
-       // Frame pointer is on by default now.
-       // golang.org/issue/18317.
-       return
-
        version, err := exec.Command("go", "tool", "compile", "-V").Output()
        if err != nil {
                bug()
                fmt.Printf("running go tool compile -V: %v\n", err)
                return
        }
-       if strings.Contains(string(version), "framepointer") {
-               // Skip this test if GOEXPERIMENT=framepointer
+       if s := string(version); goarch == "amd64" && strings.Contains(s, "X:") && !strings.Contains(s, "framepointer") {
+               // Skip this test if framepointer is NOT enabled on AMD64
                return
        }
 
@@ -266,18 +263,18 @@ TestCases:
                ptrSize := 4
                switch goarch {
                case "mips", "mipsle":
-                       fmt.Fprintf(&buf, "#define CALL JAL\n#define REGISTER (R0)\n")
+                       fmt.Fprintf(&buf, "#define REGISTER (R0)\n")
                case "mips64", "mips64le":
                        ptrSize = 8
-                       fmt.Fprintf(&buf, "#define CALL JAL\n#define REGISTER (R0)\n")
+                       fmt.Fprintf(&buf, "#define REGISTER (R0)\n")
                case "ppc64", "ppc64le":
                        ptrSize = 8
-                       fmt.Fprintf(&buf, "#define CALL BL\n#define REGISTER (CTR)\n")
+                       fmt.Fprintf(&buf, "#define REGISTER (CTR)\n")
                case "arm":
-                       fmt.Fprintf(&buf, "#define CALL BL\n#define REGISTER (R0)\n")
+                       fmt.Fprintf(&buf, "#define REGISTER (R0)\n")
                case "arm64":
                        ptrSize = 8
-                       fmt.Fprintf(&buf, "#define CALL BL\n#define REGISTER (R0)\n")
+                       fmt.Fprintf(&buf, "#define REGISTER (R0)\n")
                case "amd64":
                        ptrSize = 8
                        fmt.Fprintf(&buf, "#define REGISTER AX\n")
@@ -307,7 +304,7 @@ TestCases:
                                name := m[1]
                                size, _ := strconv.Atoi(m[2])
 
-                               // The limit was originally 128 but is now 592.
+                               // The limit was originally 128 but is now 752 (880-128).
                                // Instead of rewriting the test cases above, adjust
                                // the first stack frame to use up the extra bytes.
                                if i == 0 {