]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/torture.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / torture.go
index 4bce3a1796ad5bfd1aa1222e95d818f90d2fd49a..197b481e66de03f015fe82b949a77bbf20c6756e 100644 (file)
@@ -116,6 +116,23 @@ func determinantByte(m [4][4]byte) byte {
                m[0][3]*m[1][2]*m[2][1]*m[3][0]
 }
 
+type A []A
+
+// A sequence of constant indexings.
+func IndexChain1(s A) A {
+       return s[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
+}
+
+// A sequence of non-constant indexings.
+func IndexChain2(s A, i int) A {
+       return s[i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i]
+}
+
+// Another sequence of indexings.
+func IndexChain3(s []int) int {
+       return s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[s[0]]]]]]]]]]]]]]]]]]]]]
+}
+
 // A right-leaning tree of byte multiplications.
 func righttree(a, b, c, d uint8) uint8 {
        return a * (b * (c * (d *
@@ -262,12 +279,12 @@ func ChainAssertArrayIndex(u *UArr) J {
                Children[0].(*UArr).
                Children[0].(*UArr).
                Children[0].(*UArr).
-               // Children[0].(*UArr).
-               // Children[0].(*UArr).
-               // Children[0].(*UArr).
-               // Children[0].(*UArr).
-               // Children[0].(*UArr).
-               // Children[0].(*UArr).
+               Children[0].(*UArr).
+               Children[0].(*UArr).
+               Children[0].(*UArr).
+               Children[0].(*UArr).
+               Children[0].(*UArr).
+               Children[0].(*UArr).
                Children[0]
 }
 
@@ -278,21 +295,20 @@ type UArrPtr struct {
 func (u *UArrPtr) Child(n int) J { return u.Children[n] }
 
 func ChainAssertArrayptrIndex(u *UArrPtr) J {
-       // TODO: don't crash on longer chains.
        return u.
                Children[0].(*UArrPtr).
                Children[0].(*UArrPtr).
                Children[0].(*UArrPtr).
                Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
-               // Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
+               Children[0].(*UArrPtr).
                Children[0]
 }
 
@@ -317,3 +333,14 @@ func ChainDivConst(a int) int {
                17 / 17 / 17 / 17 /
                17 / 17 / 17 / 17
 }
+
+func ChainMulBytes(a, b, c byte) byte {
+       return a*(a*(a*(a*(a*(a*(a*(a*(a*b+c)+c)+c)+c)+c)+c)+c)+c) + c
+}
+
+func ChainCap() {
+       select {
+       case <-make(chan int, cap(make(chan int, cap(make(chan int, cap(make(chan int, cap(make(chan int))))))))):
+       default:
+       }
+}