public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9390] modula2: Rebuild bootstrap tools with faster dynamic arrays
@ 2024-03-08 12:52 Gaius Mulley
  0 siblings, 0 replies; only message in thread
From: Gaius Mulley @ 2024-03-08 12:52 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3cdaa6491fe805ffc1dc545722b97660f31572fa

commit r14-9390-g3cdaa6491fe805ffc1dc545722b97660f31572fa
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Fri Mar 8 12:52:04 2024 +0000

    modula2: Rebuild bootstrap tools with faster dynamic arrays
    
    This patch configures the larger dynamic arrays to use a larger
    growth factor and larger initial size.  It also rebuilds mc and pge
    using the improved default array sizes in Indexing.mod.
    
    gcc/m2/ChangeLog:
    
            * gm2-compiler/M2Quads.mod (Init): Use InitIndexTuned with
            default size 65K.
            * gm2-compiler/SymbolConversion.mod (Init): Ditto.
            * gm2-compiler/SymbolTable.mod (BEGIN): Ditto.
            * mc-boot/GM2Dependent.cc: Rebuild.
            * mc-boot/GM2Dependent.h: Rebuild.
            * mc-boot/GM2RTS.cc: Rebuild.
            * pge-boot/GIndexing.cc: Rebuild.
            * pge-boot/GIndexing.h: Rebuild.
            * pge-boot/GM2Dependent.cc: Rebuild.
            * pge-boot/GM2Dependent.h: Rebuild.
            * pge-boot/GM2RTS.cc: Rebuild.
    
    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

Diff:
---
 gcc/m2/gm2-compiler/M2Quads.mod          |   5 +-
 gcc/m2/gm2-compiler/SymbolConversion.mod |   6 +-
 gcc/m2/gm2-compiler/SymbolTable.mod      |   7 +-
 gcc/m2/mc-boot/GM2Dependent.cc           | 202 +++++++++++++++++++++++++++++--
 gcc/m2/mc-boot/GM2Dependent.h            |  32 +++++
 gcc/m2/mc-boot/GM2RTS.cc                 | 118 ++----------------
 gcc/m2/pge-boot/GIndexing.cc             |  59 +++++++--
 gcc/m2/pge-boot/GIndexing.h              |  15 +++
 gcc/m2/pge-boot/GM2Dependent.cc          | 202 +++++++++++++++++++++++++++++--
 gcc/m2/pge-boot/GM2Dependent.h           |  32 +++++
 gcc/m2/pge-boot/GM2RTS.cc                | 119 ++----------------
 11 files changed, 540 insertions(+), 257 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index ff0fda9cd41..2be229d0bf8 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -230,7 +230,8 @@ FROM M2StackWord IMPORT StackOfWord, InitStackWord, KillStackWord,
                         PushWord, PopWord, PeepWord, RemoveTop,
                         IsEmptyWord, NoOfItemsInStackWord ;
 
-FROM Indexing IMPORT Index, InitIndex, GetIndice, PutIndice, InBounds, HighIndice, IncludeIndiceIntoIndex ;
+FROM Indexing IMPORT Index, InitIndex, GetIndice, PutIndice, InBounds, HighIndice,
+                     IncludeIndiceIntoIndex, InitIndexTuned ;
 
 FROM M2Range IMPORT InitAssignmentRangeCheck,
                     InitReturnRangeCheck,
@@ -15451,7 +15452,7 @@ BEGIN
    LogicalXorTok := MakeKey('_LXOR') ;
    LogicalDifferenceTok := MakeKey('_LDIFF') ;
    ArithPlusTok := MakeKey ('_ARITH_+') ;
-   QuadArray := InitIndex (1) ;
+   QuadArray := InitIndexTuned (1, 1024*1024 DIV 16, 16) ;
    FreeList := 1 ;
    NewQuad(NextQuad) ;
    Assert(NextQuad=1) ;
diff --git a/gcc/m2/gm2-compiler/SymbolConversion.mod b/gcc/m2/gm2-compiler/SymbolConversion.mod
index c3c484db00a..b8f0f70b435 100644
--- a/gcc/m2/gm2-compiler/SymbolConversion.mod
+++ b/gcc/m2/gm2-compiler/SymbolConversion.mod
@@ -24,7 +24,7 @@ IMPLEMENTATION MODULE SymbolConversion ;
 FROM NameKey IMPORT Name ;
 
 FROM Indexing IMPORT Index, InitIndex, PutIndice, GetIndice, InBounds,
-                     DebugIndex ;
+                     DebugIndex, InitIndexTuned ;
 
 FROM SymbolTable IMPORT IsConst, PopValue, IsValueSolved, GetSymName,
                         GetType, SkipType ;
@@ -237,8 +237,8 @@ END Poison ;
 
 PROCEDURE Init ;
 BEGIN
-   mod2gcc := InitIndex(1) ;
-   ALLOCATE(PoisonedSymbol, 1)
+   mod2gcc := InitIndexTuned (1, 1024*1024 DIV 16, 16) ;
+   ALLOCATE (PoisonedSymbol, 1)
 END Init ;
 
 
diff --git a/gcc/m2/gm2-compiler/SymbolTable.mod b/gcc/m2/gm2-compiler/SymbolTable.mod
index c57c0333188..b49cc889dca 100644
--- a/gcc/m2/gm2-compiler/SymbolTable.mod
+++ b/gcc/m2/gm2-compiler/SymbolTable.mod
@@ -28,7 +28,10 @@ FROM M2Debug IMPORT Assert ;
 FROM libc IMPORT printf ;
 
 IMPORT Indexing ;
-FROM Indexing IMPORT InitIndex, InBounds, LowIndice, HighIndice, PutIndice, GetIndice ;
+
+FROM Indexing IMPORT InitIndex, InBounds, LowIndice, HighIndice,
+                     PutIndice, GetIndice, InitIndexTuned ;
+
 FROM Sets IMPORT Set, InitSet, IncludeElementIntoSet, IsElementInSet ;
 FROM m2linemap IMPORT location_t ;
 
@@ -1644,7 +1647,7 @@ BEGIN
    InitTree (ConstLitPoolTree) ;
    InitTree (DefModuleTree) ;
    InitTree (ModuleTree) ;
-   Symbols := InitIndex (1) ;
+   Symbols := InitIndexTuned (1, 1024*1024 DIV 16, 16) ;
    ConstLitArray := InitIndex (1) ;
    FreeSymbol := 1 ;
    ScopePtr := 1 ;
