many speed-up changes, resulting in 20-25% speedup, and fixed
authorceriel <none@none>
Mon, 13 Nov 1989 15:36:12 +0000 (15:36 +0000)
committerceriel <none@none>
Mon, 13 Nov 1989 15:36:12 +0000 (15:36 +0000)
serious floating point handling bug

21 files changed:
util/int/ChangeLog
util/int/data.c
util/int/do_comp.c
util/int/do_fpar.c
util/int/do_incdec.c
util/int/do_load.c
util/int/do_misc.c
util/int/do_sets.c
util/int/dump.c
util/int/global.c
util/int/global.h
util/int/init.c
util/int/m_sigtrp.c
util/int/mem.h
util/int/moncalls.c
util/int/read.c
util/int/shadow.h
util/int/stack.c
util/int/text.c
util/int/text.h
util/int/trap.c

index 9995a6e..759ded4 100644 (file)
@@ -1,3 +1,10 @@
+13-Nov-89  Ceriel Jacobs (ceriel) at ceriel
+       Many changes for speed-up (resulting speed-up: 20-25%).
+       Also fixed serious problem in floating point handling: the existing
+       code assumed that the low order 4 bytes of a double could be used as
+       a float (4 bytes). This is NOT true for most floating point
+       implementations, notably IEEE ones.
+
  3-Oct-88  Dick Grune (dick) at dick
        Since the definitions of VERSION and MAGIC are now available from
        standard include files, e.out.h can be simplified.
index 7a495a6..9b3e1fa 100644 (file)
@@ -60,7 +60,7 @@ newHP(ap)
        if (in_stack(p)) {
                wtrap(WHPSTACK, EHEAP);
        }
-       if (!is_aligned(p, wsize)) {
+       if (!is_wordaligned(p)) {
                wtrap(WHPODD, EHEAP);
        }
        if (maxheap) {
@@ -99,61 +99,61 @@ newHP(ap)
  ************************************************************************/
 
 dt_stdp(addr, ap)
-       ptr addr, ap;
+       register ptr addr;
+       ptr ap;
 {
        register int i;
        register long p = (long) ap;
 
        LOG(("@g6 dt_stdp(%lu, %lu)", addr, p));
        ch_in_data(addr, psize);
-       ch_aligned(addr, wsize);
-       for (i = 0; i < (int) psize; i++) {
-               ch_dt_prot(addr + i);
-               data_loc(addr + i) = (char) (p);
-               dt_dp(addr + i);
+       ch_wordaligned(addr);
+       for (i = (int) psize; i > 0; i--, addr++) {
+               ch_dt_prot(addr);
+               data_loc(addr) = (char) (p);
+               dt_dp(addr);
                p = p>>8;
        }
 }
 
 dt_stip(addr, ap)
-       ptr addr, ap;
+       register ptr addr;
+       ptr ap;
 {
        register int i;
        register long p = (long) ap;
 
        LOG(("@g6 dt_stip(%lu, %lu)", addr, p));
        ch_in_data(addr, psize);
-       ch_aligned(addr, wsize);
-       for (i = 0; i < (int) psize; i++) {
-               ch_dt_prot(addr + i);
-               data_loc(addr + i) = (char) (p);
-               dt_ip(addr + i);
+       ch_wordaligned(addr);
+       for (i = (int) psize; i > 0; i--, addr++) {
+               ch_dt_prot(addr);
+               data_loc(addr) = (char) (p);
+               dt_ip(addr);
                p = p>>8;
        }
 }
 
 dt_stn(addr, al, n)
-       ptr addr;
+       register ptr addr;
        long al;
        size n;
 {
        register int i;
        register long l = al;
+#ifdef LOGGING
+       /* a psize zero is ambiguous */
+       int sh_flags = (l == 0 && n == psize) ? (SH_INT|SH_DATAP) : SH_INT;
+#endif LOGGING
 
        LOG(("@g6 dt_stn(%lu, %lu, %lu)", addr, l, n));
        ch_in_data(addr, n);
        ch_aligned(addr, n);
-       for (i = 0; i < (int) n; i++) {
-               ch_dt_prot(addr + i);
-               data_loc(addr + i) = (char) l;
-#ifdef LOGGING
-               if (al == 0 && n == psize) {
-                       /* a psize zero, ambiguous */
-                       dt_sh(addr + i) = (SH_INT|SH_DATAP);
-               }
-               else {
-                       dt_sh(addr + i) = SH_INT;
-               }
+       for (i = (int) n; i > 0; i--, addr++) {
+               ch_dt_prot(addr);
+               data_loc(addr) = (char) l;
+#ifdef LOGGING
+               dt_sh(addr) = sh_flags;
 #endif LOGGING
                l = l>>8;
        }
@@ -161,20 +161,25 @@ dt_stn(addr, al, n)
 
 #ifndef        NOFLOAT
 dt_stf(addr, f, n)
-       ptr addr;
+       register ptr addr;
        double f;
-       size n;
+       register size n;
 {
        register char *cp = (char *) &f;
        register int i;
+       float fl;
 
        LOG(("@g6 dt_stf(%lu, %g, %lu)", addr, f, n));
        ch_in_data(addr, n);
-       ch_aligned(addr, wsize);
-       for (i = 0; i < (int) n; i++) {
-               ch_dt_prot(addr + i);
-               data_loc(addr + i) = *cp++;
-               dt_fl(addr + i);
+       ch_wordaligned(addr);
+       if ((int) n == 4) {
+               fl = f;
+               cp = (char *) &fl;
+       }
+       for (i = (int) n; i > 0; i--, addr++) {
+               ch_dt_prot(addr);
+               data_loc(addr) = *cp++;
+               dt_fl(addr);
        }
 }
 #endif NOFLOAT
@@ -191,14 +196,14 @@ dt_stf(addr, f, n)
  ************************************************************************/
 
 ptr dt_lddp(addr)
-       ptr addr;
+       register ptr addr;
 {
        register ptr p;
 
        LOG(("@g6 dt_lddp(%lu)", addr));
 
        ch_in_data(addr, psize);
-       ch_aligned(addr, wsize);
+       ch_wordaligned(addr);
 #ifdef LOGGING
        if (!is_dt_set(addr, psize, SH_DATAP)) {
                warning(WGDPEXP);
@@ -212,14 +217,14 @@ ptr dt_lddp(addr)
 }
 
 ptr dt_ldip(addr)
-       ptr addr;
+       register ptr addr;
 {
        register ptr p;
 
        LOG(("@g6 dt_ldip(%lu)", addr));
 
        ch_in_data(addr, psize);
-       ch_aligned(addr, wsize);
+       ch_wordaligned(addr);
 #ifdef LOGGING
        if (!is_dt_set(addr, psize, SH_INSP)) {
                warning(WGIPEXP);
@@ -233,7 +238,7 @@ ptr dt_ldip(addr)
 }
 
 unsigned long dt_ldu(addr, n)
-       ptr addr;
+       register ptr addr;
        size n;
 {
        register int i;
@@ -258,7 +263,7 @@ unsigned long dt_ldu(addr, n)
 }
 
 long dt_lds(addr, n)
-       ptr addr;
+       register ptr addr;
        size n;
 {
        register int i;
@@ -295,42 +300,42 @@ long dt_lds(addr, n)
  ************************************************************************/
 
 dt_mvd(d2, d1, n)                      /* d1 -> d2 */
-       ptr d2, d1;
+       register ptr d2, d1;
        size n;
 {
        register int i;
 
        ch_in_data(d1, n);
-       ch_aligned(d1, wsize);
+       ch_wordaligned(d1);
        ch_in_data(d2, n);
-       ch_aligned(d2, wsize);
+       ch_wordaligned(d2);
 
-       for (i = 0; i < (int) n; i++) {
-               ch_dt_prot(d2 + i);
-               data_loc(d2 + i) = data_loc(d1 + i);
+       for (i = (int) n; i > 0; i--, d1++, d2++) {
+               ch_dt_prot(d2);
+               data_loc(d2) = data_loc(d1);
 #ifdef LOGGING
-               dt_sh(d2 + i) = dt_sh(d1 + i) & ~SH_PROT;
+               dt_sh(d2) = dt_sh(d1) & ~SH_PROT;
 #endif LOGGING
        }
 }
 
 dt_mvs(d, s, n)                                /* s -> d */
-       ptr d, s;
+       register ptr d, s;
        size n;
 {
        register int i;
 
        ch_in_stack(s, n);
-       ch_aligned(s, wsize);
+       ch_wordaligned(s);
        ch_in_data(d, n);
-       ch_aligned(d, wsize);
+       ch_wordaligned(d);
 
-       for (i = 0; i < (int) n; i++) {
-               ch_dt_prot(d + i);
-               ch_st_prot(s + i);
-               data_loc(d + i) = stack_loc(s + i);
+       for (i = (int) n; i > 0; i--, d++, s++) {
+               ch_dt_prot(d);
+               ch_st_prot(s);
+               data_loc(d) = stack_loc(s);
 #ifdef LOGGING
-               dt_sh(d + i) = st_sh(s + i) & ~SH_PROT;
+               dt_sh(d) = st_sh(s) & ~SH_PROT;
 #endif LOGGING
        }
 }
@@ -338,8 +343,8 @@ dt_mvs(d, s, n)                             /* s -> d */
 #ifdef LOGGING
 
 PRIVATE warn_dtbits(addr, n)
-       ptr addr;
-       size n;
+       register ptr addr;
+       register size n;
 {
        register int or_bits = 0;
        register int and_bits = 0xff;
index 3fd8061..bccd577 100644 (file)
@@ -32,7 +32,7 @@ DoCMIl2(arg)
 
        LOG(("@T6 DoCMIl2(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 }
 
 DoCMIm(arg)
@@ -45,7 +45,7 @@ DoCMIm(arg)
 
        LOG(("@T6 DoCMIm(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 }
 
 DoCMIz()
@@ -57,7 +57,7 @@ DoCMIz()
 
        LOG(("@T6 DoCMIz(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 }
 
 DoCMFl2(arg)
@@ -71,7 +71,7 @@ DoCMFl2(arg)
 
        LOG(("@T6 DoCMFl2(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 #else  NOFLOAT
        arg = arg;
        nofloat();
@@ -90,7 +90,7 @@ DoCMFs(hob, wfac)
 
        LOG(("@T6 DoCMFs(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 #else  NOFLOAT
        hob = hob;
        wfac = wfac;
@@ -108,7 +108,7 @@ DoCMFz()
 
        LOG(("@T6 DoCMFz(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 #else  NOFLOAT
        nofloat();
 #endif NOFLOAT
@@ -124,7 +124,7 @@ DoCMUl2(arg)
 
        LOG(("@T6 DoCMUl2(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 }
 
 DoCMUz()
@@ -136,7 +136,7 @@ DoCMUz()
 
        LOG(("@T6 DoCMUz(%ld)", l));
        spoilFRA();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 }
 
 DoCMSl2(arg)
@@ -181,7 +181,7 @@ DoCMPz()
        spoilFRA();
        t = dppop();
        s = dppop();
-       npush((long)(t < s ? 1 : t > s ? -1 : 0), wsize);
+       wpush((long)(t < s ? 1 : t > s ? -1 : 0));
 }
 
 DoTLTz()
@@ -189,7 +189,7 @@ DoTLTz()
        /* TLT -: True if less, i.e. iff top of stack < 0 */
        LOG(("@T6 DoTLTz()"));
        spoilFRA();
-       npush((long)(wpop() < 0 ? 1 : 0), wsize);
+       wpush((long)(wpop() < 0 ? 1 : 0));
 }
 
 DoTLEz()
@@ -197,7 +197,7 @@ DoTLEz()
        /* TLE -: True if less or equal, i.e. iff top of stack <= 0 */
        LOG(("@T6 DoTLEz()"));
        spoilFRA();
-       npush((long)(wpop() <= 0 ? 1 : 0), wsize);
+       wpush((long)(wpop() <= 0 ? 1 : 0));
 }
 
 DoTEQz()
@@ -205,7 +205,7 @@ DoTEQz()
        /* TEQ -: True if equal, i.e. iff top of stack = 0 */
        LOG(("@T6 DoTEQz()"));
        spoilFRA();
-       npush((long)(wpop() == 0 ? 1 : 0), wsize);
+       wpush((long)(wpop() == 0 ? 1 : 0));
 }
 
 DoTNEz()
@@ -213,7 +213,7 @@ DoTNEz()
        /* TNE -: True if not equal, i.e. iff top of stack non zero */
        LOG(("@T6 DoTNEz()"));
        spoilFRA();
-       npush((long)(wpop() != 0 ? 1 : 0), wsize);
+       wpush((long)(wpop() != 0 ? 1 : 0));
 }
 
 DoTGEz()
@@ -221,7 +221,7 @@ DoTGEz()
        /* TGE -: True if greater or equal, i.e. iff top of stack >= 0 */
        LOG(("@T6 DoTGEz()"));
        spoilFRA();
-       npush((long)(wpop() >= 0 ? 1 : 0), wsize);
+       wpush((long)(wpop() >= 0 ? 1 : 0));
 }
 
 DoTGTz()
@@ -229,7 +229,7 @@ DoTGTz()
        /* TGT -: True if greater, i.e. iff top of stack > 0 */
        LOG(("@T6 DoTGTz()"));
        spoilFRA();
-       npush((long)(wpop() > 0 ? 1 : 0), wsize);
+       wpush((long)(wpop() > 0 ? 1 : 0));
 }
 
 /********************************************************
@@ -267,5 +267,5 @@ PRIVATE compare_obj(obj_size)
                }
        }
        st_dec(2 * obj_size);
-       npush((long) comp_res, wsize);
+       wpush((long) comp_res);
 }
index 76d3e35..80a9c24 100644 (file)
@@ -461,7 +461,7 @@ PRIVATE fef(f, n)
                f *= 2.0;
 
        fpush((sign) ? -f : f, n);      /* push mantissa */
-       npush(exponent, wsize);         /* push exponent */
+       wpush(exponent);                /* push exponent */
 }
 
 /* floating point service routines, to avoid having to use -lm */
index e47d5e4..9b3cebf 100644 (file)
@@ -21,7 +21,7 @@ DoINCz()
        /* INC -: Increment word on top of stack by 1 (*) */
        LOG(("@Z6 DoINCz()"));
        spoilFRA();
-       npush(inc(spop(wsize)), wsize);
+       wpush(inc(spop(wsize)));
 }
 
 DoINLm(arg)
@@ -150,7 +150,7 @@ DoDECz()
        /* DEC -: Decrement word on top of stack by 1 (*) */
        LOG(("@Z6 DoDECz()"));
        spoilFRA();
-       npush(dec(spop(wsize)), wsize);
+       wpush(dec(spop(wsize)));
 }
 
 DoDELn2(arg)
@@ -406,7 +406,7 @@ DoZERl2(arg)
        LOG(("@Z6 DoZERl2(%ld)", l));
        spoilFRA();
        for (i = arg_w(l); i; i -= wsize)
-               npush(0L, wsize);
+               wpush(0L);
 }
 
 DoZERs(hob, wfac)
@@ -419,7 +419,7 @@ DoZERs(hob, wfac)
        LOG(("@Z6 DoZERs(%ld)", l));
        spoilFRA();
        for (i = arg_w(l); i; i -= wsize)
-               npush(0L, wsize);
+               wpush(0L);
 }
 
 DoZERz()
@@ -430,7 +430,7 @@ DoZERz()
        LOG(("@Z6 DoZERz(%ld)", l));
        spoilFRA();
        for (i = arg_w(l); i; i -= wsize)
-               npush(0L, wsize);
+               wpush(0L);
 }
 
 PRIVATE long inc(l)
index dc60ac9..bc397de 100644 (file)
@@ -24,7 +24,7 @@ DoLOCl2(arg)
 
        LOG(("@L6 DoLOCl2(%ld)", l));
        spoilFRA();
-       npush(arg_c(l), wsize);
+       wpush(arg_c(l));
 }
 
 DoLOCl4(arg)
@@ -35,7 +35,7 @@ DoLOCl4(arg)
 
        LOG(("@L6 DoLOCl4(%ld)", l));
        spoilFRA();
-       npush(arg_c(l), wsize);
+       wpush(arg_c(l));
 }
 
 DoLOCm(arg)
@@ -46,7 +46,7 @@ DoLOCm(arg)
 
        LOG(("@L6 DoLOCm(%ld)", l));
        spoilFRA();
-       npush(l, wsize);
+       wpush(l);
 }
 
 DoLOCs(hob, wfac)
@@ -58,7 +58,7 @@ DoLOCs(hob, wfac)
 
        LOG(("@L6 DoLOCs(%ld)", l));
        spoilFRA();
-       npush(arg_c(l), wsize);
+       wpush(arg_c(l));
 }
 
 DoLDCl2(arg)
index f3fcd6c..9eecf0d 100644 (file)
@@ -402,7 +402,7 @@ DoLIMz()
        /* LIM -: Load 16 bit ignore mask */
        LOG(("@M6 DoLIMz()"));
        spoilFRA();
-       npush(IgnMask, wsize);
+       wpush(IgnMask);
 }
 
 DoLINl2(arg)
index 633b339..a0a63fc 100644 (file)
@@ -102,9 +102,9 @@ PRIVATE bit_test(w)
                        trap(ESET);
                }
        }
-       test_byte = stack_loc(SP + (bitno / 8));
+       test_byte = stack_loc(SP + (bitno >> 3));
        st_dec(w);
-       npush((long)((test_byte & BIT(bitno % 8)) ? 1 : 0), wsize);
+       wpush((long)((test_byte & BIT(bitno & 7)) ? 1 : 0));
 }
 
 /********************************************************
@@ -132,6 +132,6 @@ PRIVATE create_set(w)
                        trap(ESET);
                }
        }
-       st_stn(SP + (bitno / 8), (long)BIT(bitno % 8), 1L);
+       st_stn(SP + (bitno >> 3), (long)BIT(bitno & 7), 1L);
 }
 
index 3a2daa6..a2e1121 100644 (file)
@@ -117,7 +117,7 @@ std_raw(addr, rawfl)
 PRIVATE std_item(addr)
        ptr addr;
 {
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_stack(addr, psize)
        &&      std_bytes(addr, addr + psize, SH_DATAP|SH_INSP)
        ) {
@@ -129,7 +129,7 @@ PRIVATE std_item(addr)
                        displ_sh(st_sh(addr), stack_loc(addr))));
        }
        else
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_stack(addr, wsize)
        &&      std_bytes(addr, addr + wsize, SH_INT)
        ) {
@@ -243,7 +243,7 @@ PRIVATE FRA_dump()
 PRIVATE FRA_item(addr)
        int addr;
 {
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_FRA(addr, psize)
        &&      FRAd_bytes(addr, (int)(addr + psize), SH_DATAP|SH_INSP)
        ) {
@@ -255,7 +255,7 @@ PRIVATE FRA_item(addr)
                        displ_sh(FRA_sh[addr], FRA[addr])));
        }
        else
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_FRA(addr, wsize)
        &&      FRAd_bytes(addr, (int)(addr + wsize), SH_INT)
        ) {
@@ -321,7 +321,7 @@ gdad_all(low, high)
 PRIVATE gdad_item(addr)
        ptr addr;
 {
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_data(addr, psize)
        &&      dtd_bytes(addr, addr + psize, SH_DATAP|SH_INSP)
        ) {
@@ -333,7 +333,7 @@ PRIVATE gdad_item(addr)
                        displ_sh(dt_sh(addr), data_loc(addr))));
        }
        else
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_data(addr, wsize)
        &&      dtd_bytes(addr, addr + wsize, SH_INT)
        ) {
@@ -411,7 +411,7 @@ hpd_all()
 PRIVATE hpd_item(addr)
        ptr addr;
 {
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_data(addr, psize)
        &&      dtd_bytes(addr, addr + psize, SH_DATAP|SH_INSP)
        ) {
@@ -423,7 +423,7 @@ PRIVATE hpd_item(addr)
                        displ_sh(dt_sh(addr), data_loc(addr))));
        }
        else
-       if (    is_aligned(addr, wsize)
+       if (    is_wordaligned(addr)
        &&      is_in_data(addr, wsize)
        &&      dtd_bytes(addr, addr + wsize, SH_INT)
        ) {
index 354aa7e..7feaa56 100644 (file)
@@ -19,6 +19,7 @@ unsigned long i_maxuw;
 long min_off;
 long max_off;
 ptr max_addr;
+size wsizem1;
 
 
 /******** EM program parameters ********/
@@ -62,6 +63,7 @@ char *data;
 ptr HL;
 
 char *stack;
+char *stackML;
 ptr SL;
 
 
index 22bc3c5..9f8e15b 100644 (file)
@@ -91,6 +91,7 @@ extern unsigned long i_maxuw; /* Max. value for unsigned integer of wsize */
 extern long min_off;           /* Minimum offset */
 extern long max_off;           /* Maximum offset */
 extern ptr max_addr;           /* Maximum address */
+extern size wsizem1;           /* wordsize - 1 */
 
 
 /******** EM program parameters ********/
@@ -139,6 +140,7 @@ extern char *data;          /* global data & heap space */
 extern ptr HL;                 /* Heap Limit */
 
 extern char *stack;            /* stack space and local data */
+extern char *stackML;          /* stack + ML, to speed up stack accesses */
 extern ptr SL;                 /* Stack Limit */
 
 
index 04e7ac5..7af6bbf 100644 (file)
@@ -134,7 +134,7 @@ init(ac, av)
        }
        dt_stdp(vecp, i2p(0));          /* terminating zero */
 
-       npush((long) ac, wsize);        /* push argc */
+       wpush((long) ac);       /* push argc */
 }
 
 PRIVATE size alignedstrlen(s)
@@ -177,7 +177,7 @@ PRIVATE ptr storestring(addr, s)
 #ifdef LOGGING
 dt_clear_area(from, to)
        ptr from;
-       ptr to;
+       register ptr to;
 {
        /* includes *from but excludes *to */
        register ptr a;
@@ -189,7 +189,7 @@ dt_clear_area(from, to)
 
 st_clear_area(from, to)
        ptr from;
-       ptr to;
+       register ptr to;
 {
        /* includes both *from and *to (since ML+1 is unexpressible) */
        register ptr a;
index 2dcad94..3b30707 100644 (file)
@@ -38,6 +38,15 @@ init_signals() {
        for (sn = 0; sn < NSIG+1; sn++) {
                /* for all signals that would cause termination */
                if (!UNIX_trap(sn)) {
+#ifdef SIGCHLD
+                       if (sn == SIGCHLD) continue;
+#endif
+#ifdef SIGIO
+                       if (sn == SIGIO) continue;
+#endif
+#ifdef SIGWINCH
+                       if (sn == SIGWINCH) continue;
+#endif
                        if (signal(sn, SIG_IGN) != SIG_IGN) {
                                /* we take our fate in our own hand */
                                signal(sn, HndlIntSig);
index 64943c5..e83333e 100644 (file)
@@ -8,7 +8,7 @@
 /******** Memory address & location defines ********/
 
 #define        data_loc(a)     (*(data + (p2i(a))))
-#define        stack_loc(a)    (*(stack + (ML - (a))))
+#define        stack_loc(a)    (*(stackML - (a)))
 #define        mem_loc(a)      (in_stack(a) ? stack_loc(a) : data_loc(a))
 
 #define        loc_addr(o)     (((o) < 0) ? (LB + (o)) : (AB + (o)))
 /******** Checks on adresses and ranges ********/
 
 #define        is_aligned(a,n) ((p2i(a)) % (n) == 0)
+#define        is_wordaligned(a)       (((p2i(a)) & wsizem1) == 0)
 
 #define        ch_aligned(a,n) { if (!is_aligned(a, min(n, wsize))) \
                                                { trap(EBADPTR); } }
+#define        ch_wordaligned(a)       { if (!is_wordaligned(a)) \
+                                               { trap(EBADPTR); } }
 
 #define        in_gda(p)       ((p) < HB)
 #define        in_stack(p)     (SP <= (p) && (p) <= ML)
index 4fc09ea..096a3bb 100644 (file)
@@ -78,7 +78,7 @@ extern void sync();
 #define        pop_unsp()      ((unsigned int) upop(psize))
 #define        pop_ptr()       (dppop())
 
-#define        push_int(a)     (npush((long)(a), wsize))
+#define        push_int(a)     (wpush((long)(a)))
 #define        push_i2(a)      (npush((long)(a), INT2SIZE))
 #define        push_i4(a)      (npush((long)(a), INT4SIZE))
 #define        push_unsp(a)    (npush((long)(a), psize))
index 0dbe5af..dd2e7e8 100644 (file)
@@ -87,6 +87,7 @@ rd_header()
                fatal("Bad wordsize in loadfile");
 
        dwsize = 2 * wsize;             /* set double wordsize */
+       wsizem1 = wsize - 1;            /* wordsize - 1 used often */
        
        psize = rd_int(2L);
        if (!(psize == 2 || psize == 4) || psize < wsize)
@@ -195,9 +196,7 @@ rd_close()
  *                                                                     *
  *     A double is 8 bytes, so it can contain 4- and 8-byte (EM)       *
  *     floating point numbers. That's why a 4-byte floating point      *
- *     number is also stored in a double. In this case only the        *
- *     the 4 LSB's are used. These bytes contain the most important    *
- *     information, the MSB's are just for precision.                  *
+ *     number is also stored in a double.                              *
  ************************************************************************/
 
 PRIVATE ptr rd_repeat(pos, count, prev_pos)
index 59af6c4..aca1ea7 100644 (file)
@@ -10,6 +10,7 @@
 
 extern char *data_sh;          /* shadowbytes of data space */
 extern char *stack_sh;         /* shadowbytes of stack space */
+extern char *stackML_sh;       /* stack_sh + ML (to speed up stack access) */
 
 /* Bit 0, 1, 2 and 3: datatype/pointertype. */
 
@@ -25,7 +26,7 @@ extern char *stack_sh;                /* shadowbytes of stack space */
 /******** Shadowbytes, general ********/
 
 #define        dt_sh(a)        (*(data_sh + (p2i(a))))
-#define        st_sh(a)        (*(stack_sh + (ML - (a))))
+#define        st_sh(a)        (*(stackML_sh - (a)))
 #define        mem_sh(a)       (in_stack(a) ? st_sh(a) : dt_sh(a))
 
 /******** Shadowbytes settings for data ********/
index cf9018e..01ca81e 100644 (file)
@@ -25,6 +25,7 @@ extern size maxstack;                 /* from main.c */
 
 #ifdef LOGGING
 char *stack_sh;                                /* stadowbytes */
+char *stackML_sh;                      /* speed up access of stadowbytes */
 #endif LOGGING
 
 PRIVATE warn_stbits();
@@ -38,8 +39,10 @@ init_stack() {
 
        SL = ML + 1 - STACKSIZE;        /* initialize Stack Limit */
        stack = Malloc(STACKSIZE, "stack space");
+       stackML = stack + ML;
 #ifdef LOGGING
        stack_sh = Malloc(STACKSIZE, "shadowspace for stack");
+       stackML_sh = stack_sh + ML;
        st_clear_area(ML, SL);
 #endif LOGGING
 }
@@ -63,37 +66,39 @@ newSP(ap)
        if (LB < p) {
                wtrap(WSPGTLB, ESTACK);
        }
-       if (p < HP) {
-               wtrap(WSPINHEAP, ESTACK);
-       }
-       if (!is_aligned(p, wsize)) {
+       if (!is_wordaligned(p)) {
                wtrap(WSPODD, ESTACK);
        }
-       if (maxstack) {
-               /* more than allowed on command line */
-               if (ML - p > maxstack) {
-                       warning(WESTACK);
-                       trap(ESTACK);
+       if (p < SP) {
+               if (p < HP) {
+                       wtrap(WSPINHEAP, ESTACK);
                }
-       }
-       if (p < SL) {
-               /* extend stack space */
-               register size stacksize = ML + 1 - p;
-
-               stacksize = allocfrac(stacksize);
-               SL = ML + 1 - stacksize;
-               stack = Realloc(stack, (size)(stacksize), "stack space");
+               if (maxstack) {
+                       /* more than allowed on command line */
+                       if (ML - p > maxstack) {
+                               warning(WESTACK);
+                               trap(ESTACK);
+                       }
+               }
+               if (p < SL) {
+                       /* extend stack space */
+                       register size stacksize = ML + 1 - p;
+
+                       stacksize = allocfrac(stacksize);
+                       SL = ML + 1 - stacksize;
+                       stack = Realloc(stack, (size)(stacksize), "stack space");
+                       stackML = stack + ML;
 #ifdef LOGGING
-               stack_sh = Realloc(stack_sh, (size)(stacksize),
+                       stack_sh = Realloc(stack_sh, (size)(stacksize),
                                                "shadowspace for stack");
+                       stackML_sh = stack_sh + ML;
 #endif LOGGING
-       }
+               }
 
 #ifdef LOGGING
-       if (!in_stack(p)) {
                st_clear_area(SP - 1, p);
-       }
 #endif LOGGING
+       }
        SP = p;
 }
 
@@ -103,7 +108,7 @@ newLB(p)
        if (!in_stack(p)) {
                wtrap(WLBOUT, ESTACK);
        }
-       if (!is_aligned(p, wsize)) {
+       if (!is_wordaligned(p)) {
                wtrap(WLBODD, ESTACK);
        }
        if (!is_LB(p)) {
@@ -126,64 +131,64 @@ newLB(p)
  ************************************************************************/
 
 st_stdp(addr, ap)
-       ptr addr, ap;
+       register ptr addr;
+       ptr ap;
 {
        register int i;
        register long p = (long) ap;
 
        LOG(("@s6 st_stdp(%lu, %lu)", addr, p));
        ch_in_stack(addr, psize);
-       ch_aligned(addr, wsize);
-       for (i = 0; i < (int) psize; i++) {
-               ch_st_prot(addr + i);
-               stack_loc(addr + i) = (char) (p);
-               st_dp(addr + i);
+       ch_wordaligned(addr);
+       for (i = (int) psize; i > 0; i--, addr++) {
+               ch_st_prot(addr);
+               stack_loc(addr) = (char) (p);
+               st_dp(addr);
                p = p>>8;
        }
 
 }
 
 st_stip(addr, ap)
-       ptr addr, ap;
+       register ptr addr;
+       ptr ap;
 {
        register int i;
        register long p = (long) ap;
 
        LOG(("@s6 st_stip(%lu, %lu)", addr, p));
        ch_in_stack(addr, psize);
-       ch_aligned(addr, wsize);
-       for (i = 0; i < (int) psize; i++) {
-               ch_st_prot(addr + i);
-               stack_loc(addr + i) = (char) (p);
-               st_ip(addr + i);
+       ch_wordaligned(addr);
+       for (i = (int) psize; i > 0; i--, addr++) {
+               ch_st_prot(addr);
+               stack_loc(addr) = (char) (p);
+               st_ip(addr);
                p = p>>8;
        }
 }
 
 st_stn(addr, al, n)
-       ptr addr;
+       register ptr addr;
        long al;
        size n;
 {
        register int i;
        register long l = al;
+#ifdef LOGGING
+       /* a psize zero is ambiguous */
+       int sh_flags = (l == 0 && n == psize) ? (SH_INT|SH_DATAP) : SH_INT;
+#endif
 
        LOG(("@s6 st_stn(%lu, %ld, %lu)", addr, l, n));
        ch_in_stack(addr, n);
        ch_aligned(addr, n);
 
        /* store the bytes */
-       for (i = 0; i < (int) n; i++) {
-               ch_st_prot(addr + i);
-               stack_loc(addr + i) = (char) l;
+       for (i = (int) n; i > 0; i--, addr++) {
+               ch_st_prot(addr);
+               stack_loc(addr) = (char) l;
 #ifdef LOGGING
-               if (al == 0 && n == psize) {
-                       /* a psize zero, ambiguous */
-                       st_sh(addr + i) = (SH_INT|SH_DATAP);
-               }
-               else {
-                       st_sh(addr + i) = SH_INT;
-               }
+               st_sh(addr) = sh_flags;
 #endif LOGGING
                l = l>>8;
        }
@@ -191,20 +196,25 @@ st_stn(addr, al, n)
 
 #ifndef        NOFLOAT
 st_stf(addr, f, n)
-       ptr addr;
+       register ptr addr;
        double f;
        size n;
 {
        register char *cp = (char *) &f;
+       float fl;
        register int i;
 
        LOG(("@s6 st_stf(%lu, %g, %lu)", addr, f, n));
        ch_in_stack(addr, n);
-       ch_aligned(addr, wsize);
-       for (i = 0; i < (int) n; i++) {
-               ch_st_prot(addr + i);
-               stack_loc(addr + i) = *(cp++);
-               st_fl(addr + i);
+       ch_wordaligned(addr);
+       if ((int) n == 4) {
+               fl = f;
+               cp = (char *) &fl;
+       }
+       for (i = (int) n; i > 0; i--, addr++) {
+               ch_st_prot(addr);
+               stack_loc(addr) = *(cp++);
+               st_fl(addr);
        }
 }
 #endif NOFLOAT
@@ -222,14 +232,14 @@ st_stf(addr, f, n)
  ************************************************************************/
 
 ptr st_lddp(addr)
-       ptr addr;
+       register ptr addr;
 {
        register ptr p;
 
        LOG(("@s6 st_lddp(%lu)", addr));
 
        ch_in_stack(addr, psize);
-       ch_aligned(addr, wsize);
+       ch_wordaligned(addr);
 #ifdef LOGGING
        if (!is_st_set(addr, psize, SH_DATAP)) {
                warning(WLDPEXP);
@@ -243,14 +253,14 @@ ptr st_lddp(addr)
 }
 
 ptr st_ldip(addr)
-       ptr addr;
+       register ptr addr;
 {
        register ptr p;
 
        LOG(("@s6 st_ldip(%lu)", addr));
 
        ch_in_stack(addr, psize);
-       ch_aligned(addr, wsize);
+       ch_wordaligned(addr);
 #ifdef LOGGING
        if (!is_st_set(addr, psize, SH_INSP)) {
                warning(WLIPEXP);
@@ -264,7 +274,7 @@ ptr st_ldip(addr)
 }
 
 unsigned long st_ldu(addr, n)
-       ptr addr;
+       register ptr addr;
        size n;
 {
        register int i;
@@ -289,7 +299,7 @@ unsigned long st_ldu(addr, n)
 }
 
 long st_lds(addr, n)
-       ptr addr;
+       register ptr addr;
        size n;
 {
        register int i;
@@ -316,17 +326,24 @@ long st_lds(addr, n)
 
 #ifndef        NOFLOAT
 double st_ldf(addr, n)
-       ptr addr;
+       register ptr addr;
        size n;
 {
-       double f = 0.0;
-       register char *cp = (char *) &f;
+       double f;
+       float fl;
+       register char *cp;
        register int i;
 
        LOG(("@s6 st_ldf(%lu, %lu)", addr, n));
 
+       if ((int)n == 4) {
+               cp = (char *) &fl;
+       }
+       else {
+               cp = (char *) &f;
+       }
        ch_in_stack(addr, n);
-       ch_aligned(addr, wsize);
+       ch_wordaligned(addr);
 #ifdef LOGGING
        if (!is_st_set(addr, n, SH_FLOAT)) {
                warning(WLFEXP);
@@ -334,8 +351,11 @@ double st_ldf(addr, n)
        }
 #endif LOGGING
 
-       for (i = 0; i < (int) n; i++) {
-               *(cp++) = stack_loc(addr + i);
+       for (i = (int) n; i > 0; i--, addr++) {
+               *(cp++) = stack_loc(addr);
+       }
+       if ((int)n == 4) {
+               f = fl;
        }
        return (f);
 }
@@ -359,42 +379,42 @@ double st_ldf(addr, n)
  ************************************************************************/
 
 st_mvs(s2, s1, n)                      /* s1 -> s2 */
-       ptr s2, s1;
+       register ptr s2, s1;
        size n;
 {
        register int i;
 
        ch_in_stack(s1, n);
-       ch_aligned(s1, wsize);
+       ch_wordaligned(s1);
        ch_in_stack(s2, n);
-       ch_aligned(s2, wsize);
+       ch_wordaligned(s2);
 
-       for (i = 0; i < (int) n; i++) {
-               ch_st_prot(s2 + i);
-               ch_st_prot(s1 + i);
-               stack_loc(s2 + i) = stack_loc(s1 + i);
+       for (i = (int) n; i > 0; i--, s1++, s2++) {
+               ch_st_prot(s2);
+               ch_st_prot(s1);
+               stack_loc(s2) = stack_loc(s1);
 #ifdef LOGGING
-               st_sh(s2 + i) = st_sh(s1 + i) & ~SH_PROT;
+               st_sh(s2) = st_sh(s1) & ~SH_PROT;
 #endif LOGGING
        }
 }
 
 st_mvd(s, d, n)                                /* d -> s */
-       ptr s, d;
+       register ptr s, d;
        size n;
 {
        register int i;
 
        ch_in_data(d, n);
-       ch_aligned(d, wsize);
+       ch_wordaligned(d);
        ch_in_stack(s, n);
-       ch_aligned(s, wsize);
+       ch_wordaligned(s);
 
-       for (i = 0; i < (int) n; i++) {
-               ch_st_prot(s + i);
-               stack_loc(s + i) = data_loc(d + i);
+       for (i = (int) n; i > 0; i--, s++, d++) {
+               ch_st_prot(s);
+               stack_loc(s) = data_loc(d);
 #ifdef LOGGING
-               st_sh(s + i) = dt_sh(d + i) & ~SH_PROT;
+               st_sh(s) = dt_sh(d) & ~SH_PROT;
 #endif LOGGING
        }
 }
@@ -495,6 +515,7 @@ long wpop()
  ************************************************************************
  *                                                                     *
  *     dppush(p)       - push a data ptr, load from p.                 *
+ *     wpush(l)        - push a word, load from l.                     *
  *     npush(l, n)     - push n bytes, load from l.                    *
  *     push_dt(d, n)   - push n bytes, load from address d in data.    *
  *     push_st(s, n)   - push n bytes, load from address s in stack.   *
@@ -509,17 +530,26 @@ dppush(p)
        st_stdp(SP, p);
 }
 
-npush(l, n)
+wpush(l)
        long l;
+{
+       st_inc(wsize);
+       st_stn(SP, l, wsize);
+}
+
+npush(l, n)
+       register long l;
        size n;
 {
-       st_inc(max(n, wsize));
+       size m = max(n, wsize);
+
+       st_inc(m);
        if (n == 1)
                l &= MASK1;
        else
        if (n == 2)
                l &= MASK2;
-       st_stn(SP, l, max(n, wsize));
+       st_stn(SP, l, m);
 
 }
 
@@ -562,8 +592,8 @@ fpush(f, n)
 #ifdef LOGGING
 
 PRIVATE warn_stbits(addr, n)
-       ptr addr;
-       size n;
+       register ptr addr;
+       register size n;
 {
        register int or_bits = 0;
        register int and_bits = 0xff;
index 6a23619..a6ff14f 100644 (file)
@@ -32,7 +32,7 @@ init_text() {
  ************************************************************************/
 
 newPC(p)
-       ptr p;
+       register ptr p;
 {
        register struct proc *pr = &proctab[PI];
 
index 07c6385..e37742b 100644 (file)
 
 #define        arg_n(u)        ((u > i_maxuw) ? (wtrap(WARGL, EILLINS), 0) : u)
 
-#define        arg_s(s)        ((s <= 0 || s > max_off || s % wsize) ? \
+#define        arg_s(s)        ((s <= 0 || s > max_off || (s & wsizem1)) ? \
                                (trap(EODDZ), s) : s)
 
-#define        arg_z(s)        ((s < 0 || s > max_off || s % wsize) ? \
+#define        arg_z(s)        ((s < 0 || s > max_off || (s & wsizem1)) ? \
                                (trap(EODDZ), s) : s)
 
-#define        arg_o(s)        ((s < 0 || s > max_off || (s%wsize && wsize%s)) ? \
+#define        arg_o(s)        ((s < 0 || s > max_off || ((s&wsizem1) && wsize%s)) ? \
                                (trap(EODDZ), s) : s)
 
-#define        arg_w(s)        ((s <= 0 || s > max_off || s % wsize) ? \
+#define        arg_w(s)        ((s <= 0 || s > max_off || (s & wsizem1)) ? \
                                (trap(EODDZ), s) : s)
 
 #define        arg_p(l)        ((l >= NProc) ? (wtrap(WARGP, EILLINS), 0) : l)
 
 #define        arg_wf(s)       ((s != 4 && s != 8) ? (trap(EODDZ), s) : s)
 
-#define        arg_wi(s)       (((s != 2 && s != 4) || (s % wsize)) ? \
+#define        arg_wi(s)       (((s != 2 && s != 4) || (s & wsizem1)) ? \
                                (trap(EODDZ), s) : s)
 
 /* special tests */
index 55e6091..f54e22a 100644 (file)
@@ -90,11 +90,11 @@ do_trap(nr, L, F)
 
                /* save the Function Return Area */
                pushFRA(FRASize);
-               npush((long)FRASize, wsize);
-               npush((long)FRA_def, wsize);
+               wpush((long)FRASize);
+               wpush((long)FRA_def);
 
                /* set up the trap number as the only parameter */
-               npush((long) nr, wsize);
+               wpush((long) nr);
 
                tpi = TrapPI;           /* allowed since OnTrap == TR_TRAP */
                TrapPI = 0;