Re: [kaffe] CVS kaffe (hkraemer): fixes and improvement for the garbage collector

2003-09-30 Thread Jim Pick
 fixes and improvement for the garbage collector
 
 * fixed the endless loop in startGC when running javalayer 0.3.0
 * (hopefully) made the heap management more efficient

Excellent!  We needed that.

I'll have to test freenet again to see if it helps.

Cheers,

 - Jim


___
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe


[kaffe] CVS kaffe (hkraemer): fixes and improvement for the garbage collector

2003-09-28 Thread Kaffe CVS
PatchSet 4071 
Date: 2003/09/28 19:47:40
Author: hkraemer
Branch: HEAD
Tag: (none) 
Log:
fixes and improvement for the garbage collector

* fixed the endless loop in startGC when running javalayer 0.3.0
* (hopefully) made the heap management more efficient

Members: 
ChangeLog:1.1666-1.1667 
kaffe/kaffevm/mem/gc-incremental.c:1.67-1.68 
kaffe/kaffevm/mem/gc-mem.c:1.46-1.47 
kaffe/kaffevm/mem/gc-mem.h:1.16-1.17 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1666 kaffe/ChangeLog:1.1667
--- kaffe/ChangeLog:1.1666  Sat Sep 27 12:37:46 2003
+++ kaffe/ChangeLog Sun Sep 28 19:47:40 2003
@@ -1,3 +1,25 @@
+2003-09-28  Helmer Kraemer  [EMAIL PROTECTED]
+
+   * kaffe/kaffevm/mem/gc-incremental.c:
+   (startGC, finaliserMan) properly deal with objects on the finaliser
+   list when starting a gc pass (fixes endless loop)
+   (createGC) initialise the heap and reserve primitive pages for OOM
+   handling
+   
+   * kaffe/kaffevm/gc-mem.h: (struct gc_block) added pnext and pprev
+   fields for management of primitive blocks; removed inuse field
+   (GCBLOCKINUSE) new macro to test whether a gc_block is used
+
+   replaced all uses of the inuse field by calls to the GCBLOCKINUSE
+   macro
+
+   * kaffe/kaffevm/gc-mem.c: (gc_get_prim_freelist, gc_add_to_prim_freelist,
+   gc_remove_from_prim_freelist, gc_merge_with_successor) new helper
+   methods for management of primitive blocks
+   (gc_primitive_alloc, gc_primitive_free) manage primitive blocks
+   using a best fit algorithm
+   (gc_heap_grow) don't forget to lock the gc_heap_lock 
+   
 2003-09-27  Guilhem Lavaux [EMAIL PROTECTED]
 
* libraries/javalib/kjc.jar: Fix for path method invocation.
Index: kaffe/kaffe/kaffevm/mem/gc-incremental.c
diff -u kaffe/kaffe/kaffevm/mem/gc-incremental.c:1.67 
kaffe/kaffe/kaffevm/mem/gc-incremental.c:1.68
--- kaffe/kaffe/kaffevm/mem/gc-incremental.c:1.67   Fri Aug 22 11:42:15 2003
+++ kaffe/kaffe/kaffevm/mem/gc-incremental.cSun Sep 28 19:47:41 2003
@@ -228,7 +228,7 @@
uintp p = (uintp) UTOMEM(unit) - gc_heap_base;
int idx;
 
-   if (!(p  (MEMALIGN - 1))  p  gc_heap_range  info-inuse) {
+   if (!(p  (MEMALIGN - 1))  p  gc_heap_range  GCBLOCKINUSE(info)) {
/* Make sure 'unit' refers to the beginning of an
 * object.  We do this by making sure it is correctly
 * aligned within the block.
@@ -246,7 +246,7 @@
 static inline void
 markObjectDontCheck(gc_unit *unit, gc_block *info, int idx)
 {
-   /* If object's been traced before, don't do it again */
+   /* If the object has been traced before, don't do it again. */
if (GC_GET_COLOUR(info, idx) != GC_COLOUR_WHITE) {
return;
}
@@ -382,15 +382,15 @@
}
 
info = GCMEM2BLOCK(mem);
-   if (!info-inuse) {
+   if (!GCBLOCKINUSE(info)) {
/* go down block list to find out whether we were hitting
 * in a large object
 */
-   while (!info-inuse  (uintp)info  (uintp)gc_block_base) {
+   while (!GCBLOCKINUSE(info)  (uintp)info  (uintp)gc_block_base) {
info--;
}
/* must be a large block, hence nr must be 1 */
-   if (!info-inuse || info-nr != 1) {
+   if (!GCBLOCKINUSE(info) || info-nr != 1) {
return (0);
}
}
@@ -663,6 +663,8 @@
 startGC(Collector *gcif)
 {
gc_unit* unit;
+   gc_block* info;
+   int idx;
 
gcStats.freedmem = 0;
gcStats.freedobj = 0;
@@ -685,10 +687,25 @@
/* measure time */
startTiming(gc_time, gctime-scan);
 
-   /* Walk all objects on the finalizer list */
+   /*
+* Since objects whose finaliser has to be run need to
+* be kept alive, we have to mark them here. They will
+* be put back into the finalise list later on during
+* the gc pass.
+*
+* Since these objects are treated like garbage, we have
+* to set their colour to white before marking them.
+*/
while (gclists[finalise].cnext != gclists[finalise]) {
unit = gclists[finalise].cnext;
-   gcMarkObject(gcif, UTOMEM(unit));
+   info = GCMEM2BLOCK(unit);
+   idx = GCMEM2IDX(info, unit);
+
+   GC_SET_COLOUR (info, idx, GC_COLOUR_WHITE);
+   gcStats.finalobj -= 1;
+   gcStats.finalmem -= GCBLOCKSIZE(info);
+
+   markObjectDontCheck(unit, info, idx); 
}
 
(*walkRootSet)(gcif);
@@ -851,27 +868,52 @@
}
assert(finalRunning == true);
 
+   /*
+* Loop until the list of objects whose finaliser needs to be run is 
empty
+* [ checking the condition without holding a