]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix condition for fast pathed interface conversions
authorDmitry Vyukov <dvyukov@google.com>
Wed, 28 Jan 2015 14:28:50 +0000 (17:28 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Wed, 28 Jan 2015 15:33:10 +0000 (15:33 +0000)
For some reason the current conditions require the type to be "uintptr-shaped".
This cuts off structs and arrays with a pointer.
isdirectiface and width==widthptr is sufficient condition to enable the fast paths.

Change-Id: I11842531e7941365413606cfd6c34c202aa14786
Reviewed-on: https://go-review.googlesource.com/3414
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/gc/walk.c

index c5901b799e08dba0ca6ff5e42dff092339f483e5..b1622ae177c8d051de90bfdca40c4ca6a0add920 100644 (file)
@@ -883,8 +883,8 @@ walkexpr(Node **np, NodeList **init)
        case OCONVIFACE:
                walkexpr(&n->left, init);
 
-               // Optimize convT2E as a two-word copy when T is uintptr-shaped.
-               if(isnilinter(n->type) && isdirectiface(n->left->type) && n->left->type->width == widthptr && isint[simsimtype(n->left->type)]) {
+               // Optimize convT2E as a two-word copy when T is pointer-shaped.
+               if(isnilinter(n->type) && isdirectiface(n->left->type)) {
                        l = nod(OEFACE, typename(n->left->type), n->left);
                        l->type = n->type;
                        l->typecheck = n->typecheck;
@@ -927,7 +927,7 @@ walkexpr(Node **np, NodeList **init)
                        l->addable = 1;
                        ll = list(ll, l);
 
-                       if(isdirectiface(n->left->type) && n->left->type->width == widthptr && isint[simsimtype(n->left->type)]) {
+                       if(isdirectiface(n->left->type)) {
                                /* For pointer types, we can make a special form of optimization
                                 *
                                 * These statements are put onto the expression init list: