Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Add non-evaled c3 support for mro to B::C
Browse files Browse the repository at this point in the history
GH rurban#285 Use the perl command in init2 after mro bootstraps.

(cherry picked from commit 5bcb0ce)
Signed-off-by: Todd Rinaldo <[email protected]>

Some extra xtestc breaks are listed but probably unrelated.
  • Loading branch information
toddr committed Oct 28, 2015
1 parent 8459154 commit a082dd7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
41 changes: 34 additions & 7 deletions lib/B/C.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1187,16 +1187,46 @@ sub dump_rest {
$again;
}

my @made_c3;

sub make_c3 {
my $package = shift or die;

return if ( grep { $_ eq $package } @made_c3 );
push @made_c3, $package;

mark_package( 'mro', 1 );
mark_package($package);
my $isa_packages = mro::get_linear_isa($package) || [];
foreach my $isa (@$isa_packages) {
mark_package($isa);
}
debug( pkg => "set c3 for $package" );

## from setmro.xs:
# classname = ST(0);
# class_stash = gv_stashsv(classname, GV_ADD);
# meta = HvMROMETA(class_stash);
# Perl_mro_set_mro(aTHX_ meta, ST(1));

no strict 'refs';
my $stash = $package . '::';
my $hv = svref_2object( \%{$stash} );
$hv->save;
my $symdir = sprintf( "s\\_%x", $$hv );
my $sym = objsym($hv);
$sym or die("No objsym for $stash? ($sym)");
init2()->add( sprintf( 'Perl_mro_set_mro(aTHX_ HvMROMETA(%s), newSVpvs("c3"));', $sym ) );
}

