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

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

Issue 116060043: code review 116060043: cmd/gc: mark auxiliary symbols as containing no pointers (Closed)
Patch Set: diff -r f09014ba559b https://dvyukov%40google.com@code.google.com/p/go/ Created 10 years, 8 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/plive.c ('k') | src/cmd/gc/walk.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 #include "../ld/textflag.h"
8 #include "../../pkg/runtime/mgc0.h" 9 #include "../../pkg/runtime/mgc0.h"
9 10
10 /* 11 /*
11 * runtime interface and reflection data structures 12 * runtime interface and reflection data structures
12 */ 13 */
13 14
14 static NodeList* signatlist; 15 static NodeList* signatlist;
15 static Sym* dtypesym(Type*); 16 static Sym* dtypesym(Type*);
16 static Sym* weaktypesym(Type*); 17 static Sym* weaktypesym(Type*);
17 static Sym* dalgsym(Type*); 18 static Sym* dalgsym(Type*);
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 nam = smprint("importpath.%s.", p->prefix); 518 nam = smprint("importpath.%s.", p->prefix);
518 519
519 n = nod(ONAME, N, N); 520 n = nod(ONAME, N, N);
520 n->sym = pkglookup(nam, gopkg); 521 n->sym = pkglookup(nam, gopkg);
521 free(nam); 522 free(nam);
522 n->class = PEXTERN; 523 n->class = PEXTERN;
523 n->xoffset = 0; 524 n->xoffset = 0;
524 p->pathsym = n->sym; 525 p->pathsym = n->sym;
525 526
526 gdatastring(n, p->path); 527 gdatastring(n, p->path);
527 » ggloblsym(n->sym, types[TSTRING]->width, 1, 1); 528 » ggloblsym(n->sym, types[TSTRING]->width, DUPOK|RODATA);
528 } 529 }
529 530
530 static int 531 static int
531 dgopkgpath(Sym *s, int ot, Pkg *pkg) 532 dgopkgpath(Sym *s, int ot, Pkg *pkg)
532 { 533 {
533 if(pkg == nil) 534 if(pkg == nil)
534 return dgostringptr(s, ot, nil); 535 return dgostringptr(s, ot, nil);
535 536
536 // Emit reference to go.importpath.""., which 6l will 537 // Emit reference to go.importpath.""., which 6l will
537 // rewrite using the correct import path. Every package 538 // rewrite using the correct import path. Every package
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 if(s->flags & SymSiggen) 969 if(s->flags & SymSiggen)
969 return s; 970 return s;
970 s->flags |= SymSiggen; 971 s->flags |= SymSiggen;
971 972
972 // special case (look for runtime below): 973 // special case (look for runtime below):
973 // when compiling package runtime, 974 // when compiling package runtime,
974 // emit the type structures for int, float, etc. 975 // emit the type structures for int, float, etc.
975 tbase = t; 976 tbase = t;
976 if(isptr[t->etype] && t->sym == S && t->type->sym != S) 977 if(isptr[t->etype] && t->sym == S && t->type->sym != S)
977 tbase = t->type; 978 tbase = t->type;
978 » dupok = tbase->sym == S; 979 » dupok = 0;
980 » if(tbase->sym == S)
981 » » dupok = DUPOK;
979 982
980 if(compiling_runtime && 983 if(compiling_runtime &&
981 (tbase == types[tbase->etype] || 984 (tbase == types[tbase->etype] ||
982 tbase == bytetype || 985 tbase == bytetype ||
983 tbase == runetype || 986 tbase == runetype ||
984 tbase == errortype)) { // int, float, etc 987 tbase == errortype)) { // int, float, etc
985 goto ok; 988 goto ok;
986 } 989 }
987 990
988 // named types from other files are defined only by those files 991 // named types from other files are defined only by those files
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 else 1146 else
1144 ot = dgostringptr(s, ot, nil); 1147 ot = dgostringptr(s, ot, nil);
1145 } 1148 }
1146 ot = dsymptr(s, ot, dtypesym(t1->type), 0); 1149 ot = dsymptr(s, ot, dtypesym(t1->type), 0);
1147 ot = dgostrlitptr(s, ot, t1->note); 1150 ot = dgostrlitptr(s, ot, t1->note);
1148 ot = duintptr(s, ot, t1->width); // field offset 1151 ot = duintptr(s, ot, t1->width); // field offset
1149 } 1152 }
1150 break; 1153 break;
1151 } 1154 }
1152 ot = dextratype(s, ot, t, xt); 1155 ot = dextratype(s, ot, t, xt);
1153 » ggloblsym(s, ot, dupok, 1); 1156 » ggloblsym(s, ot, dupok|RODATA);
1154 1157
1155 // generate typelink.foo pointing at s = type.foo. 1158 // generate typelink.foo pointing at s = type.foo.
1156 // The linker will leave a table of all the typelinks for 1159 // The linker will leave a table of all the typelinks for
1157 // types in the binary, so reflect can find them. 1160 // types in the binary, so reflect can find them.
1158 // We only need the link for unnamed composites that 1161 // We only need the link for unnamed composites that
1159 // we want be able to find. 1162 // we want be able to find.
1160 if(t->sym == S) { 1163 if(t->sym == S) {
1161 switch(t->etype) { 1164 switch(t->etype) {
1162 case TARRAY: 1165 case TARRAY:
1163 case TCHAN: 1166 case TCHAN:
1164 case TMAP: 1167 case TMAP:
1165 slink = typelinksym(t); 1168 slink = typelinksym(t);
1166 dsymptr(slink, 0, s, 0); 1169 dsymptr(slink, 0, s, 0);
1167 » » » ggloblsym(slink, widthptr, dupok, 1); 1170 » » » ggloblsym(slink, widthptr, dupok|RODATA);
1168 } 1171 }
1169 } 1172 }
1170 1173
1171 return s; 1174 return s;
1172 } 1175 }
1173 1176
1174 void 1177 void
1175 dumptypestructs(void) 1178 dumptypestructs(void)
1176 { 1179 {
1177 int i; 1180 int i;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 case 1: 1263 case 1:
1261 case 2: 1264 case 2:
1262 case 4: 1265 case 4:
1263 case 8: 1266 case 8:
1264 case 16: 1267 case 16:
1265 snprint(buf, sizeof buf, "memcopy%d", (int)t->width*8); 1268 snprint(buf, sizeof buf, "memcopy%d", (int)t->width*8);
1266 ot = dsymptr(s, ot, pkglookup(buf, runtimepkg), 0); 1269 ot = dsymptr(s, ot, pkglookup(buf, runtimepkg), 0);
1267 break; 1270 break;
1268 } 1271 }
1269 1272
1270 » ggloblsym(s, ot, 1, 1); 1273 » ggloblsym(s, ot, DUPOK|RODATA);
1271 return s; 1274 return s;
1272 } 1275 }
1273 1276
1274 static int 1277 static int
1275 gcinline(Type *t) 1278 gcinline(Type *t)
1276 { 1279 {
1277 switch(t->etype) { 1280 switch(t->etype) {
1278 case TARRAY: 1281 case TARRAY:
1279 if(t->bound == 1) 1282 if(t->bound == 1)
1280 return 1; 1283 return 1;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 s->flags |= SymGcgen; 1485 s->flags |= SymGcgen;
1483 1486
1484 if(t->width == BADWIDTH) 1487 if(t->width == BADWIDTH)
1485 dowidth(t); 1488 dowidth(t);
1486 1489
1487 ot = 0; 1490 ot = 0;
1488 off = 0; 1491 off = 0;
1489 ot = duintptr(s, ot, t->width); 1492 ot = duintptr(s, ot, t->width);
1490 ot = dgcsym1(s, ot, t, &off, 0); 1493 ot = dgcsym1(s, ot, t, &off, 0);
1491 ot = duintptr(s, ot, GC_END); 1494 ot = duintptr(s, ot, GC_END);
1492 » ggloblsym(s, ot, 1, 1); 1495 » ggloblsym(s, ot, DUPOK|RODATA);
1493 1496
1494 if(t->align > 0) 1497 if(t->align > 0)
1495 off = rnd(off, t->align); 1498 off = rnd(off, t->align);
1496 if(off != t->width) 1499 if(off != t->width)
1497 fatal("dgcsym: off=%lld, size=%lld, type %T", off, t->width, t); 1500 fatal("dgcsym: off=%lld, size=%lld, type %T", off, t->width, t);
1498 1501
1499 return s; 1502 return s;
1500 } 1503 }
OLDNEW
« no previous file with comments | « src/cmd/gc/plive.c ('k') | src/cmd/gc/walk.c » ('j') | no next file with comments »

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