diff --git a/gcc/m2/mc-boot/GM2Dependent.cc b/gcc/m2/mc-boot/GM2Dependent.cc
index cda07e8460b..bf0daab4563 100644
--- a/gcc/m2/mc-boot/GM2Dependent.cc
+++ b/gcc/m2/mc-boot/GM2Dependent.cc
@@ -55,7 +55,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #   include "GSYSTEM.h"
 #   include "GStorage.h"
 #   include "GStrLib.h"
-#   include "GM2RTS.h"
 
 typedef struct M2Dependent_ArgCVEnvP_p M2Dependent_ArgCVEnvP;
 
@@ -63,11 +62,17 @@ typedef struct M2Dependent_DependencyList_r M2Dependent_DependencyList;
 
 typedef char *M2Dependent_PtrToChar;
 
+typedef struct M2Dependent_ProcedureList_r M2Dependent_ProcedureList;
+
 typedef struct M2Dependent__T2_r M2Dependent__T2;
 
 typedef M2Dependent__T2 *M2Dependent_ModuleChain;
 
-typedef struct M2Dependent__T3_a M2Dependent__T3;
+typedef struct M2Dependent__T3_r M2Dependent__T3;
+
+typedef M2Dependent__T3 *M2Dependent_ProcedureChain;
+
+typedef struct M2Dependent__T4_a M2Dependent__T4;
 
 typedef enum {M2Dependent_unregistered, M2Dependent_unordered, M2Dependent_started, M2Dependent_ordered, M2Dependent_user} M2Dependent_DependencyState;
 
@@ -82,7 +87,18 @@ struct M2Dependent_DependencyList_r {
                                       M2Dependent_DependencyState state;
                                     };
 
