OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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 // "Portable" code generation. | 5 // "Portable" code generation. |
6 // Compiled separately for 5g, 6g, and 8g, so allowed to use gg.h, opt.h. | 6 // Compiled separately for 5g, 6g, and 8g, so allowed to use gg.h, opt.h. |
7 // Must code to the intersection of the three back ends. | 7 // Must code to the intersection of the three back ends. |
8 | 8 |
9 #include <u.h> | 9 #include <u.h> |
10 #include <libc.h> | 10 #include <libc.h> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 genlist(curfn->exit); | 174 genlist(curfn->exit); |
175 gclean(); | 175 gclean(); |
176 if(nerrors != 0) | 176 if(nerrors != 0) |
177 goto ret; | 177 goto ret; |
178 | 178 |
179 pc->as = ARET; // overwrite AEND | 179 pc->as = ARET; // overwrite AEND |
180 pc->lineno = lineno; | 180 pc->lineno = lineno; |
181 | 181 |
182 if(!debug['N'] || debug['R'] || debug['P']) { | 182 if(!debug['N'] || debug['R'] || debug['P']) { |
183 regopt(ptxt); | 183 regopt(ptxt); |
| 184 nilopt(ptxt); |
184 } | 185 } |
185 expandchecks(ptxt); | 186 expandchecks(ptxt); |
186 | 187 |
187 oldstksize = stksize; | 188 oldstksize = stksize; |
188 allocauto(ptxt); | 189 allocauto(ptxt); |
189 | 190 |
190 if(0) | 191 if(0) |
191 print("allocauto: %lld to %lld\n", oldstksize, (vlong)stksize); | 192 print("allocauto: %lld to %lld\n", oldstksize, (vlong)stksize); |
192 | 193 |
193 setlineno(curfn); | 194 setlineno(curfn); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 531 } |
531 } | 532 } |
532 | 533 |
533 void | 534 void |
534 cgen_checknil(Node *n) | 535 cgen_checknil(Node *n) |
535 { | 536 { |
536 Node reg; | 537 Node reg; |
537 | 538 |
538 if(disable_checknil) | 539 if(disable_checknil) |
539 return; | 540 return; |
540 » while(n->op == ODOT || (n->op == OINDEX && isfixedarray(n->left->type->t
ype))) // NOTE: not ODOTPTR | 541 » // Ideally we wouldn't see any TUINTPTR here, but we do. |
541 » » n = n->left; | 542 » if(n->type == T || (!isptr[n->type->etype] && n->type->etype != TUINTPTR
&& n->type->etype != TUNSAFEPTR)) { |
| 543 » » dump("checknil", n); |
| 544 » » fatal("bad checknil"); |
| 545 » } |
542 if((thechar == '5' && n->op != OREGISTER) || !n->addable) { | 546 if((thechar == '5' && n->op != OREGISTER) || !n->addable) { |
543 regalloc(®, types[tptr], n); | 547 regalloc(®, types[tptr], n); |
544 cgen(n, ®); | 548 cgen(n, ®); |
545 gins(ACHECKNIL, ®, N); | 549 gins(ACHECKNIL, ®, N); |
546 regfree(®); | 550 regfree(®); |
547 return; | 551 return; |
548 } | 552 } |
549 gins(ACHECKNIL, n, N); | 553 gins(ACHECKNIL, n, N); |
550 } | 554 } |
OLD | NEW |