[perl #42074] [PATCH] add RECURSION_LIMIT macro

2 views
Skip to first unread message

Alek Storm

unread,
Mar 25, 2007, 2:16:52 PM3/25/07
to bugs-bi...@rt.perl.org
# New Ticket Created by "Alek Storm"
# Please include the string: [perl #42074]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42074 >


This patch defines a RECURSION_LIMIT macro in include/parrot/sub.h,
which interp->recursion_limit is assigned to in src/inter_create.c.
It's currently hardcoded as 1000 in inter_create.c.

Thanks,
Alek Storm

recursion_limit.patch

Paul Cochrane via RT

unread,
Mar 30, 2007, 4:38:35 PM3/30/07
to perl6-i...@perl.org
Thanks! Applied in r17863.

Chromatic

unread,
Mar 30, 2007, 6:10:20 PM3/30/07
to perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
On Friday 30 March 2007 13:38, Paul Cochrane via RT wrote:

> Thanks! Applied in r17863.

It would be pretty simple to make this a settable/queryable interpreter
property. Would that be valuable?

-- c

Paul Cochrane

unread,
Mar 30, 2007, 6:23:37 PM3/30/07
to chromatic, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
> It would be pretty simple to make this a settable/queryable interpreter
> property. Would that be valuable?

It's already a gettable interpreter property
(interp->recursion_limit). I'm guessing it would be valuable to be
able to set the value at runtime. Coke mentioned this on #parrot.
Unfortunately, I don't know how to implement this. Any takers?

Paul

Alek Storm

unread,
Mar 30, 2007, 6:25:59 PM3/30/07
to chromatic, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
How about like this:

$P0 = getinterp
$P0["recursionlimit"] = 2000
$P0["recursionlimit"] = -1

Where the last one signifies an infinite recursion limit (unsafe, but
it should still be available to HLL implementors).

Alek Storm

unread,
Mar 30, 2007, 6:46:02 PM3/30/07
to chromatic, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
Hmm. You know what I just found out? The ParrotInterpreter PMC
doesn't implement set_pmc_keyed. Any objections to implementing it?
It could then be expanded to support getting and setting interpreter
flags, which are currently handled through get_ and
set_integer_keyed_int. Providing a keyed string interface to the
flags would be a lot nicer than OR-ing values together.

Come to think of it, why are we using a keyed interface at all? Why
can't we just use getprop and setprop, or getattribute and
setattribute? It's what they were designed for, after all.

Alek Storm

unread,
Mar 30, 2007, 6:51:49 PM3/30/07
to Alek Storm, chromatic, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
-1 is often used to signify infinity, so the code using it would
probably be a little clearer if it used that. However, since 0 isn't
a logical value anyway, that's probably a good idea, though I haven't
seen much bare type-converting in the Parrot source.

On 3/30/07, Nicholas Clark <ni...@ccl4.org> wrote:


> On Fri, Mar 30, 2007 at 10:25:59PM +0000, Alek Storm wrote:
> > How about like this:
> >
> > $P0 = getinterp
> > $P0["recursionlimit"] = 2000
> > $P0["recursionlimit"] = -1
> >
> > Where the last one signifies an infinite recursion limit (unsafe, but
> > it should still be available to HLL implementors).
>

> Is the value "recursionlimit" signed or unsigned?
>
> Using 0 to flag the infinite recursion limit might feel more natural.
>
> Using -1 to mean ~0 makes me edgy. In particular, because in C you can end
> up with integer size promotion meaning that -1 isn't -1. Or at least what
> you thought was -1 isn't -1 any more, because it was converted to unsigned,
> and then converted to a larger unsigned type, and so is now an unremarkable
> positive integer, rather than all bits set.
>
> Nicholas Clark
>

Nicholas Clark

unread,
Mar 30, 2007, 6:46:55 PM3/30/07
to Alek Storm, chromatic, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
On Fri, Mar 30, 2007 at 10:25:59PM +0000, Alek Storm wrote:
> How about like this:
>
> $P0 = getinterp
> $P0["recursionlimit"] = 2000
> $P0["recursionlimit"] = -1
>
> Where the last one signifies an infinite recursion limit (unsafe, but
> it should still be available to HLL implementors).

Is the value "recursionlimit" signed or unsigned?

Leopold Toetsch

unread,
Mar 31, 2007, 1:30:17 PM3/31/07
to perl6-i...@perl.org, Paul Cochrane, chromatic

The interpreter already has it:
/t/examples/shootout_14.pir: $P0.'recursion_limit'(100000)

where $P0 isa ParrotInterpreter

static int
recursion_limit(Parrot_Interp interp, PMC *self, int l)
{
int ret = interp->recursion_limit;
interp->recursion_limit = l;
return ret;
}

> Paul

leo

Allison Randal

unread,
Mar 31, 2007, 3:22:05 PM3/31/07
to Alek Storm, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com
Alek Storm wrote:
> Hmm. You know what I just found out? The ParrotInterpreter PMC
> doesn't implement set_pmc_keyed. Any objections to implementing it?

Pass. It has methods, and access to the internal data of the interpreter
object should go through those methods.

Allison

Alek Storm

unread,
Mar 31, 2007, 3:32:45 PM3/31/07
to Allison Randal, perl6-i...@perl.org, bugs-par...@netlabs.develooper.com


Do you mean a PCCMETHOD? If we're just getting and setting attributes, I
really think we should be using getattribute and setattribute, or getprop
and setprop, instead of expanding the ParrotInterpreter namespace with a
bunch of simple getter and setter methods.

Allison Randal

unread,
Mar 31, 2007, 3:55:11 PM3/31/07
to Alek Storm, perl6-i...@perl.org
Alek Storm wrote:
>
> Do you mean a PCCMETHOD? If we're just getting and setting attributes, I
> really think we should be using getattribute and setattribute, or getprop
> and setprop, instead of expanding the ParrotInterpreter namespace with a
> bunch of simple getter and setter methods.

getattribute and setattribute are only implemented on ParrotObjects (and
other implementations of high-level objects). And really, even on
ParrotObjects getattribute and setattribute should only be called inside
the class itself. All external code using the object should access the
attributes through accessor methods (preserving encapsulation).

getprop and setprop are completely different, they access (extra) data
attached to a PMC as a hash at runtime.

Read docs/ops/object.pod and docs/ops/pmc.pod.

Allison

Reply all
Reply to author
Forward
0 new messages