Skip to content

Commit 218fccc

Browse files
committed
op_dump(): handle SVOPs and METHOPs separately
Currently SVOPs and METHOPs are dumped using the same case branch within op_dump(). This works at the moment because the op_sv field and the op_meth_sv field happen to occupy the same offset within their respective structs. This commit separates out the handling of those two OP classes, which will also allow another commit shortly to handle METHOD ops more specifically. OP_COREARGS is also added as another dumpable SVOP type (i.e. an op which may have an SV hanging off op_sv). This commit also makes it so that it now always displays the value of the op_sv field of SVOPs, which on threaded builds starts off holding an SV, but later gets set to 0 to indicate that the SV has been moved to the pad.
1 parent 8a1cb46 commit 218fccc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

dump.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,25 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
13801380

13811381
case OP_CONST:
13821382
case OP_HINTSEVAL:
1383+
case OP_COREARGS:
1384+
/* an SVOP. On non-threaded builds, these OPs use op_sv to hold
1385+
* the SV associated with the const / hints hash / op num.
1386+
* On threaded builds, op_sv initially holds the SV, then at the
1387+
* end of compiling the sub, the SV is moved into the pad by
1388+
* op_relocate_sv() and indexed by op_targ.
1389+
* XXX Currently the SV isn't relocated for OP_COREARGS.
1390+
*/
1391+
S_opdump_indent(aTHX_ o, level, bar, file,
1392+
"OP_SV = 0x%" UVxf "\n", cSVOPo->op_sv);
1393+
#ifdef USE_ITHREADS
1394+
/* SV is stored in the pad, and the right pad may not be active
1395+
* here, so skip dumping the SV */
1396+
#else
1397+
S_opdump_indent(aTHX_ o, level, bar, file, "SV = %s\n",
1398+
SvPEEK(cSVOP_sv));
1399+
#endif
1400+
break;
1401+
13831402
case OP_METHOD_NAMED:
13841403
case OP_METHOD_SUPER:
13851404
case OP_METHOD_REDIR:
@@ -1391,6 +1410,7 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o)
13911410
SvPEEK(cMETHOPo_meth));
13921411
#endif
13931412
break;
1413+
13941414
case OP_NULL:
13951415
if (o->op_targ != OP_NEXTSTATE && o->op_targ != OP_DBSTATE)
13961416
break;

0 commit comments

Comments
 (0)