File: profile.h

package info (click to toggle)
rscheme 0.7.2-1.1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 10,672 kB
  • ctags: 12,430
  • sloc: lisp: 37,104; ansic: 29,763; cpp: 2,630; sh: 1,677; makefile: 568; yacc: 202; lex: 175; perl: 33
file content (246 lines) | stat: -rw-r--r-- 5,563 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*-----------------------------------------------------------------*-C-*---
 * File:    handc/runtime/profile.h
 *
 *          Copyright (C)1997 Donovan Kolbly <d.kolbly@rscheme.org>
 *          as part of the RScheme project, licensed for free use.
 *          See <http://www.rscheme.org/> for the latest information.
 *
 * File version:     1.6
 * File mod date:    1997.11.29 23:10:51
 * System build:     v0.7.2, 97.12.21
 *
 *------------------------------------------------------------------------*/

#ifndef _H_RSCHEME_PROFILE
#define _H_RSCHEME_PROFILE

/*  the profile analyzer tool doesn't want all the runtime system's
 *  types and prototypes...
 *  (in which case, they are responsible for providing appropriate
 *   definitions for the RS_pr_tag and RS_pr_tstamp types)
 */

#ifndef PROFILING_RECORD_STRUCTS_ONLY

/*******************************************************************/

#include <rscheme/obj.h>

typedef obj RS_pr_tag;

#ifdef PLATFORM_MAC

struct timeval { 
  long int tv_sec;
  long int tv_usec;
};
typedef struct { UINT_32 t1, t2; } RS_pr_tstamp;

#else

#include <sys/time.h>
/*#ifdef HAVE_INT_64*/
#if 1
typedef unsigned long long RS_pr_tstamp;
#else
typedef struct { UINT_32 t1, t2; } RS_pr_tstamp;
#endif
#endif /* PLATFORM_MAC */

RS_pr_tstamp rsprof_time( void );

extern obj collect_gf_cache_histogram( rs_bool reset_q );

#define STMT(body) do { body } while (0)

/************************ Profiling Support ************************/

#if PROFILING_HOOKS

/* declare profiling hooks we are going to use */
extern int rsprof_active;

/* hooks to indicate how the current monotone is being exited... */
void rsprof_mt_calls( obj proc, obj tmpl );
void rsprof_mt_returns( void );
void rsprof_mt_bjumps( void );
void rsprof_mt_jumps( void );
void rsprof_mt_fails( void );
void rsprof_mt_intr( void );

/* hooks to keep track of the stack state */
void rsprof_saves( void );
void rsprof_contn_captured( obj contn );
void rsprof_contn_restored( obj contn );

/* hooks to time the execution of monotones */
void rsprof_mt_start( jump_addr entry_pt );
void rsprof_mt_done( void );
void rsprof_gc_work( void );

/* hooks to monitor object allocation and lifetimes */

void rsprof_obj_alloced( obj thing, obj a_class, UINT_32 size );
void rsprof_obj_died( obj thing );

void rsprof_timepoint( int id );

#if 0 /* ...still provided by timeprof.h and friends... */
#define timepoint(id) STMT( if(rsprof_active) rsprof_timepoint(id); )
#endif

#else

#define rsprof_active            (0)

#define rsprof_mt_calls(x,y)     STMT(;)
#define rsprof_mt_returns()      STMT(;)
#define rsprof_mt_bjumps()       STMT(;)
#define rsprof_mt_jumps()        STMT(;)
#define rsprof_mt_fails()        STMT(;)
#define rsprof_mt_intr()         STMT(;)

#define rsprof_saves()           STMT(;)
#define rsprof_contn_captured(c) STMT(;)
#define rsprof_contn_restored(c) STMT(;)

#define rsprof_mt_start(e)       STMT(;)
#define rsprof_mt_done()         STMT(;)
#define rsprof_gc_work()         STMT(;)

#define rsprof_obj_alloced(t,c,s) STMT(;)
#define rsprof_obj_died(t)       STMT(;)

#define rsprof_timepoint(id)     STMT(;)

#endif
#endif /* PROFILING_RECORD_STRUCTS_ONLY */

/* these are available even in profiling is not enabled to support
 * profile dump post-processing by normal code (using the profile-parse-next
 * glue function)
 */

enum RS_profile_code {
  RSPROF_DECL_NAME = 61,  /* '=' */
  RSPROF_NOP = 0x40,
  RSPROF_MT_CALLS,   /* A */
  RSPROF_MT_RETURNS,
  RSPROF_MT_BJUMPS,
  RSPROF_MT_JUMPS,
  RSPROF_MT_FAILS,
  RSPROF_MT_INTR,
  RSPROF_MT_START,
  RSPROF_MT_DONE,
  RSPROF_GC_WORK,    /* I */
  RSPROF_SAVES,
  RSPROF_CAPTURED,
  RSPROF_RESTORED,
  RSPROF_CAL_START,  /* M */
  RSPROF_CAL_STOP,   /* N */
  RSPROF_OBJ_ALLOCED,/* O */
  RSPROF_OBJ_DIED,   /* P */
  RSPROF_CAL_REALTIME
};

struct RS_pr_header {
  enum RS_profile_code  code : 8;
  unsigned         var_len   : 8;
  unsigned         rec_bytes : 16;
};

struct RS_pr_DECL_NAME {
  struct RS_pr_header  hdr;
  RS_pr_tag          item;
  unsigned char      name[4];
};

struct RS_pr_NOP {
  struct RS_pr_header  hdr;
};

struct RS_pr_MT_CALLS {
  struct RS_pr_header  hdr;
  RS_pr_tag          tmpl;
  unsigned short     argc;
};

struct RS_pr_MT_RETURNS {
  struct RS_pr_header  hdr;
};

struct RS_pr_MT_BJUMPS {
  struct RS_pr_header  hdr;
};

struct RS_pr_MT_JUMPS {
  struct RS_pr_header  hdr;
};

struct RS_pr_MT_FAILS {
  struct RS_pr_header  hdr;
};

struct RS_pr_MT_INTR {
  struct RS_pr_header  hdr;
};

struct RS_pr_MT_START {
  struct RS_pr_header  hdr;
  RS_pr_tstamp       tstamp;
  RS_pr_tag          tmpl;
};

struct RS_pr_MT_DONE {
  struct RS_pr_header  hdr;
  RS_pr_tstamp       tstamp;
};

struct RS_pr_GC_WORK {
  struct RS_pr_header  hdr;
  RS_pr_tstamp       tstamp;
};

struct RS_pr_SAVES {
  struct RS_pr_header  hdr;
};

struct RS_pr_CAPTURED {
  struct RS_pr_header  hdr;
  RS_pr_tag          contn;
};

struct RS_pr_RESTORED {
  struct RS_pr_header  hdr;
  RS_pr_tag          contn;
};

struct RS_pr_CAL_START {
  struct RS_pr_header  hdr;
  RS_pr_tstamp       tstamp;
};

struct RS_pr_CAL_STOP {
  struct RS_pr_header  hdr;
  RS_pr_tstamp       tstamp;
};

struct RS_pr_CAL_REALTIME {
  struct RS_pr_header  hdr;
  RS_pr_tstamp       tstamp;
  struct timeval     systime;
};

struct RS_pr_OBJ_ALLOCED {
  struct RS_pr_header  hdr;
  RS_pr_tag          item;
  RS_pr_tag          item_class;
  UINT_32            bytes;
};

struct RS_pr_OBJ_DIED {
  struct RS_pr_header  hdr;
  RS_pr_tag          item;
};

#endif /* _H_RSCHEME_PROFILE */