# 1 "GcHeapRep1.c"








# 1 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"








# 1 "/afs/cs/user/dld/gc/concurrent/genlib/Time.h"




# 1 "/afs/cs/misc/c++/build/genlib/src/utils/workaround/sys/time.h"





































struct timeval {
	long	tv_sec;		
	long	tv_usec;	
};

struct TimeZone {
	int	tz_minuteswest;	
	int	tz_dsttime;	
};



























struct	itimerval {
	struct	timeval it_interval;	
	struct	timeval it_value;	
};



# 1 "/usr/cs/include/time.h"































struct tm {
	int	tm_sec;
	int	tm_min;
	int	tm_hour;
	int	tm_mday;
	int	tm_mon;
	int	tm_year;
	int	tm_wday;
	int	tm_yday;
	int	tm_isdst;
	long	tm_gmtoff;
	char	*tm_zone;
};


extern long time(long*);
extern char *ctime(long*);
extern char *asctime(struct tm*);
extern struct tm *gmtime(long*),
          *localtime(long*);
extern char *timezone(int, int);
# 57 "/usr/cs/include/time.h"


# 81 "/afs/cs/misc/c++/build/genlib/src/utils/workaround/sys/time.h"



# 99 "/afs/cs/misc/c++/build/genlib/src/utils/workaround/sys/time.h"



extern int adjtime(struct timeval *, struct timeval *);
extern int getitimer(int, struct itimerval *);
extern int setitimer(int, struct itimerval *, struct itimerval *);
extern int gettimeofday(struct timeval *, struct TimeZone *);
extern int settimeofday(struct timeval *, struct TimeZone *);
extern int utimes(const char *, struct timeval *);



# 7 "/afs/cs/user/dld/gc/concurrent/genlib/Time.h"



# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"









# 18 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"

overload abs;



# 1 "/usr/cs/include/libc.h"























































# 1 "/usr/mach/include/sys/types.h"









































































































# 1 "/usr/mach/include/mach/machine/vm_types.h"




































# 38 "/usr/mach/include/mach/machine/vm_types.h"

typedef	unsigned int	vm_offset_t;
typedef	unsigned int	vm_size_t;


# 106 "/usr/mach/include/sys/types.h"

typedef	unsigned char	u_char;
typedef	unsigned short	u_short;
typedef	unsigned int	u_int;
typedef	unsigned long	u_long;
typedef	unsigned short	ushort;		
# 114 "/usr/mach/include/sys/types.h"



typedef	struct	_physadr { int r[1]; } *physadr;
typedef	struct	label_t	{
	int	val[14];
} label_t;

# 127 "/usr/mach/include/sys/types.h"

# 133 "/usr/mach/include/sys/types.h"

# 139 "/usr/mach/include/sys/types.h"




# 149 "/usr/mach/include/sys/types.h"

# 152 "/usr/mach/include/sys/types.h"

typedef	struct	_quad { long val[2]; } quad;

typedef	long	daddr_t;
typedef	char *	caddr_t;
typedef	u_long	ino_t;
typedef	long	swblk_t;
typedef	long	size_t;
typedef	long	time_t;
typedef	short	dev_t;
# 164 "/usr/mach/include/sys/types.h"

typedef	long	off_t;

typedef	u_short	uid_t;
typedef	u_short	gid_t;












typedef long	fd_mask;





typedef	struct fd_set {
	fd_mask	fds_bits[	(((256)+(( (sizeof(fd_mask) * 8		)	)-1))/( (sizeof(fd_mask) * 8		)	))];
} fd_set;








# 56 "/usr/cs/include/libc.h"




# 1 "/usr/cs/include/sysent.h"


























# 1 "/usr/mach/include/sys/types.h"
































































































# 197 "/usr/mach/include/sys/types.h"

# 27 "/usr/cs/include/sysent.h"

# 1 "/usr/mach/include/sys/time.h"




















































# 118 "/usr/mach/include/sys/time.h"

# 28 "/usr/cs/include/sysent.h"

extern int access(const char *, int);
extern int acct(const char *);
extern int brk(void *);
extern int sbrk(int);
extern int chdir(const char *);
extern int chmod(const char *, int);
extern int fchmod(int, int);
extern int chown(const char *, int, int);
extern int fchown(int, int, int);
extern int chroot(const char *);
extern int close(int);
extern int creat(const char *, int);
extern int dup(int);
extern int dup2(int, int);
extern int execve(const char *, const char **, const char **);
extern void _exit(int);
extern int fcntl(int, int, int);
extern int flock(int, int);
extern int fork(void);
extern int fsync(int);
extern int getdtablesize(void);
extern gid_t getgid(void);
extern gid_t getegid(void);
extern int getgroups(int, int *);
extern long gethostid(void);
extern int sethostid(long);
extern int gethostname(char *, int);
extern int sethostname(const char *, int);
extern int getpagesize(void);
extern int getpgrp(int);
extern int getpid(void);
extern int getppid(void);
extern uid_t getuid(void);
extern uid_t geteuid(void);
extern int ioctl(int, unsigned long, void *);
extern int kill(int, int);
extern int killpg(int, int);
extern int link(const char *, const char *);
extern off_t lseek(int, off_t, int);
extern int mkdir(const char *, int);
extern int mknod(const char *, int, int);
extern int mount(const char *, const char *, int);
extern int umount(const char *);
extern int open(const char *, int, int);
extern int pipe(int *);
extern int profil(void *, int, int, int);
extern int ptrace(int, int, int *, int);
extern int quota(int, int, int, void *);
extern int read(int, void *, int);
extern int readlink(const char *, void *, int);
extern int reboot(int);
extern int rename(const char *, const char *);
extern int rmdir(const char *);
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
extern int setgroups(int, int *);
extern int setpgrp(int, int);
extern int setquota(const char *, const char *);
extern int setregid(gid_t, gid_t);
extern int setreuid(uid_t, uid_t);
extern int swapon(const char *);
extern int symlink(const char *, const char *);
extern void sync(void);
extern int syscall(int, ...);
extern int truncate(const char *, off_t);
extern int ftruncate(int, off_t);
extern int umask(int);
extern int unlink(const char *);
extern int vfork(void);
extern void vhangup(void);
extern int write(int, void *, int);



# 1 "/usr/mach/include/sys/viceioctl.h"




































# 1 "/usr/mach/include/sys/types.h"
































































































# 197 "/usr/mach/include/sys/types.h"

# 37 "/usr/mach/include/sys/viceioctl.h"

# 1 "/usr/mach/include/sys/ioctl.h"





































































































































# 1 "/usr/mach/include/sys/ttychars.h"





































struct ttychars {
	char	tc_erase;	
	char	tc_kill;	
	char	tc_intrc;	
	char	tc_quitc;	
	char	tc_startc;	
	char	tc_stopc;	
	char	tc_eofc;	
	char	tc_brkc;	
	char	tc_suspc;	
	char	tc_dsuspc;	
	char	tc_rprntc;	
	char	tc_flushc;	
	char	tc_werasc;	
	char	tc_lnextc;	
};




# 60 "/usr/mach/include/sys/ttychars.h"



















# 134 "/usr/mach/include/sys/ioctl.h"

# 1 "/usr/mach/include/sys/ttydev.h"
























































# 68 "/usr/mach/include/sys/ttydev.h"


# 135 "/usr/mach/include/sys/ioctl.h"

# 1 "/usr/mach/include/sys/types.h"
































































































# 197 "/usr/mach/include/sys/types.h"

# 136 "/usr/mach/include/sys/ioctl.h"


# 1 "/usr/mach/include/sys/ttyloc.h"




































struct ttyloc
{
    long tlc_hostid;		
    long tlc_ttyid;		
};
























# 72 "/usr/mach/include/sys/ttyloc.h"


# 138 "/usr/mach/include/sys/ioctl.h"


struct tchars {
	char	t_intrc;	
	char	t_quitc;	
	char	t_startc;	
	char	t_stopc;	
	char	t_eofc;		
	char	t_brkc;		
};
struct ltchars {
	char	t_suspc;	
	char	t_dsuspc;	
	char	t_rprntc;	
	char	t_flushc;	
	char	t_werasc;	
	char	t_lnextc;	
};







struct sgttyb {
	char	sg_ispeed;		
	char	sg_ospeed;		
	char	sg_erase;		
	char	sg_kill;		
	short	sg_flags;		
};








struct winsize {
	unsigned short	ws_row;			
	unsigned short	ws_col;			
	unsigned short	ws_xpixel;		
	unsigned short	ws_ypixel;		
};




struct ttysize {
	unsigned short	ts_lines;
	unsigned short	ts_cols;
	unsigned short	ts_xxx;
	unsigned short	ts_yyy;
};













# 225 "/usr/mach/include/sys/ioctl.h"





















































































































struct tiocgcons {
    dev_t tgc_dev;	
    uid_t tgc_uid;	
};






























































# 412 "/usr/mach/include/sys/ioctl.h"







struct fsparam
{
    long fsp_free;		
    long fsp_ifree;		
    long fsp_size;		
    long fsp_isize;		
    long fsp_minfree;		
    long fsp_unused[3];		
};







































# 473 "/usr/mach/include/sys/ioctl.h"





# 486 "/usr/mach/include/sys/ioctl.h"


















# 38 "/usr/mach/include/sys/viceioctl.h"

struct ViceIoctl {
	caddr_t in, out;	
	short in_size;		
	short out_size;		
};

















# 102 "/usr/cs/include/sysent.h"

extern int icreate(int, int, int, int, int, int);
extern int iinc(int, int, long);
extern int idec(int, int, long);
extern int iopen(int, int, int);
extern int iread(int, int, int, int, void *, int);
extern int iwrite(int, int, int, int, void *, int);
extern int pioctl(const char *, unsigned long, struct ViceIoctl *, int);
extern int setpag(void);
# 118 "/usr/cs/include/sysent.h"


# 60 "/usr/cs/include/libc.h"




# 1 "/usr/cs/include/stdio.h"



















































# 54 "/usr/cs/include/stdio.h"






# 62 "/usr/cs/include/stdio.h"

extern	struct	_iobuf {
	int	_cnt;
	char	*_ptr;		
	char	*_base;		
	int	_bufsiz;
	short	_flag;
	char	_file;		
} _iob[];










# 83 "/usr/cs/include/stdio.h"











# 98 "/usr/cs/include/stdio.h"












# 120 "/usr/cs/include/stdio.h"








# 130 "/usr/cs/include/stdio.h"



extern int _flsbuf(unsigned int, struct _iobuf*);
extern int _filbuf(struct _iobuf*);
extern int fclose(struct _iobuf*);
extern struct _iobuf* fdopen(int, const char*);
extern int fflush(struct _iobuf*);
extern int fgetc(struct _iobuf*);
extern char* fgets(char*, int, struct _iobuf*);
extern struct _iobuf* fopen(const char*, const char*);
extern int fprintf(struct _iobuf*, const char*,...);
extern int fputc(int, struct _iobuf*);
extern int fputs(const char*, struct _iobuf*);
extern int fread(char*, int, int, struct _iobuf*);
extern struct _iobuf* freopen(const char*, const char*, struct _iobuf*);
extern int fscanf(struct _iobuf*, const char*,...);
extern int fseek(struct _iobuf*, long, int);
extern long ftell(const struct _iobuf*);
extern int fwrite(const char*, int, int, struct _iobuf*);
extern char* gets(char*);
extern int getw(struct _iobuf*);
extern struct _iobuf* popen(const char*, const char*);
extern int pclose(struct _iobuf *stream);
extern int printf(const char*,...);
extern int puts(const char*);
extern int putw(int, struct _iobuf*);
extern int rewind(struct _iobuf*);
extern int scanf(const char*,...);
extern void setbuf(struct _iobuf*, char*);
extern void setbuffer(struct _iobuf*, char*, int);
extern void setlinebuf(struct _iobuf*);
extern char *sprintf(char*, const char*,...);
extern int sscanf(char*, const char*,...);
extern int ungetc(int, struct _iobuf*);
# 168 "/usr/cs/include/stdio.h"

# 182 "/usr/cs/include/stdio.h"

# 192 "/usr/cs/include/stdio.h"


# 64 "/usr/cs/include/libc.h"




# 1 "/usr/misc/.c++/include/strings.h"

























# 1 "/usr/cs/include/strings.h"






























extern char
	*strcat(char*, const char*),
	*strncat(char*, const char*, int),
	*strcpy(char*, const char*),
	*strncpy(char*, const char*, int),
        *index(const char*, char),
	*rindex(const char*, char);
extern int
	strcmp(const char*, const char*),
	strncmp(const char*, const char*, int),
	strlen(const char*);
# 52 "/usr/cs/include/strings.h"


# 26 "/usr/misc/.c++/include/strings.h"

extern int
        strcasecmp(const char*, const char*),
        strncasecmp(const char*, const char*, int);

# 68 "/usr/cs/include/libc.h"


# 72 "/usr/cs/include/libc.h"




extern struct _iobuf *fopenp(const char*, const char*, char*, char*);
extern struct _iobuf *fwantread(const char*, const char*, const char*, const char*);
extern struct _iobuf *fwantwrite(const char*, const char*, const char*, const char*,
			int);
# 84 "/usr/cs/include/libc.h"




extern char* foldup(char*, const char*);
extern char* folddown(char*, const char*);
extern char* sindex(const char*, const char*);
extern char* skipto(const char*, const char*);
extern char* skipover(const char*, const char*);
extern char* nxtarg(char**, const char*);
extern char _argbreak;
extern char* getstr(const char*, char*, char*);
extern int getstab(const char*, const char**, const char*);
extern int getsearch(const char*, const char**, const char*);
extern char* strarg(const char**, const char*, const char*, char*, char*);
extern int stabarg(const char**, const char*, const char*, const char**,
		   const char*);
extern int searcharg(const char**, const char*, const char*, const char**,
		     const char*);
extern int getint(const char*, int, int, int);
extern int intarg(const char**, const char*, const char*, int, int, int);
extern long getlong(const char*, long, long, long);
extern long longarg(const char**, const char*, const char*, long, long, long);
extern short getshort(const char*, short, short, short);
extern short shortarg(const char**, const char*, const char*,
		      short, short, short);
extern float getfloat(const char*, float, float, float);
extern float floatarg(const char**, const char*, const char*,
		      float, float, float);
extern double getdouble(const char*, double, double, double);
extern double doublearg(const char**, const char*, const char*,
			double, double, double);
extern unsigned int getoct(const char*, unsigned int, unsigned int,
			   unsigned int);
extern unsigned int octarg(const char**, const char*, const char*,
			   unsigned int, unsigned int, unsigned int);
extern unsigned int gethex(const char*, unsigned int, unsigned int,
			   unsigned int);
extern unsigned int hexarg(const char**, const char*, const char*,
			   unsigned int, unsigned int, unsigned int);
extern unsigned int atoo(const char*);
extern unsigned int atoh(const char*);
extern char *salloc(const char*);
extern char *concat(const char*, int, ...);
# 140 "/usr/cs/include/libc.h"




extern char *getname(int);
extern char *pathof(char *);
extern char *errmsg(int);
# 151 "/usr/cs/include/libc.h"




extern long gtime(const struct tm*);
extern long atot(const char*);
# 160 "/usr/cs/include/libc.h"




typedef int (*PFI)();

typedef int (*PFI2)(...);

extern void abort(void);
extern int abs(int);
extern double atof(const char *);
extern int atoi(const char *);
extern long atol(const char *);
extern void bcopy(const void *, void *, int);
extern int bcmp(const void *, const void *, int);
extern void bzero(void *, int);
extern int ffs(int);
extern char *crypt(const char *, const char *);
extern void setkey(char *);
extern void encrypt(char *, int);
extern char *ecvt(double, int, int *, int *);
extern char *fcvt(double, int, int *, int *);
extern char *gcvt(double, int, char *);
extern int execl(const char *, ...);
extern int execv(const char *, const char **);
extern int execle(const char *, ...);
extern int exect(const char *, const char **, const char **);
extern void exit(int);
extern char *getenv(const char *);
extern char *getlogin(void);
extern int getopt(int, const char **, const char *);
extern char *getpass(const char *);
extern char *getusershell(void);
extern void setusershell(void);
extern void endusershell(void);
extern char *getwd(char *);
extern int initgroups(const char *, gid_t);
extern void *malloc(unsigned);
extern void free(void *);
extern void *realloc(void *, unsigned);
extern void *calloc(unsigned, unsigned);
extern void *alloca(int);
extern char *mktemp(char *);
extern int mkstemp(char *);
extern void monitor(PFI, PFI, short *, int, int);
extern void monstartup(PFI, PFI);
extern void moncontrol(int);
extern int pause(void);

extern void qsort(void *, int, int, PFI2);
# 212 "/usr/cs/include/libc.h"

extern long random(void);
extern int srandom(int);
extern void *initstate(unsigned, void *, int);
extern void *setstate(void *);
extern int rcmd(char **, int, const char *, const char *, const char *, int);
extern int rresvport(int *);
extern int ruserok(char *, int, const char *, const char *);
extern char *re_comp(char *);
extern int re_exec(char *);
extern int rexec(char **, int, const char *, const char *, const char *,
		 int *);
extern int setuid(uid_t);
extern int seteuid(uid_t);
extern int setruid(uid_t);
extern int setgid(gid_t);
extern int setegid(gid_t);
extern int setrgid(gid_t);
extern void sleep(unsigned);
extern void swab(void *, void *, int);
extern int system(const char *);
extern char *ttyname(int);
extern int isatty(int);
extern int ttyslot(void);
extern unsigned ualarm(unsigned, unsigned);
extern void usleep(unsigned);
# 261 "/usr/cs/include/libc.h"


# 23 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"

# 1 "/usr/cs/include/stdio.h"














































# 193 "/usr/cs/include/stdio.h"

# 24 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"



inline void genlib_fatal_error(char* s) {
  fprintf((&_iob[2]), "Fatal Error: %s\n", s);
  exit(1);
}




# 1 "/usr/mach/include/mach/boolean.h"


















































# 1 "/usr/mach/include/mach/machine/boolean.h"






























typedef int		boolean_t;


# 51 "/usr/mach/include/mach/boolean.h"





















# 37 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"
typedef int Bool;




# 12 "/afs/cs/user/dld/gc/concurrent/genlib/Time.h"


# 1 "/usr/cs/include/time.h"




























# 58 "/usr/cs/include/time.h"

# 14 "/afs/cs/user/dld/gc/concurrent/genlib/Time.h"

# 1 "/usr/cs/include/string.h"






















# 1 "/usr/misc/.c++/include/strings.h"





















# 30 "/usr/misc/.c++/include/strings.h"

# 23 "/usr/cs/include/string.h"






