[M3devel] Using REFANYs to store integers?

Mika Nystrom mika at async.caltech.edu
Mon Dec 10 12:38:44 CET 2007


Hello Modula-3ers...

I have a question about garbage collecting, pointers, and dirty
tricks that I'm curious if anyone (Tony??) can answer.

Here it is.  I am considering writing a bytecode interpreter that
is to run mixed into a Modula-3 environment, that is, it will be
able to deal with bytecodes as well as Modula-3 objects.  There is
no problem with that of course, as bytecodes are "code" and Modula-3
objects are "objects" and can live on separate stacks.  However,
as an optimization (not an uncommon one in these types of systems),
I'd like a space and time efficient representation for "small
integers".  A tried-and-true method (it goes back at least to the
Smalltalk-80 runtime) is to realize that pointers (in my case
REFANYs) always point to word-aligned addresses.  We can then use
integers that are congruent to 1, 2, and 3 (mod 4) to represent
other types of data.

What will happen if I LOOPHOLE such integers back and forth to
REFANY?  Will the garbage collector just ignore them?  I wrote a
test program that does it and it doesn't crash... except when you
hit ctrl-C, it often dies with an assertion failure in
RTCollector.m3.. (This both with my ancient PM3 on FreeBSD and a
relatively recent update of CM3 on PPC_DARWIN.)  If the garbage
collector somehow disapproves of these integers, is there any
conceivable thing that would be broken by making necessary adjustments
to the garbage collector such that it would just ignore them?
Or is there a better way of solving my problem?

      Best regards,
        Mika



More information about the M3devel mailing list