diff options
| author | Mike Pall <mike> | 2010-09-09 12:01:29 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2010-09-09 12:01:29 +0200 |
| commit | fd63b05253f11d7e436c3685827fce9b64725da6 (patch) | |
| tree | 309dc62115841c0ec35ca92cd2ce4871f8dc6679 | |
| parent | 8a1af8cf89e5b23d4c7e47dafd0bdba09a3c7e01 (diff) | |
| download | luajit-fd63b05253f11d7e436c3685827fce9b64725da6.tar.gz luajit-fd63b05253f11d7e436c3685827fce9b64725da6.tar.bz2 luajit-fd63b05253f11d7e436c3685827fce9b64725da6.zip | |
Use biased integer constant for TSETM array index.
| -rw-r--r-- | lib/bc.lua | 4 | ||||
| -rw-r--r-- | src/buildvm_x86.dasc | 12 | ||||
| -rw-r--r-- | src/lj_parse.c | 3 |
3 files changed, 7 insertions, 12 deletions
| @@ -70,8 +70,9 @@ local function bcline(func, pc, prefix) | |||
| 70 | local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) | 70 | local ma, mb, mc = band(m, 7), band(m, 15*8), band(m, 15*128) |
| 71 | local a = band(shr(ins, 8), 0xff) | 71 | local a = band(shr(ins, 8), 0xff) |
| 72 | local oidx = 6*band(ins, 0xff) | 72 | local oidx = 6*band(ins, 0xff) |
| 73 | local op = sub(bcnames, oidx+1, oidx+6) | ||
| 73 | local s = format("%04d %s %-6s %3s ", | 74 | local s = format("%04d %s %-6s %3s ", |
| 74 | pc, prefix or " ", sub(bcnames, oidx+1, oidx+6), ma == 0 and "" or a) | 75 | pc, prefix or " ", op, ma == 0 and "" or a) |
| 75 | local d = shr(ins, 16) | 76 | local d = shr(ins, 16) |
| 76 | if mc == 13*128 then -- BCMjump | 77 | if mc == 13*128 then -- BCMjump |
| 77 | return format("%s=> %04d\n", s, pc+d-0x7fff) | 78 | return format("%s=> %04d\n", s, pc+d-0x7fff) |
| @@ -87,6 +88,7 @@ local function bcline(func, pc, prefix) | |||
| 87 | kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) | 88 | kc = format(#kc > 40 and '"%.40s"~' or '"%s"', gsub(kc, "%c", ctlsub)) |
| 88 | elseif mc == 9*128 then -- BCMnum | 89 | elseif mc == 9*128 then -- BCMnum |
| 89 | kc = funck(func, d) | 90 | kc = funck(func, d) |
| 91 | if op == "TSETM " then kc = kc - 2^52 end | ||
| 90 | elseif mc == 12*128 then -- BCMfunc | 92 | elseif mc == 12*128 then -- BCMfunc |
| 91 | local fi = funcinfo(funck(func, -d-1)) | 93 | local fi = funcinfo(funck(func, -d-1)) |
| 92 | if fi.ffid then | 94 | if fi.ffid then |
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index bc128457..d7c36d90 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
| @@ -4288,15 +4288,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
| 4288 | case BC_TSETM: | 4288 | case BC_TSETM: |
| 4289 | | ins_AD // RA = base (table at base-1), RD = num const (start index) | 4289 | | ins_AD // RA = base (table at base-1), RD = num const (start index) |
| 4290 | | mov TMP1, KBASE // Need one more free register. | 4290 | | mov TMP1, KBASE // Need one more free register. |
| 4291 | if (sse) { | 4291 | | mov KBASE, dword [KBASE+RD*8] // Integer constant is in lo-word. |
| 4292 | | cvtsd2si KBASE, qword [KBASE+RD*8] | ||
| 4293 | } else { | ||
| 4294 | |.if not X64 | ||
| 4295 | | fld qword [KBASE+RD*8] | ||
| 4296 | | fistp ARG4 // Const is guaranteed to be an int. | ||
| 4297 | | mov KBASE, ARG4 | ||
| 4298 | |.endif | ||
| 4299 | } | ||
| 4300 | |1: | 4292 | |1: |
| 4301 | | lea RA, [BASE+RA*8] | 4293 | | lea RA, [BASE+RA*8] |
| 4302 | | mov TAB:RB, [RA-8] // Guaranteed to be a table. | 4294 | | 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) | |||
| 4308 | | jz >4 // Nothing to copy? | 4300 | | jz >4 // Nothing to copy? |
| 4309 | | add RD, KBASE // Compute needed size. | 4301 | | add RD, KBASE // Compute needed size. |
| 4310 | | cmp RD, TAB:RB->asize | 4302 | | cmp RD, TAB:RB->asize |
| 4311 | | jae >5 // Does not fit into array part? | 4303 | | jae >5 // Doesn't fit into array part? |
| 4312 | | sub RD, KBASE | 4304 | | sub RD, KBASE |
| 4313 | | shl KBASE, 3 | 4305 | | shl KBASE, 3 |
| 4314 | | add KBASE, TAB:RB->array | 4306 | | add KBASE, TAB:RB->array |
diff --git a/src/lj_parse.c b/src/lj_parse.c index f5f59d03..e1ca2ff7 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c | |||
| @@ -1369,7 +1369,8 @@ static void expr_table(LexState *ls, ExpDesc *e) | |||
| 1369 | lua_assert(bc_a(ilp->ins) == freg && | 1369 | lua_assert(bc_a(ilp->ins) == freg && |
| 1370 | bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB)); | 1370 | bc_op(ilp->ins) == (narr > 256 ? BC_TSETV : BC_TSETB)); |
| 1371 | expr_init(&en, VKNUM, 0); | 1371 | expr_init(&en, VKNUM, 0); |
| 1372 | setintV(&en.u.nval, narr-1); | 1372 | en.u.nval.u32.lo = narr-1; |
| 1373 | en.u.nval.u32.hi = 0x43300000; /* Biased integer to avoid denormals. */ | ||
| 1373 | if (narr > 256) { fs->pc--; ilp--; } | 1374 | if (narr > 256) { fs->pc--; ilp--; } |
| 1374 | ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en)); | 1375 | ilp->ins = BCINS_AD(BC_TSETM, freg, const_num(fs, &en)); |
| 1375 | setbc_b(&ilp[-1].ins, 0); | 1376 | setbc_b(&ilp[-1].ins, 0); |
