Next: objects tcbuckets, Previous: objects transcoders, Up: objects [Index]
A pointer is a fixed length memory block, two words wide, referenced by machine words tagged as vectors. The first machine word of a pointer block is tagged has pointer in its least significant bits and it has the most significant bits set to zero. The second machine word of a pointer block holds the actual pointer value.
|------------------------|-------------| reference to pointer heap pointer vector tag |------------------------|-------------| pointer first word all set to zero pointer tag |--------------------------------------| pointer second word pointer value
Pointers are allocated on the Scheme heap as follows:
ikpcb_t * pcb = ik_the_pcb(); ikptr_t s_ptr; s_ptr = ik_safe_alloc(pcb, pointer_size) | vector_tag; IK_POINTER_TAG(s_ptr) = pointer_tag;
To set or retrieve the pointer value we do:
ikptr_t s_ptr = the_pointer; void * ptr; ptr = IK_POINTER_DATA_VOIDP(X); IK_POINTER_DATA_VOIDP(X) = ptr;
The number of bytes to allocate to hold a pointer memory block.
The tag of ikptr_t
values used as first words in pointer memory blocks.
Displacement of secondary tag word. The number of bytes to add to an untagged pointer to pointer object to get the pointer to the first byte in the word holding the pointer tag.
Displacement of data area. The number of bytes to add to an untagged pointer to pointer object to get the pointer to the first byte of the data area.
An integer to add to add to a tagged ikptr_t
pointer to pointer object
to get the pointer to the first byte in the word holding the pointer
tag.
An integer to add to a tagged ikptr_t
pointer to pointer object to get
the pointer to the first byte of the word holding the pointer value.
Evaluate to true if X is a pointer object.
Evaluate to the location of the first word in a pointer object; X must be a tagged pointer referencing a pointer object.
Return the value of the pointer as ikptr_t
; X must be a
tagged pointer referencing a pointer object.
Return the value of the pointer cast to a specific type; X must be a tagged pointer referencing a pointer object.
Reset to ptr the value of the pointer X; X must be a tagged pointer referencing a pointer object.
Reset to NULL
the value of the pointer; X must be a tagged
pointer referencing a pointer object.
Evaluate to true if the pointer value is NULL
; X must be a
tagged pointer referencing a pointer object.
Return true if X is a pointer object.
Return IK_TRUE_OBJECT
if X is a pointer object, else return
IK_FALSE_OBJECT
.
Allocate a pointer object using ik_safe_alloc()
and return a
tagged reference to it. The pointer is initialised to memory.
Allocate a pointer object using ik_unsafe_alloc()
and return a
tagged reference to it. The pointer is initialised to memory.
Next: objects tcbuckets, Previous: objects transcoders, Up: objects [Index]