21 #if POTION_STACK_DIR > 0
30 fprintf(stderr,
"** TODO: continuations which switch stacks must be rewritten. (%p != %p)\n",
31 sp1, (
void *)(cc->
stack[0]));
34 DBG_vt(
"\nyield: start=%p, end=%p, cc=%p\n", start, end, cc->
stack);
39 #if POTION_X86 == POTION_JIT_TARGET
41 __asm__ (
"mov 0x8(%2), %%rsp;"
42 "mov 0x10(%2), %%rbp;"
52 "mov 0x18(%%rbx), %%rax;"
53 "movq $0x0, 0x18(%%rbx);"
54 "mov 0x28(%%rbx), %%r12;"
55 "mov 0x30(%%rbx), %%r13;"
56 "mov 0x38(%%rbx), %%r14;"
57 "mov 0x40(%%rbx), %%r15;"
58 "mov 0x20(%%rbx), %%rbx;"
61 :
"r"(start),
"r"(end),
"r"(cc->
stack)
62 :
"%rax",
"%rsp",
"%rbx"
65 __asm__ (
"mov 0x4(%2), %%esp;"
76 "mov 0xc(%%esi), %%eax;"
77 "mov 0x14(%%esi), %%edi;"
78 "mov 0x18(%%esi), %%ebx;"
79 "mov 0x10(%%esi), %%esi;"
82 :
"r"(start),
"r"(end),
"r"(cc->
stack)
83 :
"%eax",
"%esp",
"%esi"
88 fprintf(stderr,
"** TODO: callcc/yield does not work outside of X86 yet.\n");
106 #if defined(DEBUG) && (PN_SIZE_T == 8)
107 if ((
_PN)sp1 & 0xF) {
108 fprintf(stderr,
"P->mem->cstack=0x%lx ", (
_PN)sp1);
114 #if POTION_STACK_DIR > 0
123 DBG_vt(
"\ncallcc: n=%ld, start=%p, end=%p, cc=%p\n", n, start, sp2, sp1);
133 DBG_vt(
"\ncallcc: start=%p, end=%p, cc=%p\n", start, sp2, cc->
stack);
134 #if POTION_X86 == POTION_JIT_TARGET
136 __asm__ (
"mov %%rbx, 0x20(%0);"
137 "mov %%r12, 0x28(%0);"
138 "mov %%r13, 0x30(%0);"
139 "mov %%r14, 0x38(%0);"
140 "mov %%r15, 0x40(%0);"::
"r"(cc->
stack));
142 __asm__ (
"mov %%esi, 0x10(%0);"
143 "mov %%edi, 0x14(%0);"
144 "mov %%ebx, 0x18(%0)"::
"r"(cc->
stack));
149 #if defined(__clang__) && defined(__SANITIZE_ADDRESS__)
153 for (
int i=0; i < n - 1; i++) {
PN potion_continuation_yield(Potion *P, PN cl, PN self)
#define PN_ALLOC_N(V, T, C)
void potion_cont_init(Potion *P)
struct PNMemory * mem
allocator/gc
void potion_type_call_is(PN vt, PN cl)
sets the default call method of the PNVtable
void * cstack
machine stack start
a continuation saves the stack and all stack pointers.
#define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS
#define PN_MEMCPY_N(X, Y, T, N)
ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS PN potion_callcc(Potion *P, PN cl, PN self)
the global interpreter state P. currently singleton (not threads yet)
struct PNTable * strings
table of all strings
void potion_fatal(char *message)