sub save_context {

# forbid run-time extends of curpad syms, names and INC
verbose("save context:");

# need to mark assign c3 to %main::. no need to assign the default dfs
if ( mro::get_mro("main") eq 'c3' ) {
mark_package( 'mro', 1 );
debug( pkg => "set c3 for main" );
init()->add_eval('mro::set_mro("main", "c3");');
make_c3('main');
}

no strict 'refs';
Expand Down Expand Up @@ -1244,10 +1274,7 @@ sub save_context {
push @saved_isa, $p;
svref_2object( \@{ $p . '::ISA' } )->save( $p . '::ISA' );
if ( mro::get_mro($p) eq 'c3' ) {

# for mro c3 set the algo. there's no C api, only XS
debug( pkg => "set c3 for $p" );
init()->add_eval( sprintf( 'mro::set_mro(%s, "c3");', cstring($p) ) );
make_c3($p);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/B/C/OverLoad/B/GV.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ sub savecv {

# but prevent it from being deleted
unless ( $B::C::dumped_package{$package} ) {
$B::C::dumped_package{$package} = 1;

#$B::C::dumped_package{$package} = 1;
mark_package( $package, 1 );
}
return;
Expand Down
5 changes: 3 additions & 2 deletions lib/B/C/OverLoad/B/HV.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ sub save {
if ( !$B::C::stash ) { # -fno-stash: do not save stashes
$magic = $hv->save_magic( '%' . $name . '::' ); #symtab magic set in PMOP #188 (#267)
if ( mro::get_mro($name) eq 'c3' ) {
mark_package( 'mro', 1 );
B::C::make_c3($name);
}

#if ($magic =~ /c/) {
Expand Down Expand Up @@ -215,8 +215,9 @@ sub save {
#my $len = length( pack "a*", $name ); # not yet 0-byte safe. HEK len really
init2()->add(qq[$sym = gv_stashpvn($cname, $len, GV_ADDWARN|GV_ADDMULTI|$utf8);]);
}

if ( $name and mro::get_mro($name) eq 'c3' ) {
mark_package( 'mro', 1 );
B::C::make_c3($name);
}
return $sym;
}
Expand Down
15 changes: 5 additions & 10 deletions t/v5.22.0/C-COMPILED/known_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,14 @@ comp/require.t PLAN BC issue #245 - Cannot reload XSLoader
extra/reset.t TESTS BC issue 252: Reset is not localized to the current namespace
io/errno.t SIG BC issue #271: END block issue
io/layers.t SIG BC issue #31 - previously known as https://code.google.com/p/perl-compiler/issues/detail?id=29 (dupe from 203)
io/open.t TESTS Test results:
mro/basic_01_c3_utf8.t TESTS BC issue #285 - B::C can't handle utf8 packages with 'c3' inheritance.
mro/basic_02_c3_utf8.t TESTS BC issue #285 - B::C can't handle utf8 packages with 'c3' inheritance.
mro/basic_03_c3_utf8.t TESTS BC issue #285 - B::C can't handle utf8 packages with 'c3' inheritance.
mro/basic_04_c3_utf8.t TESTS BC issue #285 - B::C can't handle utf8 packages with 'c3' inheritance.
io/open.t TESTS BC issue #219 (overload) - new tests in upstream since 5.14.4
mro/basic_05_c3_utf8.t PLAN Plan was valid
mro/basic_05_dfs_utf8.t PLAN Plan was valid
mro/basic_utf8.t PLAN Plan was valid
mro/c3_with_overload.t TESTS BC issue #219 - overload issue
mro/c3_with_overload_utf8.t TESTS BC issue #219 - overload issue
mro/complex_c3.t SIG BC issue #298 - next::method broken.
mro/complex_c3_utf8.t SIG BC issue #298 - next::method broken.
mro/dbic_c3_utf8.t TESTS BC issue #285 - B::C can't handle utf8 packages with 'c3' inheritance.
mro/isarev.t TESTS Test results:
mro/isarev_utf8.t TESTS Test results:
mro/next_edgecases.t SIG Exit signal is 11 SEGV
Expand All @@ -64,7 +59,6 @@ mro/overload_c3.t TESTS BC issue #219 - overload issue
mro/overload_c3_utf8.t TESTS BC issue #219 - overload issue
mro/overload_dfs.t TESTS BC issue #219 - overload issue
mro/package_aliases_utf8.t SKIP Code compiles but never terminates when run.
mro/vulcan_c3_utf8.t TESTS BC issue #285 - B::C can't handle utf8 packages with 'c3' inheritance.
op/anonconst.t SIG BC issue #246 - experimental const_attr feature
op/array_base.t COMPAT BC issue #248 - deprecated array base feature - wont fix
op/attrhand.t PLAN BC issue #271 - Attribute::Handlers
Expand Down Expand Up @@ -195,17 +189,18 @@ xtestc/0239.t TESTS Output is: "ok 1\n\n"
xtestc/0241.t TESTS Output is: ""
xtestc/0247.t TESTS Output is: ""
xtestc/0248.t TESTS Output is: " toto \n"
xtestc/0250.t TESTS Output is: "Attempt to access disallowed ..."
xtestc/0254.t TESTS Output is: ""
xtestc/0259.t SKIP need investigation: different result on Todd or Nico sandbox
xtestc/0262.t TESTS Output is: "Constant subroutine M SQRT2 ..."
xtestc/0263.t SKIP need investigation: different result on Todd or Nico sandbox
xtestc/0269.t TESTS Output is: ""
xtestc/0271.t TESTS Output is: "cannot close pipe from kid ..."
xtestc/0273.t TESTS Output is: "Attempt to access disallowed ..."
xtestc/0274.t TESTS Output is: "1..5\nok 1\nok 2\nok 3\nok 4\n"
xtestc/0274.t GCC xtestc/0274.bin is compiled and ready to run.
xtestc/0276.t TESTS Output is: ""
xtestc/0278.t TESTS Output is: ""
xtestc/0290.t TESTS Output is: ""
xtestc/0281.t TESTS Output is: ""
xtestc/0284.t TESTS Output is: ""
xtestc/0293.t TESTS Output is: ""
xtestc/0299.t TESTS Output is: ""
xtestc/0301.t TESTS Output is: ""
Expand Down

0 comments on commit a082dd7

Please sign in to comment.