From 165f985181447026ada647d8fe24af70b5a48300 Mon Sep 17 00:00:00 2001
From: "Guillermo J. Rozas" <edu/mit/csail/zurich/gjr>
Date: Sat, 28 Aug 1993 22:46:44 +0000
Subject: [PATCH] Add hooks for Ziggy's pc-sample profiler.

---
 v7/src/microcode/dosenv.c  |  16 ++++-
 v7/src/microcode/fixobj.h  |  31 ++++++--
 v7/src/microcode/intrpt.h  |  13 +++-
 v7/src/microcode/ntenv.c   |  15 +++-
 v7/src/microcode/osenv.h   |   4 +-
 v7/src/microcode/prosenv.c |  24 ++++++-
 v7/src/microcode/uxenv.c   |  32 ++++++++-
 v7/src/microcode/uxsig.c   | 144 ++++++++++++-------------------------
 v7/src/microcode/uxtrap.c  |  48 ++-----------
 v7/src/microcode/uxtrap.h  |  48 ++++++++++++-
 v7/src/microcode/version.h |   4 +-
 v8/src/microcode/fixobj.h  |  31 ++++++--
 v8/src/microcode/version.h |   4 +-
 13 files changed, 247 insertions(+), 167 deletions(-)

diff --git a/v7/src/microcode/dosenv.c b/v7/src/microcode/dosenv.c
index 3d92274f3..8137f1529 100644
--- a/v7/src/microcode/dosenv.c
+++ b/v7/src/microcode/dosenv.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: dosenv.c,v 1.5 1993/07/07 05:46:49 gjr Exp $
+$Id: dosenv.c,v 1.6 1993/08/28 22:46:35 gjr Exp $
 
 Copyright (c) 1992-1993 Massachusetts Institute of Technology
 
@@ -140,6 +140,20 @@ DEFUN_VOID (OS_process_timer_clear)
   return;
 }
 
