From 7883eda38b4caab8e37ba7fb80a5ef2fa19f51fb Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Sun, 12 Feb 2012 22:51:51 -0600 Subject: [PATCH] move !$$root method not found case upwards remove is only needed for the last idx. think I fixed remove for intermediate also, but this path is never called. all tests but 15 pass --- lib/B/C.pm | 107 ++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/lib/B/C.pm b/lib/B/C.pm index 8959481af..874e23761 100644 --- a/lib/B/C.pm +++ b/lib/B/C.pm @@ -36,8 +36,8 @@ sub add { sub remove { my $section = shift; - if (@_) { - splice @{ $section->[-1]{values} }, shift, 1; + if (@_) { # XXX + splice @{ $section }, shift, 1; } else { pop @{ $section->[-1]{values} }; } @@ -2722,6 +2722,18 @@ sub B::CV::save { } } } + if (!$$root) { + warn "WARNING: &".$fullname." not found\n" if $verbose or $debug{sub}; + warn "No definition for sub $fullname (unable to autoload), remove cv\n" + if $debug{cv}; + $init->add( "/* $fullname not found */" ) if $verbose or $debug{sub}; + # Empty CV (methods) must be skipped not to disturb method resolution + $svsect->remove; #( $sv_ix ); + $xpvcvsect->remove; #( $xpvcv_ix ); + delsym( $cv ); + #return svref_2object( \&Dummy_initxs )->save; + return '0'; + } my $startfield = 0; my $padlist = $cv->PADLIST; @@ -2729,62 +2741,49 @@ sub B::CV::save { my $pv = $cv->PV; my $xsub = 0; my $xsubany = "Nullany"; - if ($$root) { - warn sprintf( "saving op tree for CV 0x%x, root=0x%x\n", - $$cv, $$root ) - if $debug{cv} and $debug{gv}; - my $ppname = ""; - if ($$gv) { - my $stashname = $gv->STASH->NAME; - my $gvname = $gv->NAME; - $fullname = $stashname.'::'.$gvname; - if ( $gvname ne "__ANON__" ) { - $ppname = ( ${ $gv->FORM } == $$cv ) ? "pp_form_" : "pp_sub_"; - $ppname .= ( $stashname eq "main" ) ? $gvname : "$stashname\::$gvname"; - $ppname =~ s/::/__/g; - if ( $gvname eq "INIT" ) { - $ppname .= "_$initsub_index"; - $initsub_index++; - } + warn sprintf( "saving op tree for CV 0x%x, root=0x%x\n", + $$cv, $$root ) + if $debug{cv} and $debug{gv}; + my $ppname = ""; + if ($$gv) { + my $stashname = $gv->STASH->NAME; + my $gvname = $gv->NAME; + $fullname = $stashname.'::'.$gvname; + if ( $gvname ne "__ANON__" ) { + $ppname = ( ${ $gv->FORM } == $$cv ) ? "pp_form_" : "pp_sub_"; + $ppname .= ( $stashname eq "main" ) ? $gvname : "$stashname\::$gvname"; + $ppname =~ s/::/__/g; + if ( $gvname eq "INIT" ) { + $ppname .= "_$initsub_index"; + $initsub_index++; } } - if ( !$ppname ) { - $ppname = "pp_anonsub_$anonsub_index"; - $anonsub_index++; - } - $startfield = saveoptree( $ppname, $root, $cv->START, $padlist->ARRAY ); - #warn sprintf( "done saving op tree for CV 0x%x, flags (%s), name %s, root=0x%x => start=%s\n", - # $$cv, $debug{flags}?$cv->flagspv:sprintf("0x%x",$cv->FLAGS), $ppname, $$root, $startfield ) - # if $debug{cv}; - # XXX missing cv_start for AUTOLOAD on 5.8 - $startfield = objsym($root->next) unless $startfield; # 5.8 autoload has only root - $startfield = "0" unless $startfield; - if ($$padlist) { - # XXX readonly comppad names and symbols invalid - #local $B::C::pv_copy_on_grow = 1 if $B::C::ro_inc; - warn sprintf( "saving PADLIST 0x%x for CV 0x%x\n", $$padlist, $$cv ) - if $debug{cv} and $debug{gv}; - # XXX avlen 2 - $padlistsym = $padlist->save($fullname.' :pad'); - warn sprintf( "done saving PADLIST %s 0x%x for CV 0x%x\n", - $padlistsym, $$padlist, $$cv ) - if $debug{cv} and $debug{gv}; - # do not record a forward for the pad only - $init->add( "CvPADLIST($sym) = $padlistsym;" ); - } - warn $fullname."\n" if $debug{sub}; } - else { - warn "&".$fullname." not found\n" if $verbose or $debug{sub}; - warn "No definition for sub $fullname (unable to autoload), remove cv\n" - if $debug{cv}; - $init->add( "/* $fullname not found */" ) if $verbose or $debug{sub}; - # XXX empty CV should not be saved - $svsect->remove( $sv_ix ); - $xpvcvsect->remove( $xpvcv_ix ); - delsym( $cv ); - return '0'; + if ( !$ppname ) { + $ppname = "pp_anonsub_$anonsub_index"; + $anonsub_index++; + } + $startfield = saveoptree( $ppname, $root, $cv->START, $padlist->ARRAY ); + #warn sprintf( "done saving op tree for CV 0x%x, flags (%s), name %s, root=0x%x => start=%s\n", + # $$cv, $debug{flags}?$cv->flagspv:sprintf("0x%x",$cv->FLAGS), $ppname, $$root, $startfield ) + # if $debug{cv}; + # XXX missing cv_start for AUTOLOAD on 5.8 + $startfield = objsym($root->next) unless $startfield; # 5.8 autoload has only root + $startfield = "0" unless $startfield; + if ($$padlist) { + # XXX readonly comppad names and symbols invalid + #local $B::C::pv_copy_on_grow = 1 if $B::C::ro_inc; + warn sprintf( "saving PADLIST 0x%x for CV 0x%x\n", $$padlist, $$cv ) + if $debug{cv} and $debug{gv}; + # XXX avlen 2 + $padlistsym = $padlist->save($fullname.' :pad'); + warn sprintf( "done saving PADLIST %s 0x%x for CV 0x%x\n", + $padlistsym, $$padlist, $$cv ) + if $debug{cv} and $debug{gv}; + # do not record a forward for the pad only + $init->add( "CvPADLIST($sym) = $padlistsym;" ); } + warn $fullname."\n" if $debug{sub}; # Now it is time to record the CV if ($new_cv_fw) {