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

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

Thread Previous | Thread Next
From:
Jonathan Worthington
Date:
September 18, 2005 10:11
Subject:
Re: [perl #36639] [TODO] pbc_merge utility
Message ID:
00f001c5bc73$ed71db50$0300a8c0@SERVER
"Leopold Toetsch (via RT)" <parrotbug-followup@parrotcode.org> wrote:
>
> SYNOPSIS
>
>   pbc_merge -o all.pbc a.pbc, b.pbc [, ...]
>
> ABSTRACT
>
> Read all given pbc files and repack the bytecode into one result pbc.
>
> DESCRIPTION
>
> 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 
corrections.

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,

Jonathan

$ cat in1.imc
.sub _main @MAIN
        .local string ft
        ft = _FortyTwo()
        print "Got "
        print ft
        print "\n"
.end
$ cat in2.imc
.sub _FortyTwo
        .return("42")
.end
$ 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About