First I had trouble to compile it with B::C.
But I have found workarounds for the 4 bugs which I have reported
previously.
But now I am stuck with B::CC:
1.
perl -MO=CC,-ocspoc netspoc
Modification of non-creatable array value attempted, subscript -1 at
/usr/local/lib/perl/5.10.1/B/CC.pm line 929.
CHECK failed--call queue aborted.
2.
perl -MO=CC,-ocspoc,-O0 netspoc
panic: leaveloop, no cxstack at /usr/local/lib/perl/5.10.1/B/CC.pm line
1977.
CHECK failed--call queue aborted.
How do I debug these errors?
How do I find out which are the offending parts of my program?
--
Heinz Knutzen
Install B::Debugger and use
perl -d -MOd=CC,-ocspoc netspoc
press s twise and there you are
See also http://blogs.perl.org/users/rurban/2010/01/debugging-bc-hitting-the-recursion-depth.html
and three other debugging blog posts.
> 2.
> perl -MO=CC,-ocspoc,-O0 netspoc
> panic: leaveloop, no cxstack at /usr/local/lib/perl/5.10.1/B/CC.pm line
> 1977.
> CHECK failed--call queue aborted.
To debug into the options handling you have to do
perl -d -MOd_o=CC,-O0,-ocspoc netspoc
twice s
and set a breakpoint at CC.pm:1977
But note that -O0 should be default. Strange that you get another error with -O0
> How do I debug these errors?
> How do I find out which are the offending parts of my program?
--
Reini
All debugged compiler sessions terminate with a new bug, which seems to
be introduced by the perl debugger:
===
Can't call method "save" on an undefined value at
/usr/local/lib/perl/5.10.1/B/CC.pm line 531.
===
For example, using fail2.pl from my previous bug report
- perl -MO=CC,-ofail2.c fail2.pl compiles without an error
- but aborts with error when called with the perl debugger
(regardless of using B::Debugger or not).
$ perl -d -MOd=CC,-DcOACMSGpo,-v,-ofail2.c fail2.pl
Loading DB routines from perl5db.pl version 1.32
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
Od::CODE(0x9c7ec18)((eval 4)[/usr/local/share/perl/5.10.1/Od.pm:11]:11):
11: &$compile();
DB<1> c
Considering basic block COP (0x9dc99c8) dbstate
at /usr/local/lib/perl/5.10.1/B/CC.pm line 2199
B::CC::cc('pp_sub_AutoLoader__AUTOLOAD',
'B::UNOP=SCALAR(0x9e80280)', 'B::COP=SCALAR(0x9e802e0)',
'B::AV=SCALAR(0x9e80300)', 'B::AV=SCALAR(0x9e80350)') called at
/usr/local/lib/perl/5.10.1/B/CC.pm line 2237
B::CC::cc_recurse() called at /usr/local/lib/perl/5.10.1/B/CC.pm
line 2259
B::CC::cc_main() called at /usr/local/lib/perl/5.10.1/B/CC.pm line 2475
B::CC::__ANON__[/usr/local/lib/perl/5.10.1/B/CC.pm:2475]() called
at (eval 4)[/usr/local/share/perl/5.10.1/Od.pm:11] line 11
Od::INIT() called at fail2.pl line 0
eval {...} called at fail2.pl line 0
...compiling it
at /usr/local/lib/perl/5.10.1/B/CC.pm line 2201
B::CC::cc('pp_sub_AutoLoader__AUTOLOAD',
'B::UNOP=SCALAR(0x9e80280)', 'B::COP=SCALAR(0x9e802e0)',
'B::AV=SCALAR(0x9e80300)', 'B::AV=SCALAR(0x9e80350)') called at
/usr/local/lib/perl/5.10.1/B/CC.pm line 2237
B::CC::cc_recurse() called at /usr/local/lib/perl/5.10.1/B/CC.pm
line 2259
B::CC::cc_main() called at /usr/local/lib/perl/5.10.1/B/CC.pm line 2475
B::CC::__ANON__[/usr/local/lib/perl/5.10.1/B/CC.pm:2475]() called
at (eval 4)[/usr/local/share/perl/5.10.1/Od.pm:11] line 11
Od::INIT() called at fail2.pl line 0
eval {...} called at fail2.pl line 0
compile_bblock: COP (0x9dc99c8) dbstate
at /usr/local/lib/perl/5.10.1/B/CC.pm line 2154
B::CC::compile_bblock('B::COP=SCALAR(0x9e802e0)') called at
/usr/local/lib/perl/5.10.1/B/CC.pm line 2204
B::CC::cc('pp_sub_AutoLoader__AUTOLOAD',
'B::UNOP=SCALAR(0x9e80280)', 'B::COP=SCALAR(0x9e802e0)',
'B::AV=SCALAR(0x9e80300)', 'B::AV=SCALAR(0x9e80350)') called at
/usr/local/lib/perl/5.10.1/B/CC.pm line 2237
B::CC::cc_recurse() called at /usr/local/lib/perl/5.10.1/B/CC.pm
line 2259
B::CC::cc_main() called at /usr/local/lib/perl/5.10.1/B/CC.pm line 2475
B::CC::__ANON__[/usr/local/lib/perl/5.10.1/B/CC.pm:2475]() called
at (eval 4)[/usr/local/share/perl/5.10.1/Od.pm:11] line 11
Od::INIT() called at fail2.pl line 0
eval {...} called at fail2.pl line 0
Can't call method "save" on an undefined value at
/usr/local/lib/perl/5.10.1/B/CC.pm line 531.
INIT failed--call queue aborted.
at fail2.pl line 0
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
--
Heinz Knutzen
I hoped to get a significant performance improvement when applying B::CC
to Netspoc.
But the current result is disappointing.
The runtime improvement is minimal:
- compiled 36 seconds
- interpreted 39 seconds
Do you see any chance to to get a significant runtime improvement using
B::CC?
Otherwise it doesn't make much sense for me to do more work on B::CC.
Compiled:
$ ~/local512/bin/perlcc -O -o cspoc netspoc
$ ./cspoc conf
0s Network Security Policy Compiler, version 2.415.11
7s Read 1945 routers, 4298 networks, 9166 hosts
7s Read 1086 services, 58 service groups
7s Read 256 groups, 1866 policies
7s Arranging services
7s Linking topology
7s Distributing NAT
7s Preparing security domains and areas
7s Preparing fast path traversal
7s Finding subnets
11s Converting hosts to subnets
11s Expanding policies
30s Expanded rule count: 708587
36s Expanding crypto rules
36s Optimizing globally
Segmentation fault
Interpreted:
$ perl5.12.1 netspoc conf
0s Network Security Policy Compiler, version 2.415.11
8s Read 1945 routers, 4298 networks, 9166 hosts
8s Read 1086 services, 58 service groups
8s Read 256 groups, 1866 policies
8s Arranging services
8s Linking topology
8s Distributing NAT
8s Preparing security domains and areas
8s Preparing fast path traversal
9s Finding subnets
12s Converting hosts to subnets
12s Expanding policies
32s Expanded rule count: 708587
39s Expanding crypto rules
39s Optimizing globally
^C
Yes, you certainly need to declare types, esp. integer.
Currently only certain magic suffixes are supported.
e.g. _i for integer.
I though about using attributes.
int or c_int or Cint
Shouldn't be too hard to add attribute checking to StackObj
In Todo I added this:
variable types: global analysis of variables, type hints etc.
understand type attrs
my $i : Cint;
Devel::TypeCheck instead of magic variable _ir, ... suffices
e.g. mark IVonly SV's and magic/flags change functions and
optimize all op subtrees for the compiled backends to use direct ints.
re-add my i_opt patch (github) to core or some XS optimizer
understand MooseX::Method::Signatures and MooseX::Lexical::Types declarations
> --
> Unsubscribe via mail to perl-compile...@googlegroups.com
> Options: http://groups.google.com/group/perl-compiler?hl=en
>
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/
hashes are not yet optimized, but we are planning to add hash
optimization along static initialization and using
independent com_alloc.
This proved to be very effective with arrays.
--
Reini Urban