Next: objects continuations scheme, Up: objects continuations [Index]
Continuation objects are memory blocks referenced by machine words tagged as vectors, whose first word is tagged as continuation:
|----------------|----------| reference to continuation heap pointer vector tag |----------------|----------| first word of continuation all set to zero continuation tag
the layout of a continuation memory block is:
|-----|-----|-----|-----| tag top size next
Continuation objects are collected in linked lists handled as stacks; all such linked lists share a common tail. The meaning of the fields is:
tag
A machine word containing only the secondary tag for continuation objects and all the other bits set to zero.
top
A machine word representing the memory address of the machine word at the top (lowest address) of the stack portion referenced by the continuation.
size
The size of the stack portion expressed in number of bytes.
next
A machine word being NULL
or a reference (tagged pointer) to the
next continuation object in the linked list.
To test if a value of type ikptr_t
is a reference to a continuation
object, we should do:
ikptr_t X; if (continuation_primary_tag == (continuation_primary_mask & X)) { if (continuation_tag == IK_REF(X, 0)) it_is_a_scheme_continuation(); else if (system_continuation_tag == IK_REF(X, 0)) it_is_a_system_continuation(); it_is_not(); } else it_is_not();
A Scheme continuation object is usually allocated as follows:
ikpcb_t * pcb = ...; ikptr_t s_kont; ikcont * kont; kont = (ikcont*)ik_unsafe_alloc(pcb, IK_ALIGN(continuation_size)); s_rest = (ikptr_t)((long)kont) | continuation_primary_tag; IK_REF(s_kont, off_continuation_tag) = continuation_tag; IK_REF(s_kont, off_continuation_top) = pcb->frame_pointer; IK_REF(s_kont, off_continuation_size) = \ pcb->frame_base - pcb->frame_pointer - wordsize; IK_REF(s_kont, off_continuation_next) = pcb->next_k; IK_SIGNAL_DIRT(pcb, s_kont); pcb->next_k = s_kont;
The tag of an ikptr_t
machine words referencing the memory block of
a Scheme or system continuation object.
A bit pattern used to isolate the tag bits in an ikptr_t
machine
words referencing the memory block of a Scheme or system continuation
object.
Integer values used to tag and recognise the first word in continuation memory blocks.
The number of bytes needed to hold a continuation memory block.
Scheme continuation field displacements. The number of bytes to add to an untagged pointer to Scheme continuation to get the pointer to the first byte in the word holding the specified field.
System continuation field displacements. The number of bytes to add to an untagged pointer to system continuation to get the pointer to the first byte in the word holding the specified field.
Scheme continuation field offsets. The number of bytes to add to a tagged pointer to Scheme continuation to get the pointer to the first byte in the word holding the specified field.
System continuation field offsets. The number of bytes to add to a tagged pointer to system continuation to get the pointer to the first byte in the word holding the specified field.
Evaluate to true if X is a reference to Scheme continuation object.
Evaluate to true if X is a reference to system continuation object.
Evaluate to true if X is a reference to Scheme or system continuation object.
Next: objects continuations scheme, Up: objects continuations [Index]