extern char *strcpyn(char*, const char*, int);
extern char *strcatn(char*, const char*, int);
extern int strcmpn(const char*, const char*, int);
# 36 "/usr/cs/include/string.h"







extern char *strchr();
extern char *strrchr();
extern char *strpbrk();
extern int strspn();
extern int strcspn();
extern char *strtok();
# 15 "/afs/cs/user/dld/gc/concurrent/genlib/Time.h"


# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"






# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"





# 40 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"


# 8 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"





overload pow;


# 1 "/usr/misc/.c++/include/math.h"



# 6 "/usr/misc/.c++/include/math.h"






 

# 1 "/usr/cs/include/math.h"




























































extern double asinh(double), acosh(double), atanh(double);
extern double erf(double), erfc(double);
extern double exp(double), expm1(double), log(double);
extern double log10(double), log1p(double), pow(double, double);
extern double fabs(double), floor(double), ceil(double), rint(double);
extern double lgamma(double);
extern double hypot(double, double);

# 72 "/usr/cs/include/math.h"


extern double cabs(...);
# 77 "/usr/cs/include/math.h"



# 87 "/usr/cs/include/math.h"



extern double copysign(double), drem(double, double);
extern double logb(double), scalb(double, int);
extern int finite(double);

extern double infnan(int);

# 102 "/usr/cs/include/math.h"



extern double j0(double), j1(double), jn(int, double);
extern double y0(double), y1(double), yn(int, double);
extern double sin(double), cos(double), tan(double);
extern double asin(double), acos(double), atan(double), atan2(double, double);
extern double sinh(double), cosh(double), tanh(double);
extern double cbrt(double), sqrt(double);
extern double modf(double, double*), ldexp(double, int);
extern double frexp(double, int*), atof(const char*);
# 119 "/usr/cs/include/math.h"


# 123 "/usr/cs/include/math.h"

# 126 "/usr/cs/include/math.h"
















# 145 "/usr/cs/include/math.h"

# 219 "/usr/cs/include/math.h"


# 276 "/usr/cs/include/math.h"

# 280 "/usr/cs/include/math.h"

# 14 "/usr/misc/.c++/include/math.h"



# 20 "/usr/misc/.c++/include/math.h"



extern int errno, signgam;

extern double fmod(double,double);
extern double gamma(double);

struct exception;
extern int matherr(exception *);















# 47 "/usr/misc/.c++/include/math.h"




# 53 "/usr/misc/.c++/include/math.h"

# 57 "/usr/misc/.c++/include/math.h"

# 60 "/usr/misc/.c++/include/math.h"

# 66 "/usr/misc/.c++/include/math.h"

# 69 "/usr/misc/.c++/include/math.h"

















struct exception {
	int type;
	char *name;
	double arg1;
	double arg2;
	double retval;
};














# 109 "/usr/misc/.c++/include/math.h"

# 19 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"





extern int next_prime_from(int candidate);
extern Bool is_prime(int i);




overload max;
inline int max(int a, int b) {
  if (b > a) return b;
  else return a;
}

inline float max(float a, float b) {
  if (b > a) return b;
  else return a;
}

inline double max(double a, double b) {
  if (b > a) return b;
  else return a;
}


overload min;
inline int min(int a, int b) {
  if (b > a) return a;
  else return b;
}

inline float min(float a, float b) {
  if (b > a) return a;
  else return b;
}

inline double min(double a, double b) {
  if (b > a) return a;
  else return b;
}



inline double abs(double a) {
  return (a > 0.0 ? a : -a);
}


extern int pow(int x, int y);





inline int min_containers(int n, int cont_size) {
  return (n+cont_size-1)/cont_size;
}



# 17 "/afs/cs/user/dld/gc/concurrent/genlib/Time.h"


inline float round(float f, int places) {
  float tenpow = pow(10, places);
  return (f * tenpow + 0.5) / tenpow;
}



Bool is_leap_year(int year =0);





int days_in_month(int mon, int year=0);

enum DateTimeFormatStyle {
  FULL, TIME, DATE,
};

enum TimeUnit {
  MIXED, YEARS, DAYS, HOURS, MINUTES, SECONDS,
};





class Time {
  
  
  
  
  timeval tv;

  void normalize();

 public:

  
  Time(int secs =0, int usecs =0);

  
  Time(int days, int hours, int seconds, int mins, int msecs =0, int usecs =0);

  
  Time(Time& t2) { tv = t2.tv; };

  
  Time(timeval& tv2) { tv = tv2; }
  
  
  inline operator char*();

  
  
  
  
  
  char* format(TimeUnit unit =MIXED, int precision =2);
  

  
  
  
  float years(int places = 0);
  float days(int places = 0);
  float hrs(int places = 0);
  float mins(int places = 0);
  float secs(int places = 0);
  float msecs(int places =0);
  long usecs();

  inline Time& operator=(Time& t2);

  friend Time operator-(Time& t2);

  Time& operator+=(Time& t2);
  friend Time operator+(Time& t1, Time& t2);

  Time& operator-=(Time& t2);
  friend Time operator-(Time& t1, Time& t2);

  Time& operator*=(int i);
  friend Time operator*(Time& t, int i);
  friend Time operator*(int i, Time& t);

  Time& operator*=(float f);
  friend inline Time operator*(Time& t, float f);
  friend inline Time operator*(float f, Time& t);

  Time& operator/=(int i);
  friend Time operator/(Time& t, int i);

  Time& operator/=(float f);
  friend Time operator/(Time& t, float f);

  friend float operator/(Time& t1, Time& t2);

  friend int operator<(Time& t1, Time& t2);
  friend int operator==(Time& t1, Time& t2);
  friend int operator>(Time& t1, Time& t2);

  
friend class DateTime;
friend Time operator-(DateTime& dt1, DateTime& dt2);
};





class DateTime {
  timeval tv;
  TimeZone tz;
  tm* bd;
  void breakdown();

 public:

  
  DateTime();

  
  
  
  DateTime(int mins_west, int dst =-1);

  
  DateTime(DateTime& dt);

  
  char* format(DateTimeFormatStyle =FULL);

  
  
  
  void set_zone(int mins_west, int dst =-1);

  
  
  
  
  char* format(int mins_west, int dst, DateTimeFormatStyle =FULL);

  
  int year();
  int mon();
  int day();
  int hour();
  int min();
  int sec();
  int usec();
  int wday();
  int yday();

  DateTime& operator=(DateTime& dt);

  friend DateTime operator+(DateTime& dt, Time& t);
  DateTime& operator+=(Time& t);

  friend DateTime operator-(DateTime& dt, Time& t);
  DateTime& operator-=(Time& t);

  friend Time operator-(DateTime& dt1, DateTime& dt2);

  Bool operator==(DateTime& dt);
  Bool operator<(DateTime& dt);
  Bool operator>(DateTime& dt);


  
  
  
  
  friend DateTime* Parse(char* dt_str);

  inline ~DateTime();
};







static const int Time__i_million = 1000000;
static const float Time__f_million = 1e6;



overload iabs;
inline int iabs(int i) { return ( i < 0 ? -i : i); }
inline long iabs(long i) { return ( i < 0 ? -i : i); }


inline Time::Time(int secs, int usecs) {
  tv.tv_sec = secs;
  tv.tv_usec = -usecs;
  normalize();
}


inline Time::operator char*() { return format(); }

inline long Time::usecs() {
  return iabs(tv.tv_sec)*Time__i_million + iabs(tv.tv_usec);
}

inline float Time::msecs(int places) {
  float msecs = 1000.0 * float(tv.tv_sec) + float(tv.tv_usec)/1000.0;
  return round(fabs(msecs), places);
}

inline float Time::secs(int places) {
  float secs = float(tv.tv_sec) + float(tv.tv_usec)/Time__f_million;
  return round(fabs(secs), places);
}

inline float Time::mins(int places) {
  return round(secs()/60.0, places);
}

inline float Time::hrs(int places) {
  return round(secs()/3600.0, places);
}

inline float Time::days(int places) {
  return round(secs()/86400.0, places);
}

inline float Time::years(int places) {
  return round(secs()/(86400.0 * 365.0), places);
}




inline Time& Time::operator=(Time& t2) { tv = t2.tv; return *this; }

inline Time operator-(Time& t) {
  Time t_new(t); t_new *= -1; return t_new;
}

inline Time operator+(Time& t1, Time& t2) {
  Time t_new(t1); t_new += t2; return t_new;
}

inline Time operator-(Time& t1, Time& t2) {
  Time t_new(t1); t_new -= t2; return t_new;
}

inline Time operator*(Time& t, int i) {
  Time t_new(t); t_new *= i; return t_new;
}

inline Time operator*(int i, Time& t) {
  Time t_new(t); t_new *= i; return t_new;
}

inline Time operator*(Time& t, float f) {
  Time t_new(t); t_new *= f; return t_new;
}

inline Time operator*(float f, Time& t) {
  Time t_new(t); t_new *= f; return t_new;
}

inline Time operator/(Time& t, int i) {
  Time t_new(t); t_new /= i; return t_new;
}

inline Time operator/(Time& t, float f) {
  Time t_new(t); t_new /= f; return t_new;
}

inline int operator<(Time& t1, Time& t2) {
  return ((t1.tv.tv_sec < t2.tv.tv_sec) ||
	  ((t1.tv.tv_sec == t2.tv.tv_sec) && (t1.tv.tv_usec < t2.tv.tv_usec)));
}

inline int operator==(Time& t1, Time& t2) {
  return ((t1.tv.tv_sec == t2.tv.tv_sec) && (t1.tv.tv_usec == t2.tv.tv_usec));
}

inline int operator>(Time& t1, Time& t2) {
  return ((t1.tv.tv_sec > t2.tv.tv_sec) ||
	  ((t1.tv.tv_sec == t2.tv.tv_sec) && (t1.tv.tv_usec > t2.tv.tv_usec)));
}



inline DateTime::DateTime() { gettimeofday(&tv, &tz); bd = 0; };

inline DateTime& DateTime::operator=(DateTime& dt) {
  tv = dt.tv; tz = dt.tz;
  
  
  
  (dt.bd ? (bd = new tm, *bd = *dt.bd, 0) : 0);
  return *this;
}

inline DateTime::DateTime(DateTime& dt) {
  *this = dt;
}


inline void DateTime::set_zone(int mins_west, int dst) {
  
  int secdiff = (tz.tz_minuteswest - mins_west) * 60;
  if (dst >= 0) {
    
    secdiff += (tz.tz_dsttime - dst) * 60;
    tz.tz_dsttime = dst;
  }
  tv.tv_sec += secdiff;
  tz.tz_minuteswest = mins_west;
  
  if (bd) delete bd;
  bd = 0;
}

inline DateTime::DateTime(int mins_west, int dst) {
  gettimeofday(&tv, &tz);
  bd = 0;
  set_zone(mins_west, dst);
};

inline char* DateTime::format(int mins_west, int dst,
			      DateTimeFormatStyle style) {
  DateTime dt(*this);
  dt.set_zone(mins_west, dst);
  return dt.format(style);
}

inline int DateTime::year() {
  breakdown();
  return bd->tm_year + 1900;
}

inline int DateTime::mon() {
  breakdown();
  return bd->tm_mon+1;
}

inline int DateTime::day() {
  breakdown();
  return bd->tm_mday;
}

inline int DateTime::hour() {
  breakdown();
  return bd->tm_hour;
}

inline int DateTime::min() {
  breakdown();
  return bd->tm_min;
}

inline int DateTime::sec() {
  breakdown();
  return bd->tm_min;
}

inline int DateTime::usec() {
  return tv.tv_usec;
}


inline int DateTime::wday() {
  breakdown();
  return bd->tm_wday+1;
}


inline int DateTime::yday() {
  breakdown();
  return bd->tm_yday+1;
}

inline DateTime& DateTime::operator+=(Time& t) {
  Time this_time(tv);
  this_time += t;
  tv = this_time.tv;
  return *this;
}

inline DateTime operator+(DateTime& dt, Time& t) {
  DateTime dt_new(dt); dt_new += t; return dt_new;
}

inline DateTime& DateTime::operator-=(Time& t) {
  Time this_time(tv);
  this_time -= t;
  tv = this_time.tv;
  return *this;
}

inline DateTime operator-(DateTime& dt, Time& t) {
  DateTime dt_new(dt); dt_new -= t; return dt_new;
}

inline Time operator-(DateTime& dt1, DateTime& dt2) {
  Time t1(dt1.tv);
  Time t2(dt2.tv);
  return t1 - t2;
}

inline DateTime::operator==(DateTime& dt) {
  return (tv.tv_sec == dt.tv.tv_sec) && (tv.tv_usec == dt.tv.tv_usec);
}

inline DateTime::operator>(DateTime& dt) {
  return ((tv.tv_sec > dt.tv.tv_sec) ||
	  ((tv.tv_sec == dt.tv.tv_sec) && (tv.tv_usec > dt.tv.tv_usec)));
}

inline DateTime::operator<(DateTime& dt) {
  return ((tv.tv_sec < dt.tv.tv_sec) ||
	  ((tv.tv_sec == dt.tv.tv_sec) && (tv.tv_usec < dt.tv.tv_usec)));
}

inline DateTime::~DateTime() { if (!bd) delete bd; }

# 12 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"

# 1 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"








# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"





# 40 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"


# 11 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"


# 86 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"


# 12 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

# 1 "/usr/include/assert.h"





# 9 "/usr/include/assert.h"

# 13 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

# 1 "/usr/mach/include/mach.h"



























# 1 "/usr/mach/include/mach/mach_types.h"








































































































# 1 "/usr/mach/include/mach/port.h"




















































































# 87 "/usr/mach/include/mach/port.h"


typedef int 		port_name_t;		
typedef port_name_t	port_set_name_t;	
typedef port_name_t	*port_name_array_t;

typedef int		port_type_t;		
typedef port_type_t	*port_type_array_t;

	











typedef	port_name_t	port_t;			
typedef	port_t		port_rcv_t;		
typedef	port_t		port_own_t;		
typedef	port_t		port_all_t;		
typedef	port_t		*port_array_t;


# 119 "/usr/mach/include/mach/port.h"

extern port_set_name_t PORT_ENABLED;


# 105 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/vm_inherit.h"







































typedef int		vm_inherit_t;	













# 106 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/vm_prot.h"







































typedef int		vm_prot_t;
























# 107 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/memory_object.h"








































# 1 "/usr/mach/include/mach/port.h"

















































































# 122 "/usr/mach/include/mach/port.h"

# 41 "/usr/mach/include/mach/memory_object.h"

typedef	port_t		memory_object_t;
					
					
					
					

typedef	port_t		memory_object_control_t;
					
					

typedef	port_t		memory_object_name_t;
					
					

typedef	int		memory_object_copy_strategy_t;
					

					

					

					
					






typedef	port_t		paging_object_t;
typedef	port_t		vm_pager_request_t;
typedef	port_t		vm_pager_t;



# 79 "/usr/mach/include/mach/memory_object.h"


# 108 "/usr/mach/include/mach/mach_types.h"

# 1 "/afs/cs/user/dld/gc/concurrent/mach/vm_statistics.h"



















































struct vm_statistics_tmp {
	long	pagesize;		
	long	free_count;		
	long	active_count;		
	long	inactive_count;		
	long	wire_count;		
	long	zero_fill_count;	
	long	reactivations;		
	long	pageins;		
	long	pageouts;		
	long	faults;			
	long	cow_faults;		
	long	lookups;		
	long	hits;			
};

typedef struct vm_statistics_tmp	*vm_statistics_t;
typedef struct vm_statistics_tmp	vm_statistics_data_t;

# 73 "/afs/cs/user/dld/gc/concurrent/mach/vm_statistics.h"









struct pmap_statistics {
	long		resident_count;	
	long		wired_count;	
};

typedef struct pmap_statistics	*pmap_statistics_t;


# 109 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/vm_attributes.h"






































typedef unsigned int	vm_machine_attribute_t;








typedef int		vm_machine_attribute_val_t;










# 110 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/machine/vm_types.h"

































# 42 "/usr/mach/include/mach/machine/vm_types.h"

# 111 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/machine.h"








































# 43 "/usr/mach/include/mach/machine.h"



# 1 "/usr/mach/include/mach/machine/vm_types.h"

































# 42 "/usr/mach/include/mach/machine/vm_types.h"

# 46 "/usr/mach/include/mach/machine.h"

# 1 "/usr/mach/include/mach/boolean.h"











































# 52 "/usr/mach/include/mach/boolean.h"











# 65 "/usr/mach/include/mach/boolean.h"


# 69 "/usr/mach/include/mach/boolean.h"



# 47 "/usr/mach/include/mach/machine.h"










struct machine_info {
	int		major_version;	
	int		minor_version;	
	int		max_cpus;	
	int		avail_cpus;	
	vm_size_t	memory_size;	
};

typedef struct machine_info	*machine_info_t;
typedef struct machine_info	machine_info_data_t;	

typedef int	cpu_type_t;
typedef int	cpu_subtype_t;







struct machine_slot {
	boolean_t	is_cpu;		
	cpu_type_t	cpu_type;	
	cpu_subtype_t	cpu_subtype;	
	boolean_t	running;	
	long		cpu_ticks[	3];
	int		clock_freq;	
};

typedef struct machine_slot	*machine_slot_t;
typedef struct machine_slot	machine_slot_data_t;	

# 94 "/usr/mach/include/mach/machine.h"




















		











 
































	

	

	

































	

	

	

	








































# 112 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/thread_status.h"























































# 1 "/usr/mach/include/mach/machine/thread_status.h"






















































				

struct vax_thread_state {
	int	r0;		
	int	r1;
	int	r2;
	int	r3;
	int	r4;
	int	r5;
	int	r6;
	int	r7;
	int	r8;
	int	r9;
	int	r10;
	int	r11;
	int	ap;		
	int	fp;		
	int	sp;		
	int	pc;		
	int	ps;		
};



# 108 "/usr/mach/include/mach/machine/thread_status.h"


# 56 "/usr/mach/include/mach/thread_status.h"





typedef	int		*thread_state_t;	


typedef	int	thread_state_data_t[(1024)		];




# 113 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/thread_info.h"















































# 1 "/usr/mach/include/mach/policy.h"













































# 48 "/usr/mach/include/mach/thread_info.h"

# 1 "/usr/mach/include/mach/time_value.h"




































struct time_value {
	long	seconds;
	long	microseconds;
};
typedef	struct time_value	time_value_t;

























# 49 "/usr/mach/include/mach/thread_info.h"




typedef	int	*thread_info_t;		


typedef	int	thread_info_data_t[	(1024)	];






struct thread_basic_info {
	time_value_t	user_time;	
	time_value_t	system_time;	
	int		cpu_usage;	
	int		base_priority;	
	int		cur_priority;	
	int		run_state;	
	int		flags;		
	int		suspend_count;	
	long		sleep_time;	

};

