Skip to content

Commit

Permalink
Handle first arg being in function's desired register
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Dec 4, 2023
1 parent d17181d commit 19dedcf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,10 @@ void luaK_prepcallfirstarg (FuncState *fs, expdesc *e, expdesc *func) {
e->u.reg = fs->freereg; /* base register for call */
e->k = VNONRELOC; /* expression has a fixed register */
luaK_reserveregs(fs, 2); /* function and first arg */
if (ereg == e->u.reg) { /* argument is in the register where the function should be? */
luaK_codeABC(fs, OP_MOVE, e->u.reg + 1, ereg, 0); /* move it where it should be */
ereg = e->u.reg + 1; /* and don't do it again */
}
if (e->u.reg != freg) { /* ensure function is in correct register */
luaK_codeABC(fs, OP_MOVE, e->u.reg, freg, 0);
}
Expand Down

0 comments on commit 19dedcf

Please sign in to comment.