[cmucl-imp] Re: Static array support

Lynn Quam quam at AI.SRI.COM
Tue Dec 1 21:15:25 CET 2009


There are a number of subtleties in implementing the "static" arrays.  
The Allegro :ALLOCATION keyword argument to MAKE-ARRAY is interpreted as 
follows (taken from the Allegro 7.0 documentation):

|:static|  or |:malloc| ||

    Allocate the new array in malloc (foreign) space. The array will
    never be touched by the garbage collector and must be deallocated
    explicitly. Only a restricted number of element types are supported
    for static arrays. They are listed below. :malloc and :static are
    synonyms.

|:static-reclaimable|

    Allocate the new array data in malloc (foreign) space and the header
    in Lisp space. The data will never be touched by the garbage
    collector but it will be deallocated when there are no pointers from
    Lisp (using a finalization). Only a restricted number of element
    types are supported for static arrays. They are listed below. ||
    ||

|:lispstatic-reclaimable|

    Allocate the new array in malloc (foreign) space. The array will
    never be touched by the garbage collector until there are no
    pointers from Lisp, at which point the whole array will be
    deallocated explicitly. Any Lisp type can be contained in the array.

It is important to note the  difference between |:static-reclaimable| 
and |:lispstatic-reclaimable|.  I think that |:lispstatic-reclaimable is 
what needs to be implemented for CMUCL.  |An array allocated as 
|:static-reclaimable| cannot be a simple-array in CMUCL since the array 
data does not immediately follow the header.  Therefore, it is difficult 
to compile inline array accesses unless KERNEL::%WITH-ARRAY-DATA or  
kernel::%array-data-vector is used to get the actual data-vector.   
||

Raymond Toy wrote:
> Marco Antoniotti wrote:
>   
>> On Dec 1, 2009, at 24:16 , Raymond Toy wrote:
>>
>>     
>>> Carl Shapiro wrote:
>>>       
>>>> On Mon, Nov 30, 2009 at 7:04 AM, Raymond Toy <toy.raymond at gmail.com>
>>>> wrote:
>>>>
>>>>         
>>>>> To create a static array, use make-array with :allocation :static.
>>>>>
>>>>>           
>>>> It would be great if the name :static could be reserved for the static
>>>> part of the Lisp heap.  The name :malloc is more descriptive and less
>>>> ambiguous.
>>>>
>>>>         
>>> Works for me.
>>>       
>> What about :pinned?  (Just suggesting)
>>
>>     
> Perhaps we can follow Allegro's lead? 
> <http://www.franz.com/support/documentation/current/doc/implementation.htm#cl-make-array-2> 
> (No particular reason, other than to be somewhat compatible.)
>
> So, our :static/:malloc is the same as Allegro's :static-reclaimable. 
> We could add make our :static/:malloc the same as Allegro's
> :static/:malloc since Allegro requires you to explicitly free such
> objects.   These objects are the malloc'ed foreign arrays that we now
> create.  The main difference is that we can't reload such arrays
> (currently).
>
> I've already updated the code to use :malloc, but we have plenty of time
> before the snapshot to change behavior.
>
> Ray
>
>
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zs64.net/mailman-archive/cmucl-imp/attachments/20091201/e5ad6f64/attachment.html>


More information about the cmucl-imp mailing list