Skip to content

Commit

Permalink
C+CC: fix regressions CC AV->MAGICAL in 5.6, PMf_ONCE <5.10, ARRAY_ut…
Browse files Browse the repository at this point in the history
…f8<5.10

B::AV->MAGICAL is not defined in 5.6, skip it in B::CC
PMf_ONCE is not needed <5.10
Skip ARRAY_utf8 <5.10, no shared heks there (and different sv class ids)
  • Loading branch information
Reini Urban committed Nov 20, 2013
1 parent 7615155 commit c1046ab
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
12 changes: 11 additions & 1 deletion C.xs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ typedef struct {
IV require_tag;
} a_hint_t;

#if PERL_VERSION >= 10

static const char* const svclassnames[] = {
"B::NULL",
#if PERL_VERSION < 19
Expand Down Expand Up @@ -99,6 +101,8 @@ make_sv_object(pTHX_ SV *sv)
return arg;
}

#endif

static int
my_runops(pTHX)
{
Expand Down Expand Up @@ -285,6 +289,8 @@ op_folded(op)

MODULE = B PACKAGE = B::HV PREFIX = Hv

#if PERL_VERSION >= 10

void
HvARRAY_utf8(hv)
B::HV hv
Expand All @@ -305,6 +311,8 @@ HvARRAY_utf8(hv)
}
}

#endif

MODULE = B__C PACKAGE = B::C

PROTOTYPES: DISABLE
Expand Down Expand Up @@ -344,12 +352,14 @@ method_cv(meth, packname)
#endif

BOOT:
MY_CXT_INIT;
PL_runops = my_runops;
#if PERL_VERSION >= 10
MY_CXT_INIT;
specialsv_list[0] = Nullsv;
specialsv_list[1] = &PL_sv_undef;
specialsv_list[2] = &PL_sv_yes;
specialsv_list[3] = &PL_sv_no;
specialsv_list[4] = (SV *) pWARN_ALL;
specialsv_list[5] = (SV *) pWARN_NONE;
specialsv_list[6] = (SV *) pWARN_STD;
#endif
16 changes: 9 additions & 7 deletions lib/B/C.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
package B::C;
use strict;

our $VERSION = '1.42_55';
our $VERSION = '1.42_56';
my %debug;
our $check;
my $eval_pvs = '';
Expand Down Expand Up @@ -205,7 +205,7 @@ our %Regexp;
my $caller = caller;
if ( $caller eq 'O' or $caller eq 'Od' ) {
require XSLoader;
XSLoader::load('B::C'); # for r-magic only
XSLoader::load('B::C'); # for r-magic and for utf8-keyed B::HV->ARRAY
}
}

Expand All @@ -215,8 +215,8 @@ our @EXPORT_OK =
init_sections set_callback save_unused_subs objsym save_context fixup_ppaddr
save_sig svop_or_padop_pv inc_cleanup ivx nvx);

