mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 16:51:06 -07:00
Merging recent improvements from custom/cet/main to masters, but carefully excluding inclusion of configura-specific modules in mps.c.
Copied from Perforce Change: 179473 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
0cb0531ed2
commit
6a71263677
7 changed files with 295 additions and 7 deletions
|
|
@ -232,7 +232,7 @@ $(PFM)\$(VARIETY)\zmess.exe: $(PFM)\$(VARIETY)\zmess.obj \
|
|||
$(TESTLIBOBJ)
|
||||
|
||||
$(PFM)\$(VARIETY)\eventcnv.exe: $(PFM)\$(VARIETY)\eventcnv.obj \
|
||||
$(PFM)\$(VARIETY)\eventpro.obj $(MPMOBJ) $(PLINTHOBJ)
|
||||
$(PFM)\$(VARIETY)\eventpro.obj $(PFM)\$(VARIETY)\mps.lib
|
||||
|
||||
$(PFM)\$(VARIETY)\replay.exe: $(PFM)\$(VARIETY)\replay.obj \
|
||||
$(PFM)\$(VARIETY)\eventrep.obj \
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ typedef struct PoolDebugMixinStruct *PoolDebugMixin;
|
|||
typedef struct AllocPatternStruct *AllocPattern;
|
||||
typedef struct AllocFrameStruct *AllocFrame; /* <design/alloc-frame/> */
|
||||
typedef struct ReservoirStruct *Reservoir; /* <design/reservoir/> */
|
||||
typedef struct StackContextStruct *StackContext;
|
||||
|
||||
|
||||
/* Arena*Method -- see <code/mpmst.h#ArenaClassStruct> */
|
||||
|
|
|
|||
205
mps/code/sc.h
Normal file
205
mps/code/sc.h
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/* sc.h: STACK CONTEXT
|
||||
*
|
||||
* $Id$
|
||||
* Copyright (c) 2012 Ravenbrook Limited. See end of file for license.
|
||||
*
|
||||
* Provides a context to hold the registers and stack pointer
|
||||
*
|
||||
* This file provide wrappers for using setjmp or some similar mechanism
|
||||
* to save the current callee-saves on the stack.
|
||||
*
|
||||
* See http://info.ravenbrook.com/mail/2012/08/03/14-36-35/0/ and the rest of
|
||||
* the thread for the origin of the idea.
|
||||
*
|
||||
* TODO: Make StackScan take a StackContext
|
||||
*/
|
||||
|
||||
#ifndef sc_h
|
||||
#define sc_h
|
||||
|
||||
#include "mpm.h"
|
||||
|
||||
|
||||
/* StackContext -- holds the registers including a stack pointer
|
||||
*
|
||||
* This contains the callee-save registers and the stack pointer.
|
||||
*
|
||||
* This is used to save the registers after or on entry to the arena so that
|
||||
* they can be scanned.
|
||||
*/
|
||||
|
||||
/* STACK_CONTEXT_SAVE - save the callee-saves and stack pointer
|
||||
*
|
||||
* This macro saves the callee-saves and stack pointer for the
|
||||
* current function into the passed StackContext. The StackContext
|
||||
* is no longer valid after the function returns.
|
||||
*
|
||||
* This needs to be a macro because the compiler may need to do
|
||||
* setjmp magic.
|
||||
*/
|
||||
|
||||
/* StackContextStackTop - return the stack top from the stack context.
|
||||
*
|
||||
* We assume the stack is full. In other words the stack top points at
|
||||
* a word that contains a potential Ref.
|
||||
*/
|
||||
|
||||
|
||||
/* Mac OS X on 32-bit Intel built with Clang or GCC */
|
||||
|
||||
#if defined(MPS_PF_XCI3LL) || defined(MPS_PF_XCI3GC)
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
typedef struct StackContextStruct {
|
||||
jmp_buf jumpBuffer;
|
||||
} StackContextStruct;
|
||||
|
||||
/* See the implementation of _setjmp in
|
||||
* <http://www.opensource.apple.com/source/Libc/Libc-825.24/i386/sys/_setjmp.s> */
|
||||
|
||||
#define JB_ESP 36 /* offset into the jmp_buf in bytes as defined in _setjmp.s */
|
||||
|
||||
#define STACK_CONTEXT_SAVE(sc) ((void)_setjmp((sc)->jumpBuffer))
|
||||
|
||||
#define StackContextSP(sc) ((Addr *)(sc)->jumpBuffer[JB_ESP/sizeof(int)])
|
||||
|
||||
/* On MacOS X the stackPointer can end up pointing above the StackContext
|
||||
* which we assume to be stored on the stack because it is no longer
|
||||
* needed once we have _longjmp()ed back. So take the minimum of the
|
||||
* SP and the base of the StackContext structure. */
|
||||
#define StackContextStackTop(sc) \
|
||||
(StackContextSP(sc) < (Addr*)(sc) ? StackContextSP(sc) : (Addr*)(sc))
|
||||
|
||||
|
||||
/* Mac OS X on 64-bit Intel build with Clang or GCC */
|
||||
|
||||
#elif defined(MPS_PF_XCI6LL) || defined(MPS_PF_XCI6GC)
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
/* We could use getcontext() from libunwind but that produces
|
||||
* deprecation warnings. See
|
||||
* <http://stackoverflow.com/questions/3592914/how-can-i-implement-cooperative-lightweight-threading-with-c-on-mac-os-x>
|
||||
*/
|
||||
|
||||
typedef struct StackContextStruct {
|
||||
jmp_buf jumpBuffer;
|
||||
} StackContextStruct;
|
||||
|
||||
/* See the implementation of _setjmp in
|
||||
* <http://www.opensource.apple.com/source/Libc/Libc-825.24/x86_64/sys/_setjmp.s> */
|
||||
|
||||
#define STACK_CONTEXT_SAVE(sc) ((void)_setjmp((sc)->jumpBuffer))
|
||||
|
||||
#define JB_RSP 16 /* offset into the jmp_buf in bytes as defined in _setjmp.s */
|
||||
|
||||
/* jmp_buf is an int[] but the stack pointer is 8 bytes so we need a cast */
|
||||
/* FIXME: possible aliasing problem */
|
||||
#define StackContextSP(sc) \
|
||||
(*(Addr **)((char *)(sc)->jumpBuffer+JB_RSP))
|
||||
|
||||
/* On MacOS X the stackPointer can end up pointing above the StackContext
|
||||
* which we assume to be stored on the stack because it is no longer
|
||||
* needed once we have _longjmp()ed back. So take the minimum of the
|
||||
* SP and the base of the StackContext structure. */
|
||||
#define StackContextStackTop(sc) \
|
||||
(StackContextSP(sc) < (Addr*)(sc) ? StackContextSP(sc) : (Addr*)(sc))
|
||||
|
||||
|
||||
/* Windows on 32-bit Intel with Microsoft Visual Studio */
|
||||
|
||||
#elif defined(MPS_PF_W3I3MV)
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
typedef struct StackContextStruct {
|
||||
jmp_buf jumpBuffer;
|
||||
} StackContextStruct;
|
||||
|
||||
#define STACK_CONTEXT_SAVE(sc) ((void)setjmp((sc)->jumpBuffer))
|
||||
|
||||
#define StackContextStackTop(sc) \
|
||||
((Addr *)((_JUMP_BUFFER *)(sc)->jumpBuffer)->Esp)
|
||||
|
||||
|
||||
/* Windows on 64-bit Intel with Microsoft Visual Studio */
|
||||
|
||||
#elif defined(MPS_PF_W3I6MV)
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
typedef struct StackContextStruct {
|
||||
jmp_buf jumpBuffer;
|
||||
} StackContextStruct;
|
||||
|
||||
#define STACK_CONTEXT_SAVE(sc) ((void)setjmp((sc)->jumpBuffer))
|
||||
|
||||
#define StackContextStackTop(sc) \
|
||||
((Addr *)((_JUMP_BUFFER *)(sc)->jumpBuffer)->Rsp)
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/* TODO: implement this on other platforms in a safer way.
|
||||
* Potentially the callee saves from the calling function could be spilled
|
||||
* underneath the jmp_buf so returning the address of the jmp_buf for the
|
||||
* stack top is not completely safe.
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
typedef struct StackContextStruct {
|
||||
jmp_buf jumpBuffer;
|
||||
} StackContextStruct;
|
||||
|
||||
#define STACK_CONTEXT_SAVE(sc) ((void)setjmp((sc)->jumpBuffer))
|
||||
|
||||
#define StackContextStackTop(sc) ((Addr *)(sc)->jumpBuffer)
|
||||
|
||||
|
||||
#endif /* platform defines */
|
||||
|
||||
#endif /* sc_h */
|
||||
|
||||
|
||||
/* C. COPYRIGHT AND LICENSE
|
||||
*
|
||||
* Copyright (C) 2001-2012 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
* All rights reserved. This is an open source license. Contact
|
||||
* Ravenbrook for commercial licensing options.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Redistributions in any form must be accompanied by information on how
|
||||
* to obtain complete source code for this software and any accompanying
|
||||
* software that uses this software. The source code must either be
|
||||
* included in the distribution or be available for no more than the cost
|
||||
* of distribution plus a nominal fee, and must be freely redistributable
|
||||
* under reasonable conditions. For an executable file, complete source
|
||||
* code means the source code for all modules it contains. It does not
|
||||
* include source code for modules or files that typically accompany the
|
||||
* major components of the operating system on which the executable file
|
||||
* runs.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* ssw3mv.c: STACK SCANNING FOR WIN32 WITH MICROSOFT C
|
||||
/* ssw3i3mv.c: STACK SCANNING FOR WIN32 WITH MICROSOFT C
|
||||
*
|
||||
* $Id$
|
||||
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#include "mpm.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
SRCID(ssw3mv, "$Id$");
|
||||
SRCID(ssw3i3mv, "$Id$");
|
||||
|
||||
|
||||
Res StackScan(ScanState ss, Addr *stackBot)
|
||||
|
|
@ -42,3 +42,44 @@ Res StackScan(ScanState ss, Addr *stackBot)
|
|||
|
||||
return StackScanInner(ss, stackBot, (Addr *)&((_JUMP_BUFFER *)jb)->Ebx, 3);
|
||||
}
|
||||
|
||||
/* C. COPYRIGHT AND LICENSE
|
||||
*
|
||||
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
* All rights reserved. This is an open source license. Contact
|
||||
* Ravenbrook for commercial licensing options.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Redistributions in any form must be accompanied by information on how
|
||||
* to obtain complete source code for this software and any accompanying
|
||||
* software that uses this software. The source code must either be
|
||||
* included in the distribution or be available for no more than the cost
|
||||
* of distribution plus a nominal fee, and must be freely redistributable
|
||||
* under reasonable conditions. For an executable file, complete source
|
||||
* code means the source code for all modules it contains. It does not
|
||||
* include source code for modules or files that typically accompany the
|
||||
* major components of the operating system on which the executable file
|
||||
* runs.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* ssw3mv.c: STACK SCANNING FOR WIN32 WITH MICROSOFT C
|
||||
/* ssw3i6mv.c: STACK SCANNING FOR WIN32 WITH MICROSOFT C
|
||||
*
|
||||
* $Id$
|
||||
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#include "mpm.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
SRCID(ssw3mv, "$Id$");
|
||||
SRCID(ssw3i6mv, "$Id$");
|
||||
|
||||
|
||||
Res StackScan(ScanState ss, Addr *stackBot)
|
||||
|
|
@ -61,3 +61,44 @@ Res StackScan(ScanState ss, Addr *stackBot)
|
|||
|
||||
return StackScanInner(ss, stackBot, (Addr *)&((_JUMP_BUFFER *)jb)->Rbx, 9);
|
||||
}
|
||||
|
||||
/* C. COPYRIGHT AND LICENSE
|
||||
*
|
||||
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
* All rights reserved. This is an open source license. Contact
|
||||
* Ravenbrook for commercial licensing options.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Redistributions in any form must be accompanied by information on how
|
||||
* to obtain complete source code for this software and any accompanying
|
||||
* software that uses this software. The source code must either be
|
||||
* included in the distribution or be available for no more than the cost
|
||||
* of distribution plus a nominal fee, and must be freely redistributable
|
||||
* under reasonable conditions. For an executable file, complete source
|
||||
* code means the source code for all modules it contains. It does not
|
||||
* include source code for modules or files that typically accompany the
|
||||
* major components of the operating system on which the executable file
|
||||
* runs.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ MPM = <ring> <mpm> <bt> <protocol> <boot> \
|
|||
<shield> <vmw3> <table> \
|
||||
<thw3> <thw3i3> <ss> <ssw3i3mv> <mpsi> <mpsiw3> <ld> <spi3> \
|
||||
<event> <seg> <sac> <poolmrg> <message> <dbgpool> <dbgpooli> \
|
||||
<abq> <meter> <cbs> <poolmv2> <splay> <diag> <version>
|
||||
<abq> <meter> <cbs> <poolmv2> <splay> <diag>
|
||||
PLINTH = <mpsliban> <mpsioan>
|
||||
AMC = <poolamc>
|
||||
AMS = <poolams> <poolamsi>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ MPM = <ring> <mpm> <bt> <protocol> <boot> \
|
|||
<shield> <vmw3> <table> \
|
||||
<thw3> <thw3i6> <ss> <ssw3i6mv> <mpsi> <mpsiw3> <ld> <span> \
|
||||
<event> <seg> <sac> <poolmrg> <message> <dbgpool> <dbgpooli> \
|
||||
<abq> <meter> <cbs> <poolmv2> <splay> <diag> <version>
|
||||
<abq> <meter> <cbs> <poolmv2> <splay> <diag>
|
||||
PLINTH = <mpsliban> <mpsioan>
|
||||
AMC = <poolamc>
|
||||
AMS = <poolams> <poolamsi>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue