From 6e116da468e0909ffcfb97065c8a3ff4efb9a6c5 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 4 Jun 2019 14:09:05 +0100 Subject: [PATCH] Restore assembly code (removed in change 194595) for spilling callee-save registers on fr and li platforms. Copied from Perforce Change: 196178 --- mps/code/ss.h | 65 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/mps/code/ss.h b/mps/code/ss.h index 59543ae7048..513b4e73237 100644 --- a/mps/code/ss.h +++ b/mps/code/ss.h @@ -1,7 +1,7 @@ /* ss.h: STACK SCANNING * * $Id$ - * Copyright (c) 2001-2018 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2019 Ravenbrook Limited. See end of file for license. * * This module saves the mutator context on entry to the MPS, and * provides functions for decoding the context and scanning the root @@ -13,21 +13,12 @@ #include "mpm.h" + +/* StackContext -- some of the mutator's state */ + +typedef struct StackContextStruct StackContextStruct; + -/* 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 - * . - */ - -#include - -typedef struct StackContextStruct { - jmp_buf jumpBuffer; -} StackContextStruct; - - /* StackHot -- capture a hot stack pointer * * Sets *stackOut to a stack pointer that includes the current frame. @@ -59,6 +50,44 @@ void StackHot(void **stackOut); /* STACK_CONTEXT_SAVE -- save the callee-saves and stack pointer */ +#if (defined(MPS_OS_FR) || defined(MPS_OS_LI)) && defined(MPS_ARCH_I3) + +struct StackContextStruct { + Word calleeSave[4]; +}; + +#define STACK_CONTEXT_SAVE(sc) \ + BEGIN \ + __asm__ volatile ("mov %%ebx, %0" : "=m" ((sc)->calleeSave[0])); \ + __asm__ volatile ("mov %%esi, %0" : "=m" ((sc)->calleeSave[1])); \ + __asm__ volatile ("mov %%edi, %0" : "=m" ((sc)->calleeSave[2])); \ + __asm__ volatile ("mov %%ebp, %0" : "=m" ((sc)->calleeSave[3])); \ + END + +#elif (defined(MPS_OS_FR) || defined(MPS_OS_LI)) && defined(MPS_ARCH_I6) + +struct StackContextStruct { + Word calleeSave[6]; +}; + +#define STACK_CONTEXT_SAVE(sc) \ + BEGIN \ + __asm__ volatile ("mov %%rbp, %0" : "=m" ((sc)->calleeSave[0])); \ + __asm__ volatile ("mov %%rbx, %0" : "=m" ((sc)->calleeSave[1])); \ + __asm__ volatile ("mov %%r12, %0" : "=m" ((sc)->calleeSave[2])); \ + __asm__ volatile ("mov %%r13, %0" : "=m" ((sc)->calleeSave[3])); \ + __asm__ volatile ("mov %%r14, %0" : "=m" ((sc)->calleeSave[4])); \ + __asm__ volatile ("mov %%r15, %0" : "=m" ((sc)->calleeSave[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 +103,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 @@ -92,7 +123,7 @@ extern Res StackScan(ScanState ss, void *stackCold, /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2018 Ravenbrook Limited . + * Copyright (C) 2001-2019 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. *