develooper Front page | perl.perl5.porters | Postings from February 2004

Re: op_seq (was: Freeing code)

Thread Previous | Thread Next
From:
Stephen McCamant
Date:
February 23, 2004 17:37
Subject:
Re: op_seq (was: Freeing code)
Message ID:
16442.43065.165305.340660@conquest.OCF.Berkeley.EDU
>>>>> "NC" == Nicholas Clark <nick@ccl4.org> writes:

NC> On Sat, Feb 21, 2004 at 02:31:47AM +0100, Paul Johnson wrote:

PJ> op_seq uses sixteen bits, as does op_type.  op_seq only needs to
PJ> hold three states, and op_type only needs nine bits.  This means
PJ> that we could store all the information we need in eleven bits,
PJ> save sixteen bits per op and still have five bits spare for future
PJ> use.

NC> You don't mention in this summary that your patch then (appears
NC> to) use that saved space for:

NC> + *	op_opt		Whether or not the op has been optimised by the
NC> + *			peephole optimiser.
NC> + *	op_static	Whether or not the op is statically defined.
NC> +                *	This flag is used by the B::C compiler backend
NC> +                *	and indicates that the op should not be freed.

These are the two bits that hold the three states that op_seq used
to. !op_opt corresponds to op_seq==0 and op_static to op_seq=65535.

NC> Which confuses me because then you report:

PJ> The attached patch does just that.  All the tests still pass on my
PJ> i386 linux box and the memory requirements of the following
PJ> program are reduced by almost 2.5%.

NC> This is good. There won't be memory reduction on any platform
NC> which requires structs containing 4 byte values to be 4 byte
NC> aligned, so it's not going to be a universal saving.

Eh? It looks to me like this change will save 4 bytes per OP on
platforms where OPs are 4-byte-aligned, by reducing BASEOP from 24
bytes to 20. Assuming 32 bit pointers, this changes BASEOP from

pointer
--
pointer
--
pointer
--
U32
--
U16
U16
--
U8
U8
<16 wasted bits>

to 

pointer
--
pointer
--
pointer
--
U32
--
9 bits
1 bit
1 bit
5 bits

This may not all be achieved if malloc() aligns to 8 bytes, but some
OPs have an even number of additional pointers, while others have an
odd number, so some will see a win.

 -- Stephen

Thread Previous | Thread Next


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