[kaffe] CVS kaffe (dalibor): Turned GCMEM2BLOCK into a normal function

Kaffe CVS cvs-commits at kaffe.org
Fri Sep 3 03:15:01 PDT 2004


PatchSet 5137 
Date: 2004/09/03 10:10:51
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Turned GCMEM2BLOCK into a normal function
2004-09-03  Dalibor Topic  <robilad at kaffe.org>

        * kaffe/kaffevm/kaffe-gc/gc-incremental.c,
        kaffe/kaffevm/kaffe-gc/gc-mem.c:
        Use gc_mem2block instead of GCMEM2BLOCK.
        (gc_mem2block) New function.

        * kaffe/kaffevm/kaffe-gc/gc-mem.h: (GCMEM2BLOCK) Removed.

Members: 
	ChangeLog:1.2693->1.2694 
	kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.5->1.6 
	kaffe/kaffevm/kaffe-gc/gc-mem.c:1.9->1.10 
	kaffe/kaffevm/kaffe-gc/gc-mem.h:1.7->1.8 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2693 kaffe/ChangeLog:1.2694
--- kaffe/ChangeLog:1.2693	Thu Sep  2 08:10:07 2004
+++ kaffe/ChangeLog	Fri Sep  3 10:10:51 2004
@@ -1,3 +1,12 @@
+2004-09-03  Dalibor Topic  <robilad at kaffe.org>
+
+	* kaffe/kaffevm/kaffe-gc/gc-incremental.c, 
+	kaffe/kaffevm/kaffe-gc/gc-mem.c: 
+	Use gc_mem2block instead of GCMEM2BLOCK.
+	(gc_mem2block) New function.
+
+	* kaffe/kaffevm/kaffe-gc/gc-mem.h: (GCMEM2BLOCK) Removed.
+
 2004-09-01  Kiyo Inaba <inaba at src.ricoh.co.jp>
 
 	* config/m68k/jit-m68k.def,
Index: kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c
diff -u kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.5 kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.6
--- kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c:1.5	Tue Aug 31 10:38:15 2004
+++ kaffe/kaffe/kaffevm/kaffe-gc/gc-incremental.c	Fri Sep  3 10:10:53 2004
@@ -301,7 +301,7 @@
 	 */
 
 	/* Get block info for this memory - if it exists */