typedef struct thread_basic_info	thread_basic_info_data_t;
typedef struct thread_basic_info	*thread_basic_info_t;





























struct thread_sched_info {
	int		policy;		
	int		data;		
	int		base_priority;	
	int		max_priority;   
	int		cur_priority;	
	boolean_t	depressed;	
	int		depress_priority; 
};

typedef struct thread_sched_info	thread_sched_info_data_t;
typedef struct thread_sched_info	*thread_sched_info_t;




# 114 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/thread_special_ports.h"



































































# 115 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/task_info.h"


































# 1 "/usr/mach/include/mach/machine/vm_types.h"

































# 42 "/usr/mach/include/mach/machine/vm_types.h"

# 35 "/usr/mach/include/mach/task_info.h"

# 1 "/usr/mach/include/mach/time_value.h"


































# 66 "/usr/mach/include/mach/time_value.h"

# 36 "/usr/mach/include/mach/task_info.h"




typedef	int	*task_info_t;		


typedef	int	task_info_data_t[(1024)		];






struct task_basic_info {
	int		suspend_count;	
	int		base_priority;	
	vm_size_t	virtual_size;	
	vm_size_t	resident_size;	
	time_value_t	user_time;	

	time_value_t	system_time;	

};

typedef struct task_basic_info		task_basic_info_data_t;
typedef struct task_basic_info		*task_basic_info_t;






struct task_events_info {
	long		faults;		
	long		zero_fills;	
	long		reactivations;	
	long		pageins;	
	long		cow_faults;	
	long		messages_sent;	
	long		messages_received; 
};
typedef struct task_events_info		task_events_info_data_t;
typedef struct task_events_info		*task_events_info_t;




# 116 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/task_special_ports.h"










































































# 117 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/netport.h"



















typedef unsigned long	netaddr_t;




typedef struct {
    long	np_uid_high;
    long	np_uid_low;
} np_uid_t;

typedef struct {
    netaddr_t	np_receiver;
    netaddr_t	np_owner;
    np_uid_t	np_puid;
    np_uid_t	np_sid;
} network_port_t;


# 118 "/usr/mach/include/mach/mach_types.h"


# 1 "/usr/mach/include/mach/host_info.h"





















































# 1 "/usr/mach/include/mach/machine.h"












































































# 243 "/usr/mach/include/mach/machine.h"

# 54 "/usr/mach/include/mach/host_info.h"

# 1 "/usr/mach/include/mach/machine/vm_types.h"

































# 42 "/usr/mach/include/mach/machine/vm_types.h"

# 55 "/usr/mach/include/mach/host_info.h"




typedef int	*host_info_t;		


typedef int	host_info_data_t[(1024)		];


typedef char	kernel_version_t[(512)];







struct host_basic_info {
	int		max_cpus;	
	int		avail_cpus;	
	vm_size_t	memory_size;	
	cpu_type_t	cpu_type;	
	cpu_subtype_t	cpu_subtype;	
};

typedef	struct host_basic_info	host_basic_info_data_t;
typedef struct host_basic_info	*host_basic_info_t;



struct host_sched_info {
	int		min_timeout;	
	int		min_quantum;	
};

typedef	struct host_sched_info	host_sched_info_data_t;
typedef struct host_sched_info	*host_sched_info_t;




# 120 "/usr/mach/include/mach/mach_types.h"

# 1 "/usr/mach/include/mach/processor_info.h"











































# 1 "/usr/mach/include/mach/machine.h"












































































# 243 "/usr/mach/include/mach/machine.h"

# 44 "/usr/mach/include/mach/processor_info.h"




typedef int	*processor_info_t;	


typedef int	processor_info_data_t[(1024)	];


typedef int	*processor_set_info_t;	


typedef int	processor_set_info_data_t[(1024)	];






struct processor_basic_info {
	cpu_type_t	cpu_type;	
	cpu_subtype_t	cpu_subtype;	
	boolean_t	running;	
	int		slot_num;	
	boolean_t	is_master;	
};

typedef	struct processor_basic_info	processor_basic_info_data_t;
typedef struct processor_basic_info	*processor_basic_info_t;






struct processor_set_basic_info {
	int		processor_count;	
	int		task_count;		
	int		thread_count;		
	int		load_average;		
	int		mach_factor;		
};






typedef	struct processor_set_basic_info	processor_set_basic_info_data_t;
typedef struct processor_set_basic_info	*processor_set_basic_info_t;





struct processor_set_sched_info {
	int		policies;	
	int		max_priority;	
};

typedef	struct processor_set_sched_info	processor_set_sched_info_data_t;
typedef struct processor_set_sched_info	*processor_set_sched_info_t;




# 121 "/usr/mach/include/mach/mach_types.h"

# 132 "/usr/mach/include/mach/mach_types.h"

typedef	port_t		task_t;
typedef	task_t		vm_task_t;
typedef port_t		*task_array_t;
typedef	port_t		thread_t;
typedef port_t		monitor_t;
typedef	thread_t	*thread_array_t;

typedef port_t		host_t;
typedef port_t		host_priv_t;
typedef port_t		processor_t;
typedef port_t		*processor_array_t;
typedef port_t		processor_set_t;
typedef port_t		processor_set_name_t;
typedef port_t		*processor_set_array_t;







# 1 "/usr/mach/include/mach/std_types.h"




































# 1 "/usr/mach/include/mach/boolean.h"











































# 52 "/usr/mach/include/mach/boolean.h"











# 65 "/usr/mach/include/mach/boolean.h"


# 69 "/usr/mach/include/mach/boolean.h"



# 37 "/usr/mach/include/mach/std_types.h"

# 1 "/usr/mach/include/mach/kern_return.h"

























































# 1 "/usr/mach/include/mach/machine/kern_return.h"





































typedef	int		kern_return_t;


# 58 "/usr/mach/include/mach/kern_return.h"




		



		




		





		




		



		




		




		



		





		







		



		



		



		




# 38 "/usr/mach/include/mach/std_types.h"

# 1 "/usr/mach/include/mach/port.h"

















































































# 122 "/usr/mach/include/mach/port.h"

# 39 "/usr/mach/include/mach/std_types.h"

# 1 "/usr/mach/include/mach/machine/vm_types.h"

































# 42 "/usr/mach/include/mach/machine/vm_types.h"

# 40 "/usr/mach/include/mach/std_types.h"


typedef	vm_offset_t	pointer_t;


# 154 "/usr/mach/include/mach/mach_types.h"


typedef	vm_offset_t	vm_address_t;
typedef	unsigned int	vm_region_t;
typedef	vm_region_t	*vm_region_array_t;

typedef	char		vm_page_data_t[4096];



# 28 "/usr/mach/include/mach.h"

# 1 "/usr/mach/include/mach_interface.h"






# 1 "/usr/mach/include/mach/kern_return.h"
















































































# 130 "/usr/mach/include/mach/kern_return.h"

# 7 "/usr/mach/include/mach_interface.h"


# 1 "/usr/mach/include/mach/port.h"

















































































# 122 "/usr/mach/include/mach/port.h"

# 9 "/usr/mach/include/mach_interface.h"

# 1 "/usr/mach/include/mach/message.h"






























































































# 97 "/usr/mach/include/mach/message.h"



# 1 "/usr/mach/include/mach/port.h"

















































































# 122 "/usr/mach/include/mach/port.h"

# 100 "/usr/mach/include/mach/message.h"









typedef	unsigned int	msg_size_t;

typedef	struct {
		unsigned int	msg_unused : 24,
				msg_simple : 8;
		msg_size_t	msg_size;
		int		msg_type;
		port_t		msg_local_port;
		port_t		msg_remote_port;
		int		msg_id;
} msg_header_t;

































typedef struct  {
	unsigned int	msg_type_name : 8,		
			msg_type_size : 8,		
			msg_type_number : 12,		
			msg_type_inline : 1,		
			msg_type_longform : 1,		
			msg_type_deallocate : 1,	
			msg_type_unused : 1;
} msg_type_t;

typedef	struct	{
	msg_type_t	msg_type_header;
	unsigned short	msg_type_long_name;
	unsigned short	msg_type_long_size;
	unsigned int	msg_type_long_number;
} msg_type_long_t;




























# 199 "/usr/mach/include/mach/message.h"
















# 218 "/usr/mach/include/mach/message.h"






typedef	unsigned int	msg_timeout_t;








typedef	int		msg_option_t;








# 248 "/usr/mach/include/mach/message.h"






# 256 "/usr/mach/include/mach/message.h"










typedef	int		msg_return_t;




# 273 "/usr/mach/include/mach/message.h"


















# 293 "/usr/mach/include/mach/message.h"



















msg_return_t	msg_send(

	msg_header_t	*header,
	msg_option_t	option,
	msg_timeout_t	timeout);
# 319 "/usr/mach/include/mach/message.h"


msg_return_t	msg_receive(

	msg_header_t	*header,
	msg_option_t	option,
	msg_timeout_t	timeout);
# 328 "/usr/mach/include/mach/message.h"


msg_return_t	msg_rpc(

	msg_header_t	*header,	
	msg_option_t	option,
	msg_size_t	rcv_size,
	msg_timeout_t	send_timeout,
	msg_timeout_t	rcv_timeout);
# 339 "/usr/mach/include/mach/message.h"



# 10 "/usr/mach/include/mach_interface.h"






extern void init_mach

    (port_t rep_port);
# 21 "/usr/mach/include/mach_interface.h"


# 1 "/usr/mach/include/mach/std_types.h"






























# 44 "/usr/mach/include/mach/std_types.h"

# 23 "/usr/mach/include/mach_interface.h"

# 1 "/usr/mach/include/mach/mach_types.h"







































































































# 163 "/usr/mach/include/mach/mach_types.h"

# 24 "/usr/mach/include/mach_interface.h"

# 1 "/usr/mach/include/mach/mach_extra.h"


















































# 25 "/usr/mach/include/mach_interface.h"


extern kern_return_t xxx_port_allocate
# 33 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_t *my_port
);
# 41 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_port_deallocate
# 51 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_t my_port
);
# 59 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_port_enable
# 69 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_t my_port
);
# 77 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_port_disable
# 87 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_t my_port
);
# 95 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_port_select
# 106 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_array_t *port_list,
	unsigned int *port_listCnt
);
# 115 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_port_set_backlog
# 126 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_t my_port,
	int backlog
);
# 135 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_port_status
# 150 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_t my_port,
	boolean_t *enabled,
	int *num_msgs,
	int *backlog,
	boolean_t *ownership,
	boolean_t *receive_rights
);
# 163 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_create
# 174 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	boolean_t inherit_memory,
	task_t *child_task
);
# 183 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_terminate
# 192 "/usr/mach/include/mach_interface.h"


(
	task_t target_task
);
# 199 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_threads
# 210 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	thread_array_t *thread_list,
	unsigned int *thread_listCnt
);
# 219 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_terminate
# 228 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread
);
# 235 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_allocate
# 247 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t *address,
	vm_size_t size,
	boolean_t anywhere
);
# 257 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_deallocate
# 268 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t address,
	vm_size_t size
);
# 277 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_protect
# 290 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t address,
	vm_size_t size,
	boolean_t set_maximum,
	vm_prot_t new_protection
);
# 301 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_inherit
# 313 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t address,
	vm_size_t size,
	vm_inherit_t new_inheritance
);
# 323 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_read
# 336 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t address,
	vm_size_t size,
	pointer_t *data,
	unsigned int *dataCnt
);
# 347 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_write
# 359 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t address,
	pointer_t data,
	unsigned int dataCnt
);
# 369 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_copy
# 381 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t source_address,
	vm_size_t size,
	vm_address_t dest_address
);
# 391 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_region
# 408 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t *address,
	vm_size_t *size,
	vm_prot_t *protection,
	vm_prot_t *max_protection,
	vm_inherit_t *inheritance,
	boolean_t *is_shared,
	memory_object_name_t *object_name,
	vm_offset_t *offset
);
# 423 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_statistics
# 433 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_statistics_data_t *vm_stats
);
# 441 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_by_unix_pid
# 452 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	int process_id,
	task_t *result_task
);
# 461 "/usr/mach/include/mach_interface.h"




extern kern_return_t mach_ports_register
# 472 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_array_t init_port_set,
	unsigned int init_port_setCnt
);
# 481 "/usr/mach/include/mach_interface.h"




extern kern_return_t mach_ports_lookup
# 492 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	port_array_t *init_port_set,
	unsigned int *init_port_setCnt
);
# 501 "/usr/mach/include/mach_interface.h"




extern kern_return_t unix_pid
# 511 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	int *process_id
);
# 519 "/usr/mach/include/mach_interface.h"




extern kern_return_t netipc_listen
# 534 "/usr/mach/include/mach_interface.h"


(
	port_t request_port,
	int src_addr,
	int dst_addr,
	int src_port,
	int dst_port,
	int protocol,
	port_t ipc_port
);
# 547 "/usr/mach/include/mach_interface.h"




extern kern_return_t netipc_ignore
# 557 "/usr/mach/include/mach_interface.h"


(
	port_t request_port,
	port_t ipc_port
);
# 565 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_data_provided
# 578 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	vm_offset_t offset,
	pointer_t data,
	unsigned int dataCnt,
	vm_prot_t lock_value
);
# 589 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_data_unavailable
# 600 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	vm_offset_t offset,
	vm_size_t size
);
# 609 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_get_attributes
# 621 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	boolean_t *object_ready,
	boolean_t *may_cache,
	memory_object_copy_strategy_t *copy_strategy
);
# 631 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_set_default_memory_manager
# 641 "/usr/mach/include/mach_interface.h"


(
	task_t host,
	memory_object_t *default_manager
);
# 649 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_lock_request
# 664 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	vm_offset_t offset,
	vm_size_t size,
	boolean_t should_clean,
	boolean_t should_flush,
	vm_prot_t lock_value,
	port_t reply_to
);
# 677 "/usr/mach/include/mach_interface.h"




extern kern_return_t pager_cache
# 687 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	boolean_t should_cache
);
# 695 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_host_info
# 705 "/usr/mach/include/mach_interface.h"


(
	port_t target_task,
	machine_info_data_t *info
);
# 713 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_slot_info
# 724 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	int slot,
	machine_slot_data_t *info
);
# 733 "/usr/mach/include/mach_interface.h"




extern kern_return_t xxx_cpu_control
# 744 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	int cpu,
	boolean_t running
);
# 753 "/usr/mach/include/mach_interface.h"




extern kern_return_t netport_init
# 762 "/usr/mach/include/mach_interface.h"


(
	port_t request_port
);
# 769 "/usr/mach/include/mach_interface.h"




extern kern_return_t netport_enter
# 781 "/usr/mach/include/mach_interface.h"


(
	port_t request_port,
	network_port_t netport,
	port_t port,
	boolean_t local
);
# 791 "/usr/mach/include/mach_interface.h"




extern kern_return_t netport_remove
# 801 "/usr/mach/include/mach_interface.h"


(
	port_t request_port,
	network_port_t netport
);
# 809 "/usr/mach/include/mach_interface.h"




extern kern_return_t pager_data_provided_inline
# 821 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	vm_offset_t offset,
	vm_page_data_t data,
	vm_prot_t lock_value
);
# 831 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_suspend
# 840 "/usr/mach/include/mach_interface.h"


(
	task_t target_task
);
# 847 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_resume
# 856 "/usr/mach/include/mach_interface.h"


(
	task_t target_task
);
# 863 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_get_special_port
# 874 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	int which_port,
	port_t *special_port
);
# 883 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_set_special_port
# 894 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	int which_port,
	port_t special_port
);
# 903 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_info
# 915 "/usr/mach/include/mach_interface.h"


(
	task_t target_task,
	int flavor,
	task_info_t task_info_out,
	unsigned int *task_info_outCnt
);
# 925 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_create
# 935 "/usr/mach/include/mach_interface.h"


(
	task_t parent_task,
	thread_t *child_thread
);
# 943 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_suspend
# 952 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread
);
# 959 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_resume
# 968 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread
);
# 975 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_abort
# 984 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread
);
# 991 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_get_state
# 1003 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread,
	int flavor,
	thread_state_t old_state,
	unsigned int *old_stateCnt
);
# 1013 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_set_state
# 1025 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread,
	int flavor,
	thread_state_t new_state,
	unsigned int new_stateCnt
);
# 1035 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_get_special_port
# 1046 "/usr/mach/include/mach_interface.h"


(
	thread_t thread,
	int which_port,
	port_t *special_port
);
# 1055 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_set_special_port
# 1066 "/usr/mach/include/mach_interface.h"


(
	thread_t thread,
	int which_port,
	port_t special_port
);
# 1075 "/usr/mach/include/mach_interface.h"




extern kern_return_t thread_info
# 1087 "/usr/mach/include/mach_interface.h"


(
	thread_t target_thread,
	int flavor,
	thread_info_t thread_info_out,
	unsigned int *thread_info_outCnt
);
# 1097 "/usr/mach/include/mach_interface.h"




extern kern_return_t task_set_emulation
# 1108 "/usr/mach/include/mach_interface.h"


(
	task_t target_port,
	vm_address_t routine_entry_pt,
	int routine_number
);
# 1117 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_names
# 1130 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_array_t *port_names_p,
	unsigned int *port_names_pCnt,
	port_type_array_t *port_types,
	unsigned int *port_typesCnt
);
# 1141 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_type
# 1152 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t port_name,
	port_type_t *port_type_p
);
# 1161 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_rename
# 1172 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t old_name,
	port_name_t new_name
);
# 1181 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_allocate
# 1191 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t *port_name
);
# 1199 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_deallocate
# 1209 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t port_name
);
# 1217 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_backlog
# 1228 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t port_name,
	int backlog
);
# 1237 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_status
# 1252 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t port_name,
	port_set_name_t *enabled,
	int *num_msgs,
	int *backlog,
	boolean_t *ownership,
	boolean_t *receive_rights
);
# 1265 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_allocate
# 1275 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_set_name_t *set_name
);
# 1283 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_deallocate
# 1293 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_set_name_t set_name
);
# 1301 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_add
# 1312 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_set_name_t set_name,
	port_name_t port_name
);
# 1321 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_remove
# 1331 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t port_name
);
# 1339 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_status
# 1351 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_set_name_t set_name,
	port_name_array_t *members,
	unsigned int *membersCnt
);
# 1361 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_insert_send
# 1372 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_t my_port,
	port_name_t his_name
);
# 1381 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_extract_send
# 1392 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t his_name,
	port_t *his_port
);
# 1401 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_insert_receive
# 1412 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_t my_port,
	port_name_t his_name
);
# 1421 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_extract_receive
# 1432 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t his_name,
	port_t *his_port
);
# 1441 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_map
# 1460 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t *address,
	vm_size_t size,
	vm_address_t mask,
	boolean_t anywhere,
	memory_object_t memory_object,
	vm_offset_t offset,
	boolean_t copy,
	vm_prot_t cur_protection,
	vm_prot_t max_protection,
	vm_inherit_t inheritance
);
# 1477 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_data_error
# 1489 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	vm_offset_t offset,
	vm_size_t size,
	kern_return_t error_value
);
# 1499 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_set_attributes
# 1511 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	boolean_t object_ready,
	boolean_t may_cache,
	memory_object_copy_strategy_t copy_strategy
);
# 1521 "/usr/mach/include/mach_interface.h"




