mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Use biased integer constant for TSETM array index.
This commit is contained in:
parent
8a1af8cf89
commit
fd63b05253
@ -70,8 +70,9 @@ local function bcline(func, pc, prefix)
|
||||
local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128)
|
||||
local a = band(shr(ins, 8), 0xff)
|
||||
local oidx = 6*band(ins, 0xff)
|
||||
local op = sub(bcnames, oidx+1, oidx+6)
|
||||
local s = format("%04d %s %-6s %3s ",
|
||||
pc, prefix or " ", sub(bcnames, oidx+1, oidx+6), ma == 0 and "" or a)
|
||||
pc, prefix or " ", op, ma == 0 and "" or a)
|
||||
local d = shr(ins, 16)
|
||||
if mc == 13*128 then -- BCMjump
|
||||
return format("%s=> %04d\n", s, pc+d-0x7fff)
|
||||
@ -87,6 +88,7 @@ local function bcline(func, pc, prefix)
|
||||
kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub))
|
||||
elseif mc == 9*128 then -- BCMnum
|
||||
kc = funck(func, d)
|
||||
if op == "TSETM " then kc = kc - 2^52 end
|
||||
elseif mc == 12*128 then -- BCMfunc
|
||||
local fi = funcinfo(funck(func, -d-1))
|
||||
if fi.ffid then
|
||||
|
@ -4288,15 +4288,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
case BC_TSETM:
|
||||
| ins_AD // RA = base (table at base-1), RD = num const (start index)
|
||||
| mov TMP1, KBASE // Need one more free register.
|
||||
if (sse) {
|
||||
| cvtsd2si KBASE, qword [KBASE+RD*8]
|
||||
} else {
|
||||
|.if not X64
|
||||
| fld qword [KBASE+RD*8]
|
||||
| fistp ARG4 // Const is guaranteed to be an int.
|
||||
| mov KBASE, ARG4
|
||||
|.endif
|
||||
}
|
||||
| mov KBASE, dword [KBASE+RD*8] // Integer constant is in lo-word.
|
||||
|1:
|
||||
| lea RA, [BASE+RA*8]
|
||||
| mov TAB:RB, [RA-8] // Guaranteed to be a table.
|
||||
@ -4308,7 +4300,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| jz >4 // Nothing to copy?
|
||||
| add RD, KBASE // Compute needed size.
|
||||
| cmp RD, TAB:RB->asize
|
||||
| jae >5 // Does not fit into array part?
|
||||
| jae >5 // Doesn't fit into array part?
|
||||
| sub RD, KBASE
|
||||
| shl KBASE, 3
|
||||
| add KBASE, TAB:RB->array
|
||||
|
@ -1369,7 +1369,8 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
||||
lua_assert(bc_a(ilp->ins) == freg &&
|
||||
bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB));
|
||||
expr_init(&en, VKNUM, 0);
|
||||
setintV(&en.u.nval, narr-1);
|
||||
en.u.nval.u32.lo = narr-1;
|
||||
en.u.nval.u32.hi = 0x43300000; /* Biased integer to avoid denormals. */
|
||||
if (narr > 256) { fs->pc--; ilp--; }
|
||||
ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en));
|
||||
setbc_b(&ilp[-1].ins, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user