-struct M2Dependent__T3_a { M2Dependent_ModuleChain array[M2Dependent_user-M2Dependent_unregistered+1]; };
+struct M2Dependent_ProcedureList_r {
+                                     M2Dependent_ProcedureChain head;
+                                     M2Dependent_ProcedureChain tail;
+                                   };
+
+struct M2Dependent__T3_r {
+                           PROC p;
+                           M2Dependent_ProcedureChain prev;
+                           M2Dependent_ProcedureChain next;
+                         };
+
+struct M2Dependent__T4_a { M2Dependent_ModuleChain array[M2Dependent_user-M2Dependent_unregistered+1]; };
 struct M2Dependent__T2_r {
                            void *name;
                            void *libname;
@@ -93,7 +109,7 @@ struct M2Dependent__T2_r {
                            M2Dependent_ModuleChain next;
                          };
 
-static M2Dependent__T3 Modules;
+static M2Dependent__T4 Modules;
 static bool DynamicInitialization;
 static bool Initialized;
 static bool WarningTrace;
@@ -103,6 +119,8 @@ static bool DependencyTrace;
 static bool PreTrace;
 static bool PostTrace;
 static bool ForceTrace;
+static M2Dependent_ProcedureList InitialProc;
+static M2Dependent_ProcedureList TerminateProc;
 
 /*
    ConstructModules - resolve dependencies and then call each
@@ -134,6 +152,38 @@ extern "C" void M2Dependent_RegisterModule (void * modulename, void * libname, M
 
 extern "C" void M2Dependent_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
 
+/*
+   InstallTerminationProcedure - installs a procedure, p, which will
+                                 be called when the procedure
+                                 ExecuteTerminationProcedures
+                                 is invoked.  It returns TRUE if the
+                                 procedure is installed.
+*/
+
+extern "C" bool M2Dependent_InstallTerminationProcedure (PROC p);
+
+/*
+   ExecuteInitialProcedures - executes the initial procedures installed by
+                              InstallInitialProcedure.
+*/
+
+extern "C" void M2Dependent_ExecuteInitialProcedures (void);
+
+/*
+   InstallInitialProcedure - installs a procedure to be executed just
+                             before the BEGIN code section of the
+                             main program module.
+*/
+
+extern "C" bool M2Dependent_InstallInitialProcedure (PROC p);
+
+/*
+   ExecuteTerminationProcedures - calls each installed termination procedure
+                                  in reverse order.
+*/
+
+extern "C" void M2Dependent_ExecuteTerminationProcedures (void);
+
 /*
    InitDependencyList - initialize all fields of DependencyList.
 */
@@ -359,6 +409,27 @@ static void Init (void);
 
 static void CheckInitialized (void);
 
+/*
+   ExecuteReverse - execute the procedure associated with procptr
+                    and then proceed to try and execute all previous
+                    procedures in the chain.
+*/
+
+static void ExecuteReverse (M2Dependent_ProcedureChain procptr);
+
+/*
+   AppendProc - append proc to the end of the procedure list
+                defined by proclist.
+*/
+
+static bool AppendProc (M2Dependent_ProcedureList *proclist, PROC proc);
+
+/*
+   InitProcList - initialize the head and tail pointers to NIL.
+*/
+
+static void InitProcList (M2Dependent_ProcedureList *p);
+
 
 /*
    InitDependencyList - initialize all fields of DependencyList.
@@ -965,10 +1036,10 @@ static void combine (M2Dependent_DependencyState src, M2Dependent_DependencyStat
 
 static void tracemodule (bool flag, void * modname, unsigned int modlen, void * libname, unsigned int liblen)
 {
-  typedef struct tracemodule__T4_a tracemodule__T4;
+  typedef struct tracemodule__T5_a tracemodule__T5;
 
-  struct tracemodule__T4_a { char array[100+1]; };
-  tracemodule__T4 buffer;
+  struct tracemodule__T5_a { char array[100+1]; };
+  tracemodule__T5 buffer;
   unsigned int len;
 
   if (flag)
@@ -1109,10 +1180,10 @@ static void CheckApplication (void)
 
 static void warning3 (const char *format_, unsigned int _format_high, void * arg1, void * arg2)
 {
-  typedef struct warning3__T5_a warning3__T5;
+  typedef struct warning3__T6_a warning3__T6;
 
-  struct warning3__T5_a { char array[4096+1]; };
-  warning3__T5 buffer;
+  struct warning3__T6_a { char array[4096+1]; };
+  warning3__T6 buffer;
   int len;
   char format[_format_high+1];
 
@@ -1251,6 +1322,8 @@ static void Init (void)
 {
   M2Dependent_DependencyState state;
 
+  InitProcList (&InitialProc);
+  InitProcList (&TerminateProc);
   SetupDebugFlags ();
   for (state=M2Dependent_unregistered; state<=M2Dependent_user; state= static_cast<M2Dependent_DependencyState>(static_cast<int>(state+1)))
     {
@@ -1277,6 +1350,57 @@ static void CheckInitialized (void)
 }
 
 
+/*
+   ExecuteReverse - execute the procedure associated with procptr
+                    and then proceed to try and execute all previous
+                    procedures in the chain.
+*/
+
+static void ExecuteReverse (M2Dependent_ProcedureChain procptr)
+{
+  while (procptr != NULL)
+    {
+      (*procptr->p.proc) ();  /* Invoke the procedure.  */
+      procptr = procptr->prev;  /* Invoke the procedure.  */
+    }
+}
+
+
+/*
+   AppendProc - append proc to the end of the procedure list
+                defined by proclist.
+*/
+
+static bool AppendProc (M2Dependent_ProcedureList *proclist, PROC proc)
+{
+  M2Dependent_ProcedureChain pdes;
+
+  Storage_ALLOCATE ((void **) &pdes, sizeof (M2Dependent__T3));
+  pdes->p = proc;
+  pdes->prev = (*proclist).tail;
+  pdes->next = NULL;
+  if ((*proclist).head == NULL)
+    {
+      (*proclist).head = pdes;
+    }
+  (*proclist).tail = pdes;
+  return true;
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
+/*
+   InitProcList - initialize the head and tail pointers to NIL.
+*/
+
+static void InitProcList (M2Dependent_ProcedureList *p)
+{
+  (*p).head = NULL;
+  (*p).tail = NULL;
+}
+
+
 /*
    ConstructModules - resolve dependencies and then call each
                       module constructor in turn.
@@ -1326,8 +1450,8 @@ extern "C" void M2Dependent_ConstructModules (void * applicationmodule, void * l
         if (mptr->dependency.appl)
           {
             traceprintf3 (ModuleTrace, (const char *) "application module: %s [%s]\\n", 29, mptr->name, mptr->libname);
-            traceprintf (ModuleTrace, (const char *) "  calling M2RTS_ExecuteInitialProcedures\\n", 42);
-            M2RTS_ExecuteInitialProcedures ();
+            traceprintf (ModuleTrace, (const char *) "  calling ExecuteInitialProcedures\\n", 36);
+            M2Dependent_ExecuteInitialProcedures ();
             traceprintf (ModuleTrace, (const char *) "  calling application module\\n", 30);
           }
         (*mptr->init.proc) (argc, argv, envp);
@@ -1354,7 +1478,7 @@ extern "C" void M2Dependent_DeconstructModules (void * applicationmodule, void *
   else
     {
       traceprintf (ModuleTrace, (const char *) "ExecuteTerminationProcedures\\n", 30);
-      M2RTS_ExecuteTerminationProcedures ();
+      M2Dependent_ExecuteTerminationProcedures ();
       traceprintf (ModuleTrace, (const char *) "terminating modules in sequence\\n", 33);
       mptr = Modules.array[M2Dependent_ordered-M2Dependent_unregistered]->prev;
       do {
@@ -1410,6 +1534,58 @@ extern "C" void M2Dependent_RequestDependant (void * modulename, void * libname,
   PerformRequestDependant (modulename, libname, dependantmodule, dependantlibname);
 }
 
+
+/*
+   InstallTerminationProcedure - installs a procedure, p, which will
+                                 be called when the procedure
+                                 ExecuteTerminationProcedures
+                                 is invoked.  It returns TRUE if the
+                                 procedure is installed.
+*/
+
+extern "C" bool M2Dependent_InstallTerminationProcedure (PROC p)
+{
+  return AppendProc (&TerminateProc, p);
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
+/*
+   ExecuteInitialProcedures - executes the initial procedures installed by
+                              InstallInitialProcedure.
+*/
+
+extern "C" void M2Dependent_ExecuteInitialProcedures (void)
+{
+  ExecuteReverse (InitialProc.tail);
+}
+
+
+/*
+   InstallInitialProcedure - installs a procedure to be executed just
+                             before the BEGIN code section of the
+                             main program module.
+*/
+
+extern "C" bool M2Dependent_InstallInitialProcedure (PROC p)
+{
+  return AppendProc (&InitialProc, p);
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
+/*
+   ExecuteTerminationProcedures - calls each installed termination procedure
+                                  in reverse order.
+*/
+
+extern "C" void M2Dependent_ExecuteTerminationProcedures (void)
+{
+  ExecuteReverse (TerminateProc.tail);
+}
+
 extern "C" void _M2_M2Dependent_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
 {
   CheckInitialized ();
diff --git a/gcc/m2/mc-boot/GM2Dependent.h b/gcc/m2/mc-boot/GM2Dependent.h
index 0a2a60a9653..0353236f8c1 100644
--- a/gcc/m2/mc-boot/GM2Dependent.h
+++ b/gcc/m2/mc-boot/GM2Dependent.h
@@ -72,6 +72,38 @@ EXTERN void M2Dependent_RegisterModule (void * modulename, void * libname, M2Dep
 */
 
 EXTERN void M2Dependent_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
+
+/*
+   InstallTerminationProcedure - installs a procedure, p, which will
+                                 be called when the procedure
+                                 ExecuteTerminationProcedures
+                                 is invoked.  It returns TRUE is the
+                                 procedure is installed.
+*/
+
+EXTERN bool M2Dependent_InstallTerminationProcedure (PROC p);
+
+/*
+   ExecuteInitialProcedures - executes the initial procedures installed
+                              by InstallInitialProcedure.
+*/
+
+EXTERN void M2Dependent_ExecuteInitialProcedures (void);
+
+/*
+   InstallInitialProcedure - installs a procedure to be executed just
+                             before the BEGIN code section of the main
+                             program module.
+*/
+
+EXTERN bool M2Dependent_InstallInitialProcedure (PROC p);
+
+/*
+   ExecuteTerminationProcedures - calls each installed termination procedure
+                                  in reverse order.
+*/
+
+EXTERN void M2Dependent_ExecuteTerminationProcedures (void);
 #   ifdef __cplusplus
 }
 #   endif
diff --git a/gcc/m2/mc-boot/GM2RTS.cc b/gcc/m2/mc-boot/GM2RTS.cc
index a1fd5f59788..d529a788007 100644
--- a/gcc/m2/mc-boot/GM2RTS.cc
+++ b/gcc/m2/mc-boot/GM2RTS.cc
@@ -42,11 +42,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #      define FALSE (1==0)
 #   endif
 
-#   include "GStorage.h"
-#if defined(__cplusplus)
-#   undef NULL
-#   define NULL 0
-#endif
 #define _M2RTS_H
 #define _M2RTS_C
 
@@ -63,30 +58,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
 
 #   define stderrFd 2
-typedef struct M2RTS_ProcedureList_r M2RTS_ProcedureList;
-
 typedef char *M2RTS_PtrToChar;
 
-typedef struct M2RTS__T1_r M2RTS__T1;
-
-typedef M2RTS__T1 *M2RTS_ProcedureChain;
-
 typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
 struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
 
-struct M2RTS_ProcedureList_r {
-                               M2RTS_ProcedureChain head;
-                               M2RTS_ProcedureChain tail;
-                             };
-
-struct M2RTS__T1_r {
-                     PROC p;
-                     M2RTS_ProcedureChain prev;
-                     M2RTS_ProcedureChain next;
-                   };
-
-static M2RTS_ProcedureList InitialProc;
-static M2RTS_ProcedureList TerminateProc;
 static int ExitValue;
 static bool isHalting;
 static bool CallExit;
@@ -235,21 +211,6 @@ extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, un
 extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
 extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
 
-/*
-   ExecuteReverse - execute the procedure associated with procptr
-                    and then proceed to try and execute all previous
-                    procedures in the chain.
-*/
-
-static void ExecuteReverse (M2RTS_ProcedureChain procptr);
-
-/*
-   AppendProc - append proc to the end of the procedure list
-                defined by proclist.
-*/
-
-static bool AppendProc (M2RTS_ProcedureList *proclist, PROC proc);
-
 /*
    ErrorString - writes a string to stderr.
 */
@@ -268,12 +229,6 @@ static void ErrorStringC (void * str);
 
 static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function) __attribute__ ((noreturn));
 
-/*
-   InitProcList - initialize the head and tail pointers to NIL.
-*/
-
-static void InitProcList (M2RTS_ProcedureList *p);
-
 /*
    Init - initialize the initial, terminate procedure lists and booleans.
 */
@@ -290,46 +245,6 @@ static void Init (void);
 static void CheckInitialized (void);
 
 
-/*
-   ExecuteReverse - execute the procedure associated with procptr
-                    and then proceed to try and execute all previous
-                    procedures in the chain.
-*/
-
-static void ExecuteReverse (M2RTS_ProcedureChain procptr)
-{
-  while (procptr != NULL)
-    {
-      (*procptr->p.proc) ();  /* Invoke the procedure.  */
-      procptr = procptr->prev;  /* Invoke the procedure.  */
-    }
-}
-
-
-/*
-   AppendProc - append proc to the end of the procedure list
-                defined by proclist.
-*/
-
-static bool AppendProc (M2RTS_ProcedureList *proclist, PROC proc)
-{
-  M2RTS_ProcedureChain pdes;
-
-  Storage_ALLOCATE ((void **) &pdes, sizeof (M2RTS__T1));
-  pdes->p = proc;
-  pdes->prev = (*proclist).tail;
-  pdes->next = NULL;
-  if ((*proclist).head == NULL)
-    {
-      (*proclist).head = pdes;
-    }
-  (*proclist).tail = pdes;
-  return true;
-  /* static analysis guarentees a RETURN statement will be used before here.  */
-  __builtin_unreachable ();
-}
-
-
 /*
    ErrorString - writes a string to stderr.
 */
@@ -364,10 +279,10 @@ static void ErrorStringC (void * str)
 
 static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function)
 {
-  typedef struct ErrorMessageC__T2_a ErrorMessageC__T2;
+  typedef struct ErrorMessageC__T1_a ErrorMessageC__T1;
 
-  struct ErrorMessageC__T2_a { char array[10+1]; };
-  ErrorMessageC__T2 buffer;
+  struct ErrorMessageC__T1_a { char array[10+1]; };
+  ErrorMessageC__T1 buffer;
 
   ErrorStringC (filename);
   ErrorString ((const char *) ":", 1);
@@ -388,25 +303,12 @@ static void ErrorMessageC (void * message, void * filename, unsigned int line, v
 }
 
 
-/*
-   InitProcList - initialize the head and tail pointers to NIL.
-*/
-
-static void InitProcList (M2RTS_ProcedureList *p)
-{
-  (*p).head = NULL;
-  (*p).tail = NULL;
-}
-
-
 /*
    Init - initialize the initial, terminate procedure lists and booleans.
 */
 
 static void Init (void)
 {
-  InitProcList (&InitialProc);
-  InitProcList (&TerminateProc);
   ExitValue = 0;
   isHalting = false;
   CallExit = false;  /* default by calling abort  */
@@ -485,7 +387,7 @@ extern "C" void M2RTS_RequestDependant (void * modulename, void * libname, void
 
 extern "C" bool M2RTS_InstallTerminationProcedure (PROC p)
 {
-  return AppendProc (&TerminateProc, p);
+  return M2Dependent_InstallTerminationProcedure (p);
   /* static analysis guarentees a RETURN statement will be used before here.  */
   __builtin_unreachable ();
 }
@@ -498,7 +400,7 @@ extern "C" bool M2RTS_InstallTerminationProcedure (PROC p)
 
 extern "C" void M2RTS_ExecuteInitialProcedures (void)
 {
-  ExecuteReverse (InitialProc.tail);
+  M2Dependent_ExecuteInitialProcedures ();
 }
 
 
@@ -510,7 +412,7 @@ extern "C" void M2RTS_ExecuteInitialProcedures (void)
 
 extern "C" bool M2RTS_InstallInitialProcedure (PROC p)
 {
-  return AppendProc (&InitialProc, p);
+  return M2Dependent_InstallInitialProcedure (p);
   /* static analysis guarentees a RETURN statement will be used before here.  */
   __builtin_unreachable ();
 }
@@ -523,7 +425,7 @@ extern "C" bool M2RTS_InstallInitialProcedure (PROC p)
 
 extern "C" void M2RTS_ExecuteTerminationProcedures (void)
 {
-  ExecuteReverse (TerminateProc.tail);
+  M2Dependent_ExecuteTerminationProcedures ();
 }
 
 
@@ -629,10 +531,10 @@ extern "C" void M2RTS_ExitOnHalt (int e)
 
 extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high)
 {
-  typedef struct ErrorMessage__T3_a ErrorMessage__T3;
+  typedef struct ErrorMessage__T2_a ErrorMessage__T2;
 
-  struct ErrorMessage__T3_a { char array[10+1]; };
-  ErrorMessage__T3 buffer;
+  struct ErrorMessage__T2_a { char array[10+1]; };
+  ErrorMessage__T2 buffer;
   char message[_message_high+1];
   char filename[_filename_high+1];
   char function[_function_high+1];
diff --git a/gcc/m2/pge-boot/GIndexing.cc b/gcc/m2/pge-boot/GIndexing.cc
index c898a246598..21e3a43a8c8 100644
--- a/gcc/m2/pge-boot/GIndexing.cc
+++ b/gcc/m2/pge-boot/GIndexing.cc
@@ -59,14 +59,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure;
 
 #   define MinSize 128
+#   define DefaultGrowFactor 2
 typedef struct Indexing__T2_r Indexing__T2;
 
 typedef void * *Indexing_PtrToAddress;
 
-typedef Indexing__T2 *Indexing_Index;
-
 typedef unsigned char *Indexing_PtrToByte;
 
+typedef Indexing__T2 *Indexing_Index;
+
 typedef void (*Indexing_IndexProcedure_t) (void *);
 struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; };
 
@@ -78,9 +79,19 @@ struct Indexing__T2_r {
                         unsigned int High;
                         bool Debug;
                         unsigned int Map;
+                        unsigned int GrowFactor;
                       };
 
 
+/*
+   InitIndexTuned - creates a dynamic array with low indice.
+                    The minsize is the initial number of elements the
+                    array is allocated and growfactor determines how
+                    it will be resized once it becomes full.
+*/
+
+extern "C" Indexing_Index Indexing_InitIndexTuned (unsigned int low, unsigned int minsize, unsigned int growfactor);
+
 /*
    InitIndex - creates and returns an Index.
 */
@@ -161,30 +172,52 @@ extern "C" void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a);
 
 extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p);
 
+/*
+   IsEmpty - return TRUE if the array has no entries it.
+*/
+
+extern "C" bool Indexing_IsEmpty (Indexing_Index i);
+
 
 /*
-   InitIndex - creates and returns an Index.
+   InitIndexTuned - creates a dynamic array with low indice.
+                    The minsize is the initial number of elements the
+                    array is allocated and growfactor determines how
+                    it will be resized once it becomes full.
 */
 
-extern "C" Indexing_Index Indexing_InitIndex (unsigned int low)
+extern "C" Indexing_Index Indexing_InitIndexTuned (unsigned int low, unsigned int minsize, unsigned int growfactor)
 {
   Indexing_Index i;
 
   Storage_ALLOCATE ((void **) &i, sizeof (Indexing__T2));
   i->Low = low;
   i->High = 0;
-  i->ArraySize = MinSize;
-  Storage_ALLOCATE (&i->ArrayStart, MinSize);
+  i->ArraySize = minsize*sizeof (void *);
+  Storage_ALLOCATE (&i->ArrayStart, i->ArraySize);
   i->ArrayStart = libc_memset (i->ArrayStart, 0, static_cast<size_t> (i->ArraySize));
   i->Debug = false;
   i->Used = 0;
   i->Map = (unsigned int) 0;
+  i->GrowFactor = growfactor;
   return i;
   /* static analysis guarentees a RETURN statement will be used before here.  */
   __builtin_unreachable ();
 }
 
 
+/*
+   InitIndex - creates and returns an Index.
+*/
+
+extern "C" Indexing_Index Indexing_InitIndex (unsigned int low)
+{
+  return Indexing_InitIndexTuned (low, MinSize, DefaultGrowFactor);
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
 /*
    KillIndex - returns Index to free storage.
 */
@@ -298,7 +331,7 @@ extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a)
           oldSize = i->ArraySize;
           while (((n-i->Low)*sizeof (void *)) >= i->ArraySize)
             {
-              i->ArraySize = i->ArraySize*2;
+              i->ArraySize = i->ArraySize*i->GrowFactor;
             }
           if (oldSize != i->ArraySize)
             {
@@ -484,6 +517,18 @@ extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_Inde
     }
 }
 
+
+/*
+   IsEmpty - return TRUE if the array has no entries it.
+*/
+
+extern "C" bool Indexing_IsEmpty (Indexing_Index i)
+{
+  return i->Used == 0;
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
 extern "C" void _M2_Indexing_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
 {
 }
diff --git a/gcc/m2/pge-boot/GIndexing.h b/gcc/m2/pge-boot/GIndexing.h
index 63bef3702e8..d65e8bd91dd 100644
--- a/gcc/m2/pge-boot/GIndexing.h
+++ b/gcc/m2/pge-boot/GIndexing.h
@@ -60,6 +60,15 @@ typedef void (*Indexing_IndexProcedure_t) (void *);
 struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; };
 
 
+/*
+   InitIndexTuned - creates a dynamic array with low indice.
+                    minsize is the initial number of elements the
+                    array is allocated and growfactor determines how
+                    it will be resized once it becomes full.
+*/
+
+EXTERN Indexing_Index Indexing_InitIndexTuned (unsigned int low, unsigned int minsize, unsigned int growfactor);
+
 /*
    InitIndex - creates and returns an Index.
 */
@@ -139,6 +148,12 @@ EXTERN void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a);
 */
 
 EXTERN void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p);
