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

Delta Between Two Patch Sets: src/cmd/gc/dcl.c

Issue 4634073: code review 4634073: gc: Escape analysis. (Closed)
Left Patch Set: diff -r 2afebca6d967 https://go.googlecode.com/hg/ Created 13 years, 8 months ago
Right Patch Set: diff -r adfa9f5cca40 https://go.googlecode.com/hg/ Created 13 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/gc/Makefile ('k') | src/cmd/gc/esc.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 "go.h" 5 #include "go.h"
6 #include "y.tab.h" 6 #include "y.tab.h"
7 7
8 static void funcargs(Node*); 8 static void funcargs(Node*);
9 9
10 static int 10 static int
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 case OTYPE: 450 case OTYPE:
451 case OLITERAL: 451 case OLITERAL:
452 return n->sym != S; 452 return n->sym != S;
453 } 453 }
454 return 0; 454 return 0;
455 } 455 }
456 456
457 void 457 void
458 colasdefn(NodeList *left, Node *defn) 458 colasdefn(NodeList *left, Node *defn)
459 { 459 {
460 » int nnew; 460 » int nnew, nerr;
461 NodeList *l; 461 NodeList *l;
462 Node *n; 462 Node *n;
463 463
464 nnew = 0; 464 nnew = 0;
465 nerr = 0;
465 for(l=left; l; l=l->next) { 466 for(l=left; l; l=l->next) {
466 n = l->n; 467 n = l->n;
467 if(isblank(n)) 468 if(isblank(n))
468 continue; 469 continue;
469 if(!colasname(n)) { 470 if(!colasname(n)) {
470 yyerror("non-name %#N on left side of :=", n); 471 yyerror("non-name %#N on left side of :=", n);
472 nerr++;
471 continue; 473 continue;
472 } 474 }
473 if(n->sym->block == block) 475 if(n->sym->block == block)
474 continue; 476 continue;
475 477
476 nnew++; 478 nnew++;
477 n = newname(n->sym); 479 n = newname(n->sym);
478 declare(n, dclcontext); 480 declare(n, dclcontext);
479 n->defn = defn; 481 n->defn = defn;
480 defn->ninit = list(defn->ninit, nod(ODCL, n, N)); 482 defn->ninit = list(defn->ninit, nod(ODCL, n, N));
481 l->n = n; 483 l->n = n;
482 } 484 }
483 » if(nnew == 0) 485 » if(nnew == 0 && nerr == 0)
484 yyerror("no new variables on left side of :="); 486 yyerror("no new variables on left side of :=");
485 } 487 }
486 488
487 Node* 489 Node*
488 colas(NodeList *left, NodeList *right) 490 colas(NodeList *left, NodeList *right)
489 { 491 {
490 Node *as; 492 Node *as;
491 493
492 as = nod(OAS2, N, N); 494 as = nod(OAS2, N, N);
493 as->list = left; 495 as->list = left;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // right now all we need is the name list. 739 // right now all we need is the name list.
738 // avoids cycles for recursive interface types. 740 // avoids cycles for recursive interface types.
739 n->type = typ(TINTERMETH); 741 n->type = typ(TINTERMETH);
740 n->type->nname = n->right; 742 n->type->nname = n->right;
741 n->right = N; 743 n->right = N;
742 left->type = n->type; 744 left->type = n->type;
743 queuemethod(n); 745 queuemethod(n);
744 } else { 746 } else {
745 typecheck(&n->right, Etype); 747 typecheck(&n->right, Etype);
746 n->type = n->right->type; 748 n->type = n->right->type;
747 » » » » if(n->type == T) { 749 » » » » if(n->type == T)
748 » » » » » *t0 = T; 750 » » » » » continue;
749 » » » » » return t0;
750 » » » » }
751 if(left != N) 751 if(left != N)
752 left->type = n->type; 752 left->type = n->type;
753 n->right = N; 753 n->right = N;
754 if(n->embedded && n->type != T) { 754 if(n->embedded && n->type != T) {
755 t1 = n->type; 755 t1 = n->type;
756 if(t1->sym == S && isptr[t1->etype]) { 756 if(t1->sym == S && isptr[t1->etype]) {
757 t1 = t1->type; 757 t1 = t1->type;
758 if(t1->etype == TINTER) 758 if(t1->etype == TINTER)
759 yyerror("embedded type c annot be a pointer to interface"); 759 yyerror("embedded type c annot be a pointer to interface");
760 } 760 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 continue; 814 continue;
815 } 815 }
816 816
817 f = typ(TFIELD); 817 f = typ(TFIELD);
818 f->type = n->type; 818 f->type = n->type;
819 f->note = note; 819 f->note = note;
820 f->width = BADWIDTH; 820 f->width = BADWIDTH;
821 f->isddd = n->isddd; 821 f->isddd = n->isddd;
822 822
823 // esc.c needs to find f given a PPARAM to add the tag. 823 // esc.c needs to find f given a PPARAM to add the tag.
824 » » if (funarg && n->left && n->left->class == PPARAM) { 824 » » if(funarg && n->left && n->left->class == PPARAM)
825 n->left->paramfld = f; 825 n->left->paramfld = f;
826 }
827 826
828 if(left != N && left->op == ONAME) { 827 if(left != N && left->op == ONAME) {
829 f->nname = left; 828 f->nname = left;
830 f->embedded = n->embedded; 829 f->embedded = n->embedded;
831 f->sym = f->nname->sym; 830 f->sym = f->nname->sym;
832 if(importpkg && !exportname(f->sym->name)) 831 if(importpkg && !exportname(f->sym->name))
833 f->sym = pkglookup(f->sym->name, structpkg); 832 f->sym = pkglookup(f->sym->name, structpkg);
834 if(f->sym && !isblank(f->nname)) { 833 if(f->sym && !isblank(f->nname)) {
835 for(t1=*t0; t1!=T; t1=t1->down) { 834 for(t1=*t0; t1!=T; t1=t1->down) {
836 if(t1->sym == f->sym) { 835 if(t1->sym == f->sym) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 // we want to see *t, not t0, in the method name. 1074 // we want to see *t, not t0, in the method name.
1076 if(t != t0 && t0->sym) 1075 if(t != t0 && t0->sym)
1077 t0 = ptrto(t); 1076 t0 = ptrto(t);
1078 1077
1079 suffix = ""; 1078 suffix = "";
1080 if(iface) { 1079 if(iface) {
1081 dowidth(t0); 1080 dowidth(t0);
1082 if(t0->width < types[tptr]->width) 1081 if(t0->width < types[tptr]->width)
1083 suffix = "·i"; 1082 suffix = "·i";
1084 } 1083 }
1085 » p = smprint("%#hT·%s%s", t0, nsym->name, suffix); 1084 » if(t0->sym == S && isptr[t0->etype])
1085 » » p = smprint("(%#hT).%s%s", t0, nsym->name, suffix);
1086 » else
1087 » » p = smprint("%#hT.%s%s", t0, nsym->name, suffix);
1086 s = pkglookup(p, s->pkg); 1088 s = pkglookup(p, s->pkg);
1087 free(p); 1089 free(p);
1088 return s; 1090 return s;
1089 1091
1090 bad: 1092 bad:
1091 yyerror("illegal receiver type: %T", t0); 1093 yyerror("illegal receiver type: %T", t0);
1092 return S; 1094 return S;
1093 } 1095 }
1094 1096
1095 Node* 1097 Node*
1096 methodname(Node *n, Type *t) 1098 methodname(Node *n, Type *t)
1097 { 1099 {
1098 Sym *s; 1100 Sym *s;
1099 1101
1100 s = methodsym(n->sym, t, 0); 1102 s = methodsym(n->sym, t, 0);
1101 if(s == S) 1103 if(s == S)
1102 return n; 1104 return n;
1103 return newname(s); 1105 return newname(s);
1104 } 1106 }
1105 1107
1106 Node* 1108 Node*
1107 methodname1(Node *n, Node *t) 1109 methodname1(Node *n, Node *t)
1108 { 1110 {
1109 char *star; 1111 char *star;
1110 char *p; 1112 char *p;
1111 1113
1112 » star = ""; 1114 » star = nil;
1113 if(t->op == OIND) { 1115 if(t->op == OIND) {
1114 star = "*"; 1116 star = "*";
1115 t = t->left; 1117 t = t->left;
1116 } 1118 }
1117 if(t->sym == S || isblank(n)) 1119 if(t->sym == S || isblank(n))
1118 return newname(n->sym); 1120 return newname(n->sym);
1119 » p = smprint("%s%S·%S", star, t->sym, n->sym); 1121 » if(star)
1122 » » p = smprint("(%s%S).%S", star, t->sym, n->sym);
1123 » else
1124 » » p = smprint("%S.%S", t->sym, n->sym);
1120 n = newname(pkglookup(p, t->sym->pkg)); 1125 n = newname(pkglookup(p, t->sym->pkg));
1121 free(p); 1126 free(p);
1122 return n; 1127 return n;
1123 } 1128 }
1124 1129
1125 /* 1130 /*
1126 * add a method, declared as a function, 1131 * add a method, declared as a function,
1127 * n is fieldname, pa is base type, t is function type 1132 * n is fieldname, pa is base type, t is function type
1128 */ 1133 */
1129 void 1134 void
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 dclcontext = PAUTO; 1249 dclcontext = PAUTO;
1245 funcdepth = n->funcdepth + 1; 1250 funcdepth = n->funcdepth + 1;
1246 compile(n); 1251 compile(n);
1247 curfn = nil; 1252 curfn = nil;
1248 funcdepth = 0; 1253 funcdepth = 0;
1249 dclcontext = PEXTERN; 1254 dclcontext = PEXTERN;
1250 } 1255 }
1251 1256
1252 1257
1253 1258
LEFTRIGHT

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