home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / mstoop.h < prev    next >
C/C++ Source or Header  |  1992-02-15  |  5KB  |  191 lines

  1. /***********************************************************************
  2.  *
  3.  *    Object Table declarations.
  4.  *
  5.  ***********************************************************************/
  6.  
  7. /***********************************************************************
  8.  *
  9.  * Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  10.  * Written by Steve Byrne.
  11.  *
  12.  * This file is part of GNU Smalltalk.
  13.  *
  14.  * GNU Smalltalk is free software; you can redistribute it and/or modify it
  15.  * under the terms of the GNU General Public License as published by the Free
  16.  * Software Foundation; either version 1, or (at your option) any later 
  17.  * version.
  18.  * 
  19.  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  20.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  21.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  22.  * more details.
  23.  * 
  24.  * You should have received a copy of the GNU General Public License along with
  25.  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  26.  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  27.  *
  28.  ***********************************************************************/
  29.  
  30.  
  31. /*
  32.  *    Change Log
  33.  * ============================================================================
  34.  * Author      Date       Change 
  35.  * sbb         27 Jan 91      Force INLINE_MACROS on when optimizing.
  36.  *
  37.  * sbyrne     8 Apr 90      Changed oopFree to oopValid to better reflect the
  38.  *              semantics.
  39.  *
  40.  * sbyrne    13 Jan 89      Created.
  41.  *
  42.  */
  43.  
  44.  
  45. #ifndef __MSTOOP__
  46. #define __MSTOOP__
  47.  
  48. /* Comment this out for debugging */
  49. #define INLINE_MACROS
  50.  
  51. #if defined(OPTIMIZE) && !defined(INLINE_MACROS)
  52. /* Force this on when we're optimizing */
  53. #define INLINE_MACROS
  54. #endif
  55.  
  56. /* The number of OOPs in the system.  This is exclusive of Character, True,
  57.    False, and UndefinedObject (nil) oops, which are built-ins. */
  58. #define OOP_TABLE_SIZE        (10240 * 16) /* for the nonce, then back to 4 */
  59.  
  60. #define NUM_CHAR_OBJECTS    256
  61. #define CHAR_OBJECT_BASE    OOP_TABLE_SIZE
  62. #define NUM_BUILTIN_OBJECTS    3
  63. #define BUILTIN_OBJECT_BASE    (CHAR_OBJECT_BASE + NUM_CHAR_OBJECTS)
  64.  
  65. #define nilOOPIndex        (BUILTIN_OBJECT_BASE + 0)
  66. #define trueOOPIndex        (BUILTIN_OBJECT_BASE + 1)
  67. #define falseOOPIndex        (BUILTIN_OBJECT_BASE + 2)
  68.  
  69. #define TOTAL_OOP_TABLE_SLOTS \
  70.   ( OOP_TABLE_SIZE + NUM_CHAR_OBJECTS + NUM_BUILTIN_OBJECTS )
  71.  
  72. /*
  73.  * Given a number of bytes "x", return the number of 32 bit words
  74.  * needed to represent that object, rounded up to the nearest 32 bit
  75.  * word boundary.
  76.  */
  77. #define ROUNDED_WORDS(x) \
  78.   (((x) + sizeof(long) - 1) / sizeof(long))
  79.  
  80. #define GCIsOn() \
  81.   (gcState)
  82.  
  83. #define inToSpace(oop) \
  84.   ((((oop)->flags & F_SPACE) == toSpace) || isFake(oop))
  85.  
  86. /* ### Could use "!= toSpace" instead? (not now, I think) */
  87. #define inFromSpace(oop) \
  88.   (((oop)->flags & F_SPACE) == fromSpace)
  89.  
  90. #ifdef old_code /* Sat Oct 13 15:40:02 1990 */
  91. /**/#define inToSpace(oop) \
  92. /**/  ((oop)->inSpace == toSpace)
  93. /**/
  94. /**/#define inFromSpace(oop) \
  95. /**/  ((oop)->inSpace == fromSpace)
  96. #endif /* old_code Sat Oct 13 15:40:02 1990 */
  97.  
  98. #define prepareToStoreMac(destOOP, srcOOP) 
  99.  
  100. #define maybeMoveOOPMac(oop) 
  101.  
  102. #define localMaybeMoveOOP(oop) \
  103. { \
  104.   if (!isInt(oop) && inFromSpace(oop)) { \
  105.     moveOOP(oop); \
  106.   } \
  107. }
  108.  
  109.  
  110. #ifdef OPTIMIZE
  111. #define clearGCFlipFlagsMac() 
  112. #else 
  113. #define clearGCFlipFlagsMac() \
  114.   gcFlipCounter = 0
  115. #endif /* OPTIMIZE */
  116.  
  117. #define oopAtMac(index) \
  118.   ( &oopTable[index] )
  119.  
  120. #define oopAvailableMac(index) \
  121.   ( oopTable[index].flags & F_FREE )
  122.  
  123. #define oopIndexMac(oop) \
  124.   ( (OOP)(oop) - oopTable )
  125.  
  126. #ifdef INLINE_MACROS
  127.  
  128. #define maybeMoveOOP    maybeMoveOOPMac
  129. #define clearGCFlipFlags clearGCFlipFlagsMac
  130. #define oopAt        oopAtMac
  131. #define oopAvailable    oopAvailableMac
  132. #define oopIndex    oopIndexMac
  133. #define prepareToStore    prepareToStoreMac
  134.  
  135. #else
  136.  
  137. extern void        maybeMoveOOP(), clearGCFlipFlags(), prepareToStore();
  138. extern OOP        oopAt();
  139. extern Boolean        oopAvailable();
  140. extern long        oopIndex();
  141.  
  142. #endif /* INLINE_MACROS */
  143.  
  144. typedef struct CharObjectStruct {
  145.   OBJ_HEADER;
  146. #ifdef BIG_ENDIAN
  147.   Byte        charVal;
  148.   Byte        dummy[3];    /* filler */
  149. #else
  150.   Byte        dummy[3];    /* filler */
  151.   Byte        charVal;    /* probably not necessary to care about
  152.                    ordering here */
  153. #endif
  154. } CharObject;
  155.  
  156. struct NilObjectStruct {
  157.   OBJ_HEADER;
  158. };
  159.  
  160. struct BooleanObjectStruct {
  161.   OBJ_HEADER;
  162.   OOP        booleanValue;
  163. };
  164.  
  165. extern CharObject        charObjectTable[];
  166. extern struct NilObjectStruct     nilObject;
  167. extern struct BooleanObjectStruct booleanObjects[];
  168. #ifdef pre_sc_gc /* Sat Jul 27 22:31:18 1991 */
  169. /**/extern OOP            freeOOPs;
  170. #endif /* pre_sc_gc Sat Jul 27 22:31:18 1991 */
  171. extern int            numFreeOOPs;
  172. extern unsigned long        toSpace, fromSpace, maxSpaceSize;
  173. extern Boolean            gcFlipped, gcState, gcMessage;
  174. extern int            gcFlipCounter;
  175.  
  176. extern double            growThresholdPercent, spaceGrowRate;
  177.  
  178. extern OOP            allocOOP(), charOOPAt(), findAnInstance();
  179. extern void            initOOP(), setOOPAt(), swapObjects(), 
  180.                 fixupMetaclassObjects(), moveOOP(), gcOn(),
  181.                 setGCState(), gcFlip(), 
  182.                 setSpaceInfo(), growBothSpaces(),
  183.                   allocOOPTable();
  184. extern Byte            charOOPValue();
  185. extern Object            allocObj(), curSpaceAddr();
  186. extern Boolean            oopIndexValid(), oopValid(), gcOff();
  187.  
  188. extern struct OOPStruct        *oopTable;
  189.  
  190. #endif /* __MSTOOP__ */
  191.