# for 5.6 better use the native B::C
# 5.6.2 works fine though.
# for 5.6.[01] better use the native B::C
# but 5.6.2 works fine
use B
qw(minus_c sv_undef walkoptree walkoptree_slow walksymtable main_root main_start peekop
class cchar svref_2object compile_stats comppadlist hash
Expand All @@ -232,6 +232,7 @@ BEGIN {
sub SVp_NOK() {0}; # unused
sub SVp_IOK() {0};
sub CVf_ANON() {4};
sub PMf_ONCE() {0xff}; # unused
];
@B::PVMG::ISA = qw(B::PVNV B::RV);
}
Expand Down Expand Up @@ -1613,7 +1614,7 @@ sub B::PMOP::save {
);
# See toke.c:8964
# set in the stash the PERL_MAGIC_symtab PTR to the PMOP: ((PMOP**)mg->mg_ptr) [elements++] = pm;
if ($op->pmflags & PMf_ONCE) {
if ($PERL510 and $op->pmflags & PMf_ONCE()) {
my $stash = $MULTI ? $op->pmstashpv
: ref $op->pmstash eq 'B::HV' ? $op->pmstash->NAME : '__ANON__';
warn "TODO #188: restore PMf_ONCE, set PERL_MAGIC_symtab in $stash";
Expand Down Expand Up @@ -3982,7 +3983,8 @@ sub B::HV::save {
warn sprintf( "saving HV $fullname &sv_list[$sv_list_index] 0x%x MAX=%d\n",
$$hv, $hv->MAX ) if $debug{hv};
# XXX B does not keep the UTF8 flag [RT 120535] #200
my @contents = $hv->can('ARRAY_utf8') ? $hv->ARRAY_utf8 : $hv->ARRAY; # our fixed C.xs variant
# shared heks only since 5.10
my @contents = ($PERL510 && $hv->can('ARRAY_utf8')) ? $hv->ARRAY_utf8 : $hv->ARRAY; # our fixed C.xs variant
# protect against recursive self-reference
# i.e. with use Moose at stash Class::MOP::Class::Immutable::Trait
# value => rv => cv => ... => rv => same hash
Expand Down Expand Up @@ -4037,7 +4039,7 @@ sub B::HV::save {
}
$init->add("}");
$init->split;
$init->add( sprintf("HvTOTALKEYS($sym) = %d;", $length / 2));
$init->add( sprintf("HvTOTALKEYS($sym) = %d;", $length / 2)) if !$PERL56;
$init->add( "SvREADONLY_on($sym);") if $hv->FLAGS & SVf_READONLY;
}
} elsif ($] >= 5.014) { # empty contents still needs to set keys=0
Expand Down
13 changes: 12 additions & 1 deletion lib/B/CC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,17 @@ BEGIN {
} else {
B->import('SVs_RMG');
}
if ($] <= 5.010) {
eval "sub PMf_ONCE() {0xff}; # unused";
} elsif ($] >= 5.018) { # PMf_ONCE not exported
eval q[sub PMf_ONCE(){ 0x10000 }];
} elsif ($] >= 5.014) {
eval q[sub PMf_ONCE(){ 0x8000 }];
} elsif ($] >= 5.012) {
eval q[sub PMf_ONCE(){ 0x0080 }];
} else { # 5.10. not used with <= 5.8
eval q[sub PMf_ONCE(){ 0x0002 }];
}
}

# Could rewrite push_runtime() and output_runtime() to use a
Expand Down Expand Up @@ -1781,7 +1792,7 @@ sub pp_aelemfast {
my $gv = $op->gv;
$gvsym = $gv->save;
my $gvav = $gv->AV; # test 16, tied gvav
$rmg = ($gvav and $gvav->MAGICAL & SVs_RMG) ? 1 : 0;
$rmg = $] < 5.007 ? 0 : ($gvav and $gvav->MAGICAL & SVs_RMG) ? 1 : 0;
}
$av = "GvAV($gvsym)";
}
Expand Down
5 changes: 3 additions & 2 deletions t/issue31.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ EOF

use B::C;
# $]<5.007: same as test 33
# 5.18 errors unrelated
ctestok(1, "CC", "ccode31i", $script,
# XXX TODO >5.10 since 1.35. copy SvANY(CALLREGCOMP) SvANY(REGEXP) ?
($B::C::VERSION lt '1.42_55')
? "TODO B:CC Regex in pkg var fails with 5.6 and >5.10 since 1.35 until 1.42_54"
: "B:CC Regex in pkg var");
ctestok(2, "C,-O3", "ccode31i", $script, "B:C Regex in pkg var");
: ($] > 5.017 ? "TODO " : "")."B:CC Regex in pkg var");
ctestok(2, "C,-O3", "ccode31i", $script, ($] > 5.017 ? "TODO " : "")."B:C Regex in pkg var");

END { unlink $pm; }

0 comments on commit c1046ab

Please sign in to comment.