summaryrefslogtreecommitdiff
path: root/ext/ByteLoader
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-05-02 12:41:43 +0000
committerNicholas Clark <nick@ccl4.org>2006-05-02 12:41:43 +0000
commitf4890806d306bfeee79f1864c882eb307b4f54fd (patch)
treecca03a58610968601b3ada5869d34e24939210d8 /ext/ByteLoader
parent178eff928e12522422417310bee9331fccc184cf (diff)
downloadperl-f4890806d306bfeee79f1864c882eb307b4f54fd.tar.gz
GvFILE() cannot be a pointer to the memory owned by the COP, because
COPs created by use can be freed along this memory, but the GP remains. Given that several GVs may refer to the same file, use a shared string rather than an individual allocation per GP. p4raw-id: //depot/perl@28060
Diffstat (limited to 'ext/ByteLoader')
-rw-r--r--ext/ByteLoader/bytecode.h11
-rw-r--r--ext/ByteLoader/byterun.c2
2 files changed, 12 insertions, 1 deletions
diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h
index 50198ece82..9df93ffd76 100644
--- a/ext/ByteLoader/bytecode.h
+++ b/ext/ByteLoader/bytecode.h
@@ -376,6 +376,17 @@ typedef char *pvindex;
SvREFCNT_dec(w); \
} \
} STMT_END
+#define BSET_gp_file(gv, file) \
+ STMT_START { \
+ STRLEN len = strlen(file); \
+ U32 hash; \
+ PERL_HASH(hash, file, len); \
+ if(GvFILE_HEK(gv)) { \
+ Perl_unshare_hek(aTHX_ GvFILE_HEK(gv)); \
+ } \
+ GvGP(gv)->gp_file_hek = share_hek(file, len, hash); \
+ Safefree(file); \
+ } STMT_END
/* NOTE: the bytecode header only sanity-checks the bytecode. If a script cares about
* what version of Perl it's being called under, it should do a 'use 5.006_001' or
diff --git a/ext/ByteLoader/byterun.c b/ext/ByteLoader/byterun.c
index 77568ba2c6..3738ad5bdd 100644
--- a/ext/ByteLoader/byterun.c
+++ b/ext/ByteLoader/byterun.c
@@ -658,7 +658,7 @@ byterun(pTHX_ register struct byteloader_state *bstate)
{
pvindex arg;
BGET_pvindex(arg);
- GvFILE(bstate->bs_sv) = arg;
+ BSET_gp_file(bstate->bs_sv, arg);
break;
}
case INSN_GP_IO: /* 86 */