on the usage of the unsafe operations ##sys##slot and similar

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

on the usage of the unsafe operations ##sys##slot and similar

Marco Maggi
Ciao,

  sorry  for  peeking  under  the  skirt; I'm  trying  to  get  a  basic
understanding of the  core usage and memory layout of  Scheme values; is
it correct that:

* We can  use ##sys#setislot to  store any  immediate value in  a Scheme
  vector?

* We   can  use   the  system   operations  ##sys#slot,   ##sys#setslot,
  ##sys#setislot , ##sys#size on every Scheme object whose memory layout
  is similar to the one of Scheme vectors?

TIA
--
Marco Maggi

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users
Reply | Threaded
Open this post in threaded view
|

Re: on the usage of the unsafe operations ##sys##slot and similar

Peter Bex
On Sun, May 12, 2019 at 11:10:51AM +0200, Marco Maggi wrote:
> Ciao,
>
>   sorry  for  peeking  under  the  skirt; I'm  trying  to  get  a  basic
> understanding of the  core usage and memory layout of  Scheme values

Hi Marco,

If you're interested in this, perhaps you find this blog post of mine
useful: https://www.more-magic.net/posts/internals-data-representation.html
It explains how values are represented in memory at the low level.

> is it correct that:
>
> * We can  use ##sys#setislot to  store any  immediate value in  a Scheme
>   vector?

That's correct.  It's faster than ##sys#setslot because it doesn't
check if it's an immediate.  ##sys#setslot will track mutations to
non-immediate values so that the garbage collector knows that the
object is still being used.

> * We   can  use   the  system   operations  ##sys#slot,   ##sys#setslot,
>   ##sys#setislot , ##sys#size on every Scheme object whose memory layout
>   is similar to the one of Scheme vectors?

Yeah, it can be used on any compound Scheme object.  Basically, any
non-immediate that's not a bytevector.  On bytevectors, ##sys#size
works too, but it will return the size in bytes rather than the number
of slots in the object.

Cheers,
Peter

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: on the usage of the unsafe operations ##sys##slot and similar

Marco Maggi
Peter Bex wrote:

> On Sun, May 12, 2019 at 11:10:51AM +0200, Marco Maggi wrote:

> If you're interested in this, perhaps you find this blog post of mine
> useful: https://www.more-magic.net/posts/internals-data-representation.html
> It explains how values are represented in memory at the low level.

Thanks.  This is indeed of interest to me.
--
Marco Maggi

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users