~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/cmd/gc/pgen.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
{
15
15
        Plist *pl;
16
16
        Node nod1, *n;
17
 
        Prog *ptxt;
 
17
        Prog *plocals, *ptxt, *p, *p1;
18
18
        int32 lno;
19
19
        Type *t;
20
20
        Iter save;
21
21
        vlong oldstksize;
 
22
        NodeList *l;
22
23
 
23
24
        if(newproc == N) {
24
25
                newproc = sysfunc("newproc");
29
30
                throwreturn = sysfunc("throwreturn");
30
31
        }
31
32
 
32
 
        if(fn->nbody == nil)
33
 
                return;
 
33
        lno = setlineno(fn);
 
34
 
 
35
        if(fn->nbody == nil) {
 
36
                if(pure_go || memcmp(fn->nname->sym->name, "init·", 6) == 0)
 
37
                        yyerror("missing function body", fn);
 
38
                goto ret;
 
39
        }
34
40
 
35
41
        saveerrors();
36
42
 
37
43
        // set up domain for labels
38
44
        clearlabels();
39
45
 
40
 
        lno = setlineno(fn);
41
 
 
42
46
        curfn = fn;
43
47
        dowidth(curfn->type);
44
48
 
63
67
        walk(curfn);
64
68
        if(nerrors != 0)
65
69
                goto ret;
 
70
        if(flag_race)
 
71
                racewalk(curfn);
 
72
        if(nerrors != 0)
 
73
                goto ret;
66
74
 
67
75
        continpc = P;
68
76
        breakpc = P;
76
84
        ptxt = gins(ATEXT, isblank(curfn->nname) ? N : curfn->nname, &nod1);
77
85
        if(fn->dupok)
78
86
                ptxt->TEXTFLAG = DUPOK;
79
 
        afunclit(&ptxt->from);
 
87
        afunclit(&ptxt->from, curfn->nname);
80
88
 
81
89
        ginit();
 
90
 
 
91
        plocals = gins(ALOCALS, N, N);
 
92
 
 
93
        for(t=curfn->paramfld; t; t=t->down)
 
94
                gtrack(tracksym(t->type));
 
95
 
 
96
        for(l=fn->dcl; l; l=l->next) {
 
97
                n = l->n;
 
98
                if(n->op != ONAME) // might be OTYPE or OLITERAL
 
99
                        continue;
 
100
                switch(n->class) {
 
101
                case PAUTO:
 
102
                case PPARAM:
 
103
                case PPARAMOUT:
 
104
                        nodconst(&nod1, types[TUINTPTR], l->n->type->width);
 
105
                        p = gins(ATYPE, l->n, &nod1);
 
106
                        p->from.gotype = ngotype(l->n);
 
107
                        break;
 
108
                }
 
109
        }
 
110
 
82
111
        genlist(curfn->enter);
83
112
 
84
113
        retpc = nil;
85
114
        if(hasdefer || curfn->exit) {
86
 
                Prog *p1;
87
 
 
88
115
                p1 = gjmp(nil);
89
116
                retpc = gjmp(nil);
90
117
                patch(p1, pc);
111
138
        gclean();
112
139
        if(nerrors != 0)
113
140
                goto ret;
 
141
 
114
142
        pc->as = ARET;  // overwrite AEND
115
143
        pc->lineno = lineno;
116
144
 
120
148
 
121
149
        oldstksize = stksize;
122
150
        allocauto(ptxt);
 
151
 
 
152
        plocals->to.type = D_CONST;
 
153
        plocals->to.offset = stksize;
 
154
 
123
155
        if(0)
124
156
                print("allocauto: %lld to %lld\n", oldstksize, (vlong)stksize);
125
157
 
145
177
{
146
178
        if (a->class != b->class)
147
179
                return (a->class == PAUTO) ? 1 : -1;
148
 
        if (a->class != PAUTO)
149
 
                return a->xoffset - b->xoffset;
 
180
        if (a->class != PAUTO) {
 
181
                if (a->xoffset < b->xoffset)
 
182
                        return -1;
 
183
                if (a->xoffset > b->xoffset)
 
184
                        return 1;
 
185
                return 0;
 
186
        }
150
187
        if ((a->used == 0) != (b->used == 0))
151
188
                return b->used - a->used;
152
189
        return b->type->align - a->type->align;
177
214
        ll = curfn->dcl;
178
215
        n = ll->n;
179
216
        if (n->class == PAUTO && n->op == ONAME && !n->used) {
 
217
                // No locals used at all
180
218
                curfn->dcl = nil;
181
219
                stksize = 0;
 
220
                fixautoused(ptxt);
182
221
                return;
183
222
        }
184
223
 
206
245
                stksize = rnd(stksize, n->type->align);
207
246
                if(thechar == '5')
208
247
                        stksize = rnd(stksize, widthptr);
 
248
                if(stksize >= (1ULL<<31)) {
 
249
                        setlineno(curfn);
 
250
                        yyerror("stack frame too large (>2GB)");
 
251
                }
209
252
                n->stkdelta = -stksize - n->xoffset;
210
253
        }
211
254