develooper Front page | perl.perl5.porters | Postings from January 2014

[perl #120939] [PATCH] refactor and fix leak in const_av_xsub

From:
Tony Cook via RT
Date:
January 12, 2014 22:27
Subject:
[perl #120939] [PATCH] refactor and fix leak in const_av_xsub
Message ID:
rt-4.0.18-5855-1389565617-639.120939-15-0@perl.org
On Sun Jan 05 19:35:47 2014, bulk88 wrote:
> This patch might need more refinement, specifically I think the number
> of asserts is excessive, I used them when I developed the patch and
> was
> having "Bizarre copy of" problems, but I think they are useless now.
> The
> function dropped from 0x122 bytes of machine code to 0x10c on my VC
> 2003
> 32 bits -O1 build. The TARG usage "bloated" the function a little bit
> since sv_2mortal(newSViv()) takes less machine code. It is an
> acceptable
> tradeoff AFAIK.

I'm fairly happy with this patch, but I'm not sure that:

+	I32 stack_grow = 1;
+	const I32 avlastindex = AvFILLp(av); /* 0 based */
+	I32 avitems; /* 1 based */
+	stack_grow += -(gimme_v == G_ARRAY) & avlastindex; /* branch free */

is a speed or maintenance win (it is a space win on x86_64 and presumably x86_32).

On 32/64-bit x86 this avoids a branch by using the setCC instruction, but then we later check the exact same condition again.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=120939



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About