]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/8g: don't allocate a register early for cap(CHAN).
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 1 Jul 2014 07:20:51 +0000 (09:20 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Tue, 1 Jul 2014 07:20:51 +0000 (09:20 +0200)
There is no reason to generate different code for cap and len.

Fixes #8025.
Fixes #8026.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/93570044

src/cmd/8g/cgen.c
test/torture.go

index d626c2eb02ef894c9d635c434ca9146c7b90fdc0..5988a4328c9fd98fa682596fe9048eb66a3e21fc 100644 (file)
@@ -347,8 +347,11 @@ cgen(Node *n, Node *res)
                if(istype(nl->type, TCHAN)) {
                        // chan has cap in the second 32-bit word.
                        // a zero pointer means zero length
-                       regalloc(&n1, types[tptr], res);
+                       tempname(&n1, types[tptr]);
                        cgen(nl, &n1);
+                       regalloc(&n2, types[tptr], N);
+                       gmove(&n1, &n2);
+                       n1 = n2;
 
                        nodconst(&n2, types[tptr], 0);
                        gins(optoas(OCMP, types[tptr]), &n1, &n2);
index bbf6d347d995afe32a938e5394298a369949591c..197b481e66de03f015fe82b949a77bbf20c6756e 100644 (file)
@@ -337,3 +337,10 @@ func ChainDivConst(a int) int {
 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:
+       }
+}