asmacros.h (2579) | asmacros.h (13107) |
---|---|
1/*- 2 * Copyright (c) 1993 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/*- 2 * Copyright (c) 1993 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * $Id: asmacros.h,v 1.4 1994/08/19 11:20:11 jkh Exp $ | 33 * $Id: asmacros.h,v 1.5 1994/09/08 12:25:18 bde Exp $ |
34 */ 35 36#ifndef _MACHINE_ASMACROS_H_ 37#define _MACHINE_ASMACROS_H_ 38 39#ifdef KERNEL 40 | 34 */ 35 36#ifndef _MACHINE_ASMACROS_H_ 37#define _MACHINE_ASMACROS_H_ 38 39#ifdef KERNEL 40 |
41/* XXX too much duplication in various asm*.h's and gprof.h's */ 42 |
|
41#define ALIGN_DATA .align 2 /* 4 byte alignment, zero filled */ 42#define ALIGN_TEXT .align 2,0x90 /* 4-byte alignment, nop filled */ 43#define SUPERALIGN_TEXT .align 4,0x90 /* 16-byte alignment (better for 486), nop filled */ 44 | 43#define ALIGN_DATA .align 2 /* 4 byte alignment, zero filled */ 44#define ALIGN_TEXT .align 2,0x90 /* 4-byte alignment, nop filled */ 45#define SUPERALIGN_TEXT .align 4,0x90 /* 16-byte alignment (better for 486), nop filled */ 46 |
45#define GEN_ENTRY(name) ALIGN_TEXT; .globl name; name: 46#define NON_GPROF_ENTRY(name) GEN_ENTRY(_/**/name) | 47#define GEN_ENTRY(name) ALIGN_TEXT; .globl _/**/name; _/**/name: 48#define NON_GPROF_ENTRY(name) GEN_ENTRY(name) |
47 | 49 |
48/* These three are place holders for future changes to the profiling code */ 49#define MCOUNT_LABEL(name) 50#define MEXITCOUNT 51#define FAKE_MCOUNT(caller) 52 | |
53#ifdef GPROF 54/* | 50#ifdef GPROF 51/* |
55 * ALTENTRY() must be before a corresponding ENTRY() so that it can jump 56 * over the mcounting. | 52 * __mcount is like mcount except that doesn't require its caller to set 53 * up a frame pointer. It must be called before pushing anything onto the 54 * stack. gcc should eventually generate code to call __mcount in most 55 * cases. This would make -pg in combination with -fomit-frame-pointer 56 * useful. gcc has a configuration variable PROFILE_BEFORE_PROLOGUE to 57 * allow profiling before setting up the frame pointer, but this is 58 * inadequate for good handling of special cases, e.g., -fpic works best 59 * with profiling after the prologue. 60 * 61 * Neither __mcount nor mcount requires %eax to point to 4 bytes of data, 62 * so don't waste space allocating the data or time setting it up. Changes 63 * to avoid the wastage in gcc-2.4.5-compiled code are available. 64 * 65 * mexitcount is a new profiling feature to allow accurate timing of all 66 * functions if an accurate clock is available. Changes to gcc-2.4.5 to 67 * support it are are available. The changes currently don't allow not 68 * generating mexitcounts for non-kernel code. It is best to call 69 * mexitcount right at the end of a function like the MEXITCOUNT macro 70 * does, but the changes to gcc only implement calling it as the first 71 * thing in the epilogue to avoid problems with -fpic. 72 * 73 * mcount and __mexitcount may clobber the call-used registers and %ef. 74 * mexitcount may clobber %ecx and %ef. 75 * 76 * Cross-jumping makes accurate timing more difficult. It is handled in 77 * many cases by calling mexitcount before jumping. It is not handled 78 * for some conditional jumps (e.g., in bcopyx) or for some fault-handling 79 * jumps. It is handled for some fault-handling jumps by not sharing the 80 * exit routine. 81 * 82 * ALTENTRY() must be before a corresponding ENTRY() so that it can jump to 83 * the main entry point. Note that alt entries are counted twice. They 84 * have to be counted as ordinary entries for gprof to get the call times 85 * right for the ordinary entries. 86 * 87 * High local labels are used in macros to avoid clashes with local labels 88 * in functions. 89 * 90 * "ret" is used instead of "RET" because there are a lot of "ret"s. 91 * 0xc3 is the opcode for "ret" (#define ret ... ret fails because this 92 * file is preprocessed in traditional mode). "ret" clobbers eflags 93 * but this doesn't matter. |
57 */ | 94 */ |
58#define ALTENTRY(name) GEN_ENTRY(_/**/name); MCOUNT; jmp 2f 59#define ENTRY(name) GEN_ENTRY(_/**/name); MCOUNT; 2: | 95#define ALTENTRY(name) GEN_ENTRY(name) ; MCOUNT ; MEXITCOUNT ; jmp 9f 96#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT 97#define FAKE_MCOUNT(caller) pushl caller ; call __mcount ; popl %ecx 98#define MCOUNT call __mcount 99#define MCOUNT_LABEL(name) GEN_ENTRY(name) ; nop ; ALIGN_TEXT 100#define MEXITCOUNT call mexitcount 101#define ret MEXITCOUNT ; .byte 0xc3 102#else /* not GPROF */ |
60/* | 103/* |
61 * The call to mcount supports the usual (bad) conventions. We allocate 62 * some data and pass a pointer to it although the FreeBSD doesn't use 63 * the data. We set up a frame before calling mcount because that is 64 * the standard convention although it makes work for both mcount and 65 * callers. 66 */ 67#define MCOUNT .data; ALIGN_DATA; 1:; .long 0; .text; \ 68 pushl %ebp; movl %esp,%ebp; \ 69 movl $1b,%eax; call mcount; popl %ebp 70#else 71/* | |
72 * ALTENTRY() has to align because it is before a corresponding ENTRY(). 73 * ENTRY() has to align to because there may be no ALTENTRY() before it. | 104 * ALTENTRY() has to align because it is before a corresponding ENTRY(). 105 * ENTRY() has to align to because there may be no ALTENTRY() before it. |
74 * If there is a previous ALTENTRY() then the alignment code is empty. | 106 * If there is a previous ALTENTRY() then the alignment code for ENTRY() 107 * is empty. |
75 */ | 108 */ |
76#define ALTENTRY(name) GEN_ENTRY(_/**/name) 77#define ENTRY(name) GEN_ENTRY(_/**/name) | 109#define ALTENTRY(name) GEN_ENTRY(name) 110#define ENTRY(name) GEN_ENTRY(name) 111#define FAKE_MCOUNT(caller) |
78#define MCOUNT | 112#define MCOUNT |
113#define MCOUNT_LABEL(name) 114#define MEXITCOUNT 115#endif /* GPROF */ |
|
79 | 116 |
80#endif 81 | 117/* XXX NOP and FASTER_NOP are misleadingly named */ |
82#ifdef DUMMY_NOPS /* this will break some older machines */ 83#define FASTER_NOP 84#define NOP 85#else 86#define FASTER_NOP pushl %eax ; inb $0x84,%al ; popl %eax 87#define NOP pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax 88#endif 89 90#else /* !KERNEL */ 91 92#include "/usr/src/lib/libc/i386/DEFS.h" /* XXX blech */ 93 94#ifndef RCSID 95#define RCSID(a) 96#endif 97 98#endif /* KERNEL */ 99 100#endif /* !_MACHINE_ASMACROS_H_ */ | 118#ifdef DUMMY_NOPS /* this will break some older machines */ 119#define FASTER_NOP 120#define NOP 121#else 122#define FASTER_NOP pushl %eax ; inb $0x84,%al ; popl %eax 123#define NOP pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax 124#endif 125 126#else /* !KERNEL */ 127 128#include "/usr/src/lib/libc/i386/DEFS.h" /* XXX blech */ 129 130#ifndef RCSID 131#define RCSID(a) 132#endif 133 134#endif /* KERNEL */ 135 136#endif /* !_MACHINE_ASMACROS_H_ */ |