History

tccgen: return: avoid jmp to retsym if possible

When 'return' is the last statement of the top-level block (very common and often recommended case) jump is not needed.

Pavlas, Zdenek committed 10 years ago

Commit 71b62201 parent 0a402f61 file · +5 −1Browse files

Unified · Split

tccgen.c+5−1
@@ -4922,7 +4922,9 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 4921 unmodified lines
4922 skip(')');4922 skip(')');
4923 a = gvtst(1, 0);4923 a = gvtst(1, 0);
4924 b = 0;4924 b = 0;
4925 ++local_scope;
4925 block(&a, &b, case_sym, def_sym, case_reg, 0);4926 block(&a, &b, case_sym, def_sym, case_reg, 0);
4927 --local_scope;
4926 if(!nocode_wanted)4928 if(!nocode_wanted)
4927 gjmp_addr(d);4929 gjmp_addr(d);
4928 gsym(a);4930 gsym(a);
@@ -5060,7 +5062,9 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 131 unmodified lines
5060 vtop--; /* NOT vpop() because on x86 it would flush the fp stack */5062 vtop--; /* NOT vpop() because on x86 it would flush the fp stack */
5061 }5063 }
5062 skip(';');5064 skip(';');
5063 rsym = gjmp(rsym); /* jmp */5065 /* jump unless last stmt in top-level block */
5066 if (tok != '}' || local_scope != 1)
5067 rsym = gjmp(rsym);
5064 } else if (tok == TOK_BREAK) {5068 } else if (tok == TOK_BREAK) {
5065 /* compute jump */5069 /* compute jump */
5066 if (!bsym)5070 if (!bsym)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t