diff --git a/code/ss.h b/code/ss.h index f05ff67b62..32b083001f 100644 --- a/code/ss.h +++ b/code/ss.h @@ -14,18 +14,9 @@ #include "mpm.h" -/* StackContext -- some of the mutator's state - * - * The jumpBuffer is used to capture most of the mutator's state on - * entry to the MPS, but can't capture it all. See - * . - */ +/* StackContext -- some of the mutator's state */ -#include - -typedef struct StackContextStruct { - jmp_buf jumpBuffer; -} StackContextStruct; +typedef struct StackContextStruct StackContextStruct; /* StackHot -- capture a hot stack pointer @@ -33,6 +24,7 @@ typedef struct StackContextStruct { * Sets *stackOut to a stack pointer that includes the current frame. */ +ATTRIBUTE_NOINLINE void StackHot(void **stackOut); @@ -59,6 +51,46 @@ void StackHot(void **stackOut); /* STACK_CONTEXT_SAVE -- save the callee-saves and stack pointer */ +#if (defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL)) && defined(MPS_ARCH_I3) + +struct StackContextStruct { + Word calleeSave[4]; +}; + +#define STACK_CONTEXT_SAVE(sc) \ + BEGIN \ + Word *_save = (sc)->calleeSave; \ + __asm__ volatile ("mov %%ebx, %0" : "=m" (_save[0])); \ + __asm__ volatile ("mov %%esi, %0" : "=m" (_save[1])); \ + __asm__ volatile ("mov %%edi, %0" : "=m" (_save[2])); \ + __asm__ volatile ("mov %%ebp, %0" : "=m" (_save[3])); \ + END + +#elif (defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL)) && defined(MPS_ARCH_I6) + +struct StackContextStruct { + Word calleeSave[6]; +}; + +#define STACK_CONTEXT_SAVE(sc) \ + BEGIN \ + Word *_save = (sc)->calleeSave; \ + __asm__ volatile ("mov %%rbp, %0" : "=m" (_save[0])); \ + __asm__ volatile ("mov %%rbx, %0" : "=m" (_save[1])); \ + __asm__ volatile ("mov %%r12, %0" : "=m" (_save[2])); \ + __asm__ volatile ("mov %%r13, %0" : "=m" (_save[3])); \ + __asm__ volatile ("mov %%r14, %0" : "=m" (_save[4])); \ + __asm__ volatile ("mov %%r15, %0" : "=m" (_save[5])); \ + END + +#else /* jmp_buf platforms */ + +#include + +struct StackContextStruct { + jmp_buf jumpBuffer; +}; + #if defined(MPS_OS_XC) /* We call _setjmp rather than setjmp because we can be confident what @@ -74,7 +106,9 @@ void StackHot(void **stackOut); #define STACK_CONTEXT_SAVE(sc) ((void)setjmp((sc)->jumpBuffer)) -#endif /* platform defines */ +#endif /* jmp_buf platforms */ + +#endif /* platform specific code */ /* StackScan -- scan the mutator's stack and registers @@ -84,7 +118,7 @@ void StackHot(void **stackOut); */ extern Res StackScan(ScanState ss, void *stackCold, - mps_area_scan_t scan_area, void *closure); + mps_area_scan_t scan_area, void *closure); #endif /* ss_h */ diff --git a/design/stack-scan-areas.svg b/design/stack-scan-areas.svg index 285cdad802..020bc43eec 100644 --- a/design/stack-scan-areas.svg +++ b/design/stack-scan-areas.svg @@ -13,7 +13,7 @@ height="441.15668pt" id="svg1343" sodipodi:docname="stack-scan-areas.svg" - inkscape:version="0.92.2 5c3e80d, 2017-08-06"> + inkscape:version="0.91 r13725"> image/svg+xml - + @@ -346,16 +346,15 @@ style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1" /> + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Normal';text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-dasharray:none;stroke-opacity:1" + x="176.9048" + y="231.14665" + sodipodi:linespacing="125%"> jmp_buf + sodipodi:role="line" + id="tspan4344" + x="176.9048" + y="231.14665">StackContextStruct