Specialize bytecode for pairs()/next() iterator. Speedup: 3.5x.
Parser predict pairs/next and emits specialized bytecode. Bytecode is descpecialized at runtime if the prediction was wrong. Store slot index in hidden control var to avoid key lookups.
This commit is contained in:
@@ -154,6 +154,8 @@
|
||||
_(CALLMT, base, ___, lit, call) \
|
||||
_(CALLT, base, ___, lit, call) \
|
||||
_(ITERC, base, lit, lit, call) \
|
||||
_(ITERN, base, lit, lit, call) \
|
||||
_(ISNEXT, base, ___, jump, ___) \
|
||||
_(VARG, base, lit, lit, ___) \
|
||||
\
|
||||
/* Returns. */ \
|
||||
@@ -221,6 +223,9 @@ 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);
|
||||
|
||||
/* This solves a circular dependency problem, change as needed. */
|
||||
#define FF_next_N 15
|
||||
|
||||
/* Stack slots used by FORI/FORL, relative to operand A. */
|
||||
enum {
|
||||
FORL_IDX, FORL_STOP, FORL_STEP, FORL_EXT
|
||||
|
||||
Reference in New Issue
Block a user