diff options
| author | Richard Brooksby | 2012-09-12 13:18:41 +0100 |
|---|---|---|
| committer | Richard Brooksby | 2012-09-12 13:18:41 +0100 |
| commit | a9bcf5293bf963cdd4e3fa159c12bbaf957e5fc2 (patch) | |
| tree | d18bd1e00a0689028e80a1da0f0a9318d3dd4094 /mps/code | |
| parent | c4d25ec6e6a7800fb2dbeafc9de606587343da70 (diff) | |
| download | emacs-a9bcf5293bf963cdd4e3fa159c12bbaf957e5fc2.tar.gz emacs-a9bcf5293bf963cdd4e3fa159c12bbaf957e5fc2.zip | |
Reverting to assembler method of saving callee-save registers for stack scan on w3i3mv to avoid c run-time dependency that breaks open dylan bootstrap.
Copied from Perforce
Change: 179439
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rwxr-xr-x | mps/code/ssw3i3mv.c | 94 |
1 files changed, 75 insertions, 19 deletions
diff --git a/mps/code/ssw3i3mv.c b/mps/code/ssw3i3mv.c index e09b53ec620..d33bc378e46 100755 --- a/mps/code/ssw3i3mv.c +++ b/mps/code/ssw3i3mv.c | |||
| @@ -1,35 +1,91 @@ | |||
| 1 | /* ssw3mv.c: STACK SCANNING FOR WIN32 WITH MICROSOFT C | 1 | /* ssw3i3.c: WIN32/INTEL STACK SCANNING |
| 2 | * | 2 | * |
| 3 | * $Id$ | 3 | * $Id$ |
| 4 | * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. | 4 | * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. |
| 5 | * | 5 | * |
| 6 | * This scans the stack and fixes the registers which may contain roots. | 6 | * This scans the stack and fixes the registers which may contain |
| 7 | * See <design/thread-manager/>. | 7 | * roots. See <design/thread-manager/>. |
| 8 | * | ||
| 9 | * The registers edi, esi, ebx are the registers defined to be preserved | ||
| 10 | * across function calls and therefore may contain roots. | ||
| 11 | * These are pushed on the stack for scanning. | ||
| 12 | * | ||
| 13 | * ASSUMPTIONS | ||
| 14 | * | ||
| 15 | * .align: The stack pointer is assumed to be aligned on a word | ||
| 16 | * boundary. | ||
| 8 | */ | 17 | */ |
| 9 | 18 | ||
| 19 | |||
| 10 | #include "mpm.h" | 20 | #include "mpm.h" |
| 11 | #include <setjmp.h> | ||
| 12 | 21 | ||
| 13 | SRCID(ssw3mv, "$Id$"); | 22 | SRCID(ssw3i3, "$Id$"); |
| 14 | 23 | ||
| 15 | 24 | ||
| 16 | Res StackScan(ScanState ss, Addr *stackBot) | 25 | Res StackScan(ScanState ss, Addr *stackBot) |
| 17 | { | 26 | { |
| 18 | jmp_buf jb; | 27 | Addr *stackTop; |
| 19 | 28 | Res res; | |
| 20 | /* We rely on the fact that Microsoft C's setjmp stores the callee-save | 29 | |
| 21 | registers in the jmp_buf. */ | 30 | /* NOTE: We would like to use the same `setjmp` trick as ssw3i6mv.c here, |
| 22 | (void)setjmp(jb); | 31 | to avoid assembler, but this introduces a dependency on the C run-time |
| 32 | in Open Dylan on Windows, probably because of ancient build tools. So | ||
| 33 | I have reverted to the assembler method for now. RB 2012-09-12 */ | ||
| 23 | 34 | ||
| 24 | /* These checks will just serve to warn us at compile-time if the | 35 | __asm { |
| 25 | setjmp.h header changes to indicate that the registers we want aren't | 36 | push edi /* these registers are the save registers */ |
| 26 | saved any more. */ | 37 | push esi /* and so may contain roots. They are pushed */ |
| 27 | AVER(sizeof(((_JUMP_BUFFER *)jb)->Edi) == sizeof(Addr)); | 38 | push ebx /* for scanning */ |
| 28 | AVER(sizeof(((_JUMP_BUFFER *)jb)->Esi) == sizeof(Addr)); | 39 | mov stackTop, esp /* stack pointer */ |
| 29 | AVER(sizeof(((_JUMP_BUFFER *)jb)->Ebx) == sizeof(Addr)); | 40 | } |
| 41 | |||
| 42 | res = StackScanInner(ss, stackBot, stackTop, 3); | ||
| 30 | 43 | ||
| 31 | AVER(offsetof(_JUMP_BUFFER, Edi) == offsetof(_JUMP_BUFFER, Ebx) + 4); | 44 | __asm { |
| 32 | AVER(offsetof(_JUMP_BUFFER, Esi) == offsetof(_JUMP_BUFFER, Ebx) + 8); | 45 | add esp, 0xc /* pop 3 registers to restore the stack pointer */ |
| 46 | } | ||
| 33 | 47 | ||
| 34 | return StackScanInner(ss, stackBot, (Addr *)&((_JUMP_BUFFER *)jb)->Ebx, 3); | 48 | return res; |
| 35 | } | 49 | } |
| 50 | |||
| 51 | |||
| 52 | /* C. COPYRIGHT AND LICENSE | ||
| 53 | * | ||
| 54 | * Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. | ||
| 55 | * All rights reserved. This is an open source license. Contact | ||
| 56 | * Ravenbrook for commercial licensing options. | ||
| 57 | * | ||
| 58 | * Redistribution and use in source and binary forms, with or without | ||
| 59 | * modification, are permitted provided that the following conditions are | ||
| 60 | * met: | ||
| 61 | * | ||
| 62 | * 1. Redistributions of source code must retain the above copyright | ||
| 63 | * notice, this list of conditions and the following disclaimer. | ||
| 64 | * | ||
| 65 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 66 | * notice, this list of conditions and the following disclaimer in the | ||
| 67 | * documentation and/or other materials provided with the distribution. | ||
| 68 | * | ||
| 69 | * 3. Redistributions in any form must be accompanied by information on how | ||
| 70 | * to obtain complete source code for this software and any accompanying | ||
| 71 | * software that uses this software. The source code must either be | ||
| 72 | * included in the distribution or be available for no more than the cost | ||
| 73 | * of distribution plus a nominal fee, and must be freely redistributable | ||
| 74 | * under reasonable conditions. For an executable file, complete source | ||
| 75 | * code means the source code for all modules it contains. It does not | ||
| 76 | * include source code for modules or files that typically accompany the | ||
| 77 | * major components of the operating system on which the executable file | ||
| 78 | * runs. | ||
| 79 | * | ||
| 80 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| 81 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
| 82 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
| 83 | * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 84 | * COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 85 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 86 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
| 87 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
| 88 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 89 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 90 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 91 | */ | ||