extern kern_return_t memory_object_destroy
# 1531 "/usr/mach/include/mach_interface.h"


(
	memory_object_control_t memory_control,
	kern_return_t reason
);
# 1539 "/usr/mach/include/mach_interface.h"




extern kern_return_t port_set_backup
# 1551 "/usr/mach/include/mach_interface.h"


(
	task_t task,
	port_name_t port_name,
	port_t backup,
	port_t *previous
);
# 1561 "/usr/mach/include/mach_interface.h"




extern kern_return_t vm_machine_attribute
# 1574 "/usr/mach/include/mach_interface.h"


(
	vm_task_t target_task,
	vm_address_t address,
	vm_size_t size,
	vm_machine_attribute_t attribute,
	vm_machine_attribute_val_t *value
);
# 1585 "/usr/mach/include/mach_interface.h"




# 29 "/usr/mach/include/mach.h"

# 1 "/usr/mach/include/mach_init.h"
































# 1 "/usr/mach/include/mach/mach_types.h"







































































































# 163 "/usr/mach/include/mach/mach_types.h"

# 33 "/usr/mach/include/mach_init.h"





extern	port_t	task_self_;
extern	port_t	task_notify_;
extern  port_t	thread_reply_;















extern	port_t	name_server_port;
extern	port_t	environment_port;
extern	port_t	service_port;






# 74 "/usr/mach/include/mach_init.h"






extern	vm_size_t	vm_page_size;





# 30 "/usr/mach/include/mach.h"


# 14 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

# 1 "/usr/misc/.c++/include/stream.h"









# 1 "/usr/cs/include/stdio.h"














































# 193 "/usr/cs/include/stdio.h"

# 10 "/usr/misc/.c++/include/stream.h"

# 13 "/usr/misc/.c++/include/stream.h"


# 17 "/usr/misc/.c++/include/stream.h"






enum state_value { _good=0, _eof=1, _fail=2, _bad=4 };
enum open_mode { input=0, output=1, append=2 };

struct streambuf {			

	char*	base;			
	char*	pptr;			
	char*	gptr;			
	char*	eptr;			
	char	alloc;			
	struct _iobuf*	fp;			
	
	virtual overflow(int c=(-1));	
					
	 				

	virtual int underflow();	
					
	 				
	
	inline int sgetc()		
	{
		return (gptr>=pptr) ? underflow() : *gptr&0377;
	}

	
	inline int snextc()		
	{
		return (gptr>=(pptr-1)) ? underflow() : *++gptr&0377;
	}

	inline void stossc()		
	{
		if (gptr++ >= pptr)
			underflow();
	}

	inline void sputbackc(char c)
	







	{
		if (gptr > base) *--gptr = c;
	}

	inline int sputc(int c =(-1))	
	{
		if (fp == 0)
			return (eptr<=pptr) ? overflow(c&0377) : (*pptr++=c&0377);
		else
			return 	(--( fp)->_cnt >= 0 ?	(int)(*(unsigned char *)( fp)->_ptr++ = (c)) :	((( fp)->_flag & 0200) && -( fp)->_cnt < ( fp)->_bufsiz ?		((*( fp)->_ptr = (c)) != '\n' ?			(int)(*(unsigned char *)( fp)->_ptr++) :			_flsbuf(*(unsigned char *)( fp)->_ptr,  fp)) :		_flsbuf((unsigned char)(c),  fp)));
	}

	
	inline streambuf * setbuf(char *p, int len, int count =0)
	



	{
		base = gptr = p;
		pptr = p + count;
		eptr = base + len;
		return this;
	}

	int doallocate();		
	inline int allocate(){ return base==0 ? doallocate() : 0; }

	streambuf() { base = gptr = pptr = eptr = 0; alloc = 0; fp = 0; }
	streambuf(char* p, int l) { setbuf(p,l); alloc = 0; }
	~streambuf() { if (base && alloc) delete base; }
};

# 122 "/usr/misc/.c++/include/stream.h"

extern int close(int);
# 126 "/usr/misc/.c++/include/stream.h"


struct filebuf : public streambuf {	

	int	fd;			
	char	opened;			

	int overflow(int c=(-1));	
					
					
	
	int underflow();		
	 				
	 				
	 
	filebuf* open(char *name, open_mode om);	
	 						
							
	int 	close() { int i = opened?::close(fd):0; opened=0; return i; }

	filebuf() { opened = 0; fp = 0; }
	filebuf(struct _iobuf* p) { fp = p; opened = 1; }
	filebuf(int nfd) { fd = nfd; opened = 1; }
	filebuf(int nfd, char* p, int l) : (p,l) { fd = nfd; opened = 1; }
	~filebuf() { close(); }
};

struct circbuf : public streambuf {	

	int overflow(int c=(-1));	
	 				
	 				
	
	int underflow();		
					
	 				
	circbuf() { }
	~circbuf() { }

};









struct whitespace { };



extern char* oct(long, int =0);
extern char* dec(long, int =0);
extern char* hex(long, int =0);

extern char* chr(int, int =0);		
extern char* str(const char*, int =0);
extern char* form(const char* ...);		

class istream;
class common;

class ostream {
friend istream;

	streambuf* bp;
	short	state;
public:
	ostream& operator<<(const char*);	
	ostream& operator<<(int a) { return *this<<long(a); }
	
	ostream& operator<<(unsigned a) 
		{ return *this<<(unsigned long) a; }
	ostream& operator<<(unsigned long);
	ostream& operator<<(long);	
	ostream& operator<<(double);
	ostream& operator<<(const streambuf&);
	ostream& operator<<(const whitespace&);
	ostream& operator<<(const common&);

	ostream& put(char);		
	ostream& flush() { bp->overflow(); return *this; }


		operator void*(){ return _eof<state?0:this; }
	int	operator!()	{ return _eof<state; }
	int	eof()		{ return state&_eof; }
	int	fail()		{ return _eof<state; }
	int	bad()		{ return _fail<state; }
	int	good()		{ return state==_good; }
	void	clear(state_value i =0)	{ state=i; }
	int	rdstate()	{ return state; }
	char*	bufptr()	{ return bp->base; }

		ostream(streambuf* s) { bp = s; state = 0; }
		ostream(int fd) { bp = new filebuf(fd); state = 0; }
		ostream(int size, char* p)
		{
			state = 0;
			bp = new streambuf();
			if (p == 0) p = new char[size];
			bp->setbuf(p, size);
		}
		~ostream() { flush(); }
};














class istream {
friend ostream;

	streambuf*	bp;
	ostream*	tied_to;
	char		skipws;		
	short		state;

	friend void eatwhite (istream&);
public:
	int	 skip(int i) { int ii=skipws; skipws=i; return ii; }

	


	istream& operator>>(char*);			
	istream& operator>>(char&);			
	istream& operator>>(short&);
	istream& operator>>(int&);
	istream& operator>>(long&);
	istream& operator>>(float&);
	istream& operator>>(double&);
	istream& operator>>(streambuf&);
	istream& operator>>(whitespace&);		
	istream& operator>>(common&);

	


	istream& get(char*, int, char ='\n');		
	istream& get(streambuf& sb, char ='\n');
	istream& get(char& c)				
	{
		int os = skipws;
		skipws = 0;
		*this >> c;
		skipws = os;
		return *this;
	}

	istream& putback(char c);
	ostream* tie(ostream* s) { ostream* t = tied_to; tied_to = s; return t; }

		operator void*(){ return _eof<state?0:this; }
	int	operator!()	{ return _eof<state; }
	int	eof()		{ return state&_eof; }
	int	fail()		{ return _eof<state; }
	int	bad()		{ return _fail<state; }
	int	good()		{ return state==_good; }
	void	clear(state_value i =0)	{ state=i; }
	int	rdstate()	{ return state; }
	char*	bufptr()	{ return bp->base; }	

		istream(streambuf* s, int sk =1, ostream* t =0)	
		{
			state = 0;
			skipws = sk;
			tied_to = t;
			bp = s;
		}

		istream(int size, char* p, int sk =1)		
		{
			state = 0;
			skipws = sk;
			tied_to = 0;
			bp = new streambuf();
			if (p == 0) p = new char[size];
			bp->setbuf(p, size, size);
		}

		istream(int fd, int sk =1, ostream* t =0)	
		{
			state = 0;
			skipws = sk;
			tied_to = t;
			bp = new filebuf(fd);
		}
};


extern istream cin;	
extern ostream cout;	
extern ostream cerr;	

extern whitespace WS;	


# 15 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

static const int KBYTE = 1024;
static const int MBYTE = KBYTE*KBYTE;

static const int BITS_PER_WORD = 32;
static const int BYTES_PER_WORD = 4;


inline void stop_if_error(kern_return_t ret_code, char* file, int line) {
  if (ret_code != 		0) {
    cerr << "Kernel call in file " << file << " on line " << line <<
      " fails with return code " << ret_code << ".\n";
    exit(-1);
  }
}


# 13 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"



# 1 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"































































# 1 "/usr/misc/.c++/include/stream.h"



































# 372 "/usr/misc/.c++/include/stream.h"

# 117 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"

# 1 "/usr/cs/include/libc.h"


















































# 262 "/usr/cs/include/libc.h"

# 118 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"







# 149 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"



# 1 "/usr/mach/include/cthreads.h"






















































































typedef void *any_t;

# 97 "/usr/mach/include/cthreads.h"



# 1 "/usr/mach/include/mach.h"























# 31 "/usr/mach/include/mach.h"

# 100 "/usr/mach/include/cthreads.h"

# 104 "/usr/mach/include/cthreads.h"




# 110 "/usr/mach/include/cthreads.h"












extern void cthread_init();
extern any_t calloc 	(unsigned n, unsigned size);




typedef struct cthread_queue {
	struct cthread_queue_item *head;
	struct cthread_queue_item *tail;
} *cthread_queue_t;

typedef struct cthread_queue_item {
	struct cthread_queue_item *next;
} *cthread_queue_item_t;
















































extern void
spin_lock 	(int *p);

extern void
spin_unlock 	(int *p);




typedef struct mutex {
	int lock;
	char *name;
} *mutex_t;















extern int
mutex_try_lock 	(mutex_t m);	

extern void
mutex_wait_lock 	(mutex_t m);	

extern void
mutex_unlock 	(mutex_t m);




typedef struct condition {
	int lock;
	struct cthread_queue queue;
	char *name;
} *condition_t;




















extern void
cond_signal 	(condition_t c);

extern void
cond_broadcast 	(condition_t c);

extern void
condition_wait 	(condition_t c, mutex_t m);





typedef any_t (*cthread_fn_t) 	(any_t arg);


# 1 "/usr/cs/include/setjmp.h"











































# 46 "/usr/cs/include/setjmp.h"

# 49 "/usr/cs/include/setjmp.h"

# 52 "/usr/cs/include/setjmp.h"

# 55 "/usr/cs/include/setjmp.h"


typedef int jmp_buf[10];





# 66 "/usr/cs/include/setjmp.h"











# 91 "/usr/cs/include/setjmp.h"


extern int setjmp (jmp_buf);
extern void longjmp (jmp_buf, int);
extern int _setjmp (jmp_buf);
extern void _longjmp (jmp_buf, int);



# 265 "/usr/mach/include/cthreads.h"

typedef struct cthread {
	struct cthread *next;
	struct mutex lock;
	struct condition done;
	int state;
	jmp_buf catch;
	cthread_fn_t func;
	any_t arg;
	any_t result;
	char *name;
	any_t data;
} *cthread_t;



extern cthread_t
cthread_fork 	(cthread_fn_t func, any_t arg);

extern void
cthread_detach 	(cthread_t t);

extern any_t
cthread_join 	(cthread_t t);

extern void
cthread_yield();

extern void
cthread_exit 	(any_t result);




typedef struct ur_cthread {
	struct ur_cthread *next;
	cthread_t incarnation;
} *ur_cthread_t;

extern int
cthread_sp();

extern int cthread_stack_mask;





extern void
cthread_set_name 	(cthread_t t, char *name);

extern char *
cthread_name 	(cthread_t t);

extern int
cthread_count();

extern void
cthread_set_limit 	(int n);

extern int
cthread_limit();




extern int
fork();





extern int cthread_debug;


# 152 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"



# 170 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"




































class debug_object {
 public:
  static int debug_nesting_level;
  static char* current_proc[100];
  static ostream* debug_out;
  static int debug_trace;
  static int debug_level;
  static mutex_t debug_lock;
  
  debug_object(ostream* dout, mutex_t lock =0) {
    debug_out = dout;
    char* debug_level_string = getenv("DEBUG_LEVEL");
    debug_level =
      (debug_level_string == 0) ? 0 : atoi(debug_level_string);
    debug_trace = (getenv("DEBUG_TRACE") != 0);
    debug_nesting_level = 0;
    if (lock) debug_lock = lock;
    else debug_lock = 		((mutex_t) calloc(1, sizeof(struct mutex)));
  }

  debug_object(ostream* dout, int in_trace, int in_debug_level,
	       mutex_t lock =0) {
    debug_out = dout;
    debug_level = in_debug_level;
    debug_trace = in_trace;
    debug_nesting_level = 0;
    if (lock) debug_lock = lock;
    else debug_lock = 		((mutex_t) calloc(1, sizeof(struct mutex)));
  }
  debug_object(char* name);
  ~debug_object();
};

# 247 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"






























# 287 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"



# 16 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"


# 1 "/usr/misc/.c++/include/stream.h"



































# 372 "/usr/misc/.c++/include/stream.h"

# 18 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"


# 1 "/usr/mach/include/mach.h"























# 31 "/usr/mach/include/mach.h"

# 20 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"

# 1 "/usr/mach/include/cthreads.h"





























































































# 340 "/usr/mach/include/cthreads.h"

# 21 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"


class GcHeapRep;



struct GCHRepInvObj {
  const char* where_at;
  GcHeapRep* gch;
  GCHRepInvObj(GcHeapRep* gch1, const char* where);
  ~GCHRepInvObj();
};







struct MutWaitStartRec {
  thread_t id;
  DateTime start;
  Bool for_alloc_page;
  Bool promoted;
  int scan_state;
  int page;
  void* addr;
  MutWaitStartRec() {
    id = thread_t(0); for_alloc_page = 0, addr = 0;
    start = DateTime(0);
  }
  void operator=(MutWaitStartRec& mwsr) {
    id = mwsr.id; start = mwsr.start; for_alloc_page = mwsr.for_alloc_page;
    promoted = mwsr.promoted; scan_state = mwsr.scan_state;
    page = mwsr.page; addr = mwsr.addr;
  }
};

const int MAX_THREADS = 16;
const int MUT_WAIT_LOG_SIZE = 100;

class GcPerfObj {
 public:
  
  GcPerfObj(GcHeapRep* gch, int in_use, int level =-1);
  void promote_page();
  void retain_obj(int size);
  void copy_obj();
  void copy_page();
  void scan_page();

  void start_mut_task();
  void end_stack_scan();
  void end_glob_scan();
  void end_heap_scan();
  void end_gc();

  void mut_task_n_threads(int n);
  void mut_thread_wait(thread_t thrd, void* addr, Bool is_alloc_page =0);
  void mut_thread_resume(thread_t thrd);

  void analyze_mut_log_stats();

  ~GcPerfObj();			
				

  
  int total_pages();
  int total_promoted_pages();

  Time tot_elapsed_time();
  Time tot_scan_time();
  Time stack_scan_time();
  Time glob_scan_time();
  Time heap_scan_time();
  Time bookkeeping_time();

  int percent_retained();
  int percent_freed();
  Time sec_per_mbyte();
  Time sec_per_scanned_page();
  int retained_avg_size();
  int percent_retained_wasted();
  int copied_avg_size();

  Time tot_mut_active_time();
  Time tot_mut_wait_time();
  Time avg_mut_wait_time();
  int percent_mut_wait_time();
  int percent_alloc_page_wait_number();
  int percent_alloc_page_wait_time();
  int percent_repeats();
  int percent_overlap();

  ostream& write_to_stream(ostream& ost);
  void summarize_wait_log(ostream& ost);

 private:
  GcHeapRep* the_heap;		
  int BYTES_PER_GC_PAGE;	
  int vlevel;			
  DateTime gc_start;		
  DateTime mut_task_start;	
  DateTime gc_stack_scan_end;	
  DateTime gc_glob_scan_end;
  DateTime gc_heap_scan_end;
  DateTime gc_end;		

  struct mutex wait_info_lock;
  int tot_threads;
  int cur_threads;
  MutWaitStartRec mut_wait_starts[MAX_THREADS];
  MutWaitStartRec* mut_wait_log;
  MutWaitStartRec* cur_mut_wait_log_entry;
  int n_mut_waits;
  int n_mut_alloc_page_waits;
  int n_repeats;
  Time mut_task_wait_time;
  Time mut_task_alloc_page_wait_time;
  Time longest_mut_thread_wait;

  
  
  int n_promoted;
  int n_rescan, n_in_progress, n_scanned;
  int n_first_half;

  int pages_in_use;		
  Bool stack_scan_done;		
				
  int promoted_pages_init;	
  int promoted_pages_late;	
				
  int retained_objs;		
				
  int retained_size;		
  int copied_objects;		
  int copied_pages;		
				
  int scanned_pages;		

 friend class GcPerfSummaryObj;
};

class GcPerfSummaryObj {
 public:
  GcPerfSummaryObj(GcHeapRep* gch, int level =-1);
  void init(GcHeapRep* gch, int level =-1);
  void operator+=(GcPerfObj& perf);
  void finalize(int lp);	
				
  
  void note_mut_alloc(int size);

  
  void restart_elapsed();

  
  void note_interior_ptr();

  
  Time avg_et();
  Time et_per_mbyte();
  int percent_freed();
  int avg_promoted_pages_init();
  int avg_promoted_pages_late();
  int avg_copied_pages();
  int avg_retained_objs();
  int retained_obj_size();
  int percent_retained_wasted();
  int avg_copied_objs();
  int copied_obj_size();
  int cur_heap_pages();
  float cur_heap_real_megs();
  float cur_heap_sim_megs();

