This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Store the compiled format in mg_ptr instead of after SvCUR() - fixes RT #89218
authorNicholas Clark <nick@ccl4.org>
Tue, 26 Apr 2011 11:12:34 +0000 (12:12 +0100)
committerNicholas Clark <nick@ccl4.org>
Wed, 18 May 2011 18:11:03 +0000 (19:11 +0100)
commit74e0ddf711449aba3fac400d9102bd461ee7265b
treef6b7d2f148790a56598095c857b3385db5b79c14
parent75f63940310204509f2935729c2b989e3be7c00d
Store the compiled format in mg_ptr instead of after SvCUR() - fixes RT #89218

Formats are compiled down to a sequence of U32 opcodes in doparseform().
Previously the block of opcodes was stored in the buffer of SvPVX() after
the raw string by extending the buffer, and calculating the first U32 aligned
address after SvCUR(). A flag bit on the scalar was set to signal this hackery,
tested with SvCOMPILED()

The flag bit used happened to be the same as one of the two used by to signal
Boyer-Moore compiled scalars. The assumption was that no scalar can be used for
both. Unfortunately, this isn't quite true.

Given that the scalar is alway upgraded to PVMG to add PERL_MAGIC_fm magic,
to clear the cached compiled version, there's no extra memory cost in using
mg_ptr in the MAGIC struct to point directly to the block of U32 opcodes. The
test for "is there a compiled version" can switch to mg_find(..., PERL_MAGIC_fm)
returning a pointer, and the use of a flag bit abolished.

Retain SvCOMPILED() and SvCOMPILED_{on,off}() as compatibility for XS code on
CPAN - the first is always 0, the other two now no-ops.
dump.c
embed.fnc
mg.c
pod/perldelta.pod
pp_ctl.c
proto.h
sv.h
t/op/index.t