Commit cb64ec5b authored by Russ Cox's avatar Russ Cox

only generate non-trivial signatures in the

file in which they occur.  avoids duplicate
trampoline generation across multiple files.

R=ken
OCL=20976
CL=20980
parent a9e890d5
...@@ -707,10 +707,12 @@ dumpsigt(Type *t0, Sym *s) ...@@ -707,10 +707,12 @@ dumpsigt(Type *t0, Sym *s)
// set DUPOK to allow other .6s to contain // set DUPOK to allow other .6s to contain
// the same signature. only one will be chosen. // the same signature. only one will be chosen.
// should only happen for empty signatures
p = pc; p = pc;
gins(AGLOBL, N, N); gins(AGLOBL, N, N);
p->from = at; p->from = at;
p->from.scale = DUPOK; if(a == nil)
p->from.scale = DUPOK;
p->to = ac; p->to = ac;
p->to.offset = ot; p->to.offset = ot;
} }
...@@ -891,17 +893,20 @@ dumpsignatures(void) ...@@ -891,17 +893,20 @@ dumpsignatures(void)
continue; continue;
s->siggen = 1; s->siggen = 1;
//print("dosig %T\n", t); // don't emit non-trivial signatures for types defined outside this file.
// don't emit signatures for *NamedStruct or interface if // non-trivial signatures might also drag in generated trampolines,
// they were defined by other packages. // and ar can't handle duplicates of the trampolines.
// (optimization)
s1 = S; s1 = S;
if(isptr[et] && t->type != T) if(isptr[et] && t->type != T) {
s1 = t->type->sym; s1 = t->type->sym;
else if(et == TINTER) if(s1 && !t->type->local)
continue;
}
else if(et == TINTER) {
s1 = t->sym; s1 = t->sym;
if(s1 != S && strcmp(s1->opackage, package) != 0) if(s1 && !t->local)
continue; continue;
}
if(et == TINTER) if(et == TINTER)
dumpsigi(t, s); dumpsigi(t, s);
......
...@@ -78,7 +78,7 @@ dodcltype(Type *n) ...@@ -78,7 +78,7 @@ dodcltype(Type *n)
addtyp(n, dclcontext); addtyp(n, dclcontext);
found: found:
n->sym->local = 1; n->local = 1;
if(dcladj) if(dcladj)
dcladj(n->sym); dcladj(n->sym);
return n; return n;
...@@ -118,6 +118,8 @@ updatetype(Type *n, Type *t) ...@@ -118,6 +118,8 @@ updatetype(Type *n, Type *t)
fatal("updatetype %T / %T", n, t); fatal("updatetype %T / %T", n, t);
} }
if(n->local)
t->local = 1;
*n = *t; *n = *t;
n->sym = s; n->sym = s;
...@@ -274,8 +276,8 @@ addmethod(Node *n, Type *t, int local) ...@@ -274,8 +276,8 @@ addmethod(Node *n, Type *t, int local)
st = pa->sym; st = pa->sym;
if(st == S) if(st == S)
goto bad; goto bad;
if(local && !st->local) { if(local && !f->local) {
yyerror("method receiver type must be locally defined: %S", st); yyerror("method receiver type must be locally defined: %T", f);
return; return;
} }
...@@ -558,7 +560,6 @@ dcopy(Sym *a, Sym *b) ...@@ -558,7 +560,6 @@ dcopy(Sym *a, Sym *b)
a->vargen = b->vargen; a->vargen = b->vargen;
a->block = b->block; a->block = b->block;
a->lastlineno = b->lastlineno; a->lastlineno = b->lastlineno;
a->local = b->local;
a->offset = b->offset; a->offset = b->offset;
} }
...@@ -1233,7 +1234,7 @@ variter(Node *vv, Type *t, Node *ee) ...@@ -1233,7 +1234,7 @@ variter(Node *vv, Type *t, Node *ee)
loop: loop:
if(v == N && e == N) if(v == N && e == N)
return rev(r); return rev(r);
if(v == N || e == N) { if(v == N || e == N) {
yyerror("shape error in var dcl"); yyerror("shape error in var dcl");
return rev(r); return rev(r);
...@@ -1279,7 +1280,7 @@ loop: ...@@ -1279,7 +1280,7 @@ loop:
iota += 1; iota += 1;
return; return;
} }
if(v == N || c == N) { if(v == N || c == N) {
yyerror("shape error in var dcl"); yyerror("shape error in var dcl");
iota += 1; iota += 1;
......
...@@ -203,7 +203,7 @@ dumptype(Type *t) ...@@ -203,7 +203,7 @@ dumptype(Type *t)
return; return;
// no need to dump type if it's not ours (was imported) // no need to dump type if it's not ours (was imported)
if(t->sym != S && t->sym->otype == t && !t->sym->local) if(t->sym != S && t->sym->otype == t && !t->local)
return; return;
Bprint(bout, "type %#T %l#T\n", t, t); Bprint(bout, "type %#T %l#T\n", t, t);
......
...@@ -157,6 +157,7 @@ struct Type ...@@ -157,6 +157,7 @@ struct Type
uchar siggen; uchar siggen;
uchar funarg; uchar funarg;
uchar copyany; uchar copyany;
uchar local; // created in this file
// TFUNCT // TFUNCT
uchar thistuple; uchar thistuple;
...@@ -238,7 +239,6 @@ struct Sym ...@@ -238,7 +239,6 @@ struct Sym
uchar exported; // exported uchar exported; // exported
uchar imported; // imported uchar imported; // imported
uchar sym; // huffman encoding in object file uchar sym; // huffman encoding in object file
uchar local; // created in this file
uchar uniq; // imbedded field name first found uchar uniq; // imbedded field name first found
uchar siggen; // signature generated uchar siggen; // signature generated
......
...@@ -1465,7 +1465,7 @@ walkselect(Node *sel) ...@@ -1465,7 +1465,7 @@ walkselect(Node *sel)
res = list(res, oc); res = list(res, oc);
break; break;
} }
bod = N; bod = N;
count++; count++;
...@@ -1699,6 +1699,7 @@ sigtype(Type *st) ...@@ -1699,6 +1699,7 @@ sigtype(Type *st)
t = newtype(s); t = newtype(s);
t = dodcltype(t); t = dodcltype(t);
updatetype(t, st); updatetype(t, st);
t->local = 1;
// record internal type for signature generation // record internal type for signature generation
x = mal(sizeof(*x)); x = mal(sizeof(*x));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment