From: Nick Ing-Simmons Date: Sat, 28 Nov 1998 22:46:57 +0000 (+0000) Subject: More C.pm tweaks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=338a6d08e163490b2a52a2e64a7488eec1817685;p=p5sagit%2Fp5-mst-13.2.git More C.pm tweaks Save globs even if we have saved cv itself before - may be imported. While we don't save "bootstrap" CV we need to provide a stub, so that if we require it later we don't fall through and attempt to DynaLoad module again. Attempt to save %INC so that "require" does not reload things we have compiled-in (does not work right yet - seems to be due to PL_incgv being created in perl_parse() current scheme setting GvHV() is "better" than saving the glob, but still does not work as I expect). p4raw-id: //depot/perl@2378 --- diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm index da9f7dd..e695cc2 100644 --- a/ext/B/B/C.pm +++ b/ext/B/B/C.pm @@ -1052,17 +1052,22 @@ sub save_object { foreach $sv (@_) { svref_2object($sv)->save; } -} +} + +sub Dummy_BootStrap { } sub B::GV::savecv { my $gv = shift; my $cv = $gv->CV; my $name = $gv->NAME; - if ($$cv && !objsym($cv)) { + if ($$cv) { if ($name eq "bootstrap" && $cv->XSUB) { my $file = $cv->FILEGV->SV->PV; $bootstrap->add($file); - return; + my $name = $gv->STASH->NAME.'::'.$name; + no strict 'refs'; + *{$name} = \&Dummy_BootStrap; + $cv = $gv->CV; } if ($debug_cv) { warn sprintf("saving extra CV &%s::%s (0x%x) from GV 0x%x\n", @@ -1085,6 +1090,8 @@ sub B::GV::savecv { } + + sub save_unused_subs { my %search_pack; map { $search_pack{$_} = 1 } @_; @@ -1132,9 +1139,12 @@ sub save_unused_subs { } sub save_main { + warn "Walking tree\n"; my $curpad_nam = (comppadlist->ARRAY)[0]->save; my $curpad_sym = (comppadlist->ARRAY)[1]->save; my $init_av = init_av->save; + my $inc_hv = svref_2object(\%INC)->save; + my $inc_av = svref_2object(\@INC)->save; walkoptree(main_root, "save"); warn "done main optree, walking symtable for extras\n" if $debug_cv; save_unused_subs(@unused_sub_packages); @@ -1143,6 +1153,8 @@ sub save_main { sprintf("PL_main_start = s\\_%x;", ${main_start()}), "PL_curpad = AvARRAY($curpad_sym);", "PL_initav = $init_av;", + "GvHV(PL_incgv) = $inc_hv;", + "GvAV(PL_incgv) = $inc_av;", "av_store(CvPADLIST(PL_main_cv),0,SvREFCNT_inc($curpad_nam));", "av_store(CvPADLIST(PL_main_cv),1,SvREFCNT_inc($curpad_sym));"); warn "Writing output\n";