- " re EVAL PL_op=0x%"UVxf"\n", PTR2UV(PL_op)) );
- /* wrap the call in two SAVECOMPPADs. This ensures that
- * when the save stack is eventually unwound, all the
- * accumulated SAVEt_CLEARSV's will be processed with
- * interspersed SAVEt_COMPPAD's to ensure that lexicals
- * are cleared in the right pad */
- if (PL_comppad == new_comppad)
- old_comppad = new_comppad;
- else {
- SAVECOMPPAD();
- PAD_SAVE_LOCAL(old_comppad, new_comppad);
+ " re EVAL PL_op=0x%"UVxf"\n", PTR2UV(nop)) );
+
+ /* normally if we're about to execute code from the same
+ * CV that we used previously, we just use the existing
+ * CX stack entry. However, its possible that in the
+ * meantime we may have backtracked, popped from the save
+ * stack, and undone the SAVECOMPPAD(s) associated with
+ * PUSH_MULTICALL; in which case PL_comppad no longer
+ * points to newcv's pad. */
+ if (newcv != last_pushed_cv || PL_comppad != last_pad)
+ {
+ I32 depth = (newcv == caller_cv) ? 0 : 1;
+ if (last_pushed_cv) {
+ CHANGE_MULTICALL_WITHDEPTH(newcv, depth);
+ }
+ else {
+ PUSH_MULTICALL_WITHDEPTH(newcv, depth);
+ }
+ last_pushed_cv = newcv;