+void
+DEFUN (OS_profile_timer_set, (first, interval),
+       clock_t first AND
+       clock_t interval)
+{
+  error_unimplemented_primitive ();
+}
+
+void
+DEFUN_VOID (OS_profile_timer_clear)
+{
+  return;
+}
+
 void
 DEFUN (OS_real_timer_set, (first, interval),
        clock_t first AND
diff --git a/v7/src/microcode/fixobj.h b/v7/src/microcode/fixobj.h
index 8b8fc9fa6..682c200af 100644
--- a/v7/src/microcode/fixobj.h
+++ b/v7/src/microcode/fixobj.h
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: fixobj.h,v 9.33 1993/08/23 22:25:54 cph Exp $
+$Id: fixobj.h,v 9.34 1993/08/28 22:46:36 gjr Exp $
 
-Copyright (c) 1987-93 Massachusetts Institute of Technology
+Copyright (c) 1987-1993 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -85,7 +85,9 @@ MIT in each case. */
 					   primitives. */
 
 /* Trampolines for various generic arithmetic operations.
-   These facilitate upwards compatibility and simplify compilation. */
+   These facilitate upwards compatibility and simplify compilation. 
+ */
+
 #define GENERIC_TRAMPOLINE_ZERO_P	0x24
 #define GENERIC_TRAMPOLINE_POSITIVE_P	0x25
 #define GENERIC_TRAMPOLINE_NEGATIVE_P	0x26
@@ -101,8 +103,27 @@ MIT in each case. */
 #define GENERIC_TRAMPOLINE_QUOTIENT	0x30
 #define GENERIC_TRAMPOLINE_REMAINDER	0x31
 #define GENERIC_TRAMPOLINE_MODULO	0x32
-
+
 #define ARITY_DISPATCHER_TAG		0x33
 
-#define NFixed_Objects		0x34
+/* Descartes profiling tables */
+
+#define PC_Sample_Builtin_Table		0x34 /* ``built in'' assembly code */
+#define PC_Sample_Utility_Table		0x35 /* Foreign func'n utilities */
+#define PC_Sample_Primitive_Table	0x36 /* Primitive proc samples */
+
+#define PC_Sample_Code_Block_Table	0x37 /* Compiled  proc samples */
+
+#define PC_Sample_PCB_Block_Buffer	0x38 /* Double buffer pure compiled */
+#define PC_Sample_PCB_Offset_Buffer	0x39 /* Double buffer pure comp offs */
+#define PC_Sample_HCB_Block_Buffer	0x3A /* Double buffer heathen comps */
+#define PC_Sample_HCB_Offset_Buffer	0x3B /* Double buffer heathen comps */
+
+#define PC_Sample_Interp_Proc_Buffer	0x3C /* Double buffer interp procs */
+
+#define PC_Sample_Prob_Comp_Table	0x3D /* Sure looked compiled ?! */
+#define PC_Sample_UFO_Table		0x3E /* Invalid ENV at sample time  */
+
+
 
+#define NFixed_Objects			0x3F
diff --git a/v7/src/microcode/intrpt.h b/v7/src/microcode/intrpt.h
index be9758305..7c94fef4d 100644
--- a/v7/src/microcode/intrpt.h
+++ b/v7/src/microcode/intrpt.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: intrpt.h,v 1.13 1993/08/21 02:28:59 gjr Exp $
+$Id: intrpt.h,v 1.14 1993/08/28 22:46:37 gjr Exp $
 
 Copyright (c) 1987-1993 Massachusetts Institute of Technology
 
@@ -48,10 +48,19 @@ MIT in each case. */
 #define INT_Global_Mask		\
   (INT_Global_GC | INT_Global_1 | INT_Global_3)
 
+/* Descartes profiling interrupts */
+
+#define INT_IPPB_Flush		512	/* Local interrupt */
+#define INT_IPPB_Extend	       1024	/* Local interrupt */
+#define INT_PCBPB_Flush	       2048	/* Local interrupt */
+#define INT_PCBPB_Extend       4096	/* Local interrupt */
+#define INT_HCBPB_Flush	       8192	/* Local interrupt */
+#define INT_HCBPB_Extend      16384	/* Local interrupt */
+
 #define Global_GC_Level		1
 #define Global_1_Level		3
 #define Global_3_Level		7
-#define MAX_INTERRUPT_NUMBER	8
+#define MAX_INTERRUPT_NUMBER   14	/* 2^14 = 16384 = INT_HCBPB_Extend */
 
 #define INT_Mask		((1 << (MAX_INTERRUPT_NUMBER + 1)) - 1)
 
diff --git a/v7/src/microcode/ntenv.c b/v7/src/microcode/ntenv.c
index 337153eab..94479d032 100644
--- a/v7/src/microcode/ntenv.c
+++ b/v7/src/microcode/ntenv.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: ntenv.c,v 1.6 1993/08/21 03:21:19 gjr Exp $
+$Id: ntenv.c,v 1.7 1993/08/28 22:46:38 gjr Exp $
 
 Copyright (c) 1992-1993 Massachusetts Institute of Technology
 
@@ -114,6 +114,19 @@ DEFUN_VOID (OS_process_timer_clear)
   return;
 }
 
+void
+DEFUN (OS_profile_timer_set, (first, interval),
+       clock_t first AND clock_t interval)
+{
+  return;
+}
+
+void
+DEFUN_VOID (OS_profile_timer_clear)
+{
+  return;
+}
+
 void
 DEFUN (OS_real_timer_set, (first, interval),
        clock_t first AND clock_t interval)
diff --git a/v7/src/microcode/osenv.h b/v7/src/microcode/osenv.h
index 41af186e9..ab80dd70d 100644
--- a/v7/src/microcode/osenv.h
+++ b/v7/src/microcode/osenv.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: osenv.h,v 1.4 1993/07/01 22:29:57 cph Exp $
+$Id: osenv.h,v 1.5 1993/08/28 22:46:39 gjr Exp $
 
 Copyright (c) 1990-1993 Massachusetts Institute of Technology
 
@@ -55,6 +55,8 @@ extern double EXFUN (OS_process_clock, (void));
 extern double EXFUN (OS_real_time_clock, (void));
 extern void EXFUN (OS_process_timer_set, (clock_t first, clock_t interval));
 extern void EXFUN (OS_process_timer_clear, (void));
+extern void EXFUN (OS_profile_timer_set, (clock_t first, clock_t interval));
+extern void EXFUN (OS_profile_timer_clear, (void));
 extern void EXFUN (OS_real_timer_set, (clock_t first, clock_t interval));
 extern void EXFUN (OS_real_timer_clear, (void));
 extern CONST char * EXFUN (OS_working_dir_pathname, (void));
