mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Get rid of the remaining silly cast macros from Lua.
This commit is contained in:
parent
bfce3c1127
commit
889368e921
@ -1215,7 +1215,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
dasm_put(Dst, 1850, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, ~LJ_TLIGHTUD, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL);
|
||||
dasm_put(Dst, 1929, DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable), LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next));
|
||||
dasm_put(Dst, 1987, LJ_TNIL, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]));
|
||||
dasm_put(Dst, 2056, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK));
|
||||
dasm_put(Dst, 2056, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), (uint8_t)~LJ_GC_BLACK);
|
||||
dasm_put(Dst, 2125, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist), 2+1, LJ_TTAB, 1+1, LJ_TISNUM);
|
||||
if (LJ_DUALNUM) {
|
||||
dasm_put(Dst, 2211);
|
||||
@ -2633,21 +2633,21 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
dasm_put(Dst, 13339);
|
||||
}
|
||||
dasm_put(Dst, 13344, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex);
|
||||
dasm_put(Dst, 13425, LJ_TSTR, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13425, LJ_TSTR, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
case BC_TSETS:
|
||||
dasm_put(Dst, 13484, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->nomm), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL);
|
||||
dasm_put(Dst, 13561, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, DtB(->next));
|
||||
dasm_put(Dst, 13648, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13648, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
case BC_TSETB:
|
||||
dasm_put(Dst, 13740, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable));
|
||||
dasm_put(Dst, 13835, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13835, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
|
||||
case BC_TSETM:
|
||||
dasm_put(Dst, 13883, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
|
||||
dasm_put(Dst, 14033, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 14033, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
|
||||
/* -- Calls and vararg handling ----------------------------------------- */
|
||||
|
@ -1213,7 +1213,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
dasm_put(Dst, 1827, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, ~LJ_TLIGHTUD, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL);
|
||||
dasm_put(Dst, 1906, DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable), LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next));
|
||||
dasm_put(Dst, 1963, LJ_TNIL, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]));
|
||||
dasm_put(Dst, 2031, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK));
|
||||
dasm_put(Dst, 2031, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), (uint8_t)~LJ_GC_BLACK);
|
||||
dasm_put(Dst, 2100, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist), 2+1, LJ_TTAB, 1+1, LJ_TISNUM);
|
||||
if (LJ_DUALNUM) {
|
||||
dasm_put(Dst, 2185);
|
||||
@ -2632,21 +2632,21 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
dasm_put(Dst, 13221);
|
||||
}
|
||||
dasm_put(Dst, 13226, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex);
|
||||
dasm_put(Dst, 13306, LJ_TSTR, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13306, LJ_TSTR, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
case BC_TSETS:
|
||||
dasm_put(Dst, 13363, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->nomm), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL);
|
||||
dasm_put(Dst, 13439, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, DtB(->next));
|
||||
dasm_put(Dst, 13527, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13527, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
case BC_TSETB:
|
||||
dasm_put(Dst, 13618, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable));
|
||||
dasm_put(Dst, 13712, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13712, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
|
||||
case BC_TSETM:
|
||||
dasm_put(Dst, 13758, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
|
||||
dasm_put(Dst, 13901, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 13901, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
|
||||
/* -- Calls and vararg handling ----------------------------------------- */
|
||||
|
@ -400,7 +400,7 @@
|
||||
|
|
||||
|// Move table write barrier back. Overwrites reg.
|
||||
|.macro barrierback, tab, reg
|
||||
| and byte tab->marked, cast_byte(~LJ_GC_BLACK) // black2gray(tab)
|
||||
| and byte tab->marked, (uint8_t)~LJ_GC_BLACK // black2gray(tab)
|
||||
| mov reg, [DISPATCH+DISPATCH_GL(gc.grayagain)]
|
||||
| mov [DISPATCH+DISPATCH_GL(gc.grayagain)], tab
|
||||
| mov tab->gclist, reg
|
||||
|
@ -1264,7 +1264,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
dasm_put(Dst, 1837, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL, DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable), LJ_TTAB);
|
||||
dasm_put(Dst, 1920, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next), LJ_TNIL);
|
||||
dasm_put(Dst, 1978, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]), 2+1);
|
||||
dasm_put(Dst, 2041, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 2041, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 2113, 2+1, LJ_TTAB, 1+1, LJ_TISNUM);
|
||||
if (LJ_DUALNUM) {
|
||||
dasm_put(Dst, 2202);
|
||||
@ -2791,21 +2791,21 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
dasm_put(Dst, 14358);
|
||||
}
|
||||
dasm_put(Dst, 14363, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex);
|
||||
dasm_put(Dst, 14447, LJ_TSTR, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 14447, LJ_TSTR, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
case BC_TSETS:
|
||||
dasm_put(Dst, 14504, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->nomm), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL);
|
||||
dasm_put(Dst, 14579, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, DtB(->next));
|
||||
dasm_put(Dst, 14671, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 14671, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
case BC_TSETB:
|
||||
dasm_put(Dst, 14767, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable));
|
||||
dasm_put(Dst, 14865, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 14865, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
|
||||
case BC_TSETM:
|
||||
dasm_put(Dst, 14911, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
|
||||
dasm_put(Dst, 15060, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
dasm_put(Dst, 15060, Dt6(->marked), (uint8_t)~LJ_GC_BLACK, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
|
||||
break;
|
||||
|
||||
/* -- Calls and vararg handling ----------------------------------------- */
|
||||
|
@ -500,7 +500,7 @@ LUA_API size_t lua_objlen(lua_State *L, int idx)
|
||||
if (tvisstr(o))
|
||||
return strV(o)->len;
|
||||
else if (tvistab(o))
|
||||
return cast(size_t, lj_tab_len(tabV(o)));
|
||||
return (size_t)lj_tab_len(tabV(o));
|
||||
else if (tvisudata(o))
|
||||
return udataV(o)->len;
|
||||
else if (tvisnumber(o))
|
||||
@ -1129,7 +1129,7 @@ LUA_API int lua_resume(lua_State *L, int nargs)
|
||||
|
||||
static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud)
|
||||
{
|
||||
LexState *ls = cast(LexState *, ud);
|
||||
LexState *ls = (LexState *)ud;
|
||||
GCfunc *fn;
|
||||
UNUSED(dummy);
|
||||
cframe_errfunc(L->cframe) = -1; /* Inherit error function. */
|
||||
|
27
src/lj_bc.h
27
src/lj_bc.h
@ -31,30 +31,29 @@
|
||||
#define NO_JMP (~(BCPos)0)
|
||||
|
||||
/* Macros to get instruction fields. */
|
||||
#define bc_op(i) (cast(BCOp, (i)&0xff))
|
||||
#define bc_a(i) (cast(BCReg, ((i)>>8)&0xff))
|
||||
#define bc_b(i) (cast(BCReg, (i)>>24))
|
||||
#define bc_c(i) (cast(BCReg, ((i)>>16)&0xff))
|
||||
#define bc_d(i) (cast(BCReg, (i)>>16))
|
||||
#define bc_op(i) ((BCOp)((i)&0xff))
|
||||
#define bc_a(i) ((BCReg)(((i)>>8)&0xff))
|
||||
#define bc_b(i) ((BCReg)((i)>>24))
|
||||
#define bc_c(i) ((BCReg)(((i)>>16)&0xff))
|
||||
#define bc_d(i) ((BCReg)((i)>>16))
|
||||
#define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J)
|
||||
|
||||
/* Macros to set instruction fields. */
|
||||
#define setbc_byte(p, x, ofs) \
|
||||
((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = cast_byte(x)
|
||||
((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x)
|
||||
#define setbc_op(p, x) setbc_byte(p, (x), 0)
|
||||
#define setbc_a(p, x) setbc_byte(p, (x), 1)
|
||||
#define setbc_b(p, x) setbc_byte(p, (x), 3)
|
||||
#define setbc_c(p, x) setbc_byte(p, (x), 2)
|
||||
#define setbc_d(p, x) \
|
||||
((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = cast(uint16_t, (x))
|
||||
((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x)
|
||||
#define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J))
|
||||
|
||||
/* Macros to compose instructions. */
|
||||
#define BCINS_ABC(o, a, b, c) \
|
||||
(cast(BCIns, o)|(cast(BCIns, a)<<8)|\
|
||||
(cast(BCIns, b)<<24)|(cast(BCIns, c)<<16))
|
||||
(((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16))
|
||||
#define BCINS_AD(o, a, d) \
|
||||
(cast(BCIns, o)|(cast(BCIns, a)<<8)|(cast(BCIns, d)<<16))
|
||||
(((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16))
|
||||
#define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J))
|
||||
|
||||
/* Bytecode instruction definition. Order matters, see below.
|
||||
@ -240,12 +239,12 @@ typedef enum {
|
||||
} BCMode;
|
||||
#define BCM___ BCMnone
|
||||
|
||||
#define bcmode_a(op) (cast(BCMode, lj_bc_mode[op] & 7))
|
||||
#define bcmode_b(op) (cast(BCMode, (lj_bc_mode[op]>>3) & 15))
|
||||
#define bcmode_c(op) (cast(BCMode, (lj_bc_mode[op]>>7) & 15))
|
||||
#define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7))
|
||||
#define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15))
|
||||
#define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15))
|
||||
#define bcmode_d(op) bcmode_c(op)
|
||||
#define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3))
|
||||
#define bcmode_mm(op) (cast(MMS, lj_bc_mode[op]>>11))
|
||||
#define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11))
|
||||
|
||||
#define BCMODE(name, ma, mb, mc, mm) \
|
||||
(BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)),
|
||||
|
@ -1803,7 +1803,7 @@ static void cp_decl_single(CPState *cp)
|
||||
/* Protected callback for C parser. */
|
||||
static TValue *cpcparser(lua_State *L, lua_CFunction dummy, void *ud)
|
||||
{
|
||||
CPState *cp = cast(CPState *, ud);
|
||||
CPState *cp = (CPState *)ud;
|
||||
UNUSED(dummy);
|
||||
cframe_errfunc(L->cframe) = -1; /* Inherit error function. */
|
||||
cp_init(cp);
|
||||
|
@ -74,13 +74,7 @@ typedef unsigned __int32 uintptr_t;
|
||||
#define UNUSED(x) ((void)(x)) /* to avoid warnings */
|
||||
#endif
|
||||
|
||||
#ifndef cast
|
||||
#define cast(t, exp) ((t)(exp))
|
||||
#endif
|
||||
|
||||
#define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo)
|
||||
#define cast_byte(i) cast(uint8_t, (i))
|
||||
#define cast_num(i) cast(lua_Number, (i))
|
||||
#define i32ptr(p) ((int32_t)(intptr_t)(void *)(p))
|
||||
#define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p))
|
||||
|
||||
|
@ -95,7 +95,7 @@ void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv)
|
||||
|
||||
GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env)
|
||||
{
|
||||
GCfunc *fn = cast(GCfunc *, lj_mem_newgco(L, sizeCfunc(nelems)));
|
||||
GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeCfunc(nelems));
|
||||
fn->c.gct = ~LJ_TFUNC;
|
||||
fn->c.ffid = FF_C;
|
||||
fn->c.nupvalues = (uint8_t)nelems;
|
||||
@ -107,7 +107,7 @@ GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env)
|
||||
|
||||
GCfunc *lj_func_newL(lua_State *L, GCproto *pt, GCtab *env)
|
||||
{
|
||||
GCfunc *fn = cast(GCfunc *, lj_mem_newgco(L, sizeLfunc((MSize)pt->sizeuv)));
|
||||
GCfunc *fn = (GCfunc *)lj_mem_newgco(L, sizeLfunc((MSize)pt->sizeuv));
|
||||
fn->l.gct = ~LJ_TFUNC;
|
||||
fn->l.ffid = FF_LUA;
|
||||
fn->l.nupvalues = (uint8_t)pt->sizeuv;
|
||||
|
14
src/lj_gc.c
14
src/lj_gc.c
@ -32,11 +32,11 @@
|
||||
#define GCFINALIZECOST 100
|
||||
|
||||
/* Macros to set GCobj colors and flags. */
|
||||
#define white2gray(x) ((x)->gch.marked &= cast_byte(~LJ_GC_WHITES))
|
||||
#define black2gray(x) ((x)->gch.marked &= cast_byte(~LJ_GC_BLACK))
|
||||
#define white2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES)
|
||||
#define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK)
|
||||
#define gray2black(x) ((x)->gch.marked |= LJ_GC_BLACK)
|
||||
#define makewhite(g, x) \
|
||||
((x)->gch.marked = ((x)->gch.marked & cast_byte(~LJ_GC_COLORS)) | curwhite(g))
|
||||
((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g))
|
||||
#define isfinalized(u) ((u)->marked & LJ_GC_FINALIZED)
|
||||
#define markfinalized(u) ((u)->marked |= LJ_GC_FINALIZED)
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
{ if (iswhite(obj2gco(o))) gc_mark(g, obj2gco(o)); }
|
||||
|
||||
/* Mark a string object. */
|
||||
#define gc_mark_str(s) ((s)->marked &= cast_byte(~LJ_GC_WHITES))
|
||||
#define gc_mark_str(s) ((s)->marked &= (uint8_t)~LJ_GC_WHITES)
|
||||
|
||||
/* Mark a white GCobj. */
|
||||
static void gc_mark(global_State *g, GCobj *o)
|
||||
@ -174,7 +174,7 @@ static int gc_traverse_tab(global_State *g, GCtab *t)
|
||||
else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL);
|
||||
}
|
||||
if (weak > 0) { /* Weak tables are cleared in the atomic phase. */
|
||||
t->marked = cast_byte((t->marked & ~LJ_GC_WEAK) | weak);
|
||||
t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak);
|
||||
setgcrefr(t->gclist, g->gc.weak);
|
||||
setgcref(g->gc.weak, obj2gco(t));
|
||||
}
|
||||
@ -594,7 +594,7 @@ static void atomic(global_State *g, lua_State *L)
|
||||
gc_clearweak(gcref(g->gc.weak));
|
||||
|
||||
/* Prepare for sweep phase. */
|
||||
g->gc.currentwhite = cast_byte(otherwhite(g)); /* Flip current white. */
|
||||
g->gc.currentwhite = (uint8_t)otherwhite(g); /* Flip current white. */
|
||||
g->strempty.marked = g->gc.currentwhite;
|
||||
setmref(g->gc.sweep, &g->gc.root);
|
||||
g->gc.estimate = g->gc.total - (MSize)udsize; /* Initial estimate. */
|
||||
@ -772,7 +772,7 @@ void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv)
|
||||
if (g->gc.state == GCSpropagate || g->gc.state == GCSatomic)
|
||||
gc_mark(g, gcV(tv));
|
||||
else
|
||||
TV2MARKED(tv) = (TV2MARKED(tv) & cast_byte(~LJ_GC_COLORS)) | curwhite(g);
|
||||
TV2MARKED(tv) = (TV2MARKED(tv) & (uint8_t)~LJ_GC_COLORS) | curwhite(g);
|
||||
#undef TV2MARKED
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ TRef lj_ir_kint64(jit_State *J, uint64_t u64)
|
||||
static int numistrueint(lua_Number n, int32_t *kp)
|
||||
{
|
||||
int32_t k = lj_num2int(n);
|
||||
if (n == cast_num(k)) {
|
||||
if (n == (lua_Number)k) {
|
||||
if (kp) *kp = k;
|
||||
if (k == 0) { /* Special check for -0. */
|
||||
TValue tv;
|
||||
|
@ -36,7 +36,7 @@ TKDEF(TKSTR1, TKSTR2)
|
||||
|
||||
/* -- Buffer handling ----------------------------------------------------- */
|
||||
|
||||
#define char2int(c) cast(int, cast(uint8_t, (c)))
|
||||
#define char2int(c) ((int)(uint8_t)(c))
|
||||
#define next(ls) \
|
||||
(ls->current = (ls->n--) > 0 ? char2int(*ls->p++) : fillbuf(ls))
|
||||
#define save_and_next(ls) (save(ls, ls->current), next(ls))
|
||||
|
@ -291,7 +291,7 @@ TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne)
|
||||
if (tabref(o1->gch.metatable) != tabref(o2->gch.metatable)) {
|
||||
cTValue *mo2 = lj_meta_fast(L, tabref(o2->gch.metatable), MM_eq);
|
||||
if (mo2 == NULL || !lj_obj_equal(mo, mo2))
|
||||
return cast(TValue *, (intptr_t)ne);
|
||||
return (TValue *)(intptr_t)ne;
|
||||
}
|
||||
top = curr_top(L);
|
||||
setcont(top, ne ? lj_cont_condf : lj_cont_condt);
|
||||
@ -301,7 +301,7 @@ TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne)
|
||||
setgcV(L, top+3, o2, it);
|
||||
return top+2; /* Trigger metamethod call. */
|
||||
}
|
||||
return cast(TValue *, (intptr_t)ne);
|
||||
return (TValue *)(intptr_t)ne;
|
||||
}
|
||||
|
||||
#if LJ_HASFFI
|
||||
@ -329,7 +329,7 @@ TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins)
|
||||
if (LJ_LIKELY(!tvisnil(mo)))
|
||||
return mmcall(L, cont, mo, o1, o2);
|
||||
else
|
||||
return cast(TValue *, (intptr_t)(bc_op(ins) & 1));
|
||||
return (TValue *)(intptr_t)(bc_op(ins) & 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -345,7 +345,7 @@ TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op)
|
||||
} else if (itype(o1) == itype(o2)) { /* Never called with two numbers. */
|
||||
if (tvisstr(o1) && tvisstr(o2)) {
|
||||
int32_t res = lj_str_cmp(strV(o1), strV(o2));
|
||||
return cast(TValue *, (intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1)));
|
||||
return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1));
|
||||
} else {
|
||||
trymt:
|
||||
while (1) {
|
||||
|
@ -189,7 +189,7 @@ LJFOLD(POW KNUM KINT)
|
||||
LJFOLDF(kfold_numpow)
|
||||
{
|
||||
lua_Number a = knumleft;
|
||||
lua_Number b = cast_num(fright->i);
|
||||
lua_Number b = (lua_Number)fright->i;
|
||||
lua_Number y = lj_vm_foldarith(a, b, IR_POW - IR_ADD);
|
||||
return lj_ir_knum(J, y);
|
||||
}
|
||||
@ -545,13 +545,13 @@ LJFOLDF(kfold_tobit)
|
||||
LJFOLD(CONV KINT IRCONV_NUM_INT)
|
||||
LJFOLDF(kfold_conv_kint_num)
|
||||
{
|
||||
return lj_ir_knum(J, cast_num(fleft->i));
|
||||
return lj_ir_knum(J, (lua_Number)fleft->i);
|
||||
}
|
||||
|
||||
LJFOLD(CONV KINT IRCONV_NUM_U32)
|
||||
LJFOLDF(kfold_conv_kintu32_num)
|
||||
{
|
||||
return lj_ir_knum(J, cast_num((uint32_t)fleft->i));
|
||||
return lj_ir_knum(J, (lua_Number)(uint32_t)fleft->i);
|
||||
}
|
||||
|
||||
LJFOLD(CONV KINT IRCONV_I64_INT)
|
||||
@ -567,13 +567,13 @@ LJFOLDF(kfold_conv_kint_i64)
|
||||
LJFOLD(CONV KINT64 IRCONV_NUM_I64)
|
||||
LJFOLDF(kfold_conv_kint64_num_i64)
|
||||
{
|
||||
return lj_ir_knum(J, cast_num((int64_t)ir_kint64(fleft)->u64));
|
||||
return lj_ir_knum(J, (lua_Number)(int64_t)ir_kint64(fleft)->u64);
|
||||
}
|
||||
|
||||
LJFOLD(CONV KINT64 IRCONV_NUM_U64)
|
||||
LJFOLDF(kfold_conv_kint64_num_u64)
|
||||
{
|
||||
return lj_ir_knum(J, cast_num(ir_kint64(fleft)->u64));
|
||||
return lj_ir_knum(J, (lua_Number)ir_kint64(fleft)->u64);
|
||||
}
|
||||
|
||||
LJFOLD(CONV KINT64 IRCONV_INT_I64)
|
||||
@ -589,7 +589,7 @@ LJFOLDF(kfold_conv_knum_int_num)
|
||||
lua_Number n = knumleft;
|
||||
if (!(fins->op2 & IRCONV_TRUNC)) {
|
||||
int32_t k = lj_num2int(n);
|
||||
if (irt_isguard(fins->t) && n != cast_num(k)) {
|
||||
if (irt_isguard(fins->t) && n != (lua_Number)k) {
|
||||
/* We're about to create a guard which always fails, like CONV +1.5.
|
||||
** Some pathological loops cause this during LICM, e.g.:
|
||||
** local x,k,t = 0,1.5,{1,[1.5]=2}
|
||||
|
@ -181,7 +181,7 @@ lua_State *lj_state_newstate(lua_Alloc f, void *ud)
|
||||
LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
|
||||
#endif
|
||||
{
|
||||
GG_State *GG = cast(GG_State *, f(ud, NULL, 0, sizeof(GG_State)));
|
||||
GG_State *GG = (GG_State *)f(ud, NULL, 0, sizeof(GG_State));
|
||||
lua_State *L = &GG->L;
|
||||
global_State *g = &GG->g;
|
||||
if (GG == NULL || !checkptr32(GG)) return NULL;
|
||||
|
@ -316,7 +316,7 @@ static void addchar(lua_State *L, SBuf *sb, int c)
|
||||
MSize sz = sb->sz * 2;
|
||||
lj_str_resizebuf(L, sb, sz);
|
||||
}
|
||||
sb->buf[sb->n++] = cast(char, c);
|
||||
sb->buf[sb->n++] = (char)c;
|
||||
}
|
||||
|
||||
/* Push formatted message as a string object to Lua stack. va_list variant. */
|
||||
|
@ -580,20 +580,20 @@ static MSize unbound_search(GCtab *t, MSize j)
|
||||
MSize i = j; /* i is zero or a present index */
|
||||
j++;
|
||||
/* find `i' and `j' such that i is present and j is not */
|
||||
while ((tv = lj_tab_getint(t, cast(int32_t, j))) && !tvisnil(tv)) {
|
||||
while ((tv = lj_tab_getint(t, (int32_t)j)) && !tvisnil(tv)) {
|
||||
i = j;
|
||||
j *= 2;
|
||||
if (j > (MSize)(INT_MAX-2)) { /* overflow? */
|
||||
/* table was built with bad purposes: resort to linear search */
|
||||
i = 1;
|
||||
while ((tv = lj_tab_getint(t, cast(int32_t, i))) && !tvisnil(tv)) i++;
|
||||
while ((tv = lj_tab_getint(t, (int32_t)i)) && !tvisnil(tv)) i++;
|
||||
return i - 1;
|
||||
}
|
||||
}
|
||||
/* now do a binary search between them */
|
||||
while (j - i > 1) {
|
||||
MSize m = (i+j)/2;
|
||||
cTValue *tvb = lj_tab_getint(t, cast(int32_t, m));
|
||||
cTValue *tvb = lj_tab_getint(t, (int32_t)m);
|
||||
if (tvb && !tvisnil(tvb)) i = m; else j = m;
|
||||
}
|
||||
return i;
|
||||
|
Loading…
Reference in New Issue
Block a user