Manual Pages for UNIX Darwin command on man B::CC
MyWebUniversity

Manual Pages for UNIX Darwin command on man B::CC

B::CC(3pm) Perl Programmers Reference Guide B::CC(3pm)

NAME

B::CC - Perl compiler's optimized C translation backend

SYNOPSIS

perl -MO=CC[,OPTIONS] foo.pl

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 "real" 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 com-

piled with this backend may start up more quickly than running the

original Perl program (a feature shared by the CC compiler backend-see

B::C) and may also execute slightly faster. This is by no means a good

optimising compiler-yet.

OOPPTTIIOONNSS

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.

-ooffiilleennaammee

Output to filename instead of STDOUT

-vv Verbose compilation (currently gives a few compilation statistics).

-- Force end of options

-uuPPaacckknnaammee

Force apparently unused subs from package Packname to be compiled. This allows programs to use eval "foo()" 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 "$SIG{BAR} = "foo"". A better fix, though, is

just to change it to "$SIG{BAR} = \&foo". You can have multiple -uu

options. The compiler tries to figure out which packages may possi-

bly 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 "A::B") where package "A" does not con-

tain any subs.

-mmMMoodduulleennaammee

Instead of generating source for a runnable executable, generate source for an XSUB module. The bootModulename function (which DynaLoader can look for) does the appropriate initialisation and runs the main part of the Perl source that is being compiled.

-DD Debug options (concatenated or separate flags like "perl -D").

-DDrr Writes debugging output to STDERR just as it's about to write to

the program's runtime (otherwise writes debugging info as comments in its C output).

-DDOO Outputs each OP as it's compiled

-DDss Outputs the contents of the shadow stack at each OP

-DDpp Outputs the contents of the shadow pad of lexicals as it's loaded

for each sub or the main program.

-DDqq Outputs the name of each fake PP function in the queue as it's

about to process it.

-DDll Output the filename and line number of each original line of Perl

code as it's processed ("ppnextstate").

-DDtt Outputs timing information of compilation stages.

-ff Force optimisations on or off one at a time.

-ffffrreeeettmmppss-eeaacchh-bbbblloocckk

Delays FREETMPS from the end of each statement to the end of the each basic block.

-ffffrreeeettmmppss-eeaacchh-lloooopp

Delays FREETMPS 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.

-ffoommiitt-ttaaiinntt

Omits generating code for handling perl's tainting mechanism.

-OOnn Optimisation level (n = 0, 1, 2, ...). -OO means -OO11. Currently,

-OO11 sets -ffffrreeeettmmppss-eeaacchh-bbbblloocckk and -OO22 sets -ffffrreeeettmmppss-eeaacchh-lloooopp.

EEXXAAMMPPLLEESS

perl -MO=CC,-O2,-ofoo.c foo.pl

perl ccharness -o foo foo.c

Note that "ccharness" lives in the "B" subdirectory of your perl library directory. The utility called "perlcc" may also be used to help make use of this compiler.

perl -MO=CC,-mFoo,-oFoo.c Foo.pm

perl ccharness -shared -c -o Foo.so Foo.c

BUGS

Plenty. Current status: experimental. DDIIFFFFEERREENNCCEESS 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. LLooooppss Standard perl calculates the target of "next", "last", and "redo" at

run-time. The compiler calculates the targets at compile-time. For

example, the program

sub skiponodd { next NUMBER if $[0] % 2 }

NUMBER: for ($i = 0; $i < 5; $i++) {

skiponodd($i);

print $i;

} produces the output 024

with standard perl but gives a compile-time error with the compiler.

CCoonntteexxtt ooff ""...."" The context (scalar or array) of the ".." operator determines whether

it behaves as a range or a flip/flop. Standard perl delays until run-

time the decision of which context it is in but the compiler needs to

know the context at compile-time. For example,

@a = (4,6,1,0,0,1); sub range { (shift @a)..(shift @a) } print range(); while (@a) { print scalar(range()) } generates the output 456123E0

with standard Perl but gives a compile-time error with compiled Perl.

AArriitthhmmeettiicc 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. DDeepprreeccaatteedd ffeeaattuurreess

Features of standard perl such as $[ which have been deprecated in

standard perl since Perl5 was released have not been implemented in the compiler. AUTHOR Malcolm Beattie, "mbeattie@sable.ox.ac.uk"

perl v5.8.8 2001-09-21 B::CC(3pm)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™