.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "B::CC 3" .TH B::CC 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" .SH "NAME" B::CC \- Perl compiler's optimized C translation backend .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& perl -MO=CC[,OPTIONS] foo.pl .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This compiler backend takes Perl source and generates C source code corresponding to the flow of your program. In other words, this backend is somewhat a \*(L"real\*(R" compiler in the sense that many people think about compilers. Note however that, currently, it is a very poor compiler in that although it generates (mostly, or at least sometimes) correct code, it performs relatively few optimisations. This will change as the compiler develops. The result is that running an executable compiled with this backend may start up more quickly than running the original Perl program (a feature shared by the \fBC\fR compiler backend\*(--see \fIB::C\fR) and may also execute slightly faster. This is by no means a good optimising compiler\*(--yet. .SH "OPTIONS" .IX Header "OPTIONS" If there are any non-option arguments, they are taken to be names of objects to be saved (probably doesn't work properly yet). Without extra arguments, it saves the main program. .IP "\fB\-ofilename\fR" 4 .IX Item "-ofilename" Output to filename instead of \s-1STDOUT\s0 .IP "\fB\-v\fR" 4 .IX Item "-v" Verbose compilation (currently gives a few compilation statistics). .IP "\fB\-\-\fR" 4 .IX Item "--" Force end of options .IP "\fB\-uPackname\fR" 4 .IX Item "-uPackname" Force apparently unused subs from package Packname to be compiled. This allows programs to use eval \*(L"\fIfoo()\fR\*(R" even when sub foo is never seen to be used at compile time. The down side is that any subs which really are never used also have code generated. This option is necessary, for example, if you have a signal handler foo which you initialise with \f(CW\*(C`$SIG{BAR} = "foo"\*(C'\fR. A better fix, though, is just to change it to \f(CW\*(C`$SIG{BAR} = \e&foo\*(C'\fR. You can have multiple \fB\-u\fR options. The compiler tries to figure out which packages may possibly have subs in which need compiling but the current version doesn't do it very well. In particular, it is confused by nested packages (i.e. of the form \f(CW\*(C`A::B\*(C'\fR) where package \f(CW\*(C`A\*(C'\fR does not contain any subs. .IP "\fB\-mModulename\fR" 4 .IX Item "-mModulename" Instead of generating source for a runnable executable, generate source for an \s-1XSUB\s0 module. The boot_Modulename function (which DynaLoader can look for) does the appropriate initialisation and runs the main part of the Perl source that is being compiled. .IP "\fB\-D\fR" 4 .IX Item "-D" Debug options (concatenated or separate flags like \f(CW\*(C`perl \-D\*(C'\fR). .IP "\fB\-Dr\fR" 4 .IX Item "-Dr" Writes debugging output to \s-1STDERR\s0 just as it's about to write to the program's runtime (otherwise writes debugging info as comments in its C output). .IP "\fB\-DO\fR" 4 .IX Item "-DO" Outputs each \s-1OP\s0 as it's compiled .IP "\fB\-Ds\fR" 4 .IX Item "-Ds" Outputs the contents of the shadow stack at each \s-1OP\s0 .IP "\fB\-Dp\fR" 4 .IX Item "-Dp" Outputs the contents of the shadow pad of lexicals as it's loaded for each sub or the main program. .IP "\fB\-Dq\fR" 4 .IX Item "-Dq" Outputs the name of each fake \s-1PP\s0 function in the queue as it's about to process it. .IP "\fB\-Dl\fR" 4 .IX Item "-Dl" Output the filename and line number of each original line of Perl code as it's processed (\f(CW\*(C`pp_nextstate\*(C'\fR). .IP "\fB\-Dt\fR" 4 .IX Item "-Dt" Outputs timing information of compilation stages. .IP "\fB\-f\fR" 4 .IX Item "-f" Force optimisations on or off one at a time. .IP "\fB\-ffreetmps\-each\-bblock\fR" 4 .IX Item "-ffreetmps-each-bblock" Delays \s-1FREETMPS\s0 from the end of each statement to the end of the each basic block. .IP "\fB\-ffreetmps\-each\-loop\fR" 4 .IX Item "-ffreetmps-each-loop" Delays \s-1FREETMPS\s0 from the end of each statement to the end of the group of basic blocks forming a loop. At most one of the freetmps\-each\-* options can be used. .IP "\fB\-fomit\-taint\fR" 4 .IX Item "-fomit-taint" Omits generating code for handling perl's tainting mechanism. .IP "\fB\-On\fR" 4 .IX Item "-On" Optimisation level (n = 0, 1, 2, ...). \fB\-O\fR means \fB\-O1\fR. Currently, \fB\-O1\fR sets \fB\-ffreetmps\-each\-bblock\fR and \fB\-O2\fR sets \fB\-ffreetmps\-each\-loop\fR. .SH "EXAMPLES" .IX Header "EXAMPLES" .Vb 2 \& perl -MO=CC,-O2,-ofoo.c foo.pl \& perl cc_harness -o foo foo.c .Ve .PP Note that \f(CW\*(C`cc_harness\*(C'\fR lives in the \f(CW\*(C`B\*(C'\fR subdirectory of your perl library directory. The utility called \f(CW\*(C`perlcc\*(C'\fR may also be used to help make use of this compiler. .PP .Vb 2 \& perl -MO=CC,-mFoo,-oFoo.c Foo.pm \& perl cc_harness -shared -c -o Foo.so Foo.c .Ve .SH "BUGS" .IX Header "BUGS" Plenty. Current status: experimental. .SH "DIFFERENCES" .IX Header "DIFFERENCES" These aren't really bugs but they are constructs which are heavily tied to perl's compile-and-go implementation and with which this compiler backend cannot cope. .Sh "Loops" .IX Subsection "Loops" Standard perl calculates the target of \*(L"next\*(R", \*(L"last\*(R", and \*(L"redo\*(R" at run\-time. The compiler calculates the targets at compile\-time. For example, the program .PP .Vb 5 \& sub skip_on_odd { next NUMBER if $_[0] % 2 } \& NUMBER: for ($i = 0; $i < 5; $i++) { \& skip_on_odd($i); \& print $i; \& } .Ve .PP produces the output .PP .Vb 1 \& 024 .Ve .PP with standard perl but gives a compile-time error with the compiler. .ie n .Sh "Context of ""..""" .el .Sh "Context of ``..''" .IX Subsection "Context of .." The context (scalar or array) of the \*(L"..\*(R" operator determines whether it behaves as a range or a flip/flop. Standard perl delays until runtime the decision of which context it is in but the compiler needs to know the context at compile\-time. For example, .PP .Vb 4 \& @a = (4,6,1,0,0,1); \& sub range { (shift @a)..(shift @a) } \& print range(); \& while (@a) { print scalar(range()) } .Ve .PP generates the output .PP .Vb 1 \& 456123E0 .Ve .PP with standard Perl but gives a compile-time error with compiled Perl. .Sh "Arithmetic" .IX Subsection "Arithmetic" Compiled Perl programs use native C arithmetic much more frequently than standard perl. Operations on large numbers or on boundary cases may produce different behaviour. .Sh "Deprecated features" .IX Subsection "Deprecated features" Features of standard perl such as \f(CW$[\fR which have been deprecated in standard perl since Perl5 was released have not been implemented in the compiler. .SH "AUTHOR" .IX Header "AUTHOR" Malcolm Beattie, \f(CW\*(C`mbeattie@sable.ox.ac.uk\*(C'\fR