emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proposal: block-based vector allocator


From: Stefan Monnier
Subject: Re: Proposal: block-based vector allocator
Date: Fri, 01 Jun 2012 13:40:38 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

>>> -  return (p == m->start&&  m->type == MEM_TYPE_VECTORLIKE);
>>> +  if (m->type == MEM_TYPE_VECTORLIKE)
>>> +    {
>>> +      if (m->end - m->start == VECTOR_BLOCK_BYTES)
>> 
>> Please just use a new MEM_TYPE, so we don't need to worry about the
>> possibility of having a non-vector-block which just happens to have the
>> same size as a vector-block.

> I don't understand this.  Any block-allocated vector P0 has the size
> less than or equal to VECTOR_BLOCK_BYTES.  So, mem_find (P0) will
> always return mem_node M0 where M0->end - M0->start ==
> VECTOR_BLOCK_BYTES (IOW, such a mem_node always corresponds to
> a vector block).  If P1's size is greater than VECTOR_BLOCK_BYTES,
> including the case when it's equal to sizeof (vector_block), mem_find
> (P1) will always return it's own corresponding node M1 where P1 is
> equal to M1->start and M1-> end - M1->start is never equal to
> VECTOR_BLOCK_BYTES.

I'm not saying the code is wrong.  I'm saying that its correctness
should be made more explicit by using a different MEM_TYPE for
vector blocks.  This way the correctness argument is trivial rather than
relying on some reasoning about which kind of vector allocation
is used in which circumstance.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]