-	info = GCMEM2BLOCK(mem);
+	info = gc_mem2block(mem);
 	unit = UTOUNIT(mem);
 	if (gc_heap_isobject(info, unit)) {
 		markObjectDontCheck(unit, info, GCMEM2IDX(info, unit));
@@ -316,7 +316,7 @@
 gcMarkObject(Collector* gcif UNUSED, void *gc_info UNUSED, const void* objp)
 {
   gc_unit *unit = UTOUNIT(objp);
-  gc_block *info = GCMEM2BLOCK(unit);
+  gc_block *info = gc_mem2block(unit);
   DBG(GCDIAG, assert(gc_heap_isobject(info, unit)));
   markObjectDontCheck(unit, info, GCMEM2IDX(info, unit));
 }
@@ -353,7 +353,7 @@
 uint32
 gcGetObjectSize(Collector* gcif UNUSED, const void* mem)
 {
-	return (GCBLOCKSIZE(GCMEM2BLOCK(UTOUNIT(mem))));
+	return (GCBLOCKSIZE(gc_mem2block(UTOUNIT(mem))));
 }
 
 static
@@ -361,7 +361,7 @@
 gcGetObjectIndex(Collector* gcif UNUSED, const void* mem)
 {
 	gc_unit* unit = UTOUNIT(mem);
-	gc_block* info = GCMEM2BLOCK(unit);
+	gc_block* info = gc_mem2block(unit);
 	if (!gc_heap_isobject(info, unit)) {
 		return (-1);
 	} else {
@@ -375,7 +375,7 @@
  *
  * This method uses many details of the allocator implementation.
  * Specifically, it relies on the contiguous layout of block infos
- * and the way GCMEM2BLOCK and GCMEM2IDX are implemented.
+ * and the way gc_mem2block and GCMEM2IDX are implemented.
  */
 static
 void*
@@ -397,7 +397,7 @@
 	   even for large blocks
 	  */
 
-	info = GCMEM2BLOCK(mem);
+	info = gc_mem2block(mem);
 	idx = GCMEM2IDX(info, mem);
 
 	/* report fixed objects as well */
@@ -433,7 +433,7 @@
 	walk_func_t walkf;
 
 	unit = UTOUNIT(mem);
-	info = GCMEM2BLOCK(unit);
+	info = gc_mem2block(unit);
 	idx = GCMEM2IDX(info, unit);
 
 	if (KGC_GET_COLOUR(info, idx) == KGC_COLOUR_BLACK) {
@@ -590,7 +590,7 @@
 		 */
 		while (gclists[fin_white].cnext != &gclists[fin_white]) {
 			unit = gclists[fin_white].cnext;
-			info = GCMEM2BLOCK(unit);
+			info = gc_mem2block(unit);
 			idx = GCMEM2IDX(info, unit);
 		
 			assert (KGC_GET_STATE(info, idx) == KGC_STATE_NEEDFINALIZE);
@@ -706,7 +706,7 @@
 	 */
 	while (gclists[finalise].cnext != &gclists[finalise]) {
 		unit = gclists[finalise].cnext;
-		info = GCMEM2BLOCK(unit);
+		info = gc_mem2block(unit);
 		idx = GCMEM2IDX(info, unit);
 
 		KGC_SET_COLOUR (info, idx, KGC_COLOUR_WHITE);
@@ -762,7 +762,7 @@
 			unit = gclists[i].cnext;
 			UREMOVELIST(unit);
 
-			info = GCMEM2BLOCK(unit);
+			info = gc_mem2block(unit);
 			idx = GCMEM2IDX(info, unit);
 
 			assert(KGC_GET_COLOUR(info, idx) == KGC_COLOUR_BLACK);
@@ -778,7 +778,7 @@
 	while (toRemove.cnext != &toRemove) {
 		destroy_func_t destroy;
 		unit = toRemove.cnext; 
-		info = GCMEM2BLOCK(unit);
+		info = gc_mem2block(unit);
 		idx = GCMEM2IDX(info, unit);
 
 		gcStats.freedmem += GCBLOCKSIZE(info);
@@ -797,7 +797,7 @@
 #endif
 
 		/* invoke destroy function before freeing the object */
-		info = GCMEM2BLOCK(unit);
+		info = gc_mem2block(unit);
 		idx = GCMEM2IDX(info, unit);
 		destroy = gcFunctions[KGC_GET_FUNCS(info,idx)].destroy;
 		if (destroy != 0) {
@@ -901,7 +901,7 @@
 		 */
 		while (gclists[finalise].cnext != &gclists[finalise]) {
 			unit = gclists[finalise].cnext;
-			info = GCMEM2BLOCK(unit);
+			info = gc_mem2block(unit);
 			idx = GCMEM2IDX(info, unit);
 
 			/* Call finaliser */
@@ -1081,7 +1081,7 @@
 		}
 	}
 
-	info = GCMEM2BLOCK(mem);
+	info = gc_mem2block(mem);
 	i = GCMEM2IDX(info, unit);
 
 	bsz = GCBLOCKSIZE(info);
@@ -1219,7 +1219,7 @@
 
 	lockStaticMutex(&gc_lock);
 	unit = UTOUNIT(mem);
-	info = GCMEM2BLOCK(unit);
+	info = gc_mem2block(unit);
 	idx = GCMEM2IDX(info, unit);
 	osize = GCBLOCKSIZE(info) - sizeof(gc_unit);
 
@@ -1258,7 +1258,7 @@
 	if (mem != 0) {
 		lockStaticMutex(&gc_lock);
 		unit = UTOUNIT(mem);
-		info = GCMEM2BLOCK(unit);
+		info = gc_mem2block(unit);
 		idx = GCMEM2IDX(info, unit);
 
 		if (KGC_GET_COLOUR(info, idx) == KGC_COLOUR_FIXED) {
@@ -1322,7 +1322,7 @@
 	gc_block* info;
 	int idx;
 
-	info = GCMEM2BLOCK(unit);
+	info = gc_mem2block(unit);
 	idx = KGC_GET_FUNCS(info, GCMEM2IDX(info, unit));
 
 	assert(idx >= 0 && gcFunctions[idx].description!=NULL);
Index: kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c
diff -u kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c:1.9 kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c:1.10
--- kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c:1.9	Wed Sep  1 10:31:05 2004
+++ kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.c	Fri Sep  3 10:10:53 2004
@@ -137,9 +137,9 @@
  * Evaluates to the size of the object that contains address @M.
  *
  */
-#define	KGC_OBJECT_SIZE(M)	GCMEM2BLOCK(M)->size
+#define	KGC_OBJECT_SIZE(M)	gc_mem2block(M)->size
 
-#define ASSERT_ONBLOCK(OBJ, BLK) assert(GCMEM2BLOCK(OBJ) == BLK)
+#define ASSERT_ONBLOCK(OBJ, BLK) assert(gc_mem2block(OBJ) == BLK)
 
 #if !(defined(NDEBUG) || !defined(KAFFE_VMDEBUG))
 /* Magic constant used to mark blocks under gc's management */
@@ -456,7 +456,7 @@
 	int idx;
 	int iLockRoot;
 
-	info = GCMEM2BLOCK(mem);
+	info = gc_mem2block(mem);
 	idx = GCMEM2IDX(info, mem);
 
 	DBG(GCDIAG,
@@ -1070,7 +1070,7 @@
 		gc_heap_base = heap_addr;
 	}
 
-	if (GCMEM2BLOCK(heap_addr + size)
+	if (gc_mem2block((void *) (heap_addr + size))
 	    > ((gc_block *)gc_block_base) + nblocks
 	    || heap_addr < gc_heap_base) {
 		uintp old_blocks = gc_block_base;
@@ -1156,7 +1156,7 @@
 #if defined(KAFFE_VMDEBUG)
 	mprotect((void *) heap_addr, size, NO_PROT);
 #endif
-	return GCMEM2BLOCK(heap_addr);
+	return gc_mem2block((void *) heap_addr);
 }
 
 /**
@@ -1231,4 +1231,13 @@
 	unlockStaticMutex(&gc_heap_lock);
 
 	return (blk);
+}
+
+/**
+ * Evaluates to the gc_block that contains address @M.
+ *
+ */
+gc_block *
+gc_mem2block(const void * mem) {
+  return (KGC_BLOCKS + ( ( ((uintp) (mem)) - gc_heap_base) >> gc_pgbits));
 }
Index: kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.h
diff -u kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.h:1.7 kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.h:1.8
--- kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.h:1.7	Wed Sep  1 10:31:05 2004
+++ kaffe/kaffe/kaffevm/kaffe-gc/gc-mem.h	Fri Sep  3 10:10:53 2004
@@ -93,6 +93,8 @@
 
 extern gc_block	* gc_primitive_reserve(void);
 extern void	gc_primitive_free(gc_block* mem);
+extern gc_block * gc_mem2block(const void * mem);
+
 
 /* ------------------------------------------------------------------------ */
 
@@ -139,11 +141,5 @@
  *
  */
 #define	GCMEM2IDX(B, M)		(((uint8*)(uintp)(M) - (B)->data) / (B)->size)
-
-/**
- * Evaluates to the gc_block that contains address @M.
- *
- */
-#define GCMEM2BLOCK(M)		(KGC_BLOCKS + ( ( ((uintp) (M)) - gc_heap_base) >> gc_pgbits))
 
 #endif




More information about the kaffe mailing list