+
+/*
+   IsEmpty - return TRUE if the array has no entries it.
+*/
+
+EXTERN bool Indexing_IsEmpty (Indexing_Index i);
 #   ifdef __cplusplus
 }
 #   endif
diff --git a/gcc/m2/pge-boot/GM2Dependent.cc b/gcc/m2/pge-boot/GM2Dependent.cc
index 4a4492ad292..89c80832889 100644
--- a/gcc/m2/pge-boot/GM2Dependent.cc
+++ b/gcc/m2/pge-boot/GM2Dependent.cc
@@ -58,7 +58,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #   include "GSYSTEM.h"
 #   include "GStorage.h"
 #   include "GStrLib.h"
-#   include "GM2RTS.h"
 
 typedef struct M2Dependent_ArgCVEnvP_p M2Dependent_ArgCVEnvP;
 
@@ -66,11 +65,17 @@ typedef struct M2Dependent_DependencyList_r M2Dependent_DependencyList;
 
 typedef char *M2Dependent_PtrToChar;
 
+typedef struct M2Dependent_ProcedureList_r M2Dependent_ProcedureList;
+
 typedef struct M2Dependent__T2_r M2Dependent__T2;
 
 typedef M2Dependent__T2 *M2Dependent_ModuleChain;
 
-typedef struct M2Dependent__T3_a M2Dependent__T3;
+typedef struct M2Dependent__T3_r M2Dependent__T3;
+
+typedef M2Dependent__T3 *M2Dependent_ProcedureChain;
+
+typedef struct M2Dependent__T4_a M2Dependent__T4;
 
 typedef enum {M2Dependent_unregistered, M2Dependent_unordered, M2Dependent_started, M2Dependent_ordered, M2Dependent_user} M2Dependent_DependencyState;
 
