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

Determining PMC memory addresses

12 views
Skip to first unread message

Cory Spencer

unread,
Nov 27, 2003, 11:28:41 PM11/27/03
to perl6-i...@perl.org

Is there any way in PASM to determine whether or not two PMC's share the
same memory address?

That is, for example, given the following IMC snippet:

.sub _eq
.param pmc arg1
.param pmc arg2
.local int retv

...
...

.pcc_begin_return
.return retv
.pcc_end_return
.end

what I'd like to do is to determine whether arg1 and arg2 are the SAME pmc
object (not in value, but whether or not they reside at the same location
in memory).

Regards,

Cory

Leopold Toetsch

unread,
Nov 28, 2003, 3:36:37 AM11/28/03
to Cory Spencer, perl6-i...@perl.org
Cory Spencer <cspe...@sprocket.org> wrote:

> Is there any way in PASM to determine whether or not two PMC's share the
> same memory address?

Not yet. We have the vtable methods but the opcodes are missing.

We have:

Op vtable Meaning
- is_same PMCs are ident
- is_equal PMCs are equivalent, holding the same value
Y cmp cmp PMCs
- cmp_num cmp PMCs numerically
- cmp_string cmp PMCs as strings

Proposals for opcode names welcome.

> Regards,

> Cory

leo

Cory Spencer

unread,
Nov 28, 2003, 12:08:13 PM11/28/03
to perl6-i...@perl.org

On Fri, 28 Nov 2003, Leopold Toetsch wrote:

> Op vtable Meaning
> - is_same PMCs are ident
> - is_equal PMCs are equivalent, holding the same value
> Y cmp cmp PMCs
> - cmp_num cmp PMCs numerically
> - cmp_string cmp PMCs as strings
>
> Proposals for opcode names welcome.

How does the current 'eq' opcode deal with comparissons of PMC/PMC values?

Simon Glover

unread,
Nov 28, 2003, 12:14:20 PM11/28/03
to Cory Spencer, perl6-i...@perl.org

'eq' calls is_equal, so that should have a 'Y' in the table above.

Simon

Cory Spencer

unread,
Nov 28, 2003, 12:27:45 PM11/28/03
to perl6-i...@perl.org

> > On Fri, 28 Nov 2003, Leopold Toetsch wrote:
> >
> > > Op vtable Meaning
> > > - is_same PMCs are ident
> > > - is_equal PMCs are equivalent, holding the same value
> > > Y cmp cmp PMCs
> > > - cmp_num cmp PMCs numerically
> > > - cmp_string cmp PMCs as strings
> > >
> > > Proposals for opcode names welcome.
> >
> > [snip]

Well, a page could be stolen from the Lisp book by defining eq/eql/equal
opcodes (though in ths case, differing from the Lisp counterparts in the
meaning of the tests) where

- eq is true if both arguments have the same value (that is, both are
numerically equal or both are equivalent strings)
- eql is true if both arguments are the same, identical object
- equal does a comparison to test if the two objects are structurally
similar (ie. in the case of a PerlArray, an element-by-element
comparrison would be performed to determine the similarity of the
structure.)

Cory

Jos Visser

unread,
Nov 28, 2003, 12:41:29 PM11/28/03
to perl6-i...@perl.org

I think this is definitely something we should do if we want to confuse
people as much as possible :-)

Much can be said about this topic, but let's keep in mind that:

- The length of the opcode name is not important for execution speed or
memory space used (this contrary to the early LISP
machines/interpreters).

- English is only a small language (with respect to the amount of native
speakers, which are mainly restricted to a number of large islands
and some of the residents of a large and mostly uninhabited landmass
somewhere on the western hemisphere) :-)
Non-native speakers can not be trusted to immediately grasp the
semantic differences between things as:
- equal/identical/same
- compare/test

I would therefore vote that we keep these opcodes as verbose as
possible. So no eq/eql/equal, but rather
same_address/same_content/compare/compare_as_num/compare_as_string.

And remember, I am nobody... :-)

++Jos.es

--
Viel mehr als gestern liebe ich dich heute.
Doch weniger noch als ich dich morgen lieben wird.
"Wie vor Jahr und Tag", Reinhard Mey

Cory Spencer

unread,
Nov 28, 2003, 4:19:27 PM11/28/03
to Jos Visser, perl6-i...@perl.org

> I think this is definitely something we should do if we want to confuse
> people as much as possible :-)

This is likely true, seeing as I *still* have troubles keeping the various
Lisp eq/eql/equal/equalp's straight. ;)

> I would therefore vote that we keep these opcodes as verbose as
> possible. So no eq/eql/equal, but rather
> same_address/same_content/compare/compare_as_num/compare_as_string.

Some of those are probably a little too verbose for my tastes. ;)

We're already using 'eq' to perform equality testing, and in the interests
of maintaining a consistent design I would choose to stick with something
eq-related as opposed to changing it to 'same'.

eqaddr/eqval? eq_addr/eq_val? eq_address/eq_value?

