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

Bug: :flat and :slurpy don't mix

0 views
Skip to first unread message

Bob Rogers

unread,
Dec 3, 2005, 11:11:32 PM12/3/05
to perl6-i...@perl.org
If you try to call a sub with a :slurpy parameter and give it a :flat
argument, parrot r10337 just hangs, chewing up CPU time. I know this
worked as of r10161, if it helps. Suprisingly, there isn't already a
test case for this. TIA,

-- Bob Rogers
http://rgrjr.dyndns.org/

slurpy-with-flat.patch

Bob Rogers

unread,
Dec 6, 2005, 11:39:47 PM12/6/05
to perl6-i...@perl.org
From: Bob Rogers <rogers...@rgrjr.dyndns.org>
Date: Sat, 3 Dec 2005 23:11:32 -0500

If you try to call a sub with a :slurpy parameter and give it a :flat

argument, parrot r10337 just hangs, chewing up CPU time . . .

Turns out this is because of "premature optimization" -- and all
flattening is affected, depending only on the PMC class of the :flat
array, and not whether there is a :slurpy parameter (hence another test
case). When starting to flatten, st->src.slurp_n is initialized with a
result from a hacked version of VTABLE_elements, which could return
garbage (i.e. something that looks like a PMC *). If a PerlArray is
being flattened, then the parrot_pass_args loop attempts to copy 1e8 or
so Undef values to an insatiable destination array, leading to the
appearance of an unbounded loop. I changed the array class in the new
test cases to a plain Array, which will die much sooner with an "out of
bounds" error if this should ever regress. TIA,

flat-slurpy-bug.patch

Leopold Toetsch

unread,
Dec 7, 2005, 6:44:32 AM12/7/05
to Bob Rogers, perl6-i...@perl.org

On Dec 7, 2005, at 5:39, Bob Rogers wrote:

> Turns out this is because of "premature optimization"

Argh - sorry. That shouldn't have been on of course. I did some
benchmarking and must have forgotten to disable it. It is ment to
access the signature array faster. The type of the signature array is
known as Parrot is constructing it. The flatten code must of course be
outside the range of this define.

Thanks a lot for spotting this and the tests, applied - r10385.

leo

Bob Rogers

unread,
Dec 7, 2005, 11:48:52 AM12/7/05
to Leopold Toetsch, perl6-i...@perl.org
From: Leopold Toetsch <l...@toetsch.at>
Date: Wed, 7 Dec 2005 12:44:32 +0100

On Dec 7, 2005, at 5:39, Bob Rogers wrote:

> Turns out this is because of "premature optimization"

Argh - sorry. That shouldn't have been on of course. I did some
benchmarking and must have forgotten to disable it. It is ment to
access the signature array faster. The type of the signature array is
known as Parrot is constructing it. The flatten code must of course be
outside the range of this define.

Make sense. Thanks for explaining.

But it's not clear to me that it would ever be worth optimizing
VTABLE_elements calls, even for the signature array. Seems to me that
it's called exactly twice per call/return sequence, true?

Thanks a lot for spotting this and the tests, applied - r10385.

leo

No problem; glad to be useful. If I get a chance, I'll try to work up
more call/return tests involving :slurpy and/or :flat.

-- Bob

0 new messages