From a7d00b5bf6e6faab2997c47a926bb97fdce0f091 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Thu, 13 Feb 1997 10:47:29 +0000 Subject: [PATCH] Moved definition of FUNCTION_ALIGNMENT to a machine-dependent place. Changed it from 4 to 16 for i386's. It can be anything for i386's, but compiler options limit it to a power of 2, and assembler and linker deficiencies limit it to a small power of 2 (<= 16). We use 16 in the kernel to get smaller tables (see Makefile.i386 and ). We still use the default of 4 in user mode. Use HISTCOUNTER instead of (*kcount) in the definition of KCOUNT() for consistency with other macros. --- sys/amd64/include/profile.h | 10 +++++++++- sys/i386/include/profile.h | 10 +++++++++- sys/sys/gmon.h | 5 ----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sys/amd64/include/profile.h b/sys/amd64/include/profile.h index 2dc78d9d6c7..3247d148661 100644 --- a/sys/amd64/include/profile.h +++ b/sys/amd64/include/profile.h @@ -38,6 +38,12 @@ #define _MACHINE_PROFILE_H_ #ifdef KERNEL +/* + * Config generates something to tell the compiler to align functions on 16 + * byte boundaries. A strict alignment is good for keeping the tables small. + */ +#define FUNCTION_ALIGNMENT 16 + /* * The kernel uses assembler stubs instead of unportable inlines. * This is mainly to save a little time when profiling is not enabled, @@ -49,7 +55,7 @@ #ifdef GUPROF #define CALIB_SCALE 1000 #define KCOUNT(p,index) ((p)->kcount[(index) \ - / (HISTFRACTION * sizeof(*(p)->kcount))]) + / (HISTFRACTION * sizeof(HISTCOUNTER))]) #define MCOUNT_DECL(s) #define MCOUNT_ENTER(s) #define MCOUNT_EXIT(s) @@ -62,6 +68,8 @@ #else /* !KERNEL */ +#define FUNCTION_ALIGNMENT 4 + #define _MCOUNT_DECL static __inline void _mcount #define MCOUNT \ diff --git a/sys/i386/include/profile.h b/sys/i386/include/profile.h index 2dc78d9d6c7..3247d148661 100644 --- a/sys/i386/include/profile.h +++ b/sys/i386/include/profile.h @@ -38,6 +38,12 @@ #define _MACHINE_PROFILE_H_ #ifdef KERNEL +/* + * Config generates something to tell the compiler to align functions on 16 + * byte boundaries. A strict alignment is good for keeping the tables small. + */ +#define FUNCTION_ALIGNMENT 16 + /* * The kernel uses assembler stubs instead of unportable inlines. * This is mainly to save a little time when profiling is not enabled, @@ -49,7 +55,7 @@ #ifdef GUPROF #define CALIB_SCALE 1000 #define KCOUNT(p,index) ((p)->kcount[(index) \ - / (HISTFRACTION * sizeof(*(p)->kcount))]) + / (HISTFRACTION * sizeof(HISTCOUNTER))]) #define MCOUNT_DECL(s) #define MCOUNT_ENTER(s) #define MCOUNT_EXIT(s) @@ -62,6 +68,8 @@ #else /* !KERNEL */ +#define FUNCTION_ALIGNMENT 4 + #define _MCOUNT_DECL static __inline void _mcount #define MCOUNT \ diff --git a/sys/sys/gmon.h b/sys/sys/gmon.h index 71bc9106995..9014ecc23b7 100644 --- a/sys/sys/gmon.h +++ b/sys/sys/gmon.h @@ -68,12 +68,7 @@ struct gmonhdr { * addresses, so that each counter belongs to a unique function. * A lower density of counters would give less resolution but a * higher density would be wasted. - * - * Assume that function addresses are at least 4-byte-aligned. - * It would be better to get the linker to align functions more - * strictly so that we could use smaller tables. */ -#define FUNCTION_ALIGNMENT 4 #define HISTFRACTION (FUNCTION_ALIGNMENT / sizeof(HISTCOUNTER) == 0 \ ? 1 : FUNCTION_ALIGNMENT / sizeof(HISTCOUNTER))