With respects to the compare_as_num/compare_as_string opcodes, there's
also already a 'cmp' opcode and there already seems to be the established
naming scheme of opcodeX, where X is one of n/i/s/p, depending on the type
being dealt with (ie. cleari, clearn, clears, clearp).

cmpi/cmpn/cmps/cmpp? cmpasi/cmpasn/cmpass/cmpasp?
cmp_as_i/cmp_as_n/cmp_as_s/cmp_as_p?

Personally, I'd probably pick the first option in each of the above sets,
though that is just my preference... :)

Cory

Cory Spencer

unread,
Nov 28, 2003, 4:59:29 PM11/28/03
to perl6-i...@perl.org

> We're already using 'eq' to perform equality testing, and in the interests
> of maintaining a consistent design I would choose to stick with something
> eq-related as opposed to changing it to 'same'.
>
> eqaddr/eqval? eq_addr/eq_val? eq_address/eq_value?

Oops, correction there - I'd forgotten an earlier post that pointed out
the proposed functionality of eqval/eq_val/eq_value had already been
implemented.

Leopold Toetsch

unread,
Nov 28, 2003, 2:52:43 PM11/28/03
to Jos Visser, perl6-i...@perl.org
Jos Visser <jo...@osp.nl> wrote:

> I would therefore vote that we keep these opcodes as verbose as
> possible. So no eq/eql/equal, but rather
> same_address/same_content/compare/compare_as_num/compare_as_string.

Or as verbose as needed [1]:

ident, eq, <op>, <op>_num, <op>_string for <op> in (lt le gt ge)

eq and ne are a bit special - yes they do vtable->is_equal now, but that
might be wrong when either numerically or string-compare is intended.

<op> and (<op>_num, <op>_string) seem to be suitable for languages that
don't have different compare ops and those like perl that have
respectively.

> ++Jos.es

leo

[1] eq, ne, lt, le, gt, ge are already widely used

Alex

unread,
Dec 3, 2003, 6:56:12 AM12/3/03
to
cspe...@sprocket.org (Cory Spencer) wrote in message news:<Pine.LNX.4.58.03...@okcomputer.antiflux.org>...

> Well, a page could be stolen from the Lisp book by defining eq/eql/equal
> opcodes (though in ths case, differing from the Lisp counterparts in the
> meaning of the tests) where
>
> - eq is true if both arguments have the same value (that is, both are
> numerically equal or both are equivalent strings)
> - eql is true if both arguments are the same, identical object
> - equal does a comparison to test if the two objects are structurally
> similar (ie. in the case of a PerlArray, an element-by-element
> comparrison would be performed to determine the similarity of the
> structure.)

There's a paper by Henry baker which proposes an equality predicate
which (I think) is supposed to combine address and contents equality
in a useful way:
http://home.pipeline.com/~hbaker1/ObjectIdentity.html

May be worth thinking about.

Alex

Cory Spencer

unread,
Dec 3, 2003, 11:18:59 AM12/3/03
to perl6-i...@perl.org

> We're already using 'eq' to perform equality testing, and in the interests
> of maintaining a consistent design I would choose to stick with something
> eq-related as opposed to changing it to 'same'.
>
> eqaddr/eqval? eq_addr/eq_val? eq_address/eq_value?

So just to follow up on this thread, was there any preference at all for
the name of the opcode performing equality testing of PMC memory
addresses? I needed the functionality for the code I'm working on, so
I've created a patch implementing an "eq_addr" opcode...

Regards,

Cory

Cory Spencer

unread,
Dec 3, 2003, 2:48:52 PM12/3/03
to Melvin Smith, perl6-i...@perl.org

> I don't think there was ever a consensus about opcode naming.
> It seems that we need this but can you give an example
> of where you are using it, just to give me some context to think
> with?

I've been implementing a Lisp interpretter (and hopefully at some point,
compiler) and was using the eq_addr (or whatever it's eventually destined
to be named) to test for equality between symbol types. (I'm sure there's
another hackish way of implementing the test, but this seemed like the
cleanest way of doing it at the time...)

Dan Sugalski

unread,
Dec 8, 2003, 10:04:42 AM12/8/03
to Cory Spencer, perl6-i...@perl.org

Make it eq_addr. We'll go with that scheme for the other comparisons
(eq_str, eq_num) as well.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Christopher E. Stith

unread,
Dec 8, 2003, 11:31:43 AM12/8/03
to
jo...@osp.nl (Jos Visser) wrote in message news:<20031128174...@jadzia.josvisser.nl>...

> I think this is definitely something we should do if we want to confuse
> people as much as possible :-)

Not necessarily. Most programmers have at least some understanding of
mathematics in the language in which they are about to use when
programming.

Equality, identity, and congruenc[ey] are three mathematical
principals which are fairly basic and fairly widely understood even
outside the mathematic and computer fields. I don't think that making
use of these terms would confuse so many people. I may be wrong.



> I would therefore vote that we keep these opcodes as verbose as
> possible. So no eq/eql/equal, but rather
> same_address/same_content/compare/compare_as_num/compare_as_string.

How about eq/ident/congruent? Since this is roughly the order in which
they would be used, from most to least, it even maintains Huffman
coding for the ops.

0 new messages