diff --git a/v7/src/microcode/prosenv.c b/v7/src/microcode/prosenv.c
index fd1270753..d56e2ef45 100644
--- a/v7/src/microcode/prosenv.c
+++ b/v7/src/microcode/prosenv.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: prosenv.c,v 1.9 1993/07/01 22:29:58 cph Exp $
+$Id: prosenv.c,v 1.10 1993/08/28 22:46:39 gjr Exp $
 
 Copyright (c) 1987-1993 Massachusetts Institute of Technology
 
@@ -172,6 +172,26 @@ Both arguments are in units of milliseconds.")
 		     (arg_nonnegative_integer (2)));
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
+
+DEFINE_PRIMITIVE ("PROFILE-TIMER-CLEAR", Prim_profile_timer_clear, 0, 0,
+  "Turn off the PC sample timer.")
+{
+  PRIMITIVE_HEADER (0);
+  OS_profile_timer_clear ();
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
+DEFINE_PRIMITIVE ("PROFILE-TIMER-SET", Prim_profile_timer_set, 2, 2,
+  "Set the PC sample timer.\n\
+First arg FIRST says how long to wait until the first interrupt;\n\
+second arg INTERVAL says how long to wait between interrupts after that.\n\
+Both arguments are in units of milliseconds.")
+{
+  PRIMITIVE_HEADER (2);
+  OS_profile_timer_set ((arg_nonnegative_integer (1)),
+			(arg_nonnegative_integer (2)));
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
 
 DEFINE_PRIMITIVE ("SETUP-TIMER-INTERRUPT", Prim_setup_timer_interrupt, 2, 2,
   "This is an obsolete primitive; use `process-timer-set' instead.")
@@ -188,7 +208,7 @@ DEFINE_PRIMITIVE ("SETUP-TIMER-INTERRUPT", Prim_setup_timer_interrupt, 2, 2,
     }
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
-
+
 DEFINE_PRIMITIVE ("WORKING-DIRECTORY-PATHNAME", Prim_working_dir_pathname, 0, 0,
   "Return the current working directory as a string.")
 {
diff --git a/v7/src/microcode/uxenv.c b/v7/src/microcode/uxenv.c
index e2bc44baa..9884d97ad 100644
--- a/v7/src/microcode/uxenv.c
+++ b/v7/src/microcode/uxenv.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: uxenv.c,v 1.11 1993/07/01 22:29:59 cph Exp $
+$Id: uxenv.c,v 1.12 1993/08/28 22:46:40 gjr Exp $
 
 Copyright (c) 1990-1993 Massachusetts Institute of Technology
 
@@ -34,6 +34,7 @@ MIT in each case. */
 
 #include "ux.h"
 #include "osenv.h"
+#include "config.h"		/* For TRUE/FALSE & true/false */
 
 time_t
 DEFUN_VOID (OS_encoded_time)
@@ -239,6 +240,20 @@ DEFUN_VOID (OS_process_timer_clear)
   set_timer (ITIMER_VIRTUAL, 0, 0);
 }
 
+void
+DEFUN (OS_profile_timer_set, (first, interval),
+       clock_t first AND
+       clock_t interval)
+{
+  set_timer (ITIMER_PROF, first, interval);
+}
+
+void
+DEFUN_VOID (OS_profile_timer_clear)
+{
+  set_timer (ITIMER_PROF, 0, 0);
+}
+
 void
 DEFUN (OS_real_timer_set, (first, interval),
        clock_t first AND
@@ -274,6 +289,21 @@ DEFUN (OS_process_timer_set, (first, interval),
 void
 DEFUN_VOID (OS_process_timer_clear)
 {
+  return;
+}
+
+void
+DEFUN (OS_profile_timer_set, (first, interval),
+       clock_t first AND
+       clock_t interval)
+{
+  error_unimplemented_primitive ();
+}
+
+void
+DEFUN_VOID (OS_profile_timer_clear)
+{
+  return;
 }
 
 void
diff --git a/v7/src/microcode/uxsig.c b/v7/src/microcode/uxsig.c
index 63e32fc05..ac8575fcb 100644
--- a/v7/src/microcode/uxsig.c
+++ b/v7/src/microcode/uxsig.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: uxsig.c,v 1.26 1993/06/24 06:35:59 gjr Exp $
+$Id: uxsig.c,v 1.27 1993/08/28 22:46:42 gjr Exp $
 
 Copyright (c) 1990-1993 Massachusetts Institute of Technology
 
@@ -32,11 +32,13 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
+#include "config.h"
 #include "ux.h"
 #include "ossig.h"
 #include "osctty.h"
 #include "ostty.h"
 #include "uxtrap.h"
+#include "uxsig.h"
 #include "uxutil.h"
 #include "critsec.h"
 
@@ -56,7 +58,7 @@ DEFUN (current_handler, (signo), int signo)
 #define SA_SIGINFO 0
 #endif
 
-static void
+void
 DEFUN (INSTALL_HANDLER, (signo, handler),
        int signo AND
        Tsignal_handler handler)
@@ -81,13 +83,6 @@ DEFUN (current_handler, (signo), int signo)
   return (result);
 }
 
-#define INSTALL_HANDLER UX_sigset
-
-#define NEED_HANDLER_TRANSACTION
-#define ENTER_HANDLER(signo)
-#define ABORT_HANDLER(signo, handler) UX_sigrelse (signo)
-#define EXIT_HANDLER(signo, handler)
-
 #else /* not HAVE_SYSV3_SIGNALS */
 
 static Tsignal_handler
@@ -99,15 +94,19 @@ DEFUN (current_handler, (signo), int signo)
   return (result);
 }
 
-#define INSTALL_HANDLER UX_signal
-
-#define NEED_HANDLER_TRANSACTION
-#define ENTER_HANDLER(signo) UX_signal ((signo), SIG_IGN)
-#define ABORT_HANDLER UX_signal
-#define EXIT_HANDLER UX_signal
-
 #endif /* HAVE_SYSV3_SIGNALS */
 #endif /* HAVE_POSIX_SIGNALS */
+
+#ifdef NEED_HANDLER_TRANSACTION
+
+void
+DEFUN (ta_abort_handler, (ap), PTR ap)
+{
+  ABORT_HANDLER ((((struct handler_record *) ap) -> signo),
+		 (((struct handler_record *) ap) -> handler));
+}
+
+#endif /* NEED_HANDLER_TRANSACTION */
 
 #ifdef HAVE_POSIX_SIGNALS
 
@@ -164,6 +163,20 @@ DEFUN_VOID (unblock_signals)
 }
 
 #endif /* not HAVE_POSIX_SIGNALS */
+
+void
+DEFUN (deactivate_handler, (signo), int signo)
+{
+  INSTALL_HANDLER (signo, SIG_IGN) ;
+}
+
+void
+DEFUN (activate_handler, (signo, handler),
+       int signo AND
+       Tsignal_handler handler)
+{
+  INSTALL_HANDLER (signo, handler) ;
+}
 
 /* Signal Descriptors */
 
@@ -316,75 +329,6 @@ DEFUN_VOID (initialize_signal_descriptors)
 #endif
 }
 
