Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1340)

Side by Side Diff: src/cmd/gc/walk.c

Issue 6351090: code review 6351090: cmd/gc: Inline pointer sized T2I interface conversions (Closed)
Patch Set: diff -r 46e193d130ce https://code.google.com/p/go/ Created 12 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/gc/runtime.go ('k') | src/pkg/runtime/iface.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include <u.h> 5 #include <u.h>
6 #include <libc.h> 6 #include <libc.h>
7 #include "go.h" 7 #include "go.h"
8 8
9 static Node* walkprint(Node*, NodeList**, int); 9 static Node* walkprint(Node*, NodeList**, int);
10 static Node* mapfn(char*, Type*); 10 static Node* mapfn(char*, Type*);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 void 368 void
369 walkexpr(Node **np, NodeList **init) 369 walkexpr(Node **np, NodeList **init)
370 { 370 {
371 Node *r, *l, *var, *a; 371 Node *r, *l, *var, *a;
372 NodeList *ll, *lr, *lpost; 372 NodeList *ll, *lr, *lpost;
373 Type *t; 373 Type *t;
374 int et; 374 int et;
375 int64 v; 375 int64 v;
376 int32 lno; 376 int32 lno;
377 » Node *n, *fn; 377 » Node *n, *fn, *n1, *n2;
378 Sym *sym; 378 Sym *sym;
379 char buf[100], *p; 379 char buf[100], *p;
380 380
381 n = *np; 381 n = *np;
382 382
383 if(n == N) 383 if(n == N)
384 return; 384 return;
385 385
386 if(init == &n->ninit) { 386 if(init == &n->ninit) {
387 // not okay to use n->ninit when walking n, 387 // not okay to use n->ninit when walking n,
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 l->type = ptrto(types[TUINT8]); 764 l->type = ptrto(types[TUINT8]);
765 l->addable = 1; 765 l->addable = 1;
766 l->class = PEXTERN; 766 l->class = PEXTERN;
767 l->xoffset = 0; 767 l->xoffset = 0;
768 sym->def = l; 768 sym->def = l;
769 ggloblsym(sym, widthptr, 1, 0); 769 ggloblsym(sym, widthptr, 1, 0);
770 } 770 }
771 l = nod(OADDR, sym->def, N); 771 l = nod(OADDR, sym->def, N);
772 l->addable = 1; 772 l->addable = 1;
773 ll = list(ll, l); 773 ll = list(ll, l);
774
775 if(n->left->type->width == widthptr &&
776 isint[simsimtype(n->left->type)]) {
777 /* For pointer types, we can make a special form of optimization
778 *
779 * These statements are put onto the expression init list:
780 * Itab *tab = atomicloadtype(&cache);
781 * if(tab == nil)
782 * tab = typ2Itab(type, itype, &cac he);
783 *
784 * The CONVIFACE expression is replaced with thi s:
785 * OEFACE{tab, ptr};
786 */
787 l = temp(ptrto(types[TUINT8]));
788
789 n1 = nod(OAS, l, sym->def);
790 typecheck(&n1, Etop);
791 *init = list(*init, n1);
792
793 fn = syslook("typ2Itab", 1);
794 n1 = nod(OCALL, fn, N);
795 n1->list = ll;
796 typecheck(&n1, Erv);
797 walkexpr(&n1, init);
798
799 n2 = nod(OIF, N, N);
800 n2->ntest = nod(OEQ, l, nodnil());
801 n2->nbody = list1(nod(OAS, l, n1));
802 n2->likely = -1;
803 typecheck(&n2, Etop);
804 *init = list(*init, n2);
805
806 l = nod(OEFACE, l, n->left);
807 l->typecheck = n->typecheck;·
808 l->type = n->type;
809 n = l;
810 goto ret;
811 }
774 } 812 }
775 ll = list(ll, n->left); 813 ll = list(ll, n->left);
776 argtype(fn, n->left->type); 814 argtype(fn, n->left->type);
777 argtype(fn, n->type); 815 argtype(fn, n->type);
778 dowidth(fn->type); 816 dowidth(fn->type);
779 n = nod(OCALL, fn, N); 817 n = nod(OCALL, fn, N);
780 n->list = ll; 818 n->list = ll;
781 typecheck(&n, Erv); 819 typecheck(&n, Erv);
782 walkexpr(&n, init); 820 walkexpr(&n, init);
783 goto ret; 821 goto ret;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 r = mkcall1(fn, n->type, init, n->left, n->right); 1199 r = mkcall1(fn, n->type, init, n->left, n->right);
1162 if(n->etype == ONE) 1200 if(n->etype == ONE)
1163 r = nod(ONOT, r, N); 1201 r = nod(ONOT, r, N);
1164 ················ 1202 ················
1165 // check itable/type before full compare. 1203 // check itable/type before full compare.
1166 if(n->etype == OEQ) 1204 if(n->etype == OEQ)
1167 r = nod(OANDAND, nod(OEQ, nod(OITAB, n->left, N), nod(OI TAB, n->right, N)), r); 1205 r = nod(OANDAND, nod(OEQ, nod(OITAB, n->left, N), nod(OI TAB, n->right, N)), r);
1168 else 1206 else
1169 r = nod(OOROR, nod(ONE, nod(OITAB, n->left, N), nod(OITA B, n->right, N)), r); 1207 r = nod(OOROR, nod(ONE, nod(OITAB, n->left, N), nod(OITA B, n->right, N)), r);
1170 typecheck(&r, Erv); 1208 typecheck(&r, Erv);
1171 » » walkexpr(&r, nil); 1209 » » walkexpr(&r, init);
1172 r->type = n->type; 1210 r->type = n->type;
1173 n = r; 1211 n = r;
1174 goto ret; 1212 goto ret;
1175 1213
1176 case OARRAYLIT: 1214 case OARRAYLIT:
1177 case OMAPLIT: 1215 case OMAPLIT:
1178 case OSTRUCTLIT: 1216 case OSTRUCTLIT:
1179 case OPTRLIT: 1217 case OPTRLIT:
1180 var = temp(n->type); 1218 var = temp(n->type);
1181 anylit(0, n, var, init); 1219 anylit(0, n, var, init);
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 bits -= v; 2887 bits -= v;
2850 } 2888 }
2851 break; 2889 break;
2852 } 2890 }
2853 ········ 2891 ········
2854 if(!sign && bits <= 62 && (1LL<<bits) <= max) 2892 if(!sign && bits <= 62 && (1LL<<bits) <= max)
2855 return 1; 2893 return 1;
2856 ········ 2894 ········
2857 return 0; 2895 return 0;
2858 } 2896 }
OLDNEW
« no previous file with comments | « src/cmd/gc/runtime.go ('k') | src/pkg/runtime/iface.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b