small peephole optimizations · lua/lua@10b8c99 · GitHub
Skip to content

Commit 10b8c99

Browse files
committed
small peephole optimizations
1 parent bdc751c commit 10b8c99

5 files changed

Lines changed: 63 additions & 48 deletions

File tree

‎lcode.c‎

Lines changed: 53 additions & 38 deletions

‎lcode.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lcode.h,v 1.67 2017/09/28 16:53:29 roberto Exp roberto $
2+
** $Id: lcode.h,v 1.68 2017/10/04 21:56:32 roberto Exp roberto $
33
** Code generator for Lua
44
** See Copyright Notice in lua.h
55
*/
@@ -88,6 +88,7 @@ LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
8888
LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1,
8989
expdesc *v2, int line);
9090
LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
91+
LUAI_FUNC void luaK_finish (FuncState *fs);
9192

9293

9394
#endif

‎lparser.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lparser.c,v 2.167 2017/10/04 21:53:03 roberto Exp roberto $
2+
** $Id: lparser.c,v 2.168 2017/11/23 16:35:54 roberto Exp roberto $
33
** Lua Parser
44
** See Copyright Notice in lua.h
55
*/
@@ -547,7 +547,6 @@ static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) {
547547
fs->previousline = f->linedefined;
548548
fs->iwthabs = 0;
549549
fs->lasttarget = 0;
550-
fs->jpc = NO_JUMP;
551550
fs->freereg = 0;
552551
fs->nk = 0;
553552
fs->nabslineinfo = 0;
@@ -569,6 +568,7 @@ static void close_func (LexState *ls) {
569568
Proto *f = fs->f;
570569
luaK_ret(fs, 0, 0); /* final return */
571570
leaveblock(fs);
571+
luaK_finish(fs);
572572
luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
573573
f->sizecode = fs->pc;
574574
luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, ls_byte);

‎lparser.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** $Id: lparser.h,v 1.77 2017/04/28 20:57:45 roberto Exp roberto $
2+
** $Id: lparser.h,v 1.78 2017/06/27 11:35:31 roberto Exp roberto $
33
** Lua Parser
44
** See Copyright Notice in lua.h
55
*/
@@ -124,7 +124,6 @@ typedef struct FuncState {
124124
int pc; /* next position to code (equivalent to 'ncode') */
125125
int lasttarget; /* 'label' of last 'jump label' */
126126
int previousline; /* last line that was saved in 'lineinfo' */
127-
int jpc; /* list of pending jumps to 'pc' */
128127
int nk; /* number of elements in 'k' */
129128
int np; /* number of elements in 'p' */
130129
int nabslineinfo; /* number of elements in 'abslineinfo' */

‎lvm.c‎

Lines changed: 5 additions & 5 deletions

0 commit comments

Comments
 (0)