Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Library loading - no more duplicates

1 view
Skip to first unread message

Leopold Toetsch

unread,
Dec 12, 2005, 7:16:35 AM12/12/05
to Perl 6 Internals
As of r10458 Parrot doesn't load_bytecode the same file [1] twice anymore.

That is:

load_bytecode 'foo.pir'
load_bytecode 'foo.pasm' # silently ignored
load_bytecode 'foo.pbc' # silently ignored
load_bytecode 'bar/foo.pir' # ok [2]


There is also an interface to query load_bytecode-ed code:

.include 'iglobals.pasm'
interp = getinterp
hsh = interp[.IGLOBALS_PBC_LIBS'] # well PASM/PIR too
is_loaded = exists hsh['foo']
# or iterate over the hash or whatever
fullnane = hsh['foo']

HTH
leo

[1] the hash key is the given filename w/o extension. So it's not really
testing if it is the same file, but should be good enough for now.

[2] untested - more tests welcome

Chip Salzenberg

unread,
Dec 12, 2005, 1:08:24 PM12/12/05
to Leopold Toetsch, Perl 6 Internals
On Mon, Dec 12, 2005 at 01:16:35PM +0100, Leopold Toetsch wrote:
> As of r10458 Parrot doesn't load_bytecode the same file [1] twice anymore.

Neat - this is a fine approximate solution until we have real pbc
hashing, and *may* continue to be necessary even with hashing,
depending on whether we can count on reproducible hashes from
successive compilations of the same source file.
--
Chip Salzenberg <ch...@pobox.com>

Nicholas Clark

unread,
Dec 13, 2005, 2:01:01 PM12/13/05
to Chip Salzenberg, Leopold Toetsch, Perl 6 Internals

Surely in that case we instead choose to hash based on the source file?
(Or the Parrot equivalent of hashing C code by hashing the C pre-processor
output. Something akin to how ccache works.)

Nicholas Clark

Chip Salzenberg

unread,
Dec 13, 2005, 2:43:36 PM12/13/05
to Leopold Toetsch, Perl 6 Internals
On Tue, Dec 13, 2005 at 07:01:01PM +0000, Nicholas Clark wrote:
> On Mon, Dec 12, 2005 at 10:08:24AM -0800, Chip Salzenberg wrote:
> > Neat - this is a fine approximate solution until we have real pbc
> > hashing, and *may* continue to be necessary even with hashing,
> > depending on whether we can count on reproducible hashes from
> > successive compilations of the same source file.
>
> Surely in that case we instead choose to hash based on the source file?

That's a good fallback, but a perfect hash scheme would figure out
that e.g. /tmp/bar.pbc is identical to the compilation output of
/usr/share/bar.pir, and thus refuse to load one if the other has
already been loaded.

There are lots of ways to get good enough here; I'm not worried.
--
Chip Salzenberg <ch...@pobox.com>

0 new messages