  void mut_task_n_threads(int n);
  Time secs_per_mut_wait();
  float mut_waits_per_gc();
  int avg_percent_wait();
  int avg_percent_overlap();


  ostream& write_to_stream(ostream& ost);

 private:
  GcHeapRep* the_heap;
  int BYTES_PER_GC_PAGE;	
  int vlevel;
  int n_gcs;
  int last_page;

  DateTime start_of_program;
  Time elapsed;
  Time mut_stopped, mut_longest_stop;
  Time mut_active;
  int tot_pages_collected;
  int promoted_pages_init;
  int promoted_pages_late;
  int retained_objs;
  int retained_size;
  int copied_objects;
  int copied_pages;
  int scanned_pages;

  int n_mut_waits;
  int tot_threads;
  Time tot_mut_wait_time, long_mut_wait;
  Time tot_mut_active_time;

  
  int n_promoted;
  int n_rescan, n_in_progress, n_scanned;
  int n_first_half;

  int mut_allocs_gc;
  int mut_alloc_bytes_gc;
  int mut_allocs_nogc;
  int mut_alloc_bytes_nogc;
  DateTime start_last_thou;
  Time max_thousand_allocs;
  Time min_thousand_allocs;

  int n_interior_ptrs;
};




# 290 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"




# 298 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"



# 14 "GcHeapRep1.c"

# 1 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"






# 1 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"


# 300 "/afs/cs/user/dld/gc/concurrent/GcHeap_debug.h"

# 8 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"


# 32 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

# 9 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/afs/cs/user/dld/gc/obj_desc/ObjHead.h"






# 10 "/afs/cs/user/dld/gc/obj_desc/ObjHead.h"




class ostream;





enum ObjDescType {
  DESC_DIRECT, DESC_INDIRECT, DESC_FAST_INDIRECT, DESC_FORWARD,
};

enum ObjHeadSizeType {
  ObjHead_no_vec_size,
  ObjHead_vec_size_lit_big,
  ObjHead_vec_size_big_lit,
};

static const unsigned int ObjHead_max_size = 1 << 26 - 1;
static const unsigned int ObjHead_big_size_split = 18;
static const unsigned int ObjHead_little_size_split = 8;
static const unsigned int ObjHead_big_split_mask =
  (1 << ObjHead_big_size_split) - 1;
static const unsigned int ObjHead_little_split_mask =
  (1 << ObjHead_little_size_split) - 1;


struct ObjHead {
  

  
  unsigned int siz : 26;
  
  
  
  unsigned int size_type : 2;

  
  
  unsigned int marked : 1;
  
  
  unsigned int scanned : 1;
  
  unsigned int type : 2;

  
  union {
    unsigned int bit_map;	
    char* obj_desc_str;		
    int* fast_ode;		
				
    void* forward;		
  } descriptor;

  void set_marked();
  void clear_marked();
  void set_scanned();
  void clear_scanned();

   ObjHead(long sz, unsigned int bm);
   ObjHead(long sz, char* ods);
   ObjHead(long sz, int* fast_ode);

  ObjHead(int size_type, int elems, int elem_size, unsigned int bm);
  ObjHead(int size_type, int elems, int elem_size, char* ods);
  ObjHead(int size_type, int elems, int elem_size, int* fast_ode);

  void forward(void* new_address);

  int size();
  int n_reps();
  int obj_size();

  unsigned int u_int0();
  unsigned int u_int1();
  friend ostream& operator<<(ostream& ost, ObjHead& oh);
};



# 119 "/afs/cs/user/dld/gc/obj_desc/ObjHead.h"





# 10 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"






# 1 "/afs/cs/user/dld/gc/obj_desc/ObjHead.h"


# 123 "/afs/cs/user/dld/gc/obj_desc/ObjHead.h"

# 8 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"

# 1 "/afs/cs/user/dld/gc/obj_desc/ObjDesc.h"






# 1 "/afs/cs/user/dld/gc/concurrent/genlib/array.h"


































# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"





# 40 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"


# 63 "/afs/cs/user/dld/gc/concurrent/genlib/array.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"


# 86 "/afs/cs/user/dld/gc/concurrent/genlib/gl_math.h"


# 64 "/afs/cs/user/dld/gc/concurrent/genlib/array.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_generic.h"
































# 1 "/usr/misc/.c++/include/generic.h"
























# 29 "/usr/misc/.c++/include/generic.h"








extern genericerror(int,char*);
typedef int (*GPT)(int,char*);




# 59 "/afs/cs/user/dld/gc/concurrent/genlib/gl_generic.h"


# 64 "/afs/cs/user/dld/gc/concurrent/genlib/gl_generic.h"

















# 65 "/afs/cs/user/dld/gc/concurrent/genlib/array.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/ittr.h"














































































# 66 "/afs/cs/user/dld/gc/concurrent/genlib/array.h"



const array_base_size = 8;
const array_base_2_exp = 3;
const array_zone_incr_exp = 2;	























































































































































































































































































































































# 8 "/afs/cs/user/dld/gc/obj_desc/ObjDesc.h"

# 1 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"


# 32 "/afs/cs/user/dld/gc/concurrent/gc_misc.h"

# 9 "/afs/cs/user/dld/gc/obj_desc/ObjDesc.h"

class ostream;


# 15 "/afs/cs/user/dld/gc/obj_desc/ObjDesc.h"






class ObjDescNode;
class OD_sure_ref;
class OD_unsure_ref;
class OD_skip_slots;
class OD_repeat;
class ObjDesc;

class OD_bit_ittr;

class ObjDesc_Encoding;



enum SlotValue {
  OD_SV_TERM, OD_SV_SKIP, OD_SV_SURE, OD_SV_UNSURE
};

class ObjDescNode {		
                                
				

 public:
   virtual OD_bit_ittr* to_bit_ittr();


   virtual void operator*= (int n);

  virtual void write_to(ostream& ost);
   virtual ObjDescNode* copy();

 protected:
  ObjDescNode* next;		

  ObjDescNode();		
				
  
  virtual int len()		
    { return 0; }; 
  virtual Bool has_unsure()	
    { return 0; }
  virtual int last_ref()	
    { return 0; }
  
  
   virtual Bool append_to_bitmap(u_int& bm, int i);
  virtual void append_to_encoding(ObjDesc_Encoding& ode) {};

  
  
  virtual ObjDescNode* compress_work();

  
  virtual ObjDescNode* compress_with_sr(OD_sure_ref* sr);
  
  virtual ObjDescNode* compress_with_ur(OD_unsure_ref* ur);
  
  virtual ObjDescNode* compress_with_skp(OD_skip_slots* skp);

  
  
  virtual int reps();
  
  
  virtual ObjDesc* rep_body();

  friend class ObjDesc_bit_ittr;
  friend class OD_sr_bit_ittr;
  friend class OD_ur_bit_ittr;
  friend class OD_skip_bit_ittr;
# 122 "/afs/cs/user/dld/gc/obj_desc/ObjDesc.h"

};


class OD_sure_ref : public ObjDescNode {
 public:
  OD_sure_ref(int refs =1);
  OD_sure_ref(OD_sure_ref& od_sr);

   OD_bit_ittr* to_bit_ittr();
   void operator*=(int n);
  void write_to(ostream& ost);
   virtual ObjDescNode* copy();

 private:
  int n_refs;

   int len();
   Bool has_unsure();
   int last_ref();

  Bool append_to_bitmap(u_int& bm, int i);
  void append_to_encoding(ObjDesc_Encoding& ode);

  ObjDescNode* compress_work();
  ObjDescNode* compress_with_sr(OD_sure_ref* sr);

  friend class OD_sr_bit_ittr;
};


class OD_unsure_ref : public ObjDescNode {
 public:
  OD_unsure_ref(int refs =1);
  OD_unsure_ref(OD_unsure_ref& od_ur);

   OD_bit_ittr* to_bit_ittr();
   void operator*=(int n);
  void write_to(ostream& ost);
   virtual ObjDescNode* copy();

 private:
  int n_refs;

   int len();
   Bool has_unsure();
   int last_ref();

   Bool append_to_bitmap(u_int& bm, int i);
  void append_to_encoding(ObjDesc_Encoding& ode);

  ObjDescNode* compress_work();
  ObjDescNode* compress_with_ur(OD_unsure_ref* ur);

  friend class OD_ur_bit_ittr;
};


class OD_skip_slots : public ObjDescNode {
 public:
  OD_skip_slots(int slots =1, int bytes =0);
  OD_skip_slots(OD_skip_slots& od_ss);

   OD_bit_ittr* to_bit_ittr();
   void operator*=(int n);
  void write_to(ostream& ost);
   virtual ObjDescNode* copy();

 private:
  int n_slots;
  int n_bytes;			

  int rounded_slots();
  void normalize();

   int len();
   Bool has_unsure();
   int last_ref();

   Bool append_to_bitmap(u_int& bm, int i);
  void append_to_encoding(ObjDesc_Encoding& ode);

  ObjDescNode* compress_work();
  ObjDescNode* compress_with_skp(OD_skip_slots* skp);

  friend class OD_skip_bit_ittr;
};


class OD_repeat : public ObjDescNode {
 public:
  OD_repeat(int times, ObjDesc* blk);
  OD_repeat(OD_repeat& od_r);

   OD_bit_ittr* to_bit_ittr();
   void operator*=(int n);
  void write_to(ostream& ost);
   virtual ObjDescNode* copy();

  virtual int reps();
  virtual ObjDesc* rep_body();

 private:
  int n_times;
  ObjDesc* block;

   int len();
   Bool has_unsure();
   int last_ref();

  Bool append_to_bitmap(u_int& bm, int i);
  void append_to_encoding(ObjDesc_Encoding& ode);

  ObjDescNode* compress_work();

  friend class OD_rep_bit_ittr;
};



class ObjDesc : public ObjDescNode {

 public:
  
  ObjDesc();
  ObjDesc(ObjDesc& od);

   int len();
   Bool has_unsure();
   int last_ref();

   OD_bit_ittr* to_bit_ittr();
  void write_to(ostream& ost);
  virtual ObjDescNode* copy();

  
  ObjDesc& append(ObjDescNode* odn);
  
  Bool is_direct();
  u_int to_bitmap();
  ObjDesc_Encoding* to_encoding();
  int* to_fast_encoding();

  friend ObjDesc* merge(ObjDesc* od1, ObjDesc* od2);
  void compress();

  
  
  ObjDescNode* is_single_node();

  virtual int reps();
  virtual ObjDesc* rep_body();

 private:
  ObjDescNode* hd_node();

  Bool append_to_bitmap(u_int& bm, int i);
  void append_to_encoding(ObjDesc_Encoding& ode);

  ObjDescNode* compress_work();

  ObjDescNode* head;
  ObjDescNode* tail;
  int len_var;
  int last_ref_var;
  Bool has_unsure_var;

  
  ObjDesc_Encoding* sav_ode;

  friend class ObjDesc_bit_ittr;
};




class OD_bit_ittr {
 public:
   virtual operator int();
   virtual int operator++();
   virtual SlotValue operator()();
   virtual void reset();
  
  
  
  
  virtual ObjDescNode* rest();
 protected:
  OD_bit_ittr(ObjDescNode* od);
  int yielded;
};

class OD_sr_bit_ittr : public OD_bit_ittr {
 public:
  OD_sr_bit_ittr(OD_sure_ref& od);
   operator int();
   int operator++();
   SlotValue operator()();
   void reset();
  ObjDescNode* rest();
 private:
  OD_sure_ref* od_sr;
};

class OD_ur_bit_ittr : public OD_bit_ittr {
 public:
  OD_ur_bit_ittr(OD_unsure_ref& od);
   operator int();
   int operator++();
   SlotValue operator()();
   void reset();
  ObjDescNode* rest();
 private:
  OD_unsure_ref* od_ur;
};

class OD_skip_bit_ittr : public OD_bit_ittr {
 public:
  OD_skip_bit_ittr(OD_skip_slots& od);
   operator int();
   int operator++();
   SlotValue operator()();
   void reset();
  ObjDescNode* rest();
 private:
  OD_skip_slots* od_skp;
};

class OD_rep_bit_ittr : public OD_bit_ittr {
 public:
  OD_rep_bit_ittr(OD_repeat& od);
   operator int();
  int operator++();
   SlotValue operator()();
   void reset();
  ObjDescNode* rest();
 private:
  OD_repeat* od_rep;
  OD_bit_ittr* ittr;
};

class ObjDesc_bit_ittr : public OD_bit_ittr {
 public:
  ObjDesc_bit_ittr(ObjDesc& od);
   operator int();
  int operator++();
   SlotValue operator()();
   void reset();
  ObjDescNode* rest();
 private:
  ObjDesc* obj_desc;
  ObjDescNode* cur_node;
  OD_bit_ittr* cur_node_ittr;
};
  


enum ODE_elem_type {
  FRAME_END = 0,
  SURE_REF_IMM, SURE_REF_EXT,
  UNSURE_REF_IMM, UNSURE_REF_EXT,
  SKIP_IMM, SKIP_EXT,
  REPEAT_IMM, REPEAT_EXT
};

struct ODE_elem {
 public:
  virtual operator int() { return 0; };
};


  
struct ODE_elem_head : public ODE_elem {
  struct ODE_elem_head_rep {
    unsigned int number : 3;
    unsigned int type : 5;
  };
  union {
    ODE_elem_head_rep bf_rep;
    char char_rep;
  };
  ODE_elem_head(u_int tp, u_int num);
  ODE_elem_head(char c =0);
   operator int();
   int type();
   int number();
};

struct ODE_elem_count : public ODE_elem {
  unsigned char count;
  ODE_elem_count(unsigned char cnt) { count = cnt; }
  operator int() { return count; };
};

static const int IMMED_LIMIT = 8;
static const int COUNT_LIMIT = 256;
static const int EXT_LIMIT = IMMED_LIMIT*COUNT_LIMIT;
static const int EXT_MAX = EXT_LIMIT - 1;


typedef ODE_elem* ODE_elem_ptr;
						      									      class   ODE_elem_ptrarray  {                                                      friend class   ODE_elem_ptrarray_index_ittr;				      friend class   ODE_elem_ptrarray_elem_ittr;					      									        							        int midpoint; 							        int low_index, high_index;						        int init_exp;			    ODE_elem_ptr* high_elems[4];						        ODE_elem_ptr* low_elems[4];						      									        static int second_index_part;						      									        int first_index_part(int index);					        void init_arr(int low_bound, int predict_size);			      									       public:								          ODE_elem_ptrarray(int low_bound =1, int predict_size =array_base_size);	      									          ODE_elem_ptrarray(int low_bound, int predict_size, ODE_elem_ptr initial_value);   									        int size();								        int low();								        int high();								      									        ODE_elem_ptr bottom();							        ODE_elem_ptr top();							      									        Bool inbounds(int index);						      									        ODE_elem_ptr operator[](int index);					      									        void store(int index, ODE_elem_ptr value);				      									        void addh(ODE_elem_ptr e);						      									        ODE_elem_ptr remh();							      									        void addl(ODE_elem_ptr e);						      									        ODE_elem_ptr reml();							      };									      									      									      					      class   ODE_elem_ptrarray_index_ittr {					       protected:								        Bool valid;								        int ittr_index;							          ODE_elem_ptrarray* cur_array;						       public:								        		      									        				          ODE_elem_ptrarray_index_ittr(  ODE_elem_ptrarray& dict);						       public:								        							         operator int();						        			         int operator++();						                int* operator()();						        							         void reset();	      };									      									      	      class   ODE_elem_ptrarray_elem_ittr : public   ODE_elem_ptrarray_index_ittr {	        int cur_zone_index;							        int cur_zone_size;							        int cur_zone_num;							        ODE_elem_ptr* cur_zone;							       public:								        		      									        				          ODE_elem_ptrarray_elem_ittr(  ODE_elem_ptrarray& dict);						       public:								        							         operator int();						        			         int operator++();						                ODE_elem_ptr* operator()();						        							         void reset();	      };									      									      									      					      									      		      inline int   ODE_elem_ptrarray::first_index_part(int index) {		        int diff;				        if (index >= midpoint)						          diff = index - midpoint + 1;					        else									          diff = midpoint - index;						        int zone_size = 1 << init_exp;					        int sum = zone_size;							        			        int zone;								        if (diff <= sum)							          zone = 0;								        else {								          zone_size <<= array_zone_incr_exp;					          sum += zone_size;							          if (diff <= sum)							            zone = 1;								          else {								            zone_size <<= array_zone_incr_exp;				            sum += zone_size;							            if (diff <= sum)							      	zone = 2;							            else {								      	zone_size <<= array_zone_incr_exp;				      	sum += zone_size;						      	if (diff <= sum)						      	  zone = 3;							      	else genlib_fatal_error("Array ref too big???");		            }									          }									        }									        sum -= zone_size;							        second_index_part = diff - sum - 1;					        return zone;								      }									      									      									      				      									      inline									        ODE_elem_ptrarray_index_ittr::  ODE_elem_ptrarray_index_ittr(  ODE_elem_ptrarray& a) {    cur_array = &a;							        valid = 0;							      };									      									      inline   ODE_elem_ptrarray_index_ittr::operator int() {			        return valid;								      }									      									      inline int   ODE_elem_ptrarray_index_ittr::operator++() {			        if (valid) {								          ittr_index++;							          if (ittr_index > cur_array->high_index) valid = 0;		        } else {								          ittr_index = cur_array->low_index;					          if (cur_array->high_index >= cur_array->low_index) valid = 1;	        }									        return 0;								      }									      									      inline int*   ODE_elem_ptrarray_index_ittr::operator()() {			        return (valid ? &ittr_index : 0);					      }									      									      inline void   ODE_elem_ptrarray_index_ittr::reset() {			        valid = 0;							      }									      									      					      inline									        ODE_elem_ptrarray_elem_ittr::						        ODE_elem_ptrarray_elem_ittr(  ODE_elem_ptrarray& a) : (a) {			        cur_array = &a;							        valid = 0;							      };									      									      inline   ODE_elem_ptrarray_elem_ittr::operator int() {			        return   ODE_elem_ptrarray_index_ittr::operator int();			      }									      									      inline ODE_elem_ptr*   ODE_elem_ptrarray_elem_ittr::operator()() {		        return (valid ? &(cur_zone[cur_zone_index]) : 0);			      }									      									      inline void   ODE_elem_ptrarray_elem_ittr::reset() {			        valid = 0;							      };
typedef   ODE_elem_ptrarray ODE_elem_arr;
typedef   ODE_elem_ptrarray_elem_ittr ODE_elem_arr_elem_ittr;
typedef   ODE_elem_ptrarray_index_ittr ODE_elem_arr_ii;


class ObjDesc_Encoding {
  ODE_elem_arr elems;
 public:
  ObjDesc_Encoding(int sz =20) : elems(1, sz) {}
  
  void append(ODE_elem* e) { elems.addh(e); }
  void write_C_code(struct _iobuf* f, char* desc_name);
  operator char*();

};




# 463 "/afs/cs/user/dld/gc/obj_desc/ObjDesc.h"




# 9 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/stack.h"






























# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"





# 40 "/afs/cs/user/dld/gc/concurrent/genlib/gl_general.h"


# 59 "/afs/cs/user/dld/gc/concurrent/genlib/stack.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/gl_generic.h"




























# 80 "/afs/cs/user/dld/gc/concurrent/genlib/gl_generic.h"

# 60 "/afs/cs/user/dld/gc/concurrent/genlib/stack.h"






























































									























































# 10 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"


# 14 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"















































class ObjPtrDirectIttr  {
  u_int bit_map, bit_map_sav;
  int incr;
  int remainder;			
  int reps;

  void incr_work();

 public:
  
  ObjPtrDirectIttr(u_int bm, int sz, int rps =1);
   void reset(u_int bm, int sz, int rps =1);
   operator int();
   int operator()();
   int operator++();

};



struct IndIttrRepFrame {
  char* blk_start;		
  char* blk_index;		
  int reps_left;		
				
				
  IndIttrRepFrame(char* start =0, int reps =0) {
    blk_start = start; blk_index = start; reps_left = reps;
  }
};

							      									      typedef void (*  IndIttrRepFrame_stack_print)(IndIttrRepFrame);					      									      class   IndIttrRepFrame_stack_node {							        IndIttrRepFrame ele;								        class   IndIttrRepFrame_stack_node *next;						      friend class   IndIttrRepFrame_stack;							      };									      									      									      class   IndIttrRepFrame_stack {							       public:								          IndIttrRepFrame_stack() { data = 0; garbage = 0; n_elems = 0; };		        ~  IndIttrRepFrame_stack() { clear(); };						        inline void push(const IndIttrRepFrame&);						        inline IndIttrRepFrame& pop();							        inline IndIttrRepFrame& top();							        Bool is_empty() { return data == 0; };				        int size() { return n_elems; };					        void clear();								          IndIttrRepFrame_stack& copy();							        void dump(  IndIttrRepFrame_stack_print);						      									       private:								          IndIttrRepFrame_stack_node *data;							          IndIttrRepFrame_stack_node *garbage;						        int n_elems;								        void reverse();							      };									      									      inline void   IndIttrRepFrame_stack::push(const IndIttrRepFrame& newele) {				        if (garbage) { delete garbage; garbage = 0; };			          IndIttrRepFrame_stack_node *tmpele = new   IndIttrRepFrame_stack_node;				        tmpele->next = data;							        data = tmpele;							        tmpele->ele = newele;							        n_elems++;								      }									      									      inline IndIttrRepFrame&   IndIttrRepFrame_stack::top() {						        if (!data) genlib_fatal_error("Top() of empty stack\n");		        return data->ele;							      }									      									      inline IndIttrRepFrame&   IndIttrRepFrame_stack::pop() {						        if (garbage) { delete garbage; garbage = 0; };			        if (!data) genlib_fatal_error("Pop of empty stack\n");		        garbage = data;							        data = data->next;							        n_elems--;								        return garbage->ele;							      };
typedef   IndIttrRepFrame_stack FrameStack;

class ObjPtrIndirectIttr  {
  int reps;
  int size_in_words;
  ODE_elem_head cur_elem;
  int cur_index;
  int last_ref;
  int cur_elem_left;
  char* obj_desc_str;
  FrameStack frames;
 public:
  
  
  
  
  ObjPtrIndirectIttr(char* ods, int sz_in_bytes, int rps =1) : frames() {
    size_in_words = min_containers(sz_in_bytes, BYTES_PER_WORD);
    reps = rps; cur_index = 1; last_ref = 0;
    cur_elem_left = -1; obj_desc_str = ods;
  }
  void reset(char* ods, int sz_in_bytes, int rps =1) {
    size_in_words = min_containers(sz_in_bytes, BYTES_PER_WORD);
    reps = rps; cur_index = 1; last_ref = 0;
    cur_elem_left = -1; obj_desc_str = ods;
  }
   operator int();
   int operator()();
  void operator++();
};


class ObjPtrFastIndirectIttr  {
  int reps;			
  int* incr_start;
  int* cur_incr;
  int leftover;
 public:
  
  
  
  
  
  
  ObjPtrFastIndirectIttr(int* fst_ode, int rps =1) {
    reps = rps * (*fst_ode++);
    incr_start = fst_ode;
    cur_incr = 0;
    leftover = 0;
  }
  void reset(int* fst_ode, int rps =1) {
    reps = rps * (*fst_ode++);
    incr_start = fst_ode;
    cur_incr = 0;
    leftover = 0;
  }

   operator int();
   int operator()();
  void operator++();
};









extern void fast_init_ObjPtrIttr(ObjHead* oh,
				 ObjPtrDirectIttr& direct,
				 ObjPtrIndirectIttr& indirect,
				 ObjPtrFastIndirectIttr& fast);



# 209 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"




# 11 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/afs/cs/user/dld/gc/concurrent/AllocPoint.h"










# 1 "/usr/mach/include/mach.h"























# 31 "/usr/mach/include/mach.h"

# 14 "/afs/cs/user/dld/gc/concurrent/AllocPoint.h"

# 1 "/usr/mach/include/cthreads.h"





























































































# 340 "/usr/mach/include/cthreads.h"

# 15 "/afs/cs/user/dld/gc/concurrent/AllocPoint.h"


struct AllocPoint {
  int alloc_page;
  void* free_ptr;
  int free_words;

  
  
  
  int following_free_hint;

  int allocated_pages;
  void* free_list;

  
  
  port_t unprotect_port;
  class GcHeapRep* gch;

  struct mutex lock;

  
  
  
  AllocPoint(class GcHeapRep* gc_hp =0);

  
  AllocPoint& operator=(AllocPoint& rhs);

  
  void* alloc_on_cur_page(int words, ObjHead& gc_obj_hd);
  void* alloc_at_free_list_head(int words, ObjHead& gc_obj_hd);

  
  
  void push_on_free_list();
  void free_list_promote();

  
  
  
  
  
  int following_free();

  
  void free_bracket();

  
  char* rep_inv();

  friend ostream& operator<<(ostream& ost, AllocPoint& ap);

 private:
  
  
  int following_free_search();

};


# 12 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"


# 290 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"

# 13 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"


# 1 "/usr/misc/.c++/include/stream.h"



































# 372 "/usr/misc/.c++/include/stream.h"

# 15 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/usr/mach/include/cthreads.h"





























































































# 340 "/usr/mach/include/cthreads.h"

# 16 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

# 1 "/usr/mach/include/mach.h"























# 31 "/usr/mach/include/mach.h"

# 17 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

enum ScanState {
  SCANNED, UNSCANNED, IN_PROGRESS, RESCAN,
};

inline char* scan_state2str(ScanState ss) {
  return ((ss == SCANNED) ? "SCANNED" :
	  ((ss == UNSCANNED) ? "UNSCANNED" :
	   ((ss == IN_PROGRESS) ? "IN_PROGRESS" :
	    ((ss == RESCAN) ? "RESCAN" : "BAD_VALUE"))));
}


# 33 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

const GC_HEAP_MAX_SIZE = 128 * MBYTE;



# 42 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

const GC_HEAP_CONC_MUT_ALLOC_TARGET = 20;
# 46 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

const GC_HEAP_USAGE_TARGET = 33;



# 57 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"



# 62 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"










struct PageData {
  
  
  
  int next;
  int prev;
  
  int space;

  

  
  
  
  
  int first_obj : 16;
  
  unsigned int promoted : 1;
  
  unsigned int scanned : 2;

  
  PageData();
  
  void init();
  
  void write_to_stream(ostream& ost) {
    ost << "[Space is " << space << (promoted ? ", Promoted" : "");
    if (first_obj)
      ost << ", first obj is " << first_obj;
    ost << ", scan_state is " << scan_state2str(scanned) << "]";
  }
};

inline ostream& operator<<(ostream& ost, PageData& pd) {
  pd.write_to_stream(ost);
  return ost;
}




class GcHeapRep {

 public:
  
  
  GcHeapRep(int size =MBYTE, void* start_addr =0);  
  void init(int size =MBYTE, void* start_addr =0);

  
  
  
  
  
   void* alloc(long size, ObjHead& oh);

  
  friend ostream& operator<<(ostream& ost, GcHeapRep& gch);
  friend ostream& operator<<(ostream& ost, AllocPoint& ap);
  void set_test_roots(void** tr, int root_size);
  void register_n_threads(int n);

  
  void finalize();
  ~GcHeapRep() { finalize(); }

 private:
  
  static int BITS_PER_BYTE;
  static int BYTES_PER_WORD;
  static int BITS_PER_UINT;
  static int WORDS_PER_GC_PAGE;
  static int BYTES_PER_GC_PAGE;
  static int GC_BREAKAGE_LIMIT;
  static unsigned int SPACE_WRAP_AROUND;
  static int UINTS_PER_BITMAP_PAGE;
  
  
  static unsigned int bit_on[64];

# 198 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"


  

  
  int heap_pages;
  int max_pages;

  
  void* heap_bot_ptr;
  void* heap_top_ptr;

  
  int n_gcs;

  
  PageData* page_data;

  
  
  u_int* alloc_bitmap;

  
  
  AllocPoint mut_alloc_pt;
  AllocPoint gc_alloc_pt;

  
  
  int nsq_head, nsq_tail, nsq_hot;

  
  unsigned int cur_space;
  unsigned int new_space;

  
  Bool gc_task_started;

  
  
  void** testing_roots;
  int test_roots_size;

  
  int n_mut_threads;


  

  
  Bool roots_scanned;

  
  struct mutex pd_scanned_lock;

  
  
  struct mutex nsq_lock;

  
  struct mutex free_ring_lock;

  
  
  
  struct condition page_scan_done;

  
  
  struct condition gc_done_cond;

  
  
  
  port_t gc_send_port;
  port_t mut_rcv_port;

  
  
  port_t gc_rcv_port;
  port_t mut_send_port;

  
  task_t mutator_task_port;
  
  task_t gc_task_port;

  
  
  port_t mut_done_rcv_port;
  port_t gc_done_send_port;
  
  Bool mut_task_done;

  
  
  port_t except_port;
  port_t old_except_port;

  
  
  Bool careful_protection;

  

  
  void* internal_alloc(AllocPoint& ap, long size, ObjHead& gc_obj_hd);
  void* internal_alloc_wrk(AllocPoint& ap, int words, ObjHead& gc_obj_hd);
  void* alloc_multi_page(AllocPoint& ap, int words, ObjHead& gc_obj_hd);
  void page_allocate(AllocPoint& ap, int this_page, int continued,
		     port_t unprotect_from =((port_name_t) 0)	);

  Bool find_contig_block(AllocPoint& ap, int words);
  int contig_free_pages(int start_page, int request);
  int tot_allocated_pages();
  void set_alloc_bit(void* obj_start);
  Bool is_obj_start(void* obj_start);

  
  
  
  Bool expand_heap();

  
  int ptr2page(void* ptr);
  void* page2ptr(int page);


  

  
  
  int next_page(int page);
  int prev_page(int page);

  
  unsigned int next_space(unsigned int space);
  
  
  Bool is_free_page(int page);


  

  
  void collect();

  
  void gc_task();
  
  friend any_t except_protect_loop(any_t);
  friend any_t handle_protection_exception(any_t);
  friend kern_return_t
      catch_exception_raise_wrk(port_t, thread_t, task_t,
				int exception, int code, int);
  friend void wait_for_gc_done(any_t gchp);
  friend void wait_for_gc_kill(any_t kill_port);

  
  
  void scan_stacks();
  void scan_thread_stack(thread_t thrd);

  
  void scan_globals();

  
  void scan_heap();
  
  void scan_page_set(int page);
  
  void scan_page(int page);

  
  void scan_object(ObjHead* obj_head, void* obj_start);

  
  void copy_obj_if_nec(void** ptr);

  
  
  ObjHead* ptr2obj_head(void* ptr);
  ObjHead* ptr2obj_head_work(void* ptr);

  
  void promote_page(int page, ObjHead* obj_head);

  
  void protect_page(port_t task_port, int page);
  
  void unprotect_page(port_t task_port, int page);

  
  void nsq_clear();
  void nsq_enq(int page, Bool check =0);
  int nsq_deq();
  void nsq_move_to_front(int front_page);
  Bool nsq_empty();
  
  Bool nsq_delete(int page);
  void nsq_print();
  char* nsq_rep_inv();

  friend class NsqRepChecker;


  
  void collect_newly_free();

  
  void reset_scanned_bits(int page);

  
  int debug_level;
  char* rep_inv();
  
  
  void check_mark_invariants(int page, Bool promoted, Bool prev_promoted);
  void check_ptr_invariants(int page, Bool promoted, Bool reset);

  Bool is_good_page_index(int page);

  friend class AllocPoint;
  friend class GCHRepInvObj;
  friend class GcPerfObj;
  friend class GcPerfSummaryObj;
  friend class GcHeap;

# 506 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"

};



extern ObjPtrDirectIttr direct_ittr;
extern ObjPtrIndirectIttr indirect_ittr;
extern ObjPtrFastIndirectIttr fast_ittr;








# 531 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"


# 537 "/afs/cs/user/dld/gc/concurrent/GcHeapRep.h"



# 15 "GcHeapRep1.c"

# 1 "/afs/cs/user/dld/gc/concurrent/GcHeap_ipc.h"












typedef struct {
  msg_header_t header;
  msg_type_t RetCodeType;
  kern_return_t RetCode;
} ReplyMsgType;






typedef struct {
  msg_header_t header;
} NullMsgType;

extern boolean_t NullMsg_server(msg_header_t* in, msg_header_t* out);


void do_rcv_null_msg(port_t rcv_port);


extern
# 47 "/afs/cs/user/dld/gc/concurrent/GcHeap_ipc.h"

void rcv_null_msg(port_t rqst_prt);
# 51 "/afs/cs/user/dld/gc/concurrent/GcHeap_ipc.h"




typedef struct {
  msg_header_t header;
  msg_type_t prtType;
  port_t prt;
} OnePortMsgType;

extern boolean_t OnePortMsg_server(msg_header_t* in, msg_header_t* out);



extern port_t* rcv_one_port_msg_target;

extern void do_rcv_one_port_msg(port_t rcv_port, port_t* target);

extern void rcv_one_port_msg(port_t rqst_prt, port_t prt);


# 16 "GcHeapRep1.c"

# 1 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"






























# 212 "/afs/cs/user/dld/gc/obj_desc/ObjPtrIttr.h"

# 17 "GcHeapRep1.c"

# 1 "/afs/cs/user/dld/gc/concurrent/mutex_macros.h"









# 1 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"


# 290 "/afs/cs/user/dld/gc/concurrent/genlib/debug.h"

# 12 "/afs/cs/user/dld/gc/concurrent/mutex_macros.h"

# 1 "/usr/misc/.c++/include/strings.h"





















# 30 "/usr/misc/.c++/include/strings.h"

# 13 "/afs/cs/user/dld/gc/concurrent/mutex_macros.h"

extern int lock_debug_level;
extern int in_gc_task;














































  
  


















# 88 "/afs/cs/user/dld/gc/concurrent/mutex_macros.h"



# 18 "GcHeapRep1.c"



# 1 "/usr/mach/include/mach.h"























# 31 "/usr/mach/include/mach.h"

# 22 "GcHeapRep1.c"

# 1 "/usr/mach/include/servers/netname.h"






# 1 "/usr/mach/include/mach/kern_return.h"
















































































# 130 "/usr/mach/include/mach/kern_return.h"

# 7 "/usr/mach/include/servers/netname.h"


# 1 "/usr/mach/include/mach/port.h"

















































































# 122 "/usr/mach/include/mach/port.h"

# 9 "/usr/mach/include/servers/netname.h"

# 1 "/usr/mach/include/mach/message.h"















































































































































# 341 "/usr/mach/include/mach/message.h"

# 10 "/usr/mach/include/servers/netname.h"


# 14 "/usr/mach/include/servers/netname.h"


extern void init_netname

    (port_t rep_port);
# 21 "/usr/mach/include/servers/netname.h"


# 1 "/usr/mach/include/servers/netname_defs.h"






















































typedef char netname_name_t[80];


# 23 "/usr/mach/include/servers/netname.h"


extern kern_return_t netname_check_in
# 33 "/usr/mach/include/servers/netname.h"


(
	port_t server_port,
	netname_name_t port_name,
	port_t signature,
	port_t port_id
);
# 43 "/usr/mach/include/servers/netname.h"




extern kern_return_t netname_look_up
# 55 "/usr/mach/include/servers/netname.h"


(
	port_t server_port,
	netname_name_t host_name,
	netname_name_t port_name,
	port_t *port_id
);
# 65 "/usr/mach/include/servers/netname.h"




extern kern_return_t netname_check_out
# 76 "/usr/mach/include/servers/netname.h"


(
	port_t server_port,
	netname_name_t port_name,
	port_t signature
);
# 85 "/usr/mach/include/servers/netname.h"




extern kern_return_t netname_version
# 95 "/usr/mach/include/servers/netname.h"


(
	port_t server_port,
	netname_name_t version
);
# 103 "/usr/mach/include/servers/netname.h"




# 23 "GcHeapRep1.c"

# 26 "GcHeapRep1.c"



# 1 "/usr/misc/.c++/include/stream.h"



































# 372 "/usr/misc/.c++/include/stream.h"

# 29 "GcHeapRep1.c"

# 1 "/usr/mach/include/cthreads.h"





























































































# 340 "/usr/mach/include/cthreads.h"

# 30 "GcHeapRep1.c"

# 1 "/usr/include/assert.h"





# 9 "/usr/include/assert.h"

# 31 "GcHeapRep1.c"



# 1 "/usr/mach/include/mach/machine/vm_param.h"
















































































# 34 "GcHeapRep1.c"

extern thread_t thread_self();


# 1 "/usr/mach/include/mach/machine/thread_status.h"
















































# 109 "/usr/mach/include/mach/machine/thread_status.h"

# 39 "GcHeapRep1.c"



ObjPtrDirectIttr direct_ittr(0, 0, 0);
ObjPtrIndirectIttr indirect_ittr(0, 0, 0);
ObjPtrFastIndirectIttr fast_ittr(0, 0);


inline int my_iabs(int i) { return (i >= 0 ? i : -i); };






