Fix despecialization of ITERN when already running.

This commit is contained in:
Mike Pall 2012-09-12 16:58:47 +02:00
parent 23932a6c8b
commit aed2009378
6 changed files with 15 additions and 2 deletions

View File

@ -545,6 +545,8 @@ static uint32_t keyindex(lua_State *L, GCtab *t, cTValue *key)
return t->asize + (uint32_t)(n - noderef(t->node)); return t->asize + (uint32_t)(n - noderef(t->node));
/* Hash key indexes: [t->asize..t->asize+t->nmask] */ /* Hash key indexes: [t->asize..t->asize+t->nmask] */
} while ((n = nextnode(n))); } while ((n = nextnode(n)));
if (key->u32.hi == 0xfffe7fff) /* ITERN was despecialized while running. */
return key->u32.lo - 1;
lj_err_msg(L, LJ_ERR_NEXTIDX); lj_err_msg(L, LJ_ERR_NEXTIDX);
return 0; /* unreachable */ return 0; /* unreachable */
} }

View File

@ -3897,7 +3897,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| ins_next1 | ins_next1
| ins_next2 | ins_next2
| mov CARG1, #0 | mov CARG1, #0
| str CARG1, [RA, #-8] // Initialize control var. | mvn CARG2, #0x00018000
| strd CARG1, [RA, #-8] // Initialize control var.
|1: |1:
| ins_next3 | ins_next3
|5: // Despecialize bytecode if any of the checks fail. |5: // Despecialize bytecode if any of the checks fail.

View File

@ -3617,7 +3617,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| bnez TMP1, >5 | bnez TMP1, >5
|. lui TMP2, (-(BCBIAS_J*4 >> 16) & 65535) |. lui TMP2, (-(BCBIAS_J*4 >> 16) & 65535)
| addu PC, TMP0, TMP2 | addu PC, TMP0, TMP2
| lui TMP1, 0xfffe
| ori TMP1, TMP1, 0x7fff
| sw r0, -8+LO(RA) // Initialize control var. | sw r0, -8+LO(RA) // Initialize control var.
| sw TMP1, -8+HI(RA)
|1: |1:
| ins_next | ins_next
|5: // Despecialize bytecode if any of the checks fail. |5: // Despecialize bytecode if any of the checks fail.

View File

@ -4376,7 +4376,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq
| add TMP3, PC, TMP0 | add TMP3, PC, TMP0
| bne cr0, >5 | bne cr0, >5
| lus TMP1, 0xfffe
| ori TMP1, TMP1, 0x7fff
| stw ZERO, -4(RA) // Initialize control var. | stw ZERO, -4(RA) // Initialize control var.
| stw TMP1, -8(RA)
| addis PC, TMP3, -(BCBIAS_J*4 >> 16) | addis PC, TMP3, -(BCBIAS_J*4 >> 16)
|1: |1:
| ins_next | ins_next

View File

@ -3188,7 +3188,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq | crand 4*cr0+eq, 4*cr0+eq, 4*cr7+eq
| add TMP3, PC, TMP0 | add TMP3, PC, TMP0
| bne cr0, >5 | bne cr0, >5
| lus TMP1, 0xfffe
| ori TMP1, TMP1, 0x7fff
| stw ZERO, -4(RA) // Initialize control var. | stw ZERO, -4(RA) // Initialize control var.
| stw TMP1, -8(RA)
| addis PC, TMP3, -(BCBIAS_J*4 >> 16) | addis PC, TMP3, -(BCBIAS_J*4 >> 16)
|1: |1:
| ins_next | ins_next

View File

@ -1566,7 +1566,7 @@ static void build_subroutines(BuildCtx *ctx)
| add BASE, 8 | add BASE, 8
| mov ARG3, BASE | mov ARG3, BASE
|.endif |.endif
| mov SAVE_PC, PC // Redundant (but a defined value). | mov SAVE_PC, PC // Needed for ITERN fallback.
| call extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key) | call extern lj_tab_next // (lua_State *L, GCtab *t, TValue *key)
| // Flag returned in eax (RD). | // Flag returned in eax (RD).
| mov BASE, L:RB->base | mov BASE, L:RB->base
@ -5433,6 +5433,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| cmp byte CFUNC:RB->ffid, FF_next_N; jne >5 | cmp byte CFUNC:RB->ffid, FF_next_N; jne >5
| branchPC RD | branchPC RD
| mov dword [BASE+RA*8-8], 0 // Initialize control var. | mov dword [BASE+RA*8-8], 0 // Initialize control var.
| mov dword [BASE+RA*8-4], 0xfffe7fff
|1: |1:
| ins_next | ins_next
|5: // Despecialize bytecode if any of the checks fail. |5: // Despecialize bytecode if any of the checks fail.