@@ -85,7 +90,18 @@ struct M2Dependent_DependencyList_r {
                                       M2Dependent_DependencyState state;
                                     };
 
-struct M2Dependent__T3_a { M2Dependent_ModuleChain array[M2Dependent_user-M2Dependent_unregistered+1]; };
+struct M2Dependent_ProcedureList_r {
+                                     M2Dependent_ProcedureChain head;
+                                     M2Dependent_ProcedureChain tail;
+                                   };
+
+struct M2Dependent__T3_r {
+                           PROC p;
+                           M2Dependent_ProcedureChain prev;
+                           M2Dependent_ProcedureChain next;
+                         };
+
+struct M2Dependent__T4_a { M2Dependent_ModuleChain array[M2Dependent_user-M2Dependent_unregistered+1]; };
 struct M2Dependent__T2_r {
                            void *name;
                            void *libname;
@@ -96,7 +112,7 @@ struct M2Dependent__T2_r {
                            M2Dependent_ModuleChain next;
                          };
 
-static M2Dependent__T3 Modules;
+static M2Dependent__T4 Modules;
 static bool DynamicInitialization;
 static bool Initialized;
 static bool WarningTrace;
@@ -106,6 +122,8 @@ static bool DependencyTrace;
 static bool PreTrace;
 static bool PostTrace;
 static bool ForceTrace;
+static M2Dependent_ProcedureList InitialProc;
+static M2Dependent_ProcedureList TerminateProc;
 
 /*
    ConstructModules - resolve dependencies and then call each
@@ -137,6 +155,38 @@ extern "C" void M2Dependent_RegisterModule (void * modulename, void * libname, M
 
 extern "C" void M2Dependent_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
 
+/*
+   InstallTerminationProcedure - installs a procedure, p, which will
+                                 be called when the procedure
+                                 ExecuteTerminationProcedures
+                                 is invoked.  It returns TRUE if the
+                                 procedure is installed.
+*/
+
+extern "C" bool M2Dependent_InstallTerminationProcedure (PROC p);
+
+/*
+   ExecuteInitialProcedures - executes the initial procedures installed by
+                              InstallInitialProcedure.
+*/
+
+extern "C" void M2Dependent_ExecuteInitialProcedures (void);
+
+/*
+   InstallInitialProcedure - installs a procedure to be executed just
+                             before the BEGIN code section of the
+                             main program module.
+*/
+
+extern "C" bool M2Dependent_InstallInitialProcedure (PROC p);
+
+/*
+   ExecuteTerminationProcedures - calls each installed termination procedure
+                                  in reverse order.
+*/
+
+extern "C" void M2Dependent_ExecuteTerminationProcedures (void);
+
 /*
    InitDependencyList - initialize all fields of DependencyList.
 */
@@ -362,6 +412,27 @@ static void Init (void);
 
 static void CheckInitialized (void);
 
+/*
+   ExecuteReverse - execute the procedure associated with procptr
+                    and then proceed to try and execute all previous
+                    procedures in the chain.
+*/
+
+static void ExecuteReverse (M2Dependent_ProcedureChain procptr);
+
+/*
+   AppendProc - append proc to the end of the procedure list
+                defined by proclist.
+*/
+
+static bool AppendProc (M2Dependent_ProcedureList *proclist, PROC proc);
+
+/*
+   InitProcList - initialize the head and tail pointers to NIL.
+*/
+
+static void InitProcList (M2Dependent_ProcedureList *p);
+
 
 /*
    InitDependencyList - initialize all fields of DependencyList.
@@ -968,10 +1039,10 @@ static void combine (M2Dependent_DependencyState src, M2Dependent_DependencyStat
 
 static void tracemodule (bool flag, void * modname, unsigned int modlen, void * libname, unsigned int liblen)
 {
-  typedef struct tracemodule__T4_a tracemodule__T4;
+  typedef struct tracemodule__T5_a tracemodule__T5;
 
-  struct tracemodule__T4_a { char array[100+1]; };
-  tracemodule__T4 buffer;
+  struct tracemodule__T5_a { char array[100+1]; };
+  tracemodule__T5 buffer;
   unsigned int len;
 
   if (flag)
@@ -1112,10 +1183,10 @@ static void CheckApplication (void)
 
 static void warning3 (const char *format_, unsigned int _format_high, void * arg1, void * arg2)
 {
-  typedef struct warning3__T5_a warning3__T5;
+  typedef struct warning3__T6_a warning3__T6;
 
-  struct warning3__T5_a { char array[4096+1]; };
-  warning3__T5 buffer;
+  struct warning3__T6_a { char array[4096+1]; };
+  warning3__T6 buffer;
   int len;
   char format[_format_high+1];
 
@@ -1254,6 +1325,8 @@ static void Init (void)
 {
   M2Dependent_DependencyState state;
 
+  InitProcList (&InitialProc);
+  InitProcList (&TerminateProc);
   SetupDebugFlags ();
   for (state=M2Dependent_unregistered; state<=M2Dependent_user; state= static_cast<M2Dependent_DependencyState>(static_cast<int>(state+1)))
     {
@@ -1280,6 +1353,57 @@ static void CheckInitialized (void)
 }
 
 
+/*
+   ExecuteReverse - execute the procedure associated with procptr
+                    and then proceed to try and execute all previous
+                    procedures in the chain.
+*/
+
+static void ExecuteReverse (M2Dependent_ProcedureChain procptr)
+{
+  while (procptr != NULL)
+    {
+      (*procptr->p.proc) ();  /* Invoke the procedure.  */
+      procptr = procptr->prev;  /* Invoke the procedure.  */
+    }
+}
+
+
+/*
+   AppendProc - append proc to the end of the procedure list
+                defined by proclist.
+*/
+
+static bool AppendProc (M2Dependent_ProcedureList *proclist, PROC proc)
+{
+  M2Dependent_ProcedureChain pdes;
+
+  Storage_ALLOCATE ((void **) &pdes, sizeof (M2Dependent__T3));
+  pdes->p = proc;
+  pdes->prev = (*proclist).tail;
+  pdes->next = NULL;
+  if ((*proclist).head == NULL)
+    {
+      (*proclist).head = pdes;
+    }
+  (*proclist).tail = pdes;
+  return true;
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
+/*
+   InitProcList - initialize the head and tail pointers to NIL.
+*/
+
+static void InitProcList (M2Dependent_ProcedureList *p)
+{
+  (*p).head = NULL;
+  (*p).tail = NULL;
+}
+
+
 /*
    ConstructModules - resolve dependencies and then call each
                       module constructor in turn.
@@ -1329,8 +1453,8 @@ extern "C" void M2Dependent_ConstructModules (void * applicationmodule, void * l
         if (mptr->dependency.appl)
           {
             traceprintf3 (ModuleTrace, (const char *) "application module: %s [%s]\\n", 29, mptr->name, mptr->libname);
-            traceprintf (ModuleTrace, (const char *) "  calling M2RTS_ExecuteInitialProcedures\\n", 42);
-            M2RTS_ExecuteInitialProcedures ();
+            traceprintf (ModuleTrace, (const char *) "  calling ExecuteInitialProcedures\\n", 36);
+            M2Dependent_ExecuteInitialProcedures ();
             traceprintf (ModuleTrace, (const char *) "  calling application module\\n", 30);
           }
         (*mptr->init.proc) (argc, argv, envp);
@@ -1357,7 +1481,7 @@ extern "C" void M2Dependent_DeconstructModules (void * applicationmodule, void *
   else
     {
       traceprintf (ModuleTrace, (const char *) "ExecuteTerminationProcedures\\n", 30);
-      M2RTS_ExecuteTerminationProcedures ();
+      M2Dependent_ExecuteTerminationProcedures ();
       traceprintf (ModuleTrace, (const char *) "terminating modules in sequence\\n", 33);
       mptr = Modules.array[M2Dependent_ordered-M2Dependent_unregistered]->prev;
       do {
@@ -1413,6 +1537,58 @@ extern "C" void M2Dependent_RequestDependant (void * modulename, void * libname,
   PerformRequestDependant (modulename, libname, dependantmodule, dependantlibname);
 }
 
+
+/*
+   InstallTerminationProcedure - installs a procedure, p, which will
+                                 be called when the procedure
+                                 ExecuteTerminationProcedures
+                                 is invoked.  It returns TRUE if the
+                                 procedure is installed.
+*/
+
+extern "C" bool M2Dependent_InstallTerminationProcedure (PROC p)
+{
+  return AppendProc (&TerminateProc, p);
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
+/*
+   ExecuteInitialProcedures - executes the initial procedures installed by
+                              InstallInitialProcedure.
+*/
+
+extern "C" void M2Dependent_ExecuteInitialProcedures (void)
+{
+  ExecuteReverse (InitialProc.tail);
+}
+
+
+/*
+   InstallInitialProcedure - installs a procedure to be executed just
+                             before the BEGIN code section of the
+                             main program module.
+*/
+
+extern "C" bool M2Dependent_InstallInitialProcedure (PROC p)
+{
+  return AppendProc (&InitialProc, p);
+  /* static analysis guarentees a RETURN statement will be used before here.  */
+  __builtin_unreachable ();
+}
+
+
+/*
+   ExecuteTerminationProcedures - calls each installed termination procedure
+                                  in reverse order.
+*/
+
+extern "C" void M2Dependent_ExecuteTerminationProcedures (void)
+{
+  ExecuteReverse (TerminateProc.tail);
+}
+
 extern "C" void _M2_M2Dependent_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
 {
   CheckInitialized ();
diff --git a/gcc/m2/pge-boot/GM2Dependent.h b/gcc/m2/pge-boot/GM2Dependent.h
index 0a2a60a9653..0353236f8c1 100644
--- a/gcc/m2/pge-boot/GM2Dependent.h
+++ b/gcc/m2/pge-boot/GM2Dependent.h
@@ -72,6 +72,38 @@ EXTERN void M2Dependent_RegisterModule (void * modulename, void * libname, M2Dep
 */
 
 EXTERN void M2Dependent_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
+
+/*
+   InstallTerminationProcedure - installs a procedure, p, which will
+                                 be called when the procedure
+                                 ExecuteTerminationProcedures
+                                 is invoked.  It returns TRUE is the
+                                 procedure is installed.
+*/
+
+EXTERN bool M2Dependent_InstallTerminationProcedure (PROC p);
+
+/*
+   ExecuteInitialProcedures - executes the initial procedures installed
+                              by InstallInitialProcedure.
+*/
+
+EXTERN void M2Dependent_ExecuteInitialProcedures (void);
+
+/*
+   InstallInitialProcedure - installs a procedure to be executed just
+                             before the BEGIN code section of the main
+                             program module.
+*/
+
+EXTERN bool M2Dependent_InstallInitialProcedure (PROC p);
+
+/*
+   ExecuteTerminationProcedures - calls each installed termination procedure
+                                  in reverse order.
+*/
+
+EXTERN void M2Dependent_ExecuteTerminationProcedures (void);
 #   ifdef __cplusplus
 }
 #   endif
diff --git a/gcc/m2/pge-boot/GM2RTS.cc b/gcc/m2/pge-boot/GM2RTS.cc
index 827eeab124f..5214c42ae9b 100644
--- a/gcc/m2/pge-boot/GM2RTS.cc
+++ b/gcc/m2/pge-boot/GM2RTS.cc
@@ -40,16 +40,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #      define FALSE (1==0)
 #   endif
 
-#include <stddef.h>
 #include <string.h>
 #include <limits.h>
 #include <stdlib.h>
-#   include "GStorage.h"
 #include <unistd.h>
-#if defined(__cplusplus)
-#   undef NULL
-#   define NULL 0
-#endif
 #define _M2RTS_H
 #define _M2RTS_C
 
@@ -66,30 +60,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
 
 #   define stderrFd 2
-typedef struct M2RTS_ProcedureList_r M2RTS_ProcedureList;
-
 typedef char *M2RTS_PtrToChar;
 
-typedef struct M2RTS__T1_r M2RTS__T1;
-
-typedef M2RTS__T1 *M2RTS_ProcedureChain;
-
 typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
 struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
 
-struct M2RTS_ProcedureList_r {
-                               M2RTS_ProcedureChain head;
-                               M2RTS_ProcedureChain tail;
-                             };
-
-struct M2RTS__T1_r {
-                     PROC p;
-                     M2RTS_ProcedureChain prev;
-                     M2RTS_ProcedureChain next;
-                   };
-
-static M2RTS_ProcedureList InitialProc;
-static M2RTS_ProcedureList TerminateProc;
 static int ExitValue;
 static bool isHalting;
 static bool CallExit;
@@ -238,21 +213,6 @@ extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, un
 extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
 extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message);
 
-/*
-   ExecuteReverse - execute the procedure associated with procptr
-                    and then proceed to try and execute all previous
-                    procedures in the chain.
-*/
-
-static void ExecuteReverse (M2RTS_ProcedureChain procptr);
-
-/*
-   AppendProc - append proc to the end of the procedure list
-                defined by proclist.
-*/
-
-static bool AppendProc (M2RTS_ProcedureList *proclist, PROC proc);
-
 /*
    ErrorString - writes a string to stderr.
 */
@@ -271,12 +231,6 @@ static void ErrorStringC (void * str);
 
 static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function);
 
-/*
-   InitProcList - initialize the head and tail pointers to NIL.
-*/
-
-static void InitProcList (M2RTS_ProcedureList *p);
-
 /*
    Init - initialize the initial, terminate procedure lists and booleans.
 */
@@ -293,46 +247,6 @@ static void Init (void);
 static void CheckInitialized (void);
 
 
-/*
-   ExecuteReverse - execute the procedure associated with procptr
-                    and then proceed to try and execute all previous
-                    procedures in the chain.
-*/
-
-static void ExecuteReverse (M2RTS_ProcedureChain procptr)
-{
-  while (procptr != NULL)
-    {
-      (*procptr->p.proc) ();  /* Invoke the procedure.  */
-      procptr = procptr->prev;  /* Invoke the procedure.  */
-    }
-}
-
-
-/*
-   AppendProc - append proc to the end of the procedure list
-                defined by proclist.
-*/
-
-static bool AppendProc (M2RTS_ProcedureList *proclist, PROC proc)
-{
-  M2RTS_ProcedureChain pdes;
-
-  Storage_ALLOCATE ((void **) &pdes, sizeof (M2RTS__T1));
-  pdes->p = proc;
-  pdes->prev = (*proclist).tail;
-  pdes->next = NULL;
-  if ((*proclist).head == NULL)
-    {
-      (*proclist).head = pdes;
-    }
-  (*proclist).tail = pdes;
-  return true;
-  /* static analysis guarentees a RETURN statement will be used before here.  */
-  __builtin_unreachable ();
-}
-
-
 /*
    ErrorString - writes a string to stderr.
 */
@@ -367,10 +281,10 @@ static void ErrorStringC (void * str)
 
 static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function)
 {
-  typedef struct ErrorMessageC__T2_a ErrorMessageC__T2;
+  typedef struct ErrorMessageC__T1_a ErrorMessageC__T1;
 
-  struct ErrorMessageC__T2_a { char array[10+1]; };
-  ErrorMessageC__T2 buffer;
+  struct ErrorMessageC__T1_a { char array[10+1]; };
+  ErrorMessageC__T1 buffer;
 
   ErrorStringC (filename);
   ErrorString ((const char *) ":", 1);
@@ -391,25 +305,12 @@ static void ErrorMessageC (void * message, void * filename, unsigned int line, v
 }
 
 
-/*
-   InitProcList - initialize the head and tail pointers to NIL.
-*/
-
-static void InitProcList (M2RTS_ProcedureList *p)
-{
-  (*p).head = NULL;
-  (*p).tail = NULL;
-}
-
-
 /*
    Init - initialize the initial, terminate procedure lists and booleans.
 */
 
 static void Init (void)
 {
-  InitProcList (&InitialProc);
-  InitProcList (&TerminateProc);
   ExitValue = 0;
   isHalting = false;
   CallExit = false;  /* default by calling abort  */
@@ -488,7 +389,7 @@ extern "C" void M2RTS_RequestDependant (void * modulename, void * libname, void
 
 extern "C" bool M2RTS_InstallTerminationProcedure (PROC p)
 {
-  return AppendProc (&TerminateProc, p);
+  return M2Dependent_InstallTerminationProcedure (p);
   /* static analysis guarentees a RETURN statement will be used before here.  */
   __builtin_unreachable ();
 }
@@ -501,7 +402,7 @@ extern "C" bool M2RTS_InstallTerminationProcedure (PROC p)
 
 extern "C" void M2RTS_ExecuteInitialProcedures (void)
 {
-  ExecuteReverse (InitialProc.tail);
+  M2Dependent_ExecuteInitialProcedures ();
 }
 
 
@@ -513,7 +414,7 @@ extern "C" void M2RTS_ExecuteInitialProcedures (void)
 
 extern "C" bool M2RTS_InstallInitialProcedure (PROC p)
 {
-  return AppendProc (&InitialProc, p);
+  return M2Dependent_InstallInitialProcedure (p);
   /* static analysis guarentees a RETURN statement will be used before here.  */
   __builtin_unreachable ();
 }
@@ -526,7 +427,7 @@ extern "C" bool M2RTS_InstallInitialProcedure (PROC p)
 
 extern "C" void M2RTS_ExecuteTerminationProcedures (void)
 {
-  ExecuteReverse (TerminateProc.tail);
+  M2Dependent_ExecuteTerminationProcedures ();
 }
 
 
@@ -632,10 +533,10 @@ extern "C" void M2RTS_ExitOnHalt (int e)
 
 extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high)
 {
-  typedef struct ErrorMessage__T3_a ErrorMessage__T3;
+  typedef struct ErrorMessage__T2_a ErrorMessage__T2;
 
-  struct ErrorMessage__T3_a { char array[10+1]; };
-  ErrorMessage__T3 buffer;
+  struct ErrorMessage__T2_a { char array[10+1]; };
+  ErrorMessage__T2 buffer;
   char message[_message_high+1];
   char filename[_filename_high+1];
   char function[_function_high+1];

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-08 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08 12:52 [gcc r14-9390] modula2: Rebuild bootstrap tools with faster dynamic arrays Gaius Mulley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).