kaffe-0.8.x garbage collection problem (at least on m68k)

Esa Salonen es at vat-vai.valmet.com
Wed Mar 5 00:00:59 PST 1997


>> instead of crawling through memory guessing which values are pointers,
>> why not finally bite the bullet and do a managed heap?
>
>It's amazing just how long I can put this off.
>
>Tim

That will be the ultimate fix, but meanwhile
I tried to find all structures which have alignment problems on
(some) m68k systems (when only 2 byte alignment for pointers in structures).

After following modifications, which should not do any harm for other
configurations (or maybe alpha needs aligned(8) ?), garbage collection
seems to work now (doesn't any more collect too much). 
I tried both with and without GC_INCREMENTAL definition.
There seems to be still some problems with incremental mode:
collection doesn't start automatically, but needs System.gc() calls.
in walkObject:
		gcAmount += (gcStats.totalmem * size) / ALLOCCOUNTGC;
		while (gcAmount > 0) {
			gcAmount -= grey.next->size;
			walkObject(grey.next);
			if (grey.next == &grey) {
				invokeGC();
				break;
			}

gcAmount always goes negative before grey.next == &grey
and invokeGC is never called ? (except when java program calls System.gc())

but anyway, here are the modifications:

*** kaffe-0.8.2/kaffe/kaffevm/classMethod.h	Tue Mar  4 09:59:50 1997
--- orig/kaffe-0.8.2/kaffe/kaffevm/classMethod.h	Sun Feb 23 16:11:40 1997
***************
*** 43,49 ****
  	/* If non-NULL, a pointer to the superclass.
  	 * However, if state < CSTATE_DOING_PREPARE, then
  	 * (int) superclass is a constant pool index. */
! 	Class*			superclass __attribute__ ((aligned (4))); /* for m68k alignment */
  
  	struct _constants	constants;
  	/* For regular classes, an array of the methods defined in this class.
--- 43,49 ----
  	/* If non-NULL, a pointer to the superclass.
  	 * However, if state < CSTATE_DOING_PREPARE, then
  	 * (int) superclass is a constant pool index. */
! 	Class*			superclass;
  
  	struct _constants	constants;
  	/* For regular classes, an array of the methods defined in this class.
***************
*** 86,93 ****
  	Utf8Const*		name;
  	Utf8Const*		signature;
  	accessFlags		accflags;
! 	char			outtype;
! 	unsigned char*		code __attribute__ ((aligned (4))); /* for m68k alignment */
  	int			codelen;
  	struct _instn*		insn;
  	nativecode*		ncode_start;
--- 86,92 ----
  	Utf8Const*		name;
  	Utf8Const*		signature;
  	accessFlags		accflags;
! 	unsigned char*		code;
  	int			codelen;
  	struct _instn*		insn;
  	nativecode*		ncode_start;
***************
*** 99,104 ****
--- 98,104 ----
  	int			localsz;
  	int			ins;
  	int			outs;
+ 	char			outtype;
  	Class*			class;
  	struct _lineNumbers*	lines;
  
diff -c kaffe-0.8.2/kaffe/kaffevm/code.h orig/kaffe-0.8.2/kaffe/kaffevm/code.h
*** kaffe-0.8.2/kaffe/kaffevm/code.h	Tue Mar  4 09:30:18 1997
--- orig/kaffe-0.8.2/kaffe/kaffevm/code.h	Mon Jan 27 11:02:02 1997
***************
*** 22,29 ****
  	u4			code_length;
  	u1*			code;
  	u2			exception_table_length;
- 	u2			attribute_count; /* switch lines for m68k alignment */
  	struct _jexception*	exception_table;
  	union _attribute_info*	attributes;
  } Code;
  
--- 22,29 ----
  	u4			code_length;
  	u1*			code;
  	u2			exception_table_length;
  	struct _jexception*	exception_table;
+ 	u2			attribute_count;
  	union _attribute_info*	attributes;
  } Code;
  
diff -c kaffe-0.8.2/kaffe/kaffevm/constants.h orig/kaffe-0.8.2/kaffe/kaffevm/constants.h
*** kaffe-0.8.2/kaffe/kaffevm/constants.h	Tue Mar  4 09:28:06 1997
--- orig/kaffe-0.8.2/kaffe/kaffevm/constants.h	Thu Feb 27 17:51:52 1997
***************
*** 78,84 ****
  typedef jword ConstSlot;
  
  typedef struct _constants {
! 	u4		size; /* u2 -> u4 for m68k alignment */
  	u1*		tags;
  	ConstSlot*	data;
  } constants;
--- 78,84 ----
  typedef jword ConstSlot;
  
  typedef struct _constants {
! 	u2		size;
  	u1*		tags;
  	ConstSlot*	data;
  } constants;
*** kaffe-0.8.2/kaffe/kaffevm/gc-incremental.h	Tue Mar  4 12:16:13 1997
--- orig/kaffe-0.8.2/kaffe/kaffevm/gc-incremental.h	Thu Feb 27 17:57:45 1997
***************
*** 32,38 ****
  	struct _gcInfo*		prev;
  	struct _gcInfo*		next;
  	char			colour;
! 	int			__align__ __attribute__ ((aligned (4))); /* for m68k alignment */
  } gcInfo;
  
  typedef gcInfo gcList;
--- 32,38 ----
  	struct _gcInfo*		prev;
  	struct _gcInfo*		next;
  	char			colour;
! 	int			__align__;
  } gcInfo;
  
  typedef gcInfo gcList;


More information about the kaffe mailing list