Re: LW compiler optimizations
Martin Simmons <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
>>>>> On Wed, 15 Jan 2025 19:04:25 +0100, Yuri Davidovsky (as work at disclosure dot ie) said: > > This is one of the interesting findings of this discussion: do not use > displaced arrays in Lisp (or at least in LW, not too sure how SBCL handles > that). I find it curious since before that I assumed that a displaced array > is no different to a regular array, with it just being another struct that > refers to the same memory area as the original array. Apparently, that is > not the case and it can bite when you least expect it. In LispWorks at least, a simple 1d array is a single object, where the data follows the type information in memory. Displaced arrays are two objects, because you have the displaced array and the array that it references. That make aref more complicated. There are two additional complications: - You can have a chain of multiple displaced arrays, so aref has to loop in the general case until it reaches the simple array at the end of the chain. - In the case of adjustable displaced arrays, the displaced array can be changed on-the-fly to an array with a different size. We ensure that this on-the-fly change by adjust-array is thread-safe w.r.t. aref, which makes aref to more work. There is no type declaration to specify either of these complications, so aref has to assume that any non simple array might be a chain of adjustable displaced arrays. -- Martin Simmons LispWorks Ltd http://www.lispworks.com/ _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html