develooper Front page | perl.perl6.internals | Postings from September 2005

Re: [perl #36639] [TODO] pbc_merge utility

Thread Previous | Thread Next
Jonathan Worthington
September 18, 2005 10:11
Re: [perl #36639] [TODO] pbc_merge utility
Message ID:
"Leopold Toetsch (via RT)" <> wrote:
>   pbc_merge -o all.pbc a.pbc, b.pbc [, ...]
> Read all given pbc files and repack the bytecode into one result pbc.
> Since r8676 parrot can (again) create a string representation of evaled
> code.
>   compiled = compiler(code)
>   print io, compiled
> is all to create a packfile, suitable for later loading with
> C<load_bytecode>.
> But as some language compilers like forth create a lot of evaled code,
> there should be a way to combine these packfiles into one.
> The utility should roughly work like this:
> - create all default segments
> - for all pbcs
>      append each segment to the combined one and
>      - fold constants
>      - relocate subroutine offsets to the new offset
Done, checked in as revision r9207.  Example of it at work is at the end of 
the email, which tests both sub offset relocation and constant table pointer 

To build it, after an svn up and re-configuring, do:-
make pbc_merge   # pbc_merge.exe on Win32

Or it is also built when you do:-
make parrot_utils

Feedback (bugs, issues with the code, feature requests) welcome.

> Folding constants is a bit tricky, as it needs also to walk trough the
> code and replace changed constant table entries.
This sounded harder than it actually turned out to be - the ops side of 
Parrot is well put together.

Have fun,


$ cat in1.imc
.sub _main @MAIN
        .local string ft
        ft = _FortyTwo()
        print "Got "
        print ft
        print "\n"
$ cat in2.imc
.sub _FortyTwo
$ parrot -o in1.pbc in1.imc
$ parrot -o in2.pbc in2.imc
$ pbc_merge -o out.pbc in1.pbc in2.pbc
$ parrot out.pbc
Got 42
$ pbc_merge -o out.pbc in2.pbc in1.pbc
$ parrot out.pbc
Got 42

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About