void GcHeapRep::collect() {
  					      if ((debug_object::debug_level >= 25) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "Entering collection, Heap state is:\n" << *this;					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  if (!gc_task_started) {
    
    stop_if_error(port_allocate(	task_self_, &mut_rcv_port),
		  "GcHeapRep1.c", 68);
    
    
    stop_if_error(
      task_set_special_port(	task_self_, 4	,
			    mut_rcv_port),
		  "GcHeapRep1.c", 76);

    
    cthread_init();
    int new_pid = fork();
    
    if (!new_pid) {
      gc_task();
    }
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) Child PID is " << new_pid << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    
    

    
    stop_if_error(
      task_set_special_port(	task_self_, 4	, ((port_name_t) 0)	),
		  "GcHeapRep1.c", 98);

    
    
    
    do_rcv_one_port_msg(mut_rcv_port, &mut_send_port);
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) mut_send_port is " << mut_send_port << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    
    
    stop_if_error(port_allocate(	task_self_, &mut_done_rcv_port),
		  "GcHeapRep1.c", 114);
    stop_if_error(
      netname_check_in(name_server_port, "GC-kill-mut-task-port", ((port_name_t) 0)	,
		       mut_done_rcv_port),
      "GcHeapRep1.c", 118);
    stop_if_error(send_one_port_msg(mut_send_port, mut_done_rcv_port),
		  "GcHeapRep1.c", 120);
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) sent mut_done_rcv_port (" << gc_task_port <<
	      ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    
    
    
    stop_if_error(send_one_port_msg(mut_send_port, 	task_self_),
		  "GcHeapRep1.c", 131);

    
    
    do_rcv_one_port_msg(mut_rcv_port, &gc_task_port);
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) got gc_task_port (" << gc_task_port << ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;













    cthread_t kill_thread =
      cthread_fork((cthread_fn_t)wait_for_gc_kill, (any_t)mut_done_rcv_port);
    
    
    cthread_detach(kill_thread);

    gc_task_started = 1;
  }


  port_t cur_except_port;
  stop_if_error(
    task_get_special_port(	task_self_, 3	, &cur_except_port),
    "GcHeapRep1.c", 167);
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) Before GC, except port is " <<
	    u_int(cur_except_port) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;


  
  
  
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) about to send start GC message and suspend.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  stop_if_error(send_null_msg(mut_send_port), "GcHeapRep1.c", 179);

  
  
  
  
  

  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) about to wait for mut_resume message.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  do_rcv_null_msg(mut_rcv_port);
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) resuming.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;


  stop_if_error(
    task_get_special_port(	task_self_, 3	, &cur_except_port),
    "GcHeapRep1.c", 199);
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(Mut Task) After root scan, except port is " <<
	    u_int(cur_except_port) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

}



int in_gc_task = 0;



void GcHeapRep::gc_task() {
  					      if ((debug_object::debug_level >= 10) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) ...entering...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;


  in_gc_task = 1;
  cthread_set_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation), "Main");


  
  
  port_t gc_send_port;
  stop_if_error(
    task_get_special_port(	task_self_, 4	, &gc_send_port),
		"GcHeapRep1.c", 227);
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) gc_send port is " << gc_send_port << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  
  
  
  stop_if_error(port_allocate(	task_self_, &gc_rcv_port),
		"GcHeapRep1.c", 239);
  stop_if_error(send_one_port_msg(gc_send_port, gc_rcv_port),
		"GcHeapRep1.c", 241);

  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) just sent gc_rcv_port (" <<
	    gc_rcv_port << "), waiting for gc_done_rcv_port.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  do_rcv_one_port_msg(gc_rcv_port, &gc_done_send_port);


  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) just sent gc_done_send_port (" <<
	    gc_done_send_port << "), waiting for mut_task_port.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  do_rcv_one_port_msg(gc_rcv_port, &mutator_task_port);
  if (mutator_task_port == ((port_name_t) 0)	) {
    printf("GC Task: internal name error\n");
    exit(1);
  }
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) got mut_task_port (" << mutator_task_port <<
	    ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  
  stop_if_error(send_one_port_msg(gc_send_port, 	task_self_),
		"GcHeapRep1.c", 266);
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) send GC_task_port.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  cthread_init();

  
  
  
  
  
  if (careful_protection) {
    stop_if_error(
      vm_protect(	task_self_, (vm_address_t)heap_bot_ptr,
		 GC_HEAP_MAX_SIZE, 0, (((vm_prot_t) 0x01)	|((vm_prot_t) 0x02)	|((vm_prot_t) 0x04)	)),
      "GcHeapRep1.c", 287);
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Unprotected heap from GC task.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  }

  
  
  		do { (&page_scan_done)->lock = 0; 	((&(&page_scan_done)->queue)->head = (&(&page_scan_done)->queue)->tail = 0); } while (0);

  
  
  
  					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) ....setting up exception loop....\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  
  stop_if_error(port_allocate(	task_self_, &except_port),
		"GcHeapRep1.c", 307);
  cthread_t loop_thread = cthread_fork(except_protect_loop, (any_t)this);

  cthread_set_name(loop_thread, "Except protect loop");

  cthread_detach(loop_thread);


  
  
  for (;;) {
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) About to wait for start GC message.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    do_rcv_null_msg(gc_rcv_port);

    
    if (mut_task_done) _exit(0);


    
    n_gcs++;
    					      if ((debug_object::debug_level >= 10) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "\n(GC Task) Starting collection " << n_gcs << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

# 336 "GcHeapRep1.c"


    
    roots_scanned = 0;
    
    
    stop_if_error(task_suspend(mutator_task_port), "GcHeapRep1.c", 344);
    
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Just suspended mutator, about to reprotect.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    
    stop_if_error(
      vm_protect(mutator_task_port, (vm_address_t)heap_bot_ptr,
		 GC_HEAP_MAX_SIZE, 0, 0),
      "GcHeapRep1.c", 353);
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Protected heap from mutator " <<
	      "(pages = " << heap_pages << ", BYTES_PER_GC_PAGE is " <<
	      BYTES_PER_GC_PAGE << ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    
    new_space = next_space(new_space);
    
    
    
    					      if ((debug_object::debug_level >= 10) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) ...scanning stacks....\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    scan_stacks();
# 370 "GcHeapRep1.c"

    
    
    if (mut_task_done) _exit(0);

    
    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&gc_alloc_pt.lock)->name << " at line " << 378 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&gc_alloc_pt.lock)) mutex_wait_lock(&gc_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&gc_alloc_pt.lock)->name << " at line " << 378 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    gc_alloc_pt = AllocPoint(this);
    						      do {									        mutex_unlock(&gc_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&gc_alloc_pt.lock)->name << " at line " << 380 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);

    int gc_alloc_page;
    
    
    
    if (mut_alloc_pt.free_words == WORDS_PER_GC_PAGE) {
      
      mut_alloc_pt.allocated_pages = 1;
      page_data[mut_alloc_pt.alloc_page].space = new_space;
    } else {
      mut_alloc_pt.allocated_pages = 0;
      					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) About to do mut_alloc_pt page_allocate("
		<< mut_alloc_pt.following_free() << ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      
      
      						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&mut_alloc_pt.lock)->name << " at line " << 402 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&mut_alloc_pt.lock)) mutex_wait_lock(&mut_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&mut_alloc_pt.lock)->name << " at line " << 402 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
      						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&free_ring_lock)->name << " at line " << 403 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&free_ring_lock)) mutex_wait_lock(&free_ring_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&free_ring_lock)->name << " at line " << 403 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
      page_allocate(mut_alloc_pt, mut_alloc_pt.following_free(), 0,
		    mutator_task_port);
      gc_alloc_page = mut_alloc_pt.following_free();
      						      do {									        mutex_unlock(&free_ring_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&free_ring_lock)->name << " at line " << 407 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
      						      do {									        mutex_unlock(&mut_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&mut_alloc_pt.lock)->name << " at line " << 408 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    }

    
    
    int half_free_pages = heap_pages / 4;
    		{if (!(half_free_pages >= 2)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 416);exit(1);}}; 
    for (int i = 0; i < half_free_pages; i++)
      gc_alloc_page = page_data[gc_alloc_page].next;
    					      if ((debug_object::debug_level >= 30) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Half_free = " << half_free_pages << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) About to do gc_alloc_pt page_allocate("
	      << gc_alloc_page << ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&gc_alloc_pt.lock)->name << " at line " << 423 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&gc_alloc_pt.lock)) mutex_wait_lock(&gc_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&gc_alloc_pt.lock)->name << " at line " << 423 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    gc_alloc_pt.allocated_pages = 0;
    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&free_ring_lock)->name << " at line " << 425 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&free_ring_lock)) mutex_wait_lock(&free_ring_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&free_ring_lock)->name << " at line " << 425 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    page_allocate(gc_alloc_pt, gc_alloc_page, 0, ((port_name_t) 0)	);
    						      do {									        mutex_unlock(&free_ring_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&free_ring_lock)->name << " at line " << 427 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        mutex_unlock(&gc_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&gc_alloc_pt.lock)->name << " at line " << 428 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);

    
    
    mut_alloc_pt.free_list_promote();

    
    					      if ((debug_object::debug_level >= 10) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) ...scanning globals...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    scan_globals();
    
# 443 "GcHeapRep1.c"

    
    
    if (mut_task_done) _exit(0);
    
    
    
    
    
    stop_if_error(
      task_get_special_port(mutator_task_port, 3	,
			    &old_except_port),
		  "GcHeapRep1.c", 459);
    					      if ((debug_object::debug_level >= 25) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Old_except_port is " <<
	      int(old_except_port) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    stop_if_error(
      task_set_special_port(mutator_task_port, 3	,
			    except_port),
		  "GcHeapRep1.c", 465);

    
    if (!no_concurrency) {
      					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Resuming mutator task.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      
      stop_if_error(task_resume(mutator_task_port), "GcHeapRep1.c", 473);
      if (mut_task_done) _exit(0);
      stop_if_error(send_null_msg(gc_send_port), "GcHeapRep1.c", 475);
    }

# 480 "GcHeapRep1.c"

    					      if ((debug_object::debug_level >= 10) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) ...scanning heap...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    scan_heap();

# 486 "GcHeapRep1.c"


    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 
	      "(GC Task) Finished scanning heap.  " <<
	      "About to reset exception port to " <<
	      u_int(old_except_port) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    
    
    stop_if_error(
      task_set_special_port(mutator_task_port, 3	,
			    old_except_port),
		  "GcHeapRep1.c", 500);

    

    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&mut_alloc_pt.lock)->name << " at line " << 505 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&mut_alloc_pt.lock)) mutex_wait_lock(&mut_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&mut_alloc_pt.lock)->name << " at line " << 505 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&free_ring_lock)->name << " at line " << 506 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&free_ring_lock)) mutex_wait_lock(&free_ring_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&free_ring_lock)->name << " at line " << 506 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    char* prob;
    if (prob = rep_inv()) {
       					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "REP_INVARIANT FAILS: " << "GcHeapRep1.c" << ", line " <<
		510 << ":\n   " << prob << ":\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
       					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << *this;					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
      exit(-1);
    }
    
    		{if (!(nsq_head == -1 && nsq_tail == -1 && nsq_hot == -1)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 516);exit(1);}};
    						      do {									        mutex_unlock(&mut_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&mut_alloc_pt.lock)->name << " at line " << 517 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        mutex_unlock(&free_ring_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&free_ring_lock)->name << " at line " << 518 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);


    
    
    
    
    
    
    
    
    
    
    

    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&mut_alloc_pt.lock)->name << " at line " << 544 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&mut_alloc_pt.lock)) mutex_wait_lock(&mut_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&mut_alloc_pt.lock)->name << " at line " << 544 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&free_ring_lock)->name << " at line " << 545 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&free_ring_lock)) mutex_wait_lock(&free_ring_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&free_ring_lock)->name << " at line " << 545 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);

    
    
    collect_newly_free();

    
    
    					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) <<  "(GC Task) About to bracket mut_alloc_point.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    mut_alloc_pt.free_bracket();

    
    mut_alloc_pt.allocated_pages += gc_alloc_pt.allocated_pages;
    gc_alloc_pt.allocated_pages = 0;

    
    
    if (!careful_protection) {
      stop_if_error(
	vm_protect(mutator_task_port, (vm_address_t)heap_bot_ptr,
		   GC_HEAP_MAX_SIZE, 0, (((vm_prot_t) 0x01)	|((vm_prot_t) 0x02)	|((vm_prot_t) 0x04)	)),
	"GcHeapRep1.c", 573);
      					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Unprotected heap from mutator " <<
		"(pages = " << heap_pages << ", BYTES_PER_GC_PAGE is " <<
		BYTES_PER_GC_PAGE << ").\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    }

    
    cur_space = new_space;

    						      do {									        mutex_unlock(&free_ring_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&free_ring_lock)->name << " at line " << 583 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        mutex_unlock(&mut_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&mut_alloc_pt.lock)->name << " at line " << 584 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);


    
    if (tot_allocated_pages()*100*2/heap_pages > GC_HEAP_USAGE_TARGET) {
      					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) <<  "(GC Task) About to expand heap.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      expand_heap();
    }









    					      if ((debug_object::debug_level >= 25) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) After collection, Heap state is:\n" << *this;					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;


    

    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&mut_alloc_pt.lock)->name << " at line " << 608 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&mut_alloc_pt.lock)) mutex_wait_lock(&mut_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&mut_alloc_pt.lock)->name << " at line " << 608 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&free_ring_lock)->name << " at line " << 609 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&free_ring_lock)) mutex_wait_lock(&free_ring_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&free_ring_lock)->name << " at line " << 609 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    if (prob = rep_inv()) {
       					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "REP_INVARIANT FAILS: " << "GcHeapRep1.c" << ", line " <<
		612 << ":\n   " << prob << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
       					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << *this;					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
      exit(-1);
    }
    						      do {									        mutex_unlock(&mut_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&mut_alloc_pt.lock)->name << " at line " << 616 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    						      do {									        mutex_unlock(&free_ring_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&free_ring_lock)->name << " at line " << 617 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);


    
    
    if (no_concurrency) {
      					      if ((debug_object::debug_level >= 15) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Resuming mutator task.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      
      stop_if_error(task_resume(mutator_task_port), "GcHeapRep1.c", 628);
      if (mut_task_done) _exit(0);
      stop_if_error(send_null_msg(gc_send_port), "GcHeapRep1.c", 630);
    }

# 638 "GcHeapRep1.c"


    
    if (mut_task_done) _exit(0);

  }
}