-/* Signal Handlers */
-
-#ifndef NEED_HANDLER_TRANSACTION
-
-#define DEFUN_STD_HANDLER(name, statement)				\
-static Tsignal_handler_result						\
-DEFUN (name, (signo, info, pscp),					\
-       int signo AND							\
-       SIGINFO_T info AND						\
-       struct SIGCONTEXT * pscp)					\
-{									\
-  int STD_HANDLER_abortp;						\
-  DECLARE_FULL_SIGCONTEXT (scp);					\
-  INITIALIZE_FULL_SIGCONTEXT (pscp, scp);				\
-  STD_HANDLER_abortp = (enter_interruption_extent ());			\
-  statement;								\
-  if (STD_HANDLER_abortp)						\
-    exit_interruption_extent ();					\
-  SIGNAL_HANDLER_RETURN ();						\
-}
-
-#else /* NEED_HANDLER_TRANSACTION */
-
-struct handler_record
-{
-  int signo;
-  Tsignal_handler handler;
-};
-
-#define DEFUN_STD_HANDLER(name, statement)				\
-static Tsignal_handler_result						\
-DEFUN (name, (signo, info, pscp),					\
-       int signo AND							\
-       SIGINFO_T info AND						\
-       struct SIGCONTEXT * pscp)					\
-{									\
-  int STD_HANDLER_abortp;						\
-  DECLARE_FULL_SIGCONTEXT (scp);					\
-  INITIALIZE_FULL_SIGCONTEXT (pscp, scp);				\
-  ENTER_HANDLER (signo);						\
-  STD_HANDLER_abortp = (enter_interruption_extent ());			\
-  transaction_begin ();							\
-  {									\
-    struct handler_record * record =					\
-      (dstack_alloc (sizeof (struct handler_record)));			\
-    (record -> signo) = signo;						\
-    (record -> handler) = name;						\
-    transaction_record_action (tat_abort, ta_abort_handler, record);	\
-  }									\
-  statement;								\
-  if (STD_HANDLER_abortp)						\
-    {									\
-      transaction_abort ();						\
-      exit_interruption_extent ();					\
-    }									\
-  transaction_commit ();						\
-  EXIT_HANDLER (signo, name);						\
-  SIGNAL_HANDLER_RETURN ();						\
-}
-
-static void
-DEFUN (ta_abort_handler, (ap), PTR ap)
-{
-  ABORT_HANDLER ((((struct handler_record *) ap) -> signo),
-		 (((struct handler_record *) ap) -> handler));
-}
-
-#endif /* NEED_HANDLER_TRANSACTION */
-
 #define CONTROL_B_INTERRUPT_CHAR 'B'
 #define CONTROL_G_INTERRUPT_CHAR 'G'
 #define CONTROL_U_INTERRUPT_CHAR 'U'
