3 # Copyright (c) 1996-1998 Malcolm Beattie
5 # You may distribute under the terms of either the GNU General Public
6 # License or the Artistic License, as specified in the README file.
12 use B
qw(main_cv main_root main_start comppadlist
13 class peekop walkoptree svref_2object cstring walksymtable
14 init_av begin_av end_av
15 SVf_POK SVp_POK SVf_IOK SVp_IOK SVf_NOK SVp_NOK
16 SVf_READONLY GVf_IMPORTED_AV GVf_IMPORTED_CV GVf_IMPORTED_HV
17 GVf_IMPORTED_SV SVTYPEMASK
19 use B
::Asmdata
qw(@optype @specialsv_name);
20 use B::Assembler qw(newasm endasm assemble);
24 for ($i = 0; $i < @optype; $i++) {
25 $optype_enum{$optype[$i]} = $i;
28 # Following is SVf_POK|SVp_POK
29 # XXX Shouldn't be hardwired
30 sub POK
() { SVf_POK
|SVp_POK
}
32 # Following is SVf_IOK|SVp_IOK
33 # XXX Shouldn't be hardwired
34 sub IOK
() { SVf_IOK
|SVp_IOK
}
36 # Following is SVf_NOK|SVp_NOK
37 # XXX Shouldn't be hardwired
38 sub NOK
() { SVf_NOK
|SVp_NOK
}
40 # nonexistant flags (see B::GV::bytecode for usage)
41 sub GVf_IMPORTED_IO
() { 0; }
42 sub GVf_IMPORTED_FORM
() { 0; }
44 my ($verbose, $no_assemble, $debug_bc, $debug_cv);
45 my @packages; # list of packages to compile
47 sub asm
(@
) { # print replacement that knows about assembling
51 my $buf = join '', @_;
52 assemble
($_) for (split /\n/, $buf);
56 sub asmf
(@
) { # printf replacement that knows about assembling
61 my $buf = sprintf $format, @_;
62 assemble
($_) for (split /\n/, $buf);
66 # Optimisation options. On the command line, use hyphens instead of
67 # underscores for compatibility with gcc-style options. We use
68 # underscores here because they are OK in (strict) barewords.
69 my ($compress_nullops, $omit_seq, $bypass_nullops);
70 my %optimise = (compress_nullops
=> \
$compress_nullops,
71 omit_sequence_numbers
=> \
$omit_seq,
72 bypass_nullops
=> \
$bypass_nullops);
74 my $strip_syntree; # this is left here in case stripping the
75 # syntree ever becomes safe again
79 my %symtable; # maps object addresses to object indices.
80 # Filled in at allocation (newsv/newop) time.
82 my %saved; # maps object addresses (for SVish classes) to "saved yet?"
83 # flag. Set at FOO::bytecode time usually by SV::bytecode.
84 # Manipulated via saved(), mark_saved(), unmark_saved().
86 my %strtable; # maps shared strings to object indices
87 # Filled in at allocation (pvix) time
89 my $svix = -1; # we keep track of when the sv register contains an element
90 # of the object table to avoid unnecessary repeated
91 # consecutive ldsv instructions.
93 my $opix = -1; # Ditto for the op register.
134 return cstring
($str . "\0");
141 # print full precision
142 my $str = sprintf "%.40f", $_[0];
143 $str =~ s/0+$//; # remove trailing zeros
148 sub saved
{ $saved{${$_[0]}} }
149 sub mark_saved
{ $saved{${$_[0]}} = 1 }
150 sub unmark_saved
{ $saved{${$_[0]}} = 0 }
152 sub debug
{ $debug_bc = shift }
154 sub pvix
{ # save a shared PV (mainly for COPs)
155 return $strtable{$_[0]} if defined($strtable{$_[0]});
156 asmf
"newpv %s\n", pvstring
($_[0]);
158 $strtable{$_[0]} = $ix;
159 asmf
"stpv %d\n", $ix;
165 warn sprintf("bytecode save method for %s (0x%x) not yet implemented\n",
170 # objix may stomp on the op register (for op objects)
171 # or the sv register (for SV objects)
173 sub B
::OBJECT
::objix
{
175 my $ix = $symtable{$$obj};
179 $obj->newix($nextix);
180 return $symtable{$$obj} = $nextix++;
186 asmf
"newsv %d\t# %s\n", $sv->FLAGS & SVTYPEMASK
, class($sv);
192 my $gvname = $gv->NAME;
193 my $name = cstring
($gv->STASH->NAME . "::" . $gvname);
194 asm
"gv_fetchpv $name\n";
200 my $name = $hv->NAME;
203 asmf
"gv_stashpv %s\n", cstring
($name);
206 # It's an ordinary HV. Fall back to ordinary newix method
207 $hv->B::SV
::newix
($ix);
211 sub B
::SPECIAL
::newix
{
213 # Special case. $$sv is not the address of the SV but an
214 # index into svspecialsv_list.
215 asmf
"ldspecsv $$sv\t# %s\n", $specialsv_name[$$sv];
221 my $class = class($op);
222 my $typenum = $optype_enum{$class};
223 croak
("OP::newix: can't understand class $class") unless defined($typenum);
224 asm
"newop $typenum\t# $class\n";
228 sub B
::OP
::walkoptree_debug
{
230 warn(sprintf("walkoptree: %s\n", peekop
($op)));
233 sub B
::OP
::bytecode
{
235 my $next = $op->next;
237 my $sibix = $op->sibling->objix unless $strip_syntree;
239 my $type = $op->type;
241 if ($bypass_nullops) {
242 $next = $next->next while $$next && $next->type == 0;
244 $nextix = $next->objix;
246 asmf
"# %s\n", peekop
($op) if $debug_bc;
248 asm
"op_next $nextix\n";
249 asm
"op_sibling $sibix\n" unless $strip_syntree;
250 asmf
"op_type %s\t# %d\n", "pp_" . $op->name, $type;
251 asmf
("op_seq %d\n", $op->seq) unless $omit_seq;
252 if ($type || !$compress_nullops) {
253 asmf
"op_targ %d\nop_flags 0x%x\nop_private 0x%x\n",
254 $op->targ, $op->flags, $op->private;
258 sub B
::UNOP
::bytecode
{
260 my $firstix = $op->first->objix unless $strip_syntree;
261 $op->B::OP
::bytecode
;
262 if (($op->type || !$compress_nullops) && !$strip_syntree) {
263 asm
"op_first $firstix\n";
267 sub B
::LOGOP
::bytecode
{
269 my $otherix = $op->other->objix;
270 $op->B::UNOP
::bytecode
;
271 asm
"op_other $otherix\n";
274 sub B
::SVOP
::bytecode
{
277 my $svix = $sv->objix;
278 $op->B::OP
::bytecode
;
283 sub B
::PADOP
::bytecode
{
285 my $padix = $op->padix;
286 $op->B::OP
::bytecode
;
287 asm
"op_padix $padix\n";
290 sub B
::PVOP
::bytecode
{
293 $op->B::OP
::bytecode
;
295 # This would be easy except that OP_TRANS uses a PVOP to store an
296 # endian-dependent array of 256 shorts instead of a plain string.
298 if ($op->name eq "trans") {
299 my @shorts = unpack("s256", $pv); # assembler handles endianness
300 asm
"op_pv_tr ", join(",", @shorts), "\n";
302 asmf
"newpv %s\nop_pv\n", pvstring
($pv);
306 sub B
::BINOP
::bytecode
{
308 my $lastix = $op->last->objix unless $strip_syntree;
309 $op->B::UNOP
::bytecode
;
310 if (($op->type || !$compress_nullops) && !$strip_syntree) {
311 asm
"op_last $lastix\n";
315 sub B
::LOOP
::bytecode
{
317 my $redoopix = $op->redoop->objix;
318 my $nextopix = $op->nextop->objix;
319 my $lastopix = $op->lastop->objix;
320 $op->B::LISTOP
::bytecode
;
321 asm
"op_redoop $redoopix\nop_nextop $nextopix\nop_lastop $lastopix\n";
324 sub B
::COP
::bytecode
{
326 my $file = $op->file;
327 my $line = $op->line;
328 if ($debug_bc) { # do this early to aid debugging
329 asmf
"# line %s:%d\n", $file, $line;
331 my $stashpv = $op->stashpv;
332 my $warnings = $op->warnings;
333 my $warningsix = $warnings->objix;
334 my $labelix = pvix
($op->label);
335 my $stashix = pvix
($stashpv);
336 my $fileix = pvix
($file);
338 $op->B::OP
::bytecode
;
339 asmf
<<"EOT", $labelix, $stashix, $op->cop_seq, $fileix, $op->arybase;
346 cop_warnings $warningsix
350 sub B
::PMOP
::bytecode
{
352 my $replroot = $op->pmreplroot;
353 my $replrootix = $replroot->objix;
354 my $replstartix = $op->pmreplstart->objix;
355 my $opname = $op->name;
356 # pmnext is corrupt in some PMOPs (see misc.t for example)
357 #my $pmnextix = $op->pmnext->objix;
360 # OP_PUSHRE (a mutated version of OP_MATCH for the regexp
361 # argument to a split) stores a GV in op_pmreplroot instead
362 # of a substitution syntax tree. We don't want to walk that...
363 if ($opname eq "pushre") {
366 walkoptree
($replroot, "bytecode");
369 $op->B::LISTOP
::bytecode
;
370 if ($opname eq "pushre") {
371 asmf
"op_pmreplrootgv $replrootix\n";
373 asm
"op_pmreplroot $replrootix\nop_pmreplstart $replstartix\n";
375 my $re = pvstring
($op->precomp);
376 # op_pmnext omitted since a perl bug means it's sometime corrupt
377 asmf
<<"EOT", $op->pmflags, $op->pmpermflags;
385 sub B
::SV
::bytecode
{
387 return if saved
($sv);
389 my $refcnt = $sv->REFCNT;
390 my $flags = sprintf("0x%x", $sv->FLAGS);
392 asm
"sv_refcnt $refcnt\nsv_flags $flags\n";
396 sub B
::PV
::bytecode
{
398 return if saved
($sv);
399 $sv->B::SV
::bytecode
;
400 asmf
("newpv %s\nxpv\n", pvstring
($sv->PV)) if $sv->FLAGS & POK
;
403 sub B
::IV
::bytecode
{
405 return if saved
($sv);
407 $sv->B::SV
::bytecode
;
408 asmf
"%s $iv\n", $sv->needs64bits ?
"xiv64" : "xiv32" if $sv->FLAGS & IOK
; # could be PVNV
411 sub B
::NV
::bytecode
{
413 return if saved
($sv);
414 $sv->B::SV
::bytecode
;
415 asmf
"xnv %s\n", nv
($sv->NVX);
418 sub B
::RV
::bytecode
{
420 return if saved
($sv);
422 my $rvix = $rv->objix;
424 $sv->B::SV
::bytecode
;
428 sub B
::PVIV
::bytecode
{
430 return if saved
($sv);
432 $sv->B::PV
::bytecode
;
433 asmf
"%s $iv\n", $sv->needs64bits ?
"xiv64" : "xiv32";
436 sub B
::PVNV
::bytecode
{
438 my $flag = shift || 0;
439 # The $flag argument is passed through PVMG::bytecode by BM::bytecode
440 # and AV::bytecode and indicates special handling. $flag = 1 is used by
441 # BM::bytecode and means that we should ensure we save the whole B-M
442 # table. It consists of 257 bytes (256 char array plus a final \0)
443 # which follow the ordinary PV+\0 and the 257 bytes are *not* reflected
444 # in SvCUR. $flag = 2 is used by AV::bytecode and means that we only
445 # call SV::bytecode instead of saving PV and calling NV::bytecode since
446 # PV/NV/IV stuff is different for AVs.
447 return if saved
($sv);
449 $sv->B::SV
::bytecode
;
452 $sv->B::IV
::bytecode
;
453 asmf
"xnv %s\n", nv
($sv->NVX);
455 $pv .= "\0" . $sv->TABLE;
456 asmf
"newpv %s\npv_cur %d\nxpv\n", pvstring
($pv),length($pv)-257;
458 asmf
("newpv %s\nxpv\n", pvstring
($pv)) if $sv->FLAGS & POK
;
463 sub B
::PVMG
::bytecode
{
464 my ($sv, $flag) = @_;
465 # See B::PVNV::bytecode for an explanation of $flag.
466 return if saved
($sv);
467 # XXX We assume SvSTASH is already saved and don't save it later ourselves
468 my $stashix = $sv->SvSTASH->objix;
469 my @mgchain = $sv->MAGIC;
472 # We need to traverse the magic chain and get objix for each OBJ
473 # field *before* we do B::PVNV::bytecode since objix overwrites
474 # the sv register. However, we need to write the magic-saving
475 # bytecode *after* B::PVNV::bytecode since sv isn't initialised
476 # to refer to $sv until then.
478 @mgobjix = map($_->OBJ->objix, @mgchain);
479 $sv->B::PVNV
::bytecode
($flag);
480 asm
"xmg_stash $stashix\n";
481 foreach $mg (@mgchain) {
482 asmf
"sv_magic %s\nmg_obj %d\nnewpv %s\nmg_pv\n",
483 cstring
($mg->TYPE), shift(@mgobjix), pvstring
($mg->PTR);
487 sub B
::PVLV
::bytecode
{
489 return if saved
($sv);
490 $sv->B::PVMG
::bytecode
;
491 asmf
<<'EOT', $sv->TARGOFF, $sv->TARGLEN, cstring($sv->TYPE);
498 sub B
::BM
::bytecode
{
500 return if saved
($sv);
501 # See PVNV::bytecode for an explanation of what the argument does
502 $sv->B::PVMG
::bytecode
(1);
503 asmf
"xbm_useful %d\nxbm_previous %d\nxbm_rare %d\n",
504 $sv->USEFUL, $sv->PREVIOUS, $sv->RARE;
507 sub empty_gv
{ # is a GV empty except for imported stuff?
510 return 0 if ($gv->SV->FLAGS & SVTYPEMASK
); # sv not SVt_NULL
511 my @subfield_names = qw(AV HV CV FORM IO);
512 @subfield_names = grep {;
514 !($gv->GvFLAGS & ${\"GVf_IMPORTED_
$_"}->()) && ${$gv->$_()};
516 return scalar @subfield_names;
519 sub B::GV::bytecode {
521 return if saved($gv);
522 return unless grep { $_ eq $gv->STASH->NAME; } @packages;
523 return if $gv->NAME =~ m/^\(/; # ignore overloads - they'll be rebuilt
527 asmf <<"EOT", $gv->FLAGS, $gv->GvFLAGS;
531 my $refcnt = $gv->REFCNT;
532 asmf
("sv_refcnt_add %d\n", $refcnt - 1) if $refcnt > 1;
533 return if $gv->is_empty;
534 asmf
<<"EOT", $gv->LINE, pvix($gv->FILE);
538 my $gvname = $gv->NAME;
539 my $name = cstring
($gv->STASH->NAME . "::" . $gvname);
541 my $egvix = $egv->objix;
542 my $gvrefcnt = $gv->GvREFCNT;
543 asmf
("gp_refcnt_add %d\n", $gvrefcnt - 1) if $gvrefcnt > 1;
544 if ($gvrefcnt > 1 && $ix != $egvix) {
545 asm
"gp_share $egvix\n";
547 if ($gvname !~ /^([^A-Za-z]|STDIN|STDOUT|STDERR|ARGV|SIG|ENV)$/) {
549 my @subfield_names = qw(SV AV HV CV FORM IO);
550 @subfield_names = grep {;
552 !($gv->GvFLAGS & ${\"GVf_IMPORTED_
$_"}->());
554 my @subfields = map($gv->$_(), @subfield_names);
555 my @ixes = map($_->objix, @subfields);
556 # Reset sv register for $gv
558 for ($i = 0; $i < @ixes; $i++) {
559 asmf "gp_
%s %d\n", lc($subfield_names[$i]), $ixes[$i];
561 # Now save all the subfields
563 foreach $sv (@subfields) {
570 sub B::HV::bytecode {
572 return if saved($hv);
574 my $name = $hv->NAME;
577 # It's an ordinary HV. Stashes have NAME set and need no further
578 # saving beyond the gv_stashpv that $hv->objix already ensures.
579 my @contents = $hv->ARRAY;
581 for ($i = 1; $i < @contents; $i += 2) {
582 push(@ixes, $contents[$i]->objix);
584 for ($i = 1; $i < @contents; $i += 2) {
585 $contents[$i]->bytecode;
588 for ($i = 0; $i < @contents; $i += 2) {
589 asmf("newpv
%s\nhv_store
%d\n",
590 pvstring($contents[$i]), $ixes[$i / 2]);
592 asmf "sv_refcnt
%d\nsv_flags
0x
%x\n", $hv->REFCNT, $hv->FLAGS;
596 sub B::AV::bytecode {
598 return if saved($av);
600 my $fill = $av->FILL;
605 @ixes = map($_->objix, @array);
607 foreach $sv (@array) {
611 # See PVNV::bytecode for the meaning of the flag argument of 2.
612 $av->B::PVMG::bytecode(2);
613 # Recover sv register and set AvMAX and AvFILL to -1 (since we
614 # create an AV with NEWSV and SvUPGRADE rather than doing newAV
615 # which is what sets AvMAX and AvFILL.
617 asmf "sv_flags
0x
%x\n", $av->FLAGS & ~SVf_READONLY; # SvREADONLY_off($av) in case PADCONST
618 asmf "xav_flags
0x
%x\nxav_max
-1\nxav_fill
-1\n", $av->AvFLAGS;
621 foreach $elix (@ixes) {
622 asm "av_push
$elix\n";
626 asm "av_extend
$max\n";
629 asmf "sv_flags
0x
%x\n", $av->FLAGS; # restore flags from above
632 sub B::CV::bytecode {
634 return if saved($cv);
635 return if ${$cv->GV} && ($cv->GV->GvFLAGS & GVf_IMPORTED_CV);
636 my $fileix = pvix($cv->FILE);
638 $cv->B::PVMG::bytecode;
640 my @subfield_names = qw(ROOT START STASH GV PADLIST OUTSIDE);
641 my @subfields = map($cv->$_(), @subfield_names);
642 my @ixes = map($_->objix, @subfields);
643 # Save OP tree from CvROOT (first element of @subfields)
644 my $root = shift @subfields;
646 walkoptree
($root, "bytecode");
648 # Reset sv register for $cv (since above ->objix calls stomped on it)
650 for ($i = 0; $i < @ixes; $i++) {
651 asmf
"xcv_%s %d\n", lc($subfield_names[$i]), $ixes[$i];
653 asmf
"xcv_depth %d\nxcv_flags 0x%x\n", $cv->DEPTH, $cv->CvFLAGS;
654 asmf
"xcv_file %d\n", $fileix;
655 # Now save all the subfields (except for CvROOT which was handled
656 # above) and CvSTART (now the initial element of @subfields).
657 shift @subfields; # bye-bye CvSTART
659 foreach $sv (@subfields) {
664 sub B
::IO
::bytecode
{
666 return if saved
($io);
668 my $top_gv = $io->TOP_GV;
669 my $top_gvix = $top_gv->objix;
670 my $fmt_gv = $io->FMT_GV;
671 my $fmt_gvix = $fmt_gv->objix;
672 my $bottom_gv = $io->BOTTOM_GV;
673 my $bottom_gvix = $bottom_gv->objix;
675 $io->B::PVMG
::bytecode
;
677 asm
"xio_top_gv $top_gvix\n";
678 asm
"xio_fmt_gv $fmt_gvix\n";
679 asm
"xio_bottom_gv $bottom_gvix\n";
681 foreach $field (qw(TOP_NAME FMT_NAME BOTTOM_NAME)) {
682 asmf
"newpv %s\nxio_%s\n", pvstring
($io->$field()), lc($field);
684 foreach $field (qw(LINES PAGE PAGE_LEN LINES_LEFT SUBPROCESS)) {
685 asmf
"xio_%s %d\n", lc($field), $io->$field();
687 asmf
"xio_type %s\nxio_flags 0x%x\n", cstring
($io->IoTYPE), $io->IoFLAGS;
690 $bottom_gv->bytecode;
693 sub B
::SPECIAL
::bytecode
{
694 # nothing extra needs doing
697 sub bytecompile_object
{
699 svref_2object
($sv)->bytecode;
703 sub B
::GV
::bytecodecv
{
706 if ($$cv && !saved
($cv) && !($gv->FLAGS & GVf_IMPORTED_CV
)) {
708 warn sprintf("saving extra CV &%s::%s (0x%x) from GV 0x%x\n",
709 $gv->STASH->NAME, $gv->NAME, $$cv, $$gv);
715 sub save_call_queues
{
716 if (begin_av
()->isa("B::AV")) { # this is just to save 'use Foo;' calls
717 for my $cv (begin_av
()->ARRAY) {
718 next unless grep { $_ eq $cv->STASH->NAME; } @packages;
722 if ($op->name eq 'require') { # save any BEGIN that does a require
724 asmf
"push_begin %d\n", $cv->objix;
731 if (init_av
()->isa("B::AV")) {
732 for my $cv (init_av
()->ARRAY) {
733 next unless grep { $_ eq $cv->STASH->NAME; } @packages;
735 asmf
"push_init %d\n", $cv->objix;
738 if (end_av
()->isa("B::AV")) {
739 for my $cv (end_av
()->ARRAY) {
740 next unless grep { $_ eq $cv->STASH->NAME; } @packages;
742 asmf
"push_end %d\n", $cv->objix;
749 my $ok = 1 if grep { (my $name = $_[0]) =~ s/::$//; $_ eq $name;} @packages;
750 if (grep { /^$_[0]/; } @packages) {
751 walksymtable
(\
%{"$_[0]"}, "bytecodecv", \
&symwalk
, $_[0]);
753 warn "considering $_[0] ... " . ($ok ?
"accepted\n" : "rejected\n")
758 sub bytecompile_main
{
759 my $curpad = (comppadlist
->ARRAY)[1];
760 my $curpadix = $curpad->objix;
763 walkoptree
(main_root
, "bytecode") unless ref(main_root
) eq "B::NULL";
764 warn "done main program, now walking symbol table\n" if $debug_bc;
767 walksymtable
(\
%{"main::"}, "bytecodecv", \
&symwalk
);
769 die "No packages requested for compilation!\n";
771 asmf
"main_root %d\n", main_root
->objix;
772 asmf
"main_start %d\n", main_start
->objix;
773 asmf
"curpad $curpadix\n";
774 # XXX Do min_intro_pending and max_intro_pending matter?
779 my ($option, $opt, $arg);
780 open(OUT
, ">&STDOUT");
784 while ($option = shift @options) {
785 if ($option =~ /^-(.)(.*)/) {
789 unshift @options, $option;
792 if ($opt eq "-" && $arg eq "-") {
795 } elsif ($opt eq "o") {
796 $arg ||= shift @options;
797 open(OUT
, ">$arg") or return "$arg: $!\n";
799 } elsif ($opt eq "a") {
800 $arg ||= shift @options;
801 open(OUT
, ">>$arg") or return "$arg: $!\n";
803 } elsif ($opt eq "D") {
804 $arg ||= shift @options;
805 foreach $arg (split(//, $arg)) {
809 } elsif ($arg eq "o") {
811 } elsif ($arg eq "a") {
812 B
::Assembler
::debug
(1);
813 } elsif ($arg eq "C") {
817 } elsif ($opt eq "v") {
819 } elsif ($opt eq "S") {
821 } elsif ($opt eq "f") {
822 $arg ||= shift @options;
823 my $value = $arg !~ s/^no-//;
825 my $ref = $optimise{$arg};
829 warn qq(ignoring unknown optimisation option
"$arg"\n);
831 } elsif ($opt eq "O") {
832 $arg = 1 if $arg eq "";
834 foreach $ref (values %optimise) {
841 $compress_nullops = 1;
844 } elsif ($opt eq "u") {
845 $arg ||= shift @options;
846 push @packages, $arg;
848 warn qq(ignoring unknown option
"$opt$arg"\n);
852 warn "No package specified for compilation, assuming main::\n";
853 @packages = qw(main);
856 die "Extraneous options left on B::Bytecode commandline: @options\n";
859 newasm
(\
&apr
) unless $no_assemble;
861 endasm
() unless $no_assemble;
866 sub apr
{ print @_; }
874 B::Bytecode - Perl compiler's bytecode backend
878 perl -MO=Bytecode[,OPTIONS] foo.pl
882 This compiler backend takes Perl source and generates a
883 platform-independent bytecode encapsulating code to load the
884 internal structures perl uses to run your program. When the
885 generated bytecode is loaded in, your program is ready to run,
886 reducing the time which perl would have taken to load and parse
887 your program into its internal semi-compiled form. That means that
888 compiling with this backend will not help improve the runtime
889 execution speed of your program but may improve the start-up time.
890 Depending on the environment in which your program runs this may
891 or may not be a help.
893 The resulting bytecode can be run with a special byteperl executable
894 or (for non-main programs) be loaded via the C<byteload_fh> function
899 If there are any non-option arguments, they are taken to be names of
900 objects to be saved (probably doesn't work properly yet). Without
901 extra arguments, it saves the main program.
907 Output to filename instead of STDOUT.
911 Append output to filename.
915 Force end of options.
919 Force optimisations on or off one at a time. Each can be preceded
920 by B<no-> to turn the option off (e.g. B<-fno-compress-nullops>).
922 =item B<-fcompress-nullops>
924 Only fills in the necessary fields of ops which have
925 been optimised away by perl's internal compiler.
927 =item B<-fomit-sequence-numbers>
929 Leaves out code to fill in the op_seq field of all ops
930 which is only used by perl's internal compiler.
932 =item B<-fbypass-nullops>
934 If op->op_next ever points to a NULLOP, replaces the op_next field
935 with the first non-NULLOP in the path of execution.
939 Optimisation level (n = 0, 1, 2, ...). B<-O> means B<-O1>.
940 B<-O1> sets B<-fcompress-nullops> B<-fomit-sequence numbers>.
941 B<-O2> adds B<-fbypass-nullops>.
945 Debug options (concatenated or separate flags like C<perl -D>).
949 Prints each OP as it's processed.
953 Print debugging information about bytecompiler progress.
957 Tells the (bytecode) assembler to include source assembler lines
958 in its output as bytecode comments.
962 Prints each CV taken from the final symbol tree walk.
966 Output (bytecode) assembler source rather than piping it
967 through the assembler and outputting bytecode.
971 Stores package in the output.
977 perl -MO=Bytecode,-O6,-ofoo.plc,-umain foo.pl
979 perl -MO=Bytecode,-S,-umain foo.pl > foo.S
980 assemble foo.S > foo.plc
982 Note that C<assemble> lives in the C<B> subdirectory of your perl
983 library directory. The utility called perlcc may also be used to
984 help make use of this compiler.
986 perl -MO=Bytecode,-uFoo,-oFoo.pmc Foo.pm
990 Output is still huge and there are still occasional crashes during
991 either compilation or ByteLoading. Current status: experimental.
995 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>
996 Benjamin Stuhl, C<sho_pi@hotmail.com>