summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-10-21 14:16:54 +1100
committerTony Cook <tony@develop-help.com>2021-11-15 11:35:42 +1100
commit9c913148860b0e83e6149d37e86cdb29663ee812 (patch)
tree7f710ef653664ac0a0bb48561554f5a45e8ca8ce /cop.h
parent9bce496f83cb607054f21c015c5f377c24c86bfd (diff)
downloadperl-9c913148860b0e83e6149d37e86cdb29663ee812.tar.gz
Add CopFILEAVn() and use it when cleaning up COP pointers
On threaded builds CopFILEAV() calls gv_fetchfile(), which always created the *{"::_<filenamehere"} glob, so the attempted clean up here could recreate the glob, even if it has already been removed when cleaning up a string eval. To avoid this, add CopFILEAVn() that never creates the glob, nor the AV so that the clean up never adds new objects. This change makes the check for PL_phase unnecessary, but that check is much cheaper than the call for gv_fetchfile_flags() that the macro hides, so retain the check.
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/cop.h b/cop.h
index d20631e473..662b8b360c 100644
--- a/cop.h
+++ b/cop.h
@@ -484,7 +484,11 @@ Returns the name of the file associated with the C<COP> C<c>
Returns the line number in the source code associated with the C<COP> C<c>
=for apidoc Am|AV *|CopFILEAV|const COP * c
-Returns the AV associated with the C<COP> C<c>
+Returns the AV associated with the C<COP> C<c>, creating it if necessary.
+
+=for apidoc Am|AV *|CopFILEAVn|const COP * c
+Returns the AV associated with the C<COP> C<c>, returning NULL if it
+doesn't already exist.
=for apidoc Am|SV *|CopFILESV|const COP * c
Returns the SV associated with the C<COP> C<c>
@@ -533,7 +537,7 @@ string C<p>, creating the package if necessary.
? GvAV(gv_fetchfile(CopFILE(c))) : NULL)
# define CopFILEAVx(c) (assert_(CopFILE(c)) \
GvAV(gv_fetchfile(CopFILE(c))))
-
+# define CopFILEAVn(c) (cop_file_avn(c))
# define CopSTASH(c) PL_stashpad[(c)->cop_stashoff]
# define CopSTASH_set(c,hv) ((c)->cop_stashoff = (hv) \
? alloccopstash(hv) \
@@ -551,6 +555,7 @@ string C<p>, creating the package if necessary.
# else
# define CopFILEAVx(c) (GvAV(CopFILEGV(c)))
# endif
+# define CopFILEAVn(c) (CopFILEGV(c) ? GvAVn(CopFILEGV(c)) : NULL)
# define CopFILE(c) (CopFILEGV(c) /* +2 for '_<' */ \
? GvNAME(CopFILEGV(c))+2 : NULL)
# define CopSTASH(c) ((c)->cop_stash)