diff options
author | Mike Pall <mike> | 2010-02-15 01:51:41 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-15 01:51:41 +0100 |
commit | 1288e04186d5ab48127696d685d622da1f42019c (patch) | |
tree | 1ea7811ab949b59eec07df420d06dd38d9c38a29 /src | |
parent | b6e4fde0dca25e911e2f1f614692f44c6923b1dc (diff) | |
download | luajit-1288e04186d5ab48127696d685d622da1f42019c.tar.gz luajit-1288e04186d5ab48127696d685d622da1f42019c.tar.bz2 luajit-1288e04186d5ab48127696d685d622da1f42019c.zip |
Add missing FORI coercions in recorder.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_record.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index deb5b2bb..ed882f1e 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -310,16 +310,25 @@ static TRef fori_arg(jit_State *J, const BCIns *fori, BCReg slot, IRType t) | |||
310 | return tr; | 310 | return tr; |
311 | } | 311 | } |
312 | 312 | ||
313 | /* In-place coercion of FORI arguments. */ | ||
314 | static lua_Number for_coerce(jit_State *J, TValue *o) | ||
315 | { | ||
316 | if (!tvisnum(o) && !(tvisstr(o) && lj_str_tonum(strV(o), o))) | ||
317 | lj_trace_err(J, LJ_TRERR_BADTYPE); | ||
318 | return numV(o); | ||
319 | } | ||
320 | |||
313 | /* Simulate the runtime behavior of the FOR loop iterator. | 321 | /* Simulate the runtime behavior of the FOR loop iterator. |
314 | ** It's important to exactly reproduce the semantics of the interpreter. | 322 | ** It's important to exactly reproduce the semantics of the interpreter. |
315 | */ | 323 | */ |
316 | static LoopEvent for_iter(jit_State *J, IROp *op, BCReg ra, int isforl) | 324 | static LoopEvent for_iter(jit_State *J, IROp *op, BCReg ra, int isforl) |
317 | { | 325 | { |
318 | cTValue *forbase = &J->L->base[ra]; | 326 | TValue *forbase = &J->L->base[ra]; |
319 | lua_Number stopv = numV(&forbase[FORL_STOP]); | 327 | lua_Number stopv = for_coerce(J, &forbase[FORL_STOP]); |
320 | lua_Number idxv = numV(&forbase[FORL_IDX]); | 328 | lua_Number idxv = for_coerce(J, &forbase[FORL_IDX]); |
329 | lua_Number stepv = for_coerce(J, &forbase[FORL_STEP]); | ||
321 | if (isforl) | 330 | if (isforl) |
322 | idxv += numV(&forbase[FORL_STEP]); | 331 | idxv += stepv; |
323 | if ((int32_t)forbase[FORL_STEP].u32.hi >= 0) { | 332 | if ((int32_t)forbase[FORL_STEP].u32.hi >= 0) { |
324 | if (idxv <= stopv) { *op = IR_LE; return LOOPEV_ENTER; } | 333 | if (idxv <= stopv) { *op = IR_LE; return LOOPEV_ENTER; } |
325 | *op = IR_GT; return LOOPEV_LEAVE; | 334 | *op = IR_GT; return LOOPEV_LEAVE; |