summaryrefslogtreecommitdiff
path: root/inline.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 /inline.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 'inline.h')
-rw-r--r--inline.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/inline.h b/inline.h
index e6fd4cb6a9..41da923991 100644
--- a/inline.h
+++ b/inline.h
@@ -3429,6 +3429,28 @@ Perl_sv_isbool(pTHX_ const SV *sv)
(SvPVX_const(sv) == PL_Yes || SvPVX_const(sv) == PL_No);
}
+#ifdef USE_ITHREADS
+
+PERL_STATIC_INLINE AV *
+Perl_cop_file_avn(pTHX_ const COP *cop) {
+
+ PERL_ARGS_ASSERT_COP_FILE_AVN;
+
+ const char *file = CopFILE(cop);
+ if (file) {
+ GV *gv = gv_fetchfile_flags(file, strlen(file), GVF_NOADD);
+ if (gv) {
+ return GvAVn(gv);
+ }
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+}
+
+#endif
+
/*
* ex: set ts=8 sts=4 sw=4 et:
*/