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

Does it cost anything to use a big pmc everywhere?

6 views
Skip to first unread message

amirka...@yahoo.com

unread,
Jul 28, 2005, 3:11:59 PM7/28/05
to
I'm finally doing some work on Leo's PIR Z-machine interpreter. (I've
added about 15 opcodes to the 10 or so he started with. Luckily, he did
a lot of the infrastructure stuff that scared me as a PIR newbie. The
tester I wrote while developing Plotz passes 85 tests. Mostly.)

The compiler translates Z-code into PIR, then compiles and runs it. The
image of the Z-file (where the Z-machine stores its global variables
and other useful things) is stored in a global called Image. So if you
need to access one of the Z-machine's global variables, you emit code
like:

.local pmc image
image = global 'Image'
.GET_WORD($I181 , image, 692)

where the last line is a macro that pulls the global variable out of
the Z-machine memory. But Leo was smart and, while translating, says to
only load image (i.e. to only output the first two lines) once per
Z-code subroutine.

Now here's the problem. My Z-code emitted code like this:

if $I17 == 3 goto L1234
.local pmc image
image = global 'Image'
.GET_WORD($I181 , image, 692)
L1234:
print "yes, blah"
.GET_WORD($I182 , image, 692)

If $I17==3, then when we get to the second GET_WORD we exit with an
error because we don't know what image is.

So I think to avoid these problems I need to declare image at the top
of every Z-code sub. My question is, is there any cost associated with
always declaring this array holding 50-500K ints, other than having one
P register always full? Since everything else in the translated code is
integers & strings I'm not really worried about filling my P registers.
The only other option I can think of is keeping track of how my scopes
are nesting while translating, which sounds like a disaster.

This is what I get for trying to develop in PIR after ignoring the
mailing list for 6 months and not reading the basic docs.

Thanks,

-Amir Karger
It's better to write me at myfullname@gmail

Amir Karger

unread,
Jul 29, 2005, 12:58:47 PM7/29/05
to Parrot Mailing List
[Accidentally posted to Google Groups first]

Thanks,



____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs

Leopold Toetsch

unread,
Jul 30, 2005, 6:18:42 AM7/30/05
to Amir Karger, Parrot Mailing List

On Jul 29, 2005, at 18:58, Amir Karger wrote:

> So I think to avoid these problems I need to declare image at the top
> of every Z-code sub. My question is, is there any cost associated with
> always declaring this array holding 50-500K ints, other than having one
> P register always full?

No not at all. just emit the 'image' declaration and the global fetch
on top of each subroutine. If image isn't used below, the register
occupied by image will even be reused.

You could even avoid the global lookup (if image isn't used), by making
.GETWORD a bit smarter:

.macro GET_WORD(RES, IDX)
.local pmc image
unless_null image , .$ok
image = global ".."
.local $ok:
.RES = image[.IDX] # or some such
...
.endm

But that's probably not worth the effort.

leo

0 new messages