Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3d948f4
[wip] start implementing composable continuation
ktakashi Jan 12, 2026
74fd011
Dump entire continuation frames on print_frames
ktakashi Jan 12, 2026
5cfce31
[wip] composable continuation
ktakashi Jan 13, 2026
da78bf0
[skip ci] WIP composable continuation
ktakashi Jan 13, 2026
15819c5
[skip ci] composable continuation
ktakashi Jan 13, 2026
6dd85e6
Revert back save_cont_rec
ktakashi Jan 13, 2026
8e1c30b
First skip prompt frame, then check if cont frame is in the stack.
ktakashi Jan 13, 2026
f4bfa59
First skip prompt frame then pop cont
ktakashi Jan 14, 2026
f9bc64d
Copy prompt during composable continuation splicing
ktakashi Jan 19, 2026
ae56f2e
Adding prompts field to the VM.
ktakashi Jan 20, 2026
3e40720
Restore continuation frame after winders are invoked
ktakashi Jan 21, 2026
9ca9ffe
Taking only winders which installed within the prompt
ktakashi Jan 22, 2026
1fd5f1e
Cleanup abort/cc
ktakashi Jan 22, 2026
3051829
Moved around prompt removal
ktakashi Jan 22, 2026
f7c51dd
Don't call default-abort-handler in abort/cc call frame
ktakashi Jan 23, 2026
11beef5
Checking prompt winders
ktakashi Jan 23, 2026
47d2e2b
Freshly search prompt node on abort_body
ktakashi Jan 23, 2026
4516823
Adding safe guard
ktakashi Jan 23, 2026
83b0f72
Adding continuation prompt tests
ktakashi Jan 24, 2026
31dcdc4
Adding address info to procedure write
ktakashi Jan 24, 2026
08a45d6
I don't know what I'm doing but seems getting better.
ktakashi Jan 26, 2026
cd73d54
Make continuation prompt and composable continuation test do assert
ktakashi Jan 27, 2026
87f391e
Removing unused struct field
ktakashi Jan 27, 2026
13d65e1
Adding extra condition on dladdr
ktakashi Jan 27, 2026
c590d6c
Making type field to 3 bit
ktakashi Jan 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/lib_sagittarius.stub
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,8 @@
(result (Sg_VMCallCP proc tag handler args)))

(define-c-proc %abort/cc (tag args) :no-export Sg_VMAbortCC)
(define-c-proc %call/comp (proc::<procedure> tag) :no-export Sg_VMCallComp)
(define-c-proc continuation? (o) ::<boolean> :no-side-effect Sg_ContinuationP)

(define (make-continuation-prompt-tag :optional (name (gensym))) (list name))
(define default-continuation-prompt-tag
Expand All @@ -1868,7 +1870,12 @@
(%call/prompt proc tag handler args))
(define (abort-current-continuation (tag continuation-prompt-tag?) . args)
(%abort/cc tag args))
(define (call-with-composable-continuation
proc :optional ((tag continuation-prompt-tag?)
(default-continuation-prompt-tag)))
(%call/comp proc tag))

(define call/prompt call-with-continuation-prompt)
(define abort/cc abort-current-continuation)
(define call/comp call-with-composable-continuation)
)
27 changes: 24 additions & 3 deletions src/sagittarius/private/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ typedef struct SgContFrameRec
int size;
int type;
#else
int size: 30; /* size of argument frame */
int type: 2;
int size: 29; /* size of argument frame */
int type: 3;
#endif
SgWord *pc; /* next PC */
SgObject cl; /* cl register value */
Expand Down Expand Up @@ -188,6 +188,25 @@ typedef struct values_buffer_t
} \
} while (0)

/* A prompt will be installed in a PC of cont frame */
typedef struct SgPromptRec
{
SgObject tag;
SgObject handler;
SgCStack *cstack;
SgObject winders;
} SgPrompt;
/* deque of prompt
installation -> prepend
splice -> append
*/
typedef struct SgPromptNodeRec
{
SgPrompt *prompt;
SgContFrame *frame;
struct SgPromptNodeRec *next;
} SgPromptNode;

struct SgVMRec
{
SG_HEADER;
Expand All @@ -212,6 +231,7 @@ struct SgVMRec
SgObject *fp; /* frame pointer */
SgObject *sp; /* stack pointer */
SgContFrame *cont; /* saved continuation frame */
SgPromptNode *prompts; /* prompt chain, this is the top */
/* values buffer */
int valuesCount;
SgObject values[DEFAULT_VALUES_SIZE];
Expand Down Expand Up @@ -387,8 +407,9 @@ SG_EXTERN SgObject Sg_VMCallPC(SgObject proc);
/* call-with-continuation-prompt */
SG_EXTERN SgObject Sg_VMCallCP(SgObject proc, SgObject tag,
SgObject handler, SgObject args);
SG_EXTERN SgObject Sg_VMCallComp(SgObject proc, SgObject tag);
SG_EXTERN SgObject Sg_VMAbortCC(SgObject tag, SgObject args);
SG_EXTERN SgObject Sg_VMDefaultAbortHandler(SgObject args);
SG_EXTERN int Sg_ContinuationP(SgObject o);
SG_EXTERN SgVM* Sg_VM(); /* get vm */
SG_EXTERN int Sg_SetCurrentVM(SgVM *vm);
SG_EXTERN int Sg_AttachVM(SgVM *vm);
Expand Down
3 changes: 3 additions & 0 deletions src/subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ static void proc_print(SgObject obj, SgPort *port, SgWriteContext *ctx)
Sg_Printf(port, UC(" %d:%d"),
SG_PROCEDURE_REQUIRED(obj), SG_PROCEDURE_OPTIONAL(obj));

if (SG_WRITE_MODE(ctx) == SG_WRITE_WRITE) {
Sg_Printf(port, UC(" %p"), obj);
}
Sg_Putc(port, '>');
}
SG_DEFINE_BUILTIN_CLASS_SIMPLE(Sg_ProcedureClass, proc_print);
Expand Down
Loading