Disable Lua 5.2 features by default. See -DLUAJIT_ENABLE_LUA52COMPAT.

This commit is contained in:
Mike Pall 2010-11-19 17:00:11 +01:00
parent ba602c9578
commit 57cd5026eb
10 changed files with 2973 additions and 2901 deletions

View File

@ -62,6 +62,11 @@ CCWARN= -Wall
# Note that most of these are NOT suitable for benchmarking or release mode!
XCFLAGS=
#
# Enable some upwards-compatible features from Lua 5.2 that are unlikely
# to break existing code (e.g. __pairs). Note that this does not provide
# full compatibility with Lua 5.2 at this time.
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
#
# Disable the use of CMOV and FCOMI*/FUCOMI* instructions in the interpreter.
# This is only necessary if you intend to run the code on REALLY ANCIENT CPUs
# (before Pentium Pro, or on the VIA C3). This generally slows down the

View File

@ -1098,11 +1098,16 @@ static void build_subroutines(BuildCtx *ctx)
| checktab TAB:CARG1
| lwz PC, FRAME_PC(BASE)
| checkfail ->fff_fallback
#ifdef LUAJIT_ENABLE_LUA52COMPAT
| lwz TAB:TMP2, TAB:CARG1->metatable
| evldd CFUNC:TMP0, CFUNC:RB->upvalue[0]
| cmplwi TAB:TMP2, 0
| la RA, -8(BASE)
| bne ->fff_fallback
#else
| evldd CFUNC:TMP0, CFUNC:RB->upvalue[0]
| la RA, -8(BASE)
#endif
| evstdd TAB:CARG1, 0(BASE)
| evstdd TISNIL, 8(BASE)
| li RD, (3+1)*8
@ -1153,11 +1158,16 @@ static void build_subroutines(BuildCtx *ctx)
| checktab TAB:CARG1
| lwz PC, FRAME_PC(BASE)
| checkfail ->fff_fallback
#ifdef LUAJIT_ENABLE_LUA52COMPAT
| lwz TAB:TMP2, TAB:CARG1->metatable
| evldd CFUNC:TMP0, CFUNC:RB->upvalue[0]
| cmplwi TAB:TMP2, 0
| la RA, -8(BASE)
| bne ->fff_fallback
#else
| evldd CFUNC:TMP0, CFUNC:RB->upvalue[0]
| la RA, -8(BASE)
#endif
| evsplati TMP1, 0
| evstdd TAB:CARG1, 0(BASE)
| evstdd TMP1, 8(BASE)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1511,7 +1511,9 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|.ffunc_1 pairs
| mov TAB:RB, [BASE]
| cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback
#ifdef LUAJIT_ENABLE_LUA52COMPAT
| cmp dword TAB:RB->metatable, 0; jne ->fff_fallback
#endif
| mov CFUNC:RB, [BASE-8]
| mov CFUNC:RD, CFUNC:RB->upvalue[0]
| mov PC, [BASE-4]
@ -1575,7 +1577,9 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|.ffunc_1 ipairs
| mov TAB:RB, [BASE]
| cmp dword [BASE+4], LJ_TTAB; jne ->fff_fallback
#ifdef LUAJIT_ENABLE_LUA52COMPAT
| cmp dword TAB:RB->metatable, 0; jne ->fff_fallback
#endif
| mov CFUNC:RB, [BASE-8]
| mov CFUNC:RD, CFUNC:RB->upvalue[0]
| mov PC, [BASE-4]

File diff suppressed because it is too large Load Diff

View File

@ -249,6 +249,7 @@ LJLIB_ASM(next)
return FFH_UNREACHABLE;
}
#ifdef LUAJIT_ENABLE_LUA52COMPAT
static int ffh_pairs(lua_State *L, MMS mm)
{
TValue *o = lj_lib_checkany(L, 1);
@ -264,6 +265,9 @@ static int ffh_pairs(lua_State *L, MMS mm)
return FFH_RES(3);
}
}
#else
#define ffh_pairs(L, mm) (lj_lib_checktab(L, 1), FFH_UNREACHABLE)
#endif
LJLIB_PUSH(lastcl)
LJLIB_ASM(pairs)

View File

@ -410,6 +410,12 @@ enum {
#define setvmstate(g, st) ((g)->vmstate = ~LJ_VMST_##st)
/* Metamethods. */
#ifdef LUAJIT_ENABLE_LUA52COMPAT
#define MMDEF_52(_) _(pairs) _(ipairs)
#else
#define MMDEF_52(_)
#endif
#define MMDEF(_) \
_(index) _(newindex) _(gc) _(mode) _(eq) \
/* Only the above (fast) metamethods are negative cached (max. 8). */ \
@ -417,7 +423,7 @@ enum {
/* The following must be in ORDER ARITH. */ \
_(add) _(sub) _(mul) _(div) _(mod) _(pow) _(unm) \
/* The following are used in the standard libraries. */ \
_(metatable) _(tostring) _(pairs) _(ipairs)
_(metatable) _(tostring) MMDEF_52(_)
typedef enum {
#define MMENUM(name) MM_##name,

View File

@ -1426,7 +1426,10 @@ static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd)
static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd)
{
if (!recff_metacall(J, rd, MM_ipairs)) {
#ifdef LUAJIT_ENABLE_LUA52COMPAT
if (!recff_metacall(J, rd, MM_ipairs))
#endif
{
TRef tab = J->base[0];
if (tref_istab(tab)) {
J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0]));