diff options
-rw-r--r-- | src/lj_opt_narrow.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lj_opt_narrow.c b/src/lj_opt_narrow.c index b7bd3232..58b3763d 100644 --- a/src/lj_opt_narrow.c +++ b/src/lj_opt_narrow.c | |||
@@ -247,10 +247,16 @@ static void narrow_stripov_backprop(NarrowConv *nc, IRRef ref, int depth) | |||
247 | if (bp) { | 247 | if (bp) { |
248 | ref = bp->val; | 248 | ref = bp->val; |
249 | } else if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { | 249 | } else if (++depth < NARROW_MAX_BACKPROP && nc->sp < nc->maxsp) { |
250 | NarrowIns *savesp = nc->sp; | ||
250 | narrow_stripov_backprop(nc, ir->op1, depth); | 251 | narrow_stripov_backprop(nc, ir->op1, depth); |
251 | narrow_stripov_backprop(nc, ir->op2, depth); | 252 | if (nc->sp < nc->maxsp) { |
252 | *nc->sp++ = NARROWINS(IRT(ir->o - IR_ADDOV + IR_ADD, IRT_INT), ref); | 253 | narrow_stripov_backprop(nc, ir->op2, depth); |
253 | return; | 254 | if (nc->sp < nc->maxsp) { |
255 | *nc->sp++ = NARROWINS(IRT(ir->o - IR_ADDOV + IR_ADD, IRT_INT), ref); | ||
256 | return; | ||
257 | } | ||
258 | } | ||
259 | nc->sp = savesp; /* Path too deep, need to backtrack. */ | ||
254 | } | 260 | } |
255 | } | 261 | } |
256 | *nc->sp++ = NARROWINS(NARROW_REF, ref); | 262 | *nc->sp++ = NARROWINS(NARROW_REF, ref); |
@@ -263,6 +269,8 @@ static int narrow_conv_backprop(NarrowConv *nc, IRRef ref, int depth) | |||
263 | IRIns *ir = IR(ref); | 269 | IRIns *ir = IR(ref); |
264 | IRRef cref; | 270 | IRRef cref; |
265 | 271 | ||
272 | if (nc->sp >= nc->maxsp) return 10; /* Path too deep. */ | ||
273 | |||
266 | /* Check the easy cases first. */ | 274 | /* Check the easy cases first. */ |
267 | if (ir->o == IR_CONV && (ir->op2 & IRCONV_SRCMASK) == IRT_INT) { | 275 | if (ir->o == IR_CONV && (ir->op2 & IRCONV_SRCMASK) == IRT_INT) { |
268 | if ((nc->mode & IRCONV_CONVMASK) <= IRCONV_ANY) | 276 | if ((nc->mode & IRCONV_CONVMASK) <= IRCONV_ANY) |