Skip to content

Commit

Permalink
* core: allow safe compilation on non-x86, although continuations an…
Browse files Browse the repository at this point in the history
…d jit will not function for now.
  • Loading branch information
_why committed Jul 28, 2009
1 parent 0403836 commit 9c12bd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/callcc.c
Expand Up @@ -32,7 +32,7 @@ PN potion_continuation_yield(Potion *P, PN cl, PN self) {
//
// move stack pointer, fill in stack, resume
//
#ifdef POTION_X86
#if POTION_X86 == POTION_JIT_TARGET
#if __WORDSIZE == 64
__asm__ ("mov 0x8(%3), %%rsp;"
"mov 0x10(%3), %%rbp;"
Expand Down Expand Up @@ -105,7 +105,7 @@ PN potion_callcc(Potion *P, PN cl, PN self) {
cc->stack[0] = (PN)sp1;
cc->stack[1] = (PN)sp2;
cc->stack[2] = (PN)sp3;
#ifdef POTION_X86
#if POTION_X86 == POTION_JIT_TARGET
#if __WORDSIZE == 64
__asm__ ("mov %%rbx, 0x18(%0);"
"mov %%r12, 0x20(%0);"
Expand Down
6 changes: 4 additions & 2 deletions core/internal.h
Expand Up @@ -84,7 +84,7 @@ int potion_munmap(void *, size_t);
//
// stack manipulation routines
//
#ifdef POTION_X86
#if POTION_X86 == POTION_JIT_TARGET
#if __WORDSIZE == 64
#define PN_SAVED_REGS 5
#define POTION_ESP(p) __asm__("mov %%rsp, %0" : "=r" (*p))
Expand All @@ -95,8 +95,10 @@ int potion_munmap(void *, size_t);
#define POTION_EBP(p) __asm__("mov %%ebp, %0" : "=r" (*p))
#endif
#else
#define PN_SAVED_REGS 0
__attribute__ ((noinline)) void potion_esp(void **);
#define POTION_ESP(p) potion_esp(p)
#define POTION_ESP(p) potion_esp((void **)p)
#define POTION_EBP(p) potion_esp((void **)p)
#endif

#ifndef O_BINARY
Expand Down
2 changes: 2 additions & 0 deletions core/vm-x86.c
Expand Up @@ -94,6 +94,7 @@ void potion_x86_debug() {
int n = 0;
_PN rax, *rbp, *sp;

#if POTION_X86 == POTION_JIT_TARGET
#if __WORDSIZE != 64
__asm__ ("mov %%eax, %0;"
#else
Expand All @@ -110,6 +111,7 @@ void potion_x86_debug() {
#endif
:"=r"(sp)
);
#endif

P = (Potion *)sp[2];
printf("Potion: %p (%p)\n", P, &P);
Expand Down

0 comments on commit 9c12bd6

Please sign in to comment.