void GcHeapRep::scan_stacks() {
  
  if (testing_roots) {
    void** tr = testing_roots;
    for (int i = 0; i < test_roots_size; i++) {
      ObjHead* obj_head = ptr2obj_head(*(tr+i));
      if (obj_head) {
						      if ((debug_object::debug_level >= 30) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "Scanning test_roots, found possible pointer: " <<
		  hex(u_int(tr+i)) << " -> " << hex(u_int(*(u_int*)(tr+i)))
		  << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
	promote_page(ptr2page(obj_head), obj_head);
# 667 "GcHeapRep1.c"

	obj_head->set_marked();
      }
    }
    return;
  }

  
  thread_array_t mut_threads;
  unsigned n_mut_threads;
  stop_if_error(
    task_threads(mutator_task_port, &mut_threads, &n_mut_threads),
		"GcHeapRep1.c", 680);

  for (int i = 0; i < n_mut_threads; i++)
    scan_thread_stack(mut_threads[i]);

  stop_if_error(
    vm_deallocate(	task_self_, (vm_address_t)mut_threads,
		  sizeof(thread_t)*n_mut_threads),
		"GcHeapRep1.c", 688);
}




void GcHeapRep::scan_thread_stack(thread_t thrd) {

  thread_state_data_t thread_state;
  u_int reg_count = (1024)		;
# 704 "GcHeapRep1.c"


  int flavor = (1);
  const int sp_index = 14;
  reg_count = (sizeof(struct vax_thread_state)/sizeof(int));

# 715 "GcHeapRep1.c"


  stop_if_error(
    thread_get_state(thrd, flavor, thread_state, &reg_count),
		"GcHeapRep1.c", 719);

  const int stack_size = ~cthread_stack_mask + 1;
  void* stk_ptr = (void*)thread_state[sp_index];
  void* stk_base =		
    (void*)((u_int(stk_ptr) & cthread_stack_mask) + stack_size);
  					      if ((debug_object::debug_level >= 51) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Before min, stk_base is " << 
	    hex(u_int(stk_base)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  stk_base =
    ((u_int)stk_base < (u_int)((vm_offset_t) 0x80000000)) ?
      stk_base : (void*)((vm_offset_t) 0x80000000);
  
  					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) In scan_stacks, stk_ptr is " <<
	    hex(u_int(stk_ptr)) << ", stk_base is " <<
	    hex(u_int(stk_base)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  vm_address_t low_page_pointer =
    (vm_address_t)(((u_int)stk_ptr / vm_page_size) * vm_page_size);
  int stack_extent = stk_base - (void*)low_page_pointer;
  int first_offset = stk_ptr - (void*)low_page_pointer;
  pointer_t mut_thrd_stk_low;
  int mut_thrd_stk_extent;
  
  					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) In scan_stacks, about to call vm_read:\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task)   low_page_pointer is " <<
	    hex(u_int(low_page_pointer)) << ", stack_extent is " <<
	    hex(u_int(stack_extent)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };; 
  stop_if_error(
    vm_read(mutator_task_port, low_page_pointer, stack_extent,
	    &mut_thrd_stk_low, &mut_thrd_stk_extent),
    "GcHeapRep1.c", 752);
  		{if (!(mut_thrd_stk_extent == stack_extent)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 753);exit(1);}};

  					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) In scan_stacks, mut_thrd_stk_low is " <<
	    hex(u_int(mut_thrd_stk_low)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  
  void** x = (void**)(mut_thrd_stk_low + stack_extent) - 1;

  
  while (u_int(x) > u_int(mut_thrd_stk_low)+first_offset) {
    					      if ((debug_object::debug_level >= 80) && u_int(x)/0x100*0x100 == u_int(x)) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 
	      " At stk location " << hex(u_int(x)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    					      if ((debug_object::debug_level >= 90) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "   Stk location " << hex(u_int(x)) << " contains " <<
	      hex(u_int(*x)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    ObjHead* obj_head = ptr2obj_head(*x);
    if (obj_head) {
      					      if ((debug_object::debug_level >= 30) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "Scanning stacks, found possible pointer: " <<
		hex(u_int(x)) << " -> " << hex(u_int(*(u_int*)x)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      promote_page(ptr2page(obj_head), obj_head);
# 778 "GcHeapRep1.c"

      obj_head->set_marked();
    }
    x -= 1;
  }

  
  stop_if_error(
    vm_deallocate(	task_self_, (vm_address_t)mut_thrd_stk_low,
		  stack_extent),
    "GcHeapRep1.c", 789);

  
  					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "In scan_stacks, now looking at registers.\n" <<
	    "  Reg count is " << reg_count << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  for (int i = 0; i < reg_count; i++) {
    void* y = (void*)thread_state[i];
    					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "   Register " << i << " contains " <<
	      hex(u_int(thread_state[i])) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    ObjHead* obj_head = ptr2obj_head(y);
    if (obj_head) {
      					      if ((debug_object::debug_level >= 50) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "Scanning register, found possible pointer: " <<
		hex(u_int(y)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      promote_page(ptr2page(obj_head), obj_head);
# 806 "GcHeapRep1.c"

      obj_head->set_marked();
    }
  }

}













extern void** __gc_glob_list_list[];



extern int etext;
extern int end;   

void GcHeapRep::scan_globals() {
  static void* min_glob_addr;

  
  
# 869 "GcHeapRep1.c"

  
  
  
  void* data_low =
    (void*)((((u_int(&etext)-1)/1024 + 1) * 1024)
	    / vm_page_size * vm_page_size);


  
  
  
  void* data_high = (void*)(((u_int(&end)-1)/vm_page_size + 1) * vm_page_size);
  u_int data_extent = data_high - data_low;
  					      if ((debug_object::debug_level >= 16) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) In scan_globals, &etext is " <<
	    hex(u_int(&etext)) << ", &end is " << hex(u_int(&end)) << "...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  					      if ((debug_object::debug_level >= 16) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) ... data_low is " <<
	    hex(u_int(data_low)) << ", data_high is " <<
	    hex(u_int(data_high)) << ", data_extent is " <<
	    data_extent << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  pointer_t mut_data_low;
  u_int mut_data_extent;
  stop_if_error(
    vm_read(mutator_task_port, (pointer_t)data_low, data_extent,
	    &mut_data_low, &mut_data_extent),
    "GcHeapRep1.c", 901);
  		{if (!(data_extent == mut_data_extent)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 902);exit(1);}};
  					      if ((debug_object::debug_level >= 16) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) In scan_globals, mut_data_low is " <<
	    hex(u_int(mut_data_low)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  
  
  for (void*** p = __gc_glob_list_list; *p; p++)
    for (void** p2 = *p; *p2; p2 += 2) {
      int offset1 = (*p2) - data_low;
      int offset2 = (*(p2+1)) - data_low;
      scan_object((ObjHead*)(mut_data_low + offset1),
		  (void*)mut_data_low + offset2);
    };

  
  stop_if_error(
    vm_write(mutator_task_port, (vm_address_t)data_low, mut_data_low,
	     (data_extent / vm_page_size) * vm_page_size),
    "GcHeapRep1.c", 923);

  
  stop_if_error(
    vm_deallocate(	task_self_, (vm_address_t)mut_data_low,
		  data_extent),
    "GcHeapRep1.c", 930);
}












const lmo_q_size = 1024;
static void* late_marked_obj_queue[lmo_q_size];
static int lmo_q_back;

inline void lmo_q_reset() { lmo_q_back = 0; };

inline void lmo_q_enq(void* ptr) {
  late_marked_obj_queue[lmo_q_back++] = ptr;
  		{if (!(lmo_q_back < lmo_q_size)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 961);exit(1);}};
}




void GcHeapRep::scan_heap() {
  					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "In scan_heap.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  					      if ((debug_object::debug_level >= 30) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "State of heap is:\n" << (*this);					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  
  
  
  
  
  int this_page = nsq_deq();
  while (this_page != -1) {
    
    if (mut_task_done) _exit(0);

    
    if (page_data[this_page].scanned != SCANNED)
      scan_page_set(this_page);
    
    this_page = nsq_deq();
  }

  
  
  
  
  unprotect_page(mutator_task_port, gc_alloc_pt.alloc_page);

  					      if ((debug_object::debug_level >= 25) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "After collect, state of heap is:\n" << (*this);					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
}









void GcHeapRep::scan_page_set(int page) {
  		{if (!(page_data[page].scanned != SCANNED &&
	 page_data[page].space == new_space)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 1024);exit(1);}};

  					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) In scan_page_set for " << page << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

  int cur_page = page;

  
  
  int gc_alloc_page = gc_alloc_pt.alloc_page;

  
  
  
  
  

  if (cur_page == gc_alloc_page) {
    
    
    if (page_data[cur_page].next != -1) {
      					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task)  page is gc_alloc_page; pushing to back.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      nsq_enq(cur_page);
      
      return;
    }
  }
    
  for (;;) {
    scan_page(cur_page);
    
    
    
    
    
    if (page_data[cur_page].first_obj == 0) break;

    if (page_data[cur_page-1].space != new_space) {

      
      if (!page_data[cur_page].promoted) {
						      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Scan_page_set: page is not in new space.\n"
		  << "       next page: promoted is " <<
		  page_data[cur_page+1].promoted << " first_obj is " <<
		  page_data[cur_page+1].first_obj << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
	exit(0);
      }

      break;
    }

    
    
    
    if (page_data[cur_page-1].scanned == SCANNED ||
	page_data[cur_page-1].scanned == RESCAN)
      break;

    
    cur_page--;
  }

  		{if (!(page_data[cur_page].scanned == SCANNED ||
	 page_data[cur_page].scanned == RESCAN)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 1106);exit(1);}};
  
  
  gc_alloc_page = gc_alloc_pt.alloc_page;
  for (int up_page = cur_page; up_page <= page; up_page++) {
    if (up_page == gc_alloc_page) {
      
      if (!nsq_empty()) {
	
	
	
	if (page_data[up_page].scanned == SCANNED) {
	  					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) scanned gc_alloc_page (" << gc_alloc_page
		    << "), but queue is not empty.  Reinserting.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
	  						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&pd_scanned_lock)->name << " at line " << 1126 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&pd_scanned_lock)) mutex_wait_lock(&pd_scanned_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&pd_scanned_lock)->name << " at line " << 1126 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
	  nsq_enq(up_page);
	  page_data[up_page].scanned = RESCAN;
	  						      do {									        mutex_unlock(&pd_scanned_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&pd_scanned_lock)->name << " at line " << 1129 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
	}
	
	continue;
      }
    }
    

    if (debug_object::debug_level > 0) {
      						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&mut_alloc_pt.lock)->name << " at line " << 1140 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&mut_alloc_pt.lock)) mutex_wait_lock(&mut_alloc_pt.lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&mut_alloc_pt.lock)->name << " at line " << 1140 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
      check_ptr_invariants(up_page, page_data[up_page].promoted, 0);
      						      do {									        mutex_unlock(&mut_alloc_pt.lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&mut_alloc_pt.lock)->name << " at line " << 1142 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
    }

    					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Unprotecting page " << up_page <<
	      page_data[up_page] << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
    unprotect_page(mutator_task_port, up_page);
  }
  
  
  
  
  
  
  						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&pd_scanned_lock)->name << " at line " << 1161 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&pd_scanned_lock)) mutex_wait_lock(&pd_scanned_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&pd_scanned_lock)->name << " at line " << 1161 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
   	do { 		if ((&page_scan_done)->queue.head) cond_broadcast(&page_scan_done); 	} while (0);
  						      do {									        mutex_unlock(&pd_scanned_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&pd_scanned_lock)->name << " at line " << 1163 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);

  
  
  cthread_yield();

  					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Leaving scan_page_set for " << page << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
}



Bool rescanning;



void GcHeapRep::scan_page(int page) {
  
  
  if (page_data[page].first_obj < 0) {
    return;
  }

  					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task)     Scanning page " << page << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  
  
  
  void* obj_ptr = page2ptr(page) +
    page_data[page].first_obj * BYTES_PER_WORD;
  ObjHead* hd_ptr = (ObjHead*)obj_ptr;
  void* obj_start = obj_ptr + sizeof(ObjHead);

  Bool promoted_page = page_data[page].promoted;
  
  void* next_page_top = page2ptr(page) + BYTES_PER_GC_PAGE;
  
  
  						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&pd_scanned_lock)->name << " at line " << 1209 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&pd_scanned_lock)) mutex_wait_lock(&pd_scanned_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&pd_scanned_lock)->name << " at line " << 1209 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);

  rescanning = (page_data[page].scanned == RESCAN);

  page_data[page].scanned = IN_PROGRESS;
  						      do {									        mutex_unlock(&pd_scanned_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&pd_scanned_lock)->name << " at line " << 1214 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
  
  
  
  lmo_q_reset();
  
  
  					      if ((debug_object::debug_level >= 21) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "    ...about to enter inner scanning loop...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  int size_in_words;
  while (is_obj_start(obj_start) && (obj_ptr < next_page_top)) {
    size_in_words =
      min_containers(hd_ptr->size() + sizeof(ObjHead), BYTES_PER_WORD);

# 1232 "GcHeapRep1.c"


    					      if ((debug_object::debug_level >= 35) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "      ...obj_ptr is " << hex(int(obj_ptr)) <<
	      ", size is " << size_in_words << "...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

    

    
    
    if (promoted_page) {
      if (hd_ptr->marked
# 1248 "GcHeapRep1.c"

	  )
	{
	  scan_object(hd_ptr, obj_start);
	  hd_ptr->set_scanned();
	  hd_ptr->clear_marked();
	}
    } else {
      if (hd_ptr->type != DESC_FORWARD)
	scan_object(hd_ptr, obj_start);
    }
    		{if (!(!(hd_ptr->marked && !promoted_page))){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 1259);exit(1);}};
    
    
    obj_ptr += (size_in_words * BYTES_PER_WORD);
    hd_ptr = (ObjHead*)obj_ptr;
    obj_start = obj_ptr + sizeof(ObjHead);
  }
  					      if ((debug_object::debug_level >= 21) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "    ...just left inner scanning loop...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  
  
  
  
  

  					      if ((debug_object::debug_level >= 21) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "    ...about to do assert...\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  		{if (!(obj_ptr <= next_page_top ||
	 !((ObjHead*)(obj_ptr - size_in_words*BYTES_PER_WORD))->scanned ||
	 (page+1 < heap_pages &&
	  (page_data[page+1].space == new_space ||
	   page_data[page+1].space == cur_space)))){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 1283);exit(1);}};


  					      if ((debug_object::debug_level >= 21) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "    ...about to do lmo_queue - back is " << lmo_q_back
	    << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  
  int lmo_q_front = 0;
  		{if (!(lmo_q_back == 0 || page_data[page].promoted)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 1291);exit(1);}};
  while (lmo_q_front < lmo_q_back) {
    ObjHead* obj_hd = (ObjHead*)late_marked_obj_queue[lmo_q_front++];
    scan_object(obj_hd, (void*)obj_hd+sizeof(ObjHead));
# 1297 "GcHeapRep1.c"

  }
  
  					      if ((debug_object::debug_level >= 21) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "    ...about to set page to SCANNED.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&pd_scanned_lock)->name << " at line " << 1301 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&pd_scanned_lock)) mutex_wait_lock(&pd_scanned_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&pd_scanned_lock)->name << " at line " << 1301 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
  page_data[page].scanned = SCANNED;
  						      do {									        mutex_unlock(&pd_scanned_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&pd_scanned_lock)->name << " at line " << 1303 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);

# 1307 "GcHeapRep1.c"


  					      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task)     Leaving scan_page for " << page << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
}



void GcHeapRep::scan_object(ObjHead* obj_head, void* obj_start) {
  void** scan_ptr = (void**)obj_start - 1;
  
  					      if ((debug_object::debug_level >= 35) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "    In scan_object: obj_head is " << hex(u_int(obj_head)) <<
	    ", scan_ptr is " << hex(u_int(scan_ptr)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;


  Bool long_obj = 0;


  fast_init_ObjPtrIttr(obj_head, direct_ittr, indirect_ittr, fast_ittr);
  switch (obj_head->type) {
   case DESC_DIRECT:
    for (direct_ittr++; direct_ittr; direct_ittr++) {
      int incr = direct_ittr();
      
      scan_ptr += my_iabs(incr);
      if (*scan_ptr) copy_obj_if_nec(scan_ptr);
    }
    break;
   case DESC_FAST_INDIRECT:
    for (fast_ittr++; fast_ittr; fast_ittr++) {
      int incr = fast_ittr();
      
      scan_ptr += my_iabs(incr);
      if (*scan_ptr) copy_obj_if_nec(scan_ptr);
    }
    break;
   case DESC_INDIRECT:
    for (indirect_ittr++; indirect_ittr; indirect_ittr++) {
      int incr = indirect_ittr();
      
      scan_ptr += my_iabs(incr);
      if (*scan_ptr) copy_obj_if_nec(scan_ptr);
    }
    break;
   default:
    		{if (!(0)){fprintf((&_iob[2]),"Assertion failed: file \"%s\", line %d\n", "GcHeapRep1.c", 1355);exit(1);}};
  }
}






void GcHeapRep::copy_obj_if_nec(void** scan_ptr) {
  void* obj_head = ptr2obj_head(*scan_ptr);
  					      if ((debug_object::debug_level >= 40) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "        In copy_obj_if_nec for " << hex(u_int(*scan_ptr)) <<
	    ", translates to obj_head " << hex(u_int(obj_head)) <<".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
  
  if (obj_head) {
    ObjHead* gc_obj_hd = (ObjHead*)obj_head;
    
    
    
    
    if (gc_obj_hd->type == DESC_FORWARD) {
      void* obj_start = obj_head + sizeof(ObjHead);
      					      if ((debug_object::debug_level >= 45) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "        ...forwarding pointer is " <<
	      hex(u_int(gc_obj_hd->descriptor.forward)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      *scan_ptr = (gc_obj_hd->descriptor.forward + (*scan_ptr-obj_start));
      return;
    }
    
    int obj_page = ptr2page(obj_head);

    
    
    if (gc_obj_hd->scanned) {
      					      if ((debug_object::debug_level >= 45) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "        ...object has already been scanned.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      return;
    }
    
    
    if (page_data[obj_page].promoted) {
# 1405 "GcHeapRep1.c"


      					      if ((debug_object::debug_level >= 40) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "        ...the page is promoted, so not copying.\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      
      
      

      
      switch(page_data[obj_page].scanned) {
       case UNSCANNED: case RESCAN:
	gc_obj_hd->set_marked();
	promote_page(obj_page, gc_obj_hd);
	break;

       case IN_PROGRESS:
	
	
	
	
	if (!gc_obj_hd->marked) {
	  lmo_q_enq(obj_head);
	  
	  
	  gc_obj_hd->set_scanned();
# 1443 "GcHeapRep1.c"

	}
	
	
	
	promote_page(obj_page, gc_obj_hd);
	break;

       case SCANNED:
	
	
	
	
	
	
	
	
	

	goto do_copy;
# 1488 "GcHeapRep1.c"

       default:
						      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "Illegal switch value " << page_data[obj_page].scanned <<
		  " at line " << 1491 << " in GcHeapRep1.c.";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      }
# 1495 "GcHeapRep1.c"

      
    } else {
      
      
      
      if (page_data[obj_page].space != cur_space) {

	if (!(rescanning && page_data[obj_page].space == new_space)) {
	   					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "Assertion failed: " << "GcHeapRep1.c" << ", line " << 1507
	    << ":\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
	   					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "     rescanning = " << rescanning << ", space = " <<
	    page_data[obj_page].space << "(" <<
	      (page_data[obj_page].space == new_space ? "NEW" :
	       (page_data[obj_page].space == cur_space ? "CUR" :
		"FREE"));					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
	   					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "), page = " << obj_page << ", *scan_ptr = "
	    << hex(u_int(*scan_ptr)) << ",\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
	   					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "     obj_head = " << hex(u_int(obj_head)) <<
	    ", *gc_obj_hd = " << *gc_obj_hd << ",\n     " <<
	      "scan_ptr = " << hex(u_int(scan_ptr)) <<
		", scan_page is " << ptr2page((void*)scan_ptr) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
	   					      if ((debug_object::debug_level >= 0) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "  State of heap is:\n" << *this << "\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;;
	  exit(-1);
	}

	return;
      }

     do_copy:
      
      

      void* new_loc =
	internal_alloc(gc_alloc_pt, gc_obj_hd->size(), *gc_obj_hd);
      					      if ((debug_object::debug_level >= 45) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "        ...copying the object to " <<
		hex(u_int(new_loc)) << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;
      bcopy((char*)(obj_head+sizeof(ObjHead)), (char*)new_loc,
	    gc_obj_hd->size());
      gc_obj_hd->forward(new_loc);

      
      void* obj_start = obj_head + sizeof(ObjHead);
      *scan_ptr = new_loc + (*scan_ptr-obj_start);
      
      
      
      
      
      
      int new_page = ptr2page(new_loc);
      						      do {									        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locking " << (&pd_scanned_lock)->name << " at line " << 1557 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				         	do { 		if (! mutex_try_lock(&pd_scanned_lock)) mutex_wait_lock(&pd_scanned_lock); 	} while (0);							        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Locked " << (&pd_scanned_lock)->name << " at line " << 1557 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
      if (page_data[new_page].scanned == SCANNED) {
	nsq_enq(new_page, 1);
	page_data[new_page].scanned = RESCAN;

						      if ((debug_object::debug_level >= 20) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << "(GC Task) Reprotecting allocation page " <<
		  new_page << page_data[new_page] << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;

	protect_page(mutator_task_port, new_page);
      }
      						      do {									        mutex_unlock(&pd_scanned_lock);							        char* this_fn;							        if (debug_object::debug_level >= lock_debug_level) {			          char this_file_name[50];						          strcpy(this_file_name, "GcHeapRep1.c");					          this_fn = this_file_name;						          if (strncmp(this_fn, "/afs/cs/user/dld/gc/concurrent/", 31) == 0)	            this_fn = this_fn+31;						        }									        					      if ((debug_object::debug_level >= lock_debug_level) ) {			         	do { 		if (! mutex_try_lock(debug_object::debug_lock)) mutex_wait_lock(debug_object::debug_lock); 	} while (0);				        if (debug_object::debug_trace) {					          (*debug_object::debug_out) <<					            str("$$$ ", 3*debug_object::debug_nesting_level + 1);		        }									        (*debug_object::debug_out) << 						      	    (in_gc_task ? "(GC Task/" : "(Mut Task/") <<		      	    cthread_name(		(	(* (ur_cthread_t *) (cthread_sp() & cthread_stack_mask))->incarnation)) << ") " <<			      	    "Unlocked " << (&pd_scanned_lock)->name << " at line " << 1567 <<	      	    ", file " << this_fn << ".\n";					        (*debug_object::debug_out).flush();					        mutex_unlock(debug_object::debug_lock);				      };;				      } while (0);
# 1570 "GcHeapRep1.c"

    }
  }
}
