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

Missing Ops

7 views
Skip to first unread message

Leopold Toetsch

unread,
Sep 8, 2003, 3:34:09 PM9/8/03
to P6I
While playing with YAL (Yet Another Language) I'm discovering a lot of
asymmetries in ops files:

neg_p is missing (neg_p_p only, but neg_i is there)
mod_p_p_i, mod_p_p_n are missing (add, sub, ... have these variants)
keyed assign ops are missing (set only)

The question is what to do:
1) should these ops just be implemented or
2) should the assembler work around missing ops
3) should each HLL work around missing ops

leo

Leon Brocard

unread,
Sep 8, 2003, 4:15:26 PM9/8/03
to perl6-i...@perl.org
Leopold Toetsch sent the following bits through the ether:

> 1) should these ops just be implemented or

At this point we want to make it really easy to target parrot. I know
it's not hard to work around these exceptions, but I reckon
implementing the complete set of ops for now would be a good idea. We
can always move the logic into the assembler later if we decide to
prune ops.

ObLeonBrocard: he just be restin', arrr
--
Leon Brocard.............................http://www.astray.com/
scribot.................................http://www.scribot.com/

... I was young, I needed the money

Dan Sugalski

unread,
Sep 8, 2003, 4:33:35 PM9/8/03
to Leopold Toetsch, P6I
On Mon, 8 Sep 2003, Leopold Toetsch wrote:

> While playing with YAL (Yet Another Language) I'm discovering a lot of
> asymmetries in ops files:
>
> neg_p is missing (neg_p_p only, but neg_i is there)
> mod_p_p_i, mod_p_p_n are missing (add, sub, ... have these variants)
> keyed assign ops are missing (set only)
>
> The question is what to do:
> 1) should these ops just be implemented or

This one. We can consider pruning out unused variants later, after we've
been up and running and have reasonable HLL output to check against.

Dan

Piers Cawley

unread,
Sep 9, 2003, 6:17:17 AM9/9/03
to Leon Brocard, perl6-i...@perl.org
Leon Brocard <ac...@astray.com> writes:
> [Something! For the first time in ages!]

Hurrah! A summarizer breaths easily!

Leopold Toetsch

unread,
Sep 9, 2003, 6:23:04 AM9/9/03
to Dan Sugalski, P6I
Dan Sugalski wrote:

Ok. Started that.
- neg_p
- new vtables for cmodulus (both mod and cmod where doing C-modulus)
- c?modulus_{int,float}
- separated the implementation into utils.c

BTW PerlInt.divide() always yields a PerlNum, this seems bogus to me.
I think we need some clarification for the PerlNum implementation.


> Dan

leo


Dan Sugalski

unread,
Sep 9, 2003, 8:41:56 AM9/9/03
to Leopold Toetsch, P6I
On Tue, 9 Sep 2003, Leopold Toetsch wrote:

> Dan Sugalski wrote:
>
> > On Mon, 8 Sep 2003, Leopold Toetsch wrote:
> >>1) should these ops just be implemented or
> >>
> >
> > This one. We can consider pruning out unused variants later, after we've
> > been up and running and have reasonable HLL output to check against.
>
> Ok. Started that.
> - neg_p
> - new vtables for cmodulus (both mod and cmod where doing C-modulus)
> - c?modulus_{int,float}
> - separated the implementation into utils.c

Cool.



> BTW PerlInt.divide() always yields a PerlNum, this seems bogus to me.
> I think we need some clarification for the PerlNum implementation.

That's right--perl math always ends up as floats.

Dan

Leopold Toetsch

unread,
Sep 9, 2003, 9:56:11 AM9/9/03
to Dan Sugalski, perl6-i...@perl.org

I'm not sure:

$ perl -MDevel::Peek -e 'Dump 4.2/2.'
SV = PVNV(0x8149f78) at 0x8124b78
REFCNT = 1
FLAGS = (NOK,READONLY,pIOK,pNOK)
IV = 2
NV = 2.1
PV = 0

$ perl -MDevel::Peek -e 'Dump 4.2/2.1'
SV = PVNV(0x8149f80) at 0x8124b78
REFCNT = 1
FLAGS = (IOK,NOK,READONLY,pIOK,pNOK)
IV = 2
NV = 2
PV = 0

AFAIK is (IOK, pIOK) the same as a real IV.

At least they look differently:

$ perl -le 'print 4.2/2.1'
2

$ echo 'div N0, 4.2, 2.1
print N0
print "\n"' | parrot -a -
2.000000

> Dan

leo

Nicholas Clark

unread,
Sep 9, 2003, 10:22:51 AM9/9/03
to Dan Sugalski, Leopold Toetsch, P6I

No longer true as of 5.7.3 when IVs/UVs are larger than the floating point
mantissa and the result is exact:

$ /usr/local/perl5.8.1-snap21133/bin/perl5.8.1 -MDevel::Peek -le '$a=0xFFFFFFFFFFFFFFFF/3; Dump $a'
SV = IV(0x8145674) at 0x8144cb8
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 6148914691236517205

The same perl for a small value uses NVs:

$ /usr/local/perl5.8.1-snap21133/bin/perl5.8.1 -MDevel::Peek -le '$a=0xFF/3; Dump $a'
SV = NV(0x814b4cc) at 0x8144c90
REFCNT = 1
FLAGS = (NOK,pNOK)
NV = 85

Nicholas Clark

Dan Sugalski

unread,
Sep 9, 2003, 11:02:52 AM9/9/03
to Leopold Toetsch, perl6-i...@perl.org
On Tue, 9 Sep 2003, Leopold Toetsch wrote:

> Dan Sugalski <d...@sidhe.org> wrote:
> > On Tue, 9 Sep 2003, Leopold Toetsch wrote:
> >
> >> BTW PerlInt.divide() always yields a PerlNum, this seems bogus to me.
> >> I think we need some clarification for the PerlNum implementation.
>
> > That's right--perl math always ends up as floats.
>
> I'm not sure:

> FLAGS = (NOK,READONLY,pIOK,pNOK)
> FLAGS = (IOK,NOK,READONLY,pIOK,pNOK)

> AFAIK is (IOK, pIOK) the same as a real IV.

Internally it's sometimes not a float in new versions of perl, as Nicholas
pointed out, but unless the 'use integer' pragma's in effect, the math is
treated as if it were a floating point operation.

The IOK flag is an indication that the integer cache slot is valid--it
means that perl realized that the operation produces an integral value and
filled in the slot appropriately.

For us, teh equivalent would be returning a PerlInt if we find the
result produces an integral value, and a PerlNum if it doesn't. (Assuming,
of course, that the operation took place on two perl-style PMCs, as other
languages may have different rules on what happens)

Dan

Leopold Toetsch

unread,
Sep 11, 2003, 7:52:53 AM9/11/03
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> For us, teh equivalent would be returning a PerlInt if we find the
> result produces an integral value, and a PerlNum if it doesn't. (Assuming,
> of course, that the operation took place on two perl-style PMCs, as other
> languages may have different rules on what happens)

Ok. Most done. (PerlNum) 4.2+2.8 gives PerlInt 7 now.

> Dan

leo

0 new messages