Permalink
Browse files

rip out Perl version portability from B

B is distributed only with the core, not dual-life, so has no need to
be portable between Perl versions.
  • Loading branch information...
Zefram
Zefram committed Nov 14, 2017
1 parent a1c09da commit eb32218efcbe5450c9671923c624955355282e18
Showing with 109 additions and 437 deletions.
  1. +9 −78 ext/B/B.pm
  2. +2 −56 ext/B/B.xs
  3. +4 −29 ext/B/B/Concise.pm
  4. +1 −33 ext/B/t/OptreeCheck.pm
  5. +9 −30 ext/B/t/b.t
  6. +24 −54 ext/B/t/f_sort.t
  7. +54 −115 ext/B/t/optree_constants.t
  8. +1 −29 ext/B/t/optree_misc.t
  9. +4 −8 ext/B/t/optree_samples.t
  10. +1 −5 ext/B/t/terse.t
View
@@ -48,12 +48,12 @@ push @B::EXPORT_OK, (qw(minus_c ppname save_BEGINs
@B::IV::ISA = 'B::SV';
@B::NV::ISA = 'B::SV';
# RV is eliminated with 5.11.0, but effectively is a specialisation of IV now.
@B::RV::ISA = $] >= 5.011 ? 'B::IV' : 'B::SV';
@B::RV::ISA = 'B::IV';
@B::PVIV::ISA = qw(B::PV B::IV);
@B::PVNV::ISA = qw(B::PVIV B::NV);
@B::PVMG::ISA = 'B::PVNV';
@B::REGEXP::ISA = 'B::PVMG' if $] >= 5.011;
@B::INVLIST::ISA = 'B::PV' if $] >= 5.019;
@B::REGEXP::ISA = 'B::PVMG';
@B::INVLIST::ISA = 'B::PV';
@B::PVLV::ISA = 'B::GV';
@B::BM::ISA = 'B::GV';
@B::AV::ISA = 'B::PVMG';
@@ -549,52 +549,10 @@ give incomprehensible results, or worse.
=head2 SV-RELATED CLASSES
B::IV, B::NV, B::RV, B::PV, B::PVIV, B::PVNV, B::PVMG, B::BM (5.9.5 and
earlier), B::PVLV, B::AV, B::HV, B::CV, B::GV, B::FM, B::IO. These classes
B::IV, B::NV, B::PV, B::PVIV, B::PVNV, B::PVMG,
B::PVLV, B::AV, B::HV, B::CV, B::GV, B::FM, B::IO. These classes
correspond in the obvious way to the underlying C structures of similar names.
The inheritance hierarchy mimics the underlying C "inheritance". For the
5.10.x branch, (I<ie> 5.10.0, 5.10.1 I<etc>) this is:
B::SV
|
+------------+------------+------------+
| | | |
B::PV B::IV B::NV B::RV
\ / /
\ / /
B::PVIV /
\ /
\ /
\ /
B::PVNV
|
|
B::PVMG
|
+-----+-----+-----+-----+
| | | | |
B::AV B::GV B::HV B::CV B::IO
| |
| |
B::PVLV B::FM
For 5.9.0 and earlier, PVLV is a direct subclass of PVMG, and BM is still
present as a distinct type, so the base of this diagram is
|
|
B::PVMG
|
+------+-----+-----+-----+-----+-----+
| | | | | | |
B::PVLV B::BM B::AV B::GV B::HV B::CV B::IO
|
|
B::FM
For 5.11.0 and later, B::RV is abolished, and IVs can be used to store
references, and a new type B::REGEXP is introduced, giving this structure:
The inheritance hierarchy mimics the underlying C "inheritance":
B::SV
|
@@ -958,17 +916,6 @@ IoIFP($io) == PerlIO_stderr().
Like C<ARRAY>, but takes an index as an argument to get only one element,
rather than a list of all of them.
=item OFF
This method is deprecated if running under Perl 5.8, and is no longer present
if running under Perl 5.9
=item AvFLAGS
This method returns the AV specific
flags. In Perl 5.9 these are now stored
in with the main SV flags, so this method is no longer present.
=back
=head2 B::CV Methods
@@ -989,8 +936,7 @@ in with the main SV flags, so this method is no longer present.
=item PADLIST
Returns a B::PADLIST object under Perl 5.18 or higher, or a B::AV in
earlier versions.
Returns a B::PADLIST object.
=item OUTSIDE
@@ -1028,11 +974,6 @@ Returns the name of a lexical sub, otherwise C<undef>.
=item ARRAY
=item PMROOT
This method is not present if running under Perl 5.9, as the PMROOT
information is no longer stored directly in the hash.
=back
=head2 OP-RELATED CLASSES
@@ -1175,16 +1116,8 @@ op is contained within.
=item pmreplstart
=item pmnext
Only up to Perl 5.9.4
=item pmflags
=item extflags
Since Perl 5.9.5
=item precomp
=item pmoffset
@@ -1300,10 +1233,8 @@ Perl 5.22 introduced the B::PADNAMELIST and B::PADNAME classes.
=item ARRAY
A list of pads. The first one contains the names.
The first one is a B::PADNAMELIST under Perl 5.22, and a B::AV under
earlier versions. The rest are currently B::AV objects, but that could
A list of pads. The first one is a B::PADNAMELIST containing the names.
The rest are currently B::AV objects, but that could
change in future versions.
=item ARRAYelt
View
@@ -468,9 +468,7 @@ typedef IO *B__IO;
typedef MAGIC *B__MAGIC;
typedef HE *B__HE;
typedef struct refcounted_he *B__RHE;
#ifdef PadlistARRAY
typedef PADLIST *B__PADLIST;
#endif
typedef PADNAMELIST *B__PADNAMELIST;
typedef PADNAME *B__PADNAME;
@@ -628,10 +626,6 @@ BOOT:
ASSIGN_COMMON_ALIAS(I, defstash);
cv = newXS("B::curstash", intrpvar_sv_common, file);
ASSIGN_COMMON_ALIAS(I, curstash);
#ifdef PL_formfeed
cv = newXS("B::formfeed", intrpvar_sv_common, file);
ASSIGN_COMMON_ALIAS(I, formfeed);
#endif
#ifdef USE_ITHREADS
cv = newXS("B::regex_padav", intrpvar_sv_common, file);
ASSIGN_COMMON_ALIAS(I, regex_padav);
@@ -648,15 +642,11 @@ BOOT:
#endif
}
#ifndef PL_formfeed
void
formfeed()
PPCODE:
PUSHs(make_sv_object(aTHX_ GvSV(gv_fetchpvs("\f", GV_ADD, SVt_PV))));
#endif
long
amagic_generation()
CODE:
@@ -669,16 +659,12 @@ comppadlist()
PREINIT:
PADLIST *padlist = CvPADLIST(PL_main_cv ? PL_main_cv : PL_compcv);
PPCODE:
#ifdef PadlistARRAY
{
SV * const rv = sv_newmortal();
sv_setiv(newSVrv(rv, padlist ? "B::PADLIST" : "B::NULL"),
PTR2IV(padlist));
PUSHs(rv);
}
#else
PUSHs(make_sv_object(aTHX_ (SV *)padlist));
#endif
void
sv_undef()
@@ -1667,19 +1653,12 @@ PV(sv)
U32 utf8 = 0;
CODE:
if (ix == 3) {
#ifndef PERL_FBM_TABLE_OFFSET
const MAGIC *const mg = mg_find(sv, PERL_MAGIC_bm);
if (!mg)
croak("argument to B::BM::TABLE is not a PVBM");
p = mg->mg_ptr;
len = mg->mg_len;
#else
p = SvPV(sv, len);
/* Boyer-Moore table is just after string and its safety-margin \0 */
p += len + PERL_FBM_TABLE_OFFSET;
len = 256;
#endif
} else if (ix == 2) {
/* This used to read 257. I think that that was buggy - should have
been 258. (The "\0", the flags byte, and 256 for the table.)
@@ -1697,38 +1676,22 @@ PV(sv)
5.15 and later store the BM table via MAGIC, so the compiler
should handle this just fine without changes if PVBM now
always returns the SvPVX() buffer. */
#ifdef isREGEXP
p = isREGEXP(sv)
? RX_WRAPPED_const((REGEXP*)sv)
: SvPVX_const(sv);
#else
p = SvPVX_const(sv);
#endif
#ifdef PERL_FBM_TABLE_OFFSET
len = SvCUR(sv) + (SvVALID(sv) ? 256 + PERL_FBM_TABLE_OFFSET : 0);
#else
len = SvCUR(sv);
#endif
} else if (ix) {
#ifdef isREGEXP
p = isREGEXP(sv) ? RX_WRAPPED((REGEXP*)sv) : SvPVX(sv);
#else
p = SvPVX(sv);
#endif
len = strlen(p);
} else if (SvPOK(sv)) {
len = SvCUR(sv);
p = SvPVX_const(sv);
utf8 = SvUTF8(sv);
}
#ifdef isREGEXP
else if (isREGEXP(sv)) {
} else if (isREGEXP(sv)) {
len = SvCUR(sv);
p = RX_WRAPPED_const((REGEXP*)sv);
utf8 = SvUTF8(sv);
}
#endif
else {
} else {
/* XXX for backward compatibility, but should fail */
/* croak( "argument is not SvPOK" ); */
p = NULL;
@@ -2008,8 +1971,6 @@ I32
CvDEPTH(cv)
B::CV cv
#ifdef PadlistARRAY
B::PADLIST
CvPADLIST(cv)
B::CV cv
@@ -2018,17 +1979,6 @@ CvPADLIST(cv)
OUTPUT:
RETVAL
#else
B::AV
CvPADLIST(cv)
B::CV cv
PPCODE:
PUSHs(make_sv_object(aTHX_ (SV *)CvPADLIST(cv)));
#endif
SV *
CvHSCXT(cv)
B::CV cv
@@ -2129,8 +2079,6 @@ HASH(h)
RETVAL
#ifdef PadlistARRAY
MODULE = B PACKAGE = B::PADLIST PREFIX = Padlist
SSize_t
@@ -2190,8 +2138,6 @@ PadlistREFCNT(padlist)
OUTPUT:
RETVAL
#endif
MODULE = B PACKAGE = B::PADNAMELIST PREFIX = Padnamelist
void
View
@@ -717,16 +717,9 @@ sub concise_sv {
$hr->{svval} = "*$stash" . $gv->SAFENAME;
return "*$stash" . $gv->SAFENAME;
} else {
if ($] >= 5.011) {
while (class($sv) eq "IV" && $sv->FLAGS & SVf_ROK) {
$hr->{svval} .= "\\";
$sv = $sv->RV;
}
} else {
while (class($sv) eq "RV") {
$hr->{svval} .= "\\";
$sv = $sv->RV;
}
while (class($sv) eq "IV" && $sv->FLAGS & SVf_ROK) {
$hr->{svval} .= "\\";
$sv = $sv->RV;
}
if (class($sv) eq "SPECIAL") {
$hr->{svval} .= ["Null", "sv_undef", "sv_yes", "sv_no",
@@ -938,10 +931,7 @@ sub concise_op {
$h{arg} = "($label$stash $cseq $loc)";
if ($show_src) {
fill_srclines($pathnm) unless exists $srclines{$pathnm};
# Would love to retain Jim's use of // but this code needs to be
# portable to 5.8.x
my $line = $srclines{$pathnm}[$ln];
$line = "-src unavailable under -e" unless defined $line;
my $line = $srclines{$pathnm}[$ln] // "-src unavailable under -e";
$h{src} = "$ln: $line";
}
} elsif ($h{class} eq "LOOP") {
@@ -1111,10 +1101,6 @@ sub tree {
# number for the user's program as being a small offset later, so all we
# have to worry about are changes in the offset.
# [For 5.8.x and earlier perl is generating sequence numbers for all ops,
# and using them to reference labels]
# When you say "perl -MO=Concise -e '$a'", the output should look like:
# 4 <@> leave[t1] vKP/REFC ->(end)
@@ -1717,21 +1703,10 @@ The numeric value of the OP's private flags.
The sequence number of the OP. Note that this is a sequence number
generated by B::Concise.
=item B<#seqnum>
5.8.x and earlier only. 5.9 and later do not provide this.
The real sequence number of the OP, as a regular number and not adjusted
to be relative to the start of the real program. (This will generally be
a fairly large number because all of B<B::Concise> is compiled before
your program is).
=item B<#opt>
Whether or not the op has been optimized by the peephole optimizer.
Only available in 5.9 and later.
=item B<#sibaddr>
The address of the OP's next youngest sibling, in hexadecimal.
Oops, something went wrong.

0 comments on commit eb32218

Please sign in to comment.