Skip to content

Commit

Permalink
Promote instructions.
Browse files Browse the repository at this point in the history
This allows yk to constant fold a lot of the resulting instruction
decoding. The benefits of doing so can be significant: it speeds
big_loop.lua up by about 38%!
  • Loading branch information
ltratt committed Oct 30, 2024
1 parent 2e2dae3 commit bc8d54d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,13 +1133,23 @@ void luaV_finishOp (lua_State *L) {


/* fetch an instruction and prepare its execution */
#define vmfetch() { \
#ifdef USE_YK
# define vmfetch() { \
if (l_unlikely(trap)) { /* stack reallocation or hooks? */ \
trap = luaG_traceexec(L, pc); /* handle hooks */ \
updatebase(ci); /* correct stack */ \
} \
i = (Instruction) yk_promote(*(pc++)); \
}
#else
# define vmfetch() { \
if (l_unlikely(trap)) { /* stack reallocation or hooks? */ \
trap = luaG_traceexec(L, pc); /* handle hooks */ \
updatebase(ci); /* correct stack */ \
} \
i = *(pc++); \
i = (Instruction) *(pc++); \
}
#endif

#define vmdispatch(o) switch(o)
#define vmcase(l) case l:
Expand Down

0 comments on commit bc8d54d

Please sign in to comment.