@@ -410,23 +354,23 @@ DEFUN (echo_keyboard_interrupt, (c, dc), cc_t c AND cc_t dc)
   fflush (stdout);
 }
 
-DEFUN_STD_HANDLER (sighnd_control_g,
+static DEFUN_STD_HANDLER (sighnd_control_g,
   {
     echo_keyboard_interrupt ((OS_ctty_int_char ()), ALERT_CHAR);
     tty_set_next_interrupt_char (CONTROL_G_INTERRUPT_CHAR);
   })
 
-DEFUN_STD_HANDLER (sighnd_control_u,
+static DEFUN_STD_HANDLER (sighnd_control_u,
   {
     tty_set_next_interrupt_char (CONTROL_U_INTERRUPT_CHAR);
   })
 
-DEFUN_STD_HANDLER (sighnd_control_x,
+static DEFUN_STD_HANDLER (sighnd_control_x,
   {
     tty_set_next_interrupt_char (CONTROL_X_INTERRUPT_CHAR);
   })
 
-DEFUN_STD_HANDLER (sighnd_control_b,
+static DEFUN_STD_HANDLER (sighnd_control_b,
   {
     tty_set_next_interrupt_char (CONTROL_B_INTERRUPT_CHAR);
   })
@@ -434,7 +378,7 @@ DEFUN_STD_HANDLER (sighnd_control_b,
 static void EXFUN
   (interactive_interrupt_handler, (struct FULL_SIGCONTEXT * scp));
 
-DEFUN_STD_HANDLER (sighnd_interactive,
+static DEFUN_STD_HANDLER (sighnd_interactive,
   (interactive_interrupt_handler (scp)))
 
 void
@@ -484,7 +428,7 @@ void EXFUN ((*stop_signal_hook), (int signo));
 #  define IF_POSIX_SIGNALS(code) do {} while (0)
 #endif
 
-DEFUN_STD_HANDLER (sighnd_stop,
+static DEFUN_STD_HANDLER (sighnd_stop,
   IF_POSIX_SIGNALS(
   {
     sigset_t old_mask;
@@ -520,7 +464,7 @@ DEFUN_VOID (OS_restartable_exit)
 
 #ifdef HAVE_ITIMER
 
-DEFUN_STD_HANDLER (sighnd_timer,
+static DEFUN_STD_HANDLER (sighnd_timer,
   {
     request_timer_interrupt ();
   })
@@ -529,7 +473,7 @@ DEFUN_STD_HANDLER (sighnd_timer,
 
 extern void EXFUN (reschedule_alarm, (void));
 
-DEFUN_STD_HANDLER (sighnd_timer,
+static DEFUN_STD_HANDLER (sighnd_timer,
   {
     reschedule_alarm ();
     request_timer_interrupt ();
@@ -537,26 +481,26 @@ DEFUN_STD_HANDLER (sighnd_timer,
 
 #endif /* HAVE_ITIMER */
 
-DEFUN_STD_HANDLER (sighnd_save_then_terminate,
+static DEFUN_STD_HANDLER (sighnd_save_then_terminate,
   (request_suspend_interrupt ()))
 
-DEFUN_STD_HANDLER (sighnd_terminate,
+static DEFUN_STD_HANDLER (sighnd_terminate,
   (termination_signal
    ((! (option_emacs_subprocess && (signo == SIGHUP)))
     ? (find_signal_name (signo))
     : 0)))
 
-DEFUN_STD_HANDLER (sighnd_fpe,
+static DEFUN_STD_HANDLER (sighnd_fpe,
   {
     if (executing_scheme_primitive_p ())
       error_floating_point_exception ();
     trap_handler ("floating-point exception", signo, info, scp);
   })
 
-DEFUN_STD_HANDLER (sighnd_hardware_trap,
+static DEFUN_STD_HANDLER (sighnd_hardware_trap,
   (trap_handler ("hardware fault", signo, info, scp)))
 
-DEFUN_STD_HANDLER (sighnd_software_trap,
+static DEFUN_STD_HANDLER (sighnd_software_trap,
   (trap_handler ("system software fault", signo, info, scp)))
 
 #ifdef HAVE_NICE
@@ -565,7 +509,7 @@ DEFUN_STD_HANDLER (sighnd_software_trap,
 #define NICE_DELTA 5
 #endif
 
-DEFUN_STD_HANDLER (sighnd_renice,
+static DEFUN_STD_HANDLER (sighnd_renice,
   {
     fprintf (stderr, "\n;;; Renicing! New nice value = %d\n",
 	     ((nice (NICE_DELTA)) + 20));
@@ -600,7 +544,7 @@ void EXFUN ((*subprocess_death_hook), (pid_t pid, wait_status_t * status));
 #define BREAK break
 #endif
 
-DEFUN_STD_HANDLER (sighnd_dead_subprocess,
+static DEFUN_STD_HANDLER (sighnd_dead_subprocess,
   {
     while (1)
       {
diff --git a/v7/src/microcode/uxtrap.c b/v7/src/microcode/uxtrap.c
index 978f2d388..25b57f090 100644
--- a/v7/src/microcode/uxtrap.c
+++ b/v7/src/microcode/uxtrap.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: uxtrap.c,v 1.22 1993/07/29 07:02:51 gjr Exp $
+$Id: uxtrap.c,v 1.23 1993/08/28 22:46:05 gjr Exp $
 
 Copyright (c) 1990-1993 Massachusetts Institute of Technology
 
@@ -232,19 +232,6 @@ DEFUN (trap_handler, (message, signo, info, scp),
   }
 }
 
-#define STATE_UNKNOWN		(LONG_TO_UNSIGNED_FIXNUM (0))
-#define STATE_PRIMITIVE		(LONG_TO_UNSIGNED_FIXNUM (1))
-#define STATE_COMPILED_CODE	(LONG_TO_UNSIGNED_FIXNUM (2))
-#define STATE_PROBABLY_COMPILED	(LONG_TO_UNSIGNED_FIXNUM (3))
-
-struct trap_recovery_info
-{
-  SCHEME_OBJECT state;
-  SCHEME_OBJECT pc_info_1;
-  SCHEME_OBJECT pc_info_2;
-  SCHEME_OBJECT extra_trap_info;
-};
-
 static struct trap_recovery_info dummy_recovery_info =
 {
   STATE_UNKNOWN,
@@ -455,34 +442,7 @@ DEFUN (continue_from_trap, (signo, info, scp),
 #define STACK_ALIGNMENT_MASK		SCHEME_ALIGNMENT_MASK
 #define FREE_PARANOIA_MARGIN		0x100
 
-/* PCs must be aligned according to this. */
-
-#define PC_ALIGNMENT_MASK		((1 << PC_ZERO_BITS) - 1)
-
-/* But they may have bits that can be masked by this. */
-
-#ifndef PC_VALUE_MASK
-#define PC_VALUE_MASK			(~0)
-#endif
-
 #define C_STACK_SIZE			0x01000000
-
-#ifdef HAS_COMPILER_SUPPORT
-#define ALLOW_ONLY_C 0
-#else
-#define ALLOW_ONLY_C 1
-#define PLAUSIBLE_CC_BLOCK_P(block) 0
-#endif
-
-static SCHEME_OBJECT * EXFUN
-  (find_block_address, (char * pc_value, SCHEME_OBJECT * area_start));
-
-#if !(defined (_NEXTOS) && (_NEXTOS_VERSION >= 20))
-#if !(defined (_HPUX) && (_HPUX_VERSION >= 80) && defined (hp9000s300))
-extern long etext;
-#endif
-#  define get_etext() (&etext)
-#endif
 
 static void
 DEFUN (continue_from_trap, (signo, info, scp),
@@ -581,7 +541,7 @@ DEFUN (continue_from_trap, (signo, info, scp),
     }
     else if (pc_in_builtin)
     {
-      (trinfo . state) = STATE_PROBABLY_COMPILED;
+      (trinfo . state) = STATE_BUILTIN;
       (trinfo . pc_info_1) = (LONG_TO_UNSIGNED_FIXNUM (builtin_index));
       (trinfo . pc_info_2) = SHARP_T;
     }
@@ -622,7 +582,7 @@ DEFUN (continue_from_trap, (signo, info, scp),
 
     if (pc_in_utility)
     {
-      (trinfo . state) = STATE_PROBABLY_COMPILED;
+      (trinfo . state) = STATE_UTILITY;
       (trinfo . pc_info_1) = (LONG_TO_UNSIGNED_FIXNUM (utility_index));
       (trinfo . pc_info_2) = UNSPECIFIC;
     }
@@ -683,7 +643,7 @@ static SCHEME_OBJECT * EXFUN
 
 #define MINIMUM_SCAN_RANGE		2048
 
-static SCHEME_OBJECT *
+SCHEME_OBJECT *
 DEFUN (find_block_address, (pc_value, area_start),
        char * pc_value AND
        SCHEME_OBJECT * area_start)
diff --git a/v7/src/microcode/uxtrap.h b/v7/src/microcode/uxtrap.h
index 1d1dfd959..5e8d06307 100644
--- a/v7/src/microcode/uxtrap.h
+++ b/v7/src/microcode/uxtrap.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: uxtrap.h,v 1.20 1993/07/29 07:02:52 gjr Exp $
+$Id: uxtrap.h,v 1.21 1993/08/28 22:46:43 gjr Exp $
 
 Copyright (c) 1990-1993 Massachusetts Institute of Technology
 
@@ -37,6 +37,8 @@ MIT in each case. */
 
 #include "os.h"
 
+/* Machine/OS-dependent section (long) */
+
 #ifdef hp9000s300
 
 #include <sys/sysmacros.h>
@@ -519,7 +521,33 @@ struct full_sigcontext
 #ifndef INITIALIZE_UX_SIGNAL_CODES
 #define INITIALIZE_UX_SIGNAL_CODES()
 #endif
+
+/* PCs must be aligned according to this. */
+
+#define PC_ALIGNMENT_MASK		((1 << PC_ZERO_BITS) - 1)
+
+/* But they may have bits that can be masked by this. */
+
+#ifndef PC_VALUE_MASK
+#define PC_VALUE_MASK			(~0)
+#endif
+
+#ifdef HAS_COMPILER_SUPPORT
+# define ALLOW_ONLY_C 0
+#else
+# define ALLOW_ONLY_C 1
+# define PLAUSIBLE_CC_BLOCK_P(block) 0
+#endif
+
+#if !(defined (_NEXTOS) && (_NEXTOS_VERSION >= 20))
+#if !(defined (_HPUX) && (_HPUX_VERSION >= 80) && defined (hp9000s300))
+extern long etext;
+#endif
+#  define get_etext() (&etext)
+#endif
 
+/* Machine/OS-independent section */
+
 enum trap_state
 {
   trap_state_trapped,
@@ -542,4 +570,22 @@ extern void EXFUN
 extern void EXFUN (hard_reset, (struct FULL_SIGCONTEXT * scp));
 extern void EXFUN (soft_reset, (void));
 
+#define STATE_UNKNOWN		(LONG_TO_UNSIGNED_FIXNUM (0))
+#define STATE_PRIMITIVE		(LONG_TO_UNSIGNED_FIXNUM (1))
+#define STATE_COMPILED_CODE	(LONG_TO_UNSIGNED_FIXNUM (2))
+#define STATE_PROBABLY_COMPILED	(LONG_TO_UNSIGNED_FIXNUM (3))
+#define STATE_BUILTIN		(LONG_TO_UNSIGNED_FIXNUM (4))
+#define STATE_UTILITY		(LONG_TO_UNSIGNED_FIXNUM (5))  /* CommGas? */
+
+struct trap_recovery_info
+{
+  SCHEME_OBJECT state;
+  SCHEME_OBJECT pc_info_1;
+  SCHEME_OBJECT pc_info_2;
+  SCHEME_OBJECT extra_trap_info;
+};
+
+extern SCHEME_OBJECT * EXFUN
+  (find_block_address, (char * pc_value, SCHEME_OBJECT * area_start));
+
 #endif /* SCM_UXTRAP_H */
diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h
index 1ac7e2372..41668ed78 100644
--- a/v7/src/microcode/version.h
+++ b/v7/src/microcode/version.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: version.h,v 11.139 1993/08/28 05:45:25 gjr Exp $
+$Id: version.h,v 11.140 1993/08/28 22:46:44 gjr Exp $
 
 Copyright (c) 1988-1993 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION		11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION	139
+#define SUBVERSION	140
 #endif
diff --git a/v8/src/microcode/fixobj.h b/v8/src/microcode/fixobj.h
index 8b8fc9fa6..682c200af 100644
--- a/v8/src/microcode/fixobj.h
+++ b/v8/src/microcode/fixobj.h
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: fixobj.h,v 9.33 1993/08/23 22:25:54 cph Exp $
+$Id: fixobj.h,v 9.34 1993/08/28 22:46:36 gjr Exp $
 
-Copyright (c) 1987-93 Massachusetts Institute of Technology
+Copyright (c) 1987-1993 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -85,7 +85,9 @@ MIT in each case. */
 					   primitives. */
 
 /* Trampolines for various generic arithmetic operations.
-   These facilitate upwards compatibility and simplify compilation. */
+   These facilitate upwards compatibility and simplify compilation. 
+ */
+
 #define GENERIC_TRAMPOLINE_ZERO_P	0x24
 #define GENERIC_TRAMPOLINE_POSITIVE_P	0x25
 #define GENERIC_TRAMPOLINE_NEGATIVE_P	0x26
@@ -101,8 +103,27 @@ MIT in each case. */
 #define GENERIC_TRAMPOLINE_QUOTIENT	0x30
 #define GENERIC_TRAMPOLINE_REMAINDER	0x31
 #define GENERIC_TRAMPOLINE_MODULO	0x32
-
+
 #define ARITY_DISPATCHER_TAG		0x33
 
-#define NFixed_Objects		0x34
+/* Descartes profiling tables */
+
+#define PC_Sample_Builtin_Table		0x34 /* ``built in'' assembly code */
+#define PC_Sample_Utility_Table		0x35 /* Foreign func'n utilities */
+#define PC_Sample_Primitive_Table	0x36 /* Primitive proc samples */
+
+#define PC_Sample_Code_Block_Table	0x37 /* Compiled  proc samples */
+
+#define PC_Sample_PCB_Block_Buffer	0x38 /* Double buffer pure compiled */
+#define PC_Sample_PCB_Offset_Buffer	0x39 /* Double buffer pure comp offs */
+#define PC_Sample_HCB_Block_Buffer	0x3A /* Double buffer heathen comps */
+#define PC_Sample_HCB_Offset_Buffer	0x3B /* Double buffer heathen comps */
+
+#define PC_Sample_Interp_Proc_Buffer	0x3C /* Double buffer interp procs */
+
+#define PC_Sample_Prob_Comp_Table	0x3D /* Sure looked compiled ?! */
+#define PC_Sample_UFO_Table		0x3E /* Invalid ENV at sample time  */
+
+
 
+#define NFixed_Objects			0x3F
diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h
index 1ac7e2372..41668ed78 100644
--- a/v8/src/microcode/version.h
+++ b/v8/src/microcode/version.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: version.h,v 11.139 1993/08/28 05:45:25 gjr Exp $
+$Id: version.h,v 11.140 1993/08/28 22:46:44 gjr Exp $
 
 Copyright (c) 1988-1993 Massachusetts Institute of Technology
 
@@ -46,5 +46,5 @@ MIT in each case. */
 #define VERSION		11
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION	139
+#define SUBVERSION	140
 #endif
-- 
2.25.1