Search
Monday, 18th of November 2019, 19:59:26 UTC
20:04:39
pfdietz
(let ((t1 (first pair)) (t2 (second pair)) (t3 (third pair))) ...)
20:05:20
pfdietz
It's correct for large values of 2
20:49:25
stylewarning
is there a higher-level API to get something into static space other than rolling with SB-KERNEL:ALLOCATE-STATIC-VECTOR?
20:52:34
phoe
stylewarning: higher-level? What do you mean?
20:53:09
stylewarning
I want to make use of static space and I'm not sure if there's a way to allocate data that doesn't require fiddling with widetags and bytes
20:54:43
phoe
as in, you want to allocate standard Lisp objects in static space?
20:55:20
stylewarning
Yes, or even just a simple-vector
20:55:58
stylewarning
Oh, there's MAKE-STATIC-VECTOR.
20:57:08
Bike
https://github.com/sionescu/static-vectors exists too
20:57:43
stylewarning
Bike: i specifically want objects managed in the heap, which means they can't be C allocatedx
20:58:04
stylewarning
and static-vectors just ensures the objects won't move around (AFAIK) and not about their management, but I could be wrong
20:59:17
phoe
static-vectors are not GCed I think
20:59:57
phoe
so you want something that is allocated on the heap but that is not moved?
21:00:08
stylewarning
-y, sorry for the constant typos
21:00:32
phoe
the moving GC is not going to enjoy that
21:00:51
phoe
static-vectors allocates in C space I think
21:01:27
phoe
if you want them to not move then SB-SYS:WITH-PINNED-OBJECTS
21:02:15
phoe
these are created on the heap but they will not be moved inside the body
21:11:59
Shinmera
stylewarning: static-vectors may be gced (they are on ECL, for instance, but not on SBCL)
21:12:19
stylewarning
Shinmera: that's right
21:13:36
phoe
you must call free-static-vector to ensure that they are collected
21:14:22
Shinmera
anyway, I regularly have fast-paths in my stuff that pins the array on SBCL (if it can be pinned and accessed directly)
21:14:34
Shinmera
when the exchange with C is necessary
21:17:08
saturn2
CFFI also has this interface https://gitlab.common-lisp.net/cffi/cffi/raw/master/doc/shareable-vectors.txt
21:20:20
phoe
saturn2: this seems like exactly what sb-sys:with-pinned-objects does
21:20:30
phoe
except obviously CFFI is a compalib
21:20:44
saturn2
yep, on sbcl that's what it uses, but it supports other lisps too
21:21:45
phoe
stylewarning: so I guess that this is what you want, the provided objects will not be moved in the dynamic scope of that operator
21:22:09
phoe
but may be collected once control leaves that scope
22:17:41
stylewarning
Why doesn't (reconstitute-object (get-lisp-obj-address x)) return x?
22:22:08
Bike
reconstitute-object actually does get-lisp-obj-address itself, at least in my sbcl
22:23:10
stylewarning
hm, I wonder what the deal is then, why it's written that way
22:23:58
phoe
;;; Given the address (untagged, aligned, and interpreted as a FIXNUM)
22:24:00
phoe
;;; of a lisp object, return the object, (...)
22:24:08
phoe
but then it takes the address of the address
22:24:21
phoe
(let* ((object-sap (int-sap (get-lisp-obj-address address))) ...
22:24:27
stylewarning
yeah, i don't understand
22:24:31
phoe
so it takes the address of the fixnum and turns it into a sap
22:25:22
Bike
i don't see anything actually using the function. maybe it just rotted a little.
22:25:36
stylewarning
Bike: MAP-OBJECTS-IN-RANGE uses it
22:26:02
phoe
Bike: `git grep reconstitute-object` returns multiple lines
22:28:06
phoe
and then it takes the header of the sap, meaning that it grabs and understands the fixnum as a header...
22:28:08
pkhuong
phoe: get-lisp-obj-address on a fixnum returns a machine word with the tag bits
22:28:34
pkhuong
it's a trick to avoid consing across function call boundaries
22:29:04
pkhuong
(and the lowtag for fixnums is always 0)
22:30:22
phoe
am I using this correctly? https://plaster.tymoon.eu/view/1556#1556
22:30:34
pkhuong
stylewarning: the inverse of g-l-o-a is make-lisp-obj
22:31:17
phoe
oh, that's why I corrupt the image
22:32:15
pkhuong
phoe: no. you want to clear the tag bits in the tagged address returned by g-l-o-a
22:32:39
pkhuong
then call %make-lisp-obj to turn the machine word into a fixnum
22:32:53
pkhuong
(it'll be a fixnum because the lowtag bits are all 0)
22:39:22
pkhuong
fwiw, all this would be more obvious on a 32 bit build
Tuesday, 19th of November 2019, 7:59:26 UTC