Major redesign of function call handling.
Drop call gates. Use function headers, dispatched like bytecodes. Emit BC_FUNCF/BC_FUNCV bytecode at PC 0 for all Lua functions. C functions and ASM fast functions get extra bytecodes. Modify internal calling convention: new base in BASE (formerly in RA). Can now use better C function wrapper semantics (dynamic on/off). Prerequisite for call hooks with zero-overhead if disabled. Prerequisite for compiling recursive calls. Prerequisite for efficient 32/64 bit prototype guards.
This commit is contained in:
21
src/lj_bc.h
21
src/lj_bc.h
@@ -178,7 +178,17 @@
|
||||
_(ILOOP, rbase, ___, jump, ___) \
|
||||
_(JLOOP, rbase, ___, lit, ___) \
|
||||
\
|
||||
_(JMP, rbase, ___, jump, ___)
|
||||
_(JMP, rbase, ___, jump, ___) \
|
||||
\
|
||||
/* Function headers. I/J = interp/JIT, F/V/C = fixarg/vararg/C func. */ \
|
||||
_(FUNCF, rbase, ___, ___, ___) \
|
||||
_(IFUNCF, rbase, ___, ___, ___) \
|
||||
_(JFUNCF, rbase, ___, lit, ___) \
|
||||
_(FUNCV, rbase, ___, ___, ___) \
|
||||
_(IFUNCV, rbase, ___, ___, ___) \
|
||||
_(JFUNCV, rbase, ___, lit, ___) \
|
||||
_(FUNCC, ___, ___, ___, ___) \
|
||||
_(FUNCCW, ___, ___, ___, ___)
|
||||
|
||||
/* Bytecode opcode numbers. */
|
||||
typedef enum {
|
||||
@@ -206,6 +216,10 @@ LJ_STATIC_ASSERT((int)BC_ITERL + 1 == (int)BC_IITERL);
|
||||
LJ_STATIC_ASSERT((int)BC_ITERL + 2 == (int)BC_JITERL);
|
||||
LJ_STATIC_ASSERT((int)BC_LOOP + 1 == (int)BC_ILOOP);
|
||||
LJ_STATIC_ASSERT((int)BC_LOOP + 2 == (int)BC_JLOOP);
|
||||
LJ_STATIC_ASSERT((int)BC_FUNCF + 1 == (int)BC_IFUNCF);
|
||||
LJ_STATIC_ASSERT((int)BC_FUNCF + 2 == (int)BC_JFUNCF);
|
||||
LJ_STATIC_ASSERT((int)BC_FUNCV + 1 == (int)BC_IFUNCV);
|
||||
LJ_STATIC_ASSERT((int)BC_FUNCV + 2 == (int)BC_JFUNCV);
|
||||
|
||||
/* Stack slots used by FORI/FORL, relative to operand A. */
|
||||
enum {
|
||||
@@ -229,8 +243,9 @@ typedef enum {
|
||||
|
||||
#define BCMODE(name, ma, mb, mc, mm) \
|
||||
(BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)),
|
||||
#define BCMODE_FF 0
|
||||
|
||||
LJ_DATA const uint16_t lj_bc_mode[BC__MAX+1];
|
||||
LJ_DATA const uint16_t lj_bc_ofs[BC__MAX+1];
|
||||
LJ_DATA const uint16_t lj_bc_mode[];
|
||||
LJ_DATA const uint16_t lj_bc_ofs[];
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user