git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1088 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 1996-10-24 14:16:30 +00:00
parent 01e9d07a67
commit a472b7f3ea
4 changed files with 39 additions and 2 deletions

View File

@ -1,7 +1,7 @@
include ../config/Makefile
CC=$(BYTECC)
CFLAGS=-O $(BYTECCCOMPOPTS)
CFLAGS=-O $(BYTECCCOMPOPTS) -DBC_PROFILE
DFLAGS=-g -DDEBUG $(BYTECCCOMPOPTS)
OBJS=interp.o misc.o stacks.o fix_code.o startup.o main.o \

View File

@ -36,7 +36,7 @@
/* We use threaded code interpretation if the compiler provides labels
as first-class values (GCC 2.x). */
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(DEBUG)
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(DEBUG) && !defined(BC_PROFILE)
#define THREADED_CODE
#endif

View File

@ -173,6 +173,12 @@ value interprete(prog, prog_size)
Assert(sp >= stack_low);
Assert(sp <= stack_high);
#endif
#if BC_PROFILE
{
extern unsigned long bc_counts [];
++ bc_counts [*pc];
}
#endif /* BC_PROFILE */
switch(*pc++) {
#endif

View File

@ -129,6 +129,21 @@ Algorithm:
extern void init_ieee_floats();
#ifdef BC_PROFILE
unsigned long bc_counts [128];
void savecounts ()
{
char *countfilename = getenv ("CAML_BC_COUNTFILE");
if (countfilename != NULL){
FILE *countfile = fopen (countfilename, "w");
if (countfile != NULL){
fwrite (bc_counts, sizeof (unsigned long), 128, countfile);
}
}
}
#endif /* BC_PROFILE */
void caml_main(argc, argv)
int argc;
char ** argv;
@ -150,6 +165,22 @@ void caml_main(argc, argv)
verbose_init = 1;
#endif
#ifdef BC_PROFILE
{
char *countfilename = getenv ("CAML_BC_COUNTFILE");
int i;
if (countfilename != NULL){
FILE *countfile = fopen (countfilename, "r");
for (i = 0; i < 128; i++) bc_counts [i] = 0;
if (countfile != NULL){
fread (bc_counts, sizeof (unsigned long), 128, countfile);
}
}
atexit (savecounts);
}
#endif /* BC_PROFILE */
i = 0;
fd = attempt_open(&argv[0], &trail, 0);