diff --git a/mps/src/sslii3.c b/mps/src/sslii3.c index 382a8e174c0..23e0f25c2a2 100644 --- a/mps/src/sslii3.c +++ b/mps/src/sslii3.c @@ -1,6 +1,6 @@ /* impl.c.sslii3: LINUX/INTEL STACK SCANNING * - * $HopeName: $ + * $HopeName: MMsrc!sslii3.c(trunk.1) $ * Copyright (C) 1999. Harlequin Group plc. All rights reserved. * * This scans the stack and fixes the registers which may contain @@ -10,17 +10,31 @@ * across function calls and therefore may contain roots. * These are pushed on the stack for scanning. * + * SOURCES + * + * .source.callees.saves: Set of callee-saved registers taken from + * CALL_USED_REGISTERS in /config/i386/i386.h. + * * ASSUMPTIONS * - * .align: The stack pointer is assumed to be aligned on a word + * .assume.align: The stack pointer is assumed to be aligned on a word * boundary. + * + * .assume.asm.stack: The compiler must not do wacky things with the + * stack pointer around a call since we need to ensure that the + * callee-save regs are visible during TraceScanArea. + * + * .assume.asm.order: The volatile modifier should prevent movement + * of code, which might break .assume.asm.stack. + * */ #include "mpm.h" -SRCID(sslii3, "$HopeName: $"); +SRCID(sslii3, "$HopeName: MMsrc!sslii3.c(trunk.1) $"); +/* .assume.asm.order */ #define ASMV(x) __asm__ volatile (x) @@ -29,15 +43,16 @@ Res StackScan(ScanState ss, Addr *stackBot) Addr *stackTop; Res res; - ASMV("push %ebx"); /* these registers are the save registers */ + /* .assume.asm.stack */ + ASMV("push %ebx"); /* These registers are callee-saved */ ASMV("push %esi"); /* and so may contain roots. They are pushed */ - ASMV("push %edi"); /* for scanning */ - ASMV("mov %%esp, %0" : "=r" (stackTop) :); /* stack pointer */ + ASMV("push %edi"); /* for scanning. See .source.callees.saves. */ + ASMV("mov %%esp, %0" : "=r" (stackTop) :); /* stackTop = esp */ - AVER(AddrIsAligned((Addr)stackTop, sizeof(Addr))); /* .align */ + AVER(AddrIsAligned((Addr)stackTop, sizeof(Addr))); /* .assume.align */ res = TraceScanArea(ss, stackTop, stackBot); - ASMV("add $12, %esp"); /* pop 3 registers to restore the stack pointer */ + ASMV("add $12, %esp"); /* pop 3 regs to restore the stack pointer */ return res; }