[kaffe] CVS kaffe (hkraemer): new gc allocation types and minor fixes

Kaffe CVS cvs-commits at kaffe.org
Mon Sep 22 08:34:02 PDT 2003


PatchSet 4055 
Date: 2003/09/22 15:31:22
Author: hkraemer
Branch: HEAD
Tag: (none) 
Log:
new gc allocation types and minor fixes

* Added several new gc allocation types so it's easier
to see how kaffe allocates memory.

* Modified our class loading stuff so it calls the correct
loadClass method of user class loaders.

* Searches for static fields now also consider implemented
interfaces; this is necessary since these fields need not
be included in the classfile itself (just the same as with
the miranda methods)

Members: 
	ChangeLog:1.1650->1.1651 
	kaffe/kaffevm/access.c:1.2->1.3 
	kaffe/kaffevm/classMethod.c:1.110->1.111 
	kaffe/kaffevm/classPool.c:1.21->1.22 
	kaffe/kaffevm/code-analyse.c:1.38->1.39 
	kaffe/kaffevm/code-analyse.h:1.17->1.18 
	kaffe/kaffevm/code.c:1.10->1.11 
	kaffe/kaffevm/exception.c:1.72->1.73 
	kaffe/kaffevm/external.c:1.49->1.50 
	kaffe/kaffevm/gc.h:1.19->1.20 
	kaffe/kaffevm/gcFuncs.c:1.48->1.49 
	kaffe/kaffevm/inflate.c:1.10->1.11 
	kaffe/kaffevm/locks.c:1.45->1.46 
	kaffe/kaffevm/lookup.c:1.33->1.34 
	kaffe/kaffevm/string.c:1.26->1.27 
	kaffe/kaffevm/support.h:1.24->1.25 
	kaffe/kaffevm/verify.c:1.27->1.28 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1650 kaffe/ChangeLog:1.1651
--- kaffe/ChangeLog:1.1650	Mon Sep 22 14:29:16 2003
+++ kaffe/ChangeLog	Mon Sep 22 15:31:22 2003
@@ -1,3 +1,36 @@
+2003-09-22  Helmer Kraemer  <hkraemer at freenet.de>
+
+	* kaffe/kaffevm/access.c: (findSuperMethod) minor tweak
+	to bail out immediately when the method is found
+	
+	* kaffe/kaffevm/classMethod.c: (userLoadClass) call
+	loadClass(String) instead of loadClass(String,boolean)
+	as per spec
+	(lookupClassField) search implemented interfaces when
+	searching for static fields; pass the class that owns
+	the field to resolveFieldType, not the class where we
+	started the search
+
+	* kaffe/kaffevm/exception.c: (throwException) when
+	allocating a new VMThrowable, we must also assign
+	it to eobj->vmState, so we don't loose stack traces
+	(floatingException) don't create the stack trace twice
+
+	* kaffe/kaffevm/lookup.c: (getField) initialise ret->class
+	with the class that owns the field, not the class that was
+	passed to getField
+
+	* kaffe/kaffevm/locks.c: (getHeavyLock) minor tweak so
+	we don't leak a heavy lock
+	
+	* kaffe/kaffevm/classMethod.c, kaffe/kaffevm/classPool.c,
+	kaffe/kaffevm/code-analyse.c, kaffe/kaffevm/code-analyse.h,
+	kaffe/kaffevm/code.c, kaffe/kaffevm/external.c,
+	kaffe/kaffevm/gc.h, kaffe/kaffevm/gcFuncs.c,
+	kaffe/kaffevm/inflate.c, kaffe/kaffevm/string.c,
+	kaffe/kaffevm/support.h, kaffe/kaffevm/verify.c:
+	added several new allocation types to the gc
+
 2003-09-22  Dalibor Topic <robilad at kaffe.org>
 
 	* developers/patch-libtool-ltdl-memory-header-warning.diff:
Index: kaffe/kaffe/kaffevm/access.c
diff -u kaffe/kaffe/kaffevm/access.c:1.2 kaffe/kaffe/kaffevm/access.c:1.3
--- kaffe/kaffe/kaffevm/access.c:1.2	Mon Sep  1 03:06:58 2003
+++ kaffe/kaffe/kaffevm/access.c	Mon Sep 22 15:31:24 2003
@@ -203,7 +203,7 @@
 	{
 		int lpc;
 
-		for( lpc = 0; lpc < CLASS_NMETHODS(cl); lpc++ )
+		for( lpc = 0; lpc < CLASS_NMETHODS(cl) && !retval; lpc++ )
 		{
 			if( CLASS_METHODS(cl)[lpc].idx == meth->idx )
 			{
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.110 kaffe/kaffe/kaffevm/classMethod.c:1.111
--- kaffe/kaffe/kaffevm/classMethod.c:1.110	Mon Sep  1 03:06:58 2003
+++ kaffe/kaffe/kaffevm/classMethod.c	Mon Sep 22 15:31:24 2003
@@ -690,9 +690,9 @@
 	}
 	else
 	*/
-	if( (new_methods = KREALLOC(CLASS_METHODS(cl),
-					 sizeof(Method) *
-					 (CLASS_NMETHODS(cl) + 1))) )
+	if( (new_methods = gc_realloc(CLASS_METHODS(cl),
+				      sizeof(Method) *
+				      (CLASS_NMETHODS(cl) + 1), GC_ALLOC_METHOD)) )
 	{
 		int index;
 		
@@ -1020,7 +1020,7 @@
 	} else {
 		basename++;
 	}
-	c->sourcefile = KMALLOC(strlen(basename) + 1);
+	c->sourcefile = gc_malloc(strlen(basename) + 1, GC_ALLOC_CLASSMISC);
 	if (c->sourcefile != 0) {
 		strcpy(c->sourcefile, basename);
 	} else {
@@ -1055,7 +1055,7 @@
 	if (! checkBufSize(fp, nr*(2*4), CLASS_CNAME(c), einfo))
 	    return false;
 
-	ic = KMALLOC(sizeof(innerClass) * nr);
+	ic = gc_malloc(sizeof(innerClass) * nr, GC_ALLOC_CLASSMISC);
 	if (!ic) {
 		postOutOfMemory(einfo);
 		return false;
@@ -1361,7 +1361,7 @@
 		env,
 		(*env)->GetObjectClass(env, loader),
 		"loadClass",
-		"(Ljava/lang/String;Z)Ljava/lang/Class;")) )
+		"(Ljava/lang/String;)Ljava/lang/Class;")) )
 	{
 		jthrowable excobj;
 		
@@ -1369,8 +1369,7 @@
 			(*env)->CallObjectMethod(env,
 						 loader,
 						 meth,
-						 jname,
-						 false);
+						 jname);
 		
 		/*
 		 * Check whether an exception occurred.  If one was pending,
@@ -1717,7 +1716,7 @@
 	 * a bitmap to help the gc scan the object.  The first part is
 	 * inherited from the superclass.
 	 */
-	map = BITMAP_NEW(CLASS_FSIZE(class)/ALIGNMENTOF_VOIDP);
+	map = BITMAP_NEW(CLASS_FSIZE(class)/ALIGNMENTOF_VOIDP, GC_ALLOC_CLASSMISC);
 	if (map == 0) {
 		postOutOfMemory(einfo);
 		return (false);
@@ -1998,7 +1997,7 @@
 
 	if (methodNeedsTrampoline(meth)) {
 		/* XXX don't forget to pick those up at class gc time */
-		tramp = (methodTrampoline*)KMALLOC(sizeof(methodTrampoline));
+		tramp = (methodTrampoline*)gc_malloc(sizeof(methodTrampoline), GC_ALLOC_TRAMPOLINE);
 		if (tramp == 0) {
 			postOutOfMemory(einfo);
 			return (0);
@@ -2192,7 +2191,7 @@
 		return (true);
 	}
 
-	class->if2itable = KMALLOC(class->total_interface_len * sizeof(short));
+	class->if2itable = gc_malloc(class->total_interface_len * sizeof(short), GC_ALLOC_CLASSMISC);
 
 	if (class->if2itable == 0) {
 		postOutOfMemory(einfo);
@@ -2206,7 +2205,7 @@
 		j += 1;		/* add one word to store interface class */
 		j += class->interfaces[i]->msize;
 	}
-	class->itable2dtable = KMALLOC(j * sizeof(void *));
+	class->itable2dtable = gc_malloc(j * sizeof(void *), GC_ALLOC_CLASSMISC);
 	if (class->itable2dtable == 0) {
 		postOutOfMemory(einfo);
 		return (false);
@@ -2385,16 +2384,16 @@
 			short firstnewentry;
 			if (iface->implementors == NULL) {
 				len = (i + 1) + 4; /* 4 is slack only */
-				iface->implementors = KMALLOC(len * sizeof(short));
+				iface->implementors = gc_malloc(len * sizeof(short), GC_ALLOC_CLASSMISC);
 			} else {
 				/* double in size */
 				len = iface->implementors[0] * 2;
 				if (len <= i) {
 					len = i + 4;
 				}
-				iface->implementors = KREALLOC(
+				iface->implementors = gc_realloc(
 					iface->implementors,
-					len * sizeof(short));
+					len * sizeof(short), GC_ALLOC_CLASSMISC);
 			}
 
 			if (iface->implementors == 0) {
@@ -2603,6 +2602,7 @@
 		}
 		fptr++;
 	}
+
 	return (0);
 }
 
@@ -2619,15 +2619,34 @@
 		fptr = lookupClassFieldLocal(c, name, isStatic);
 		if (fptr) {
 			/* Resolve field if necessary */
-			if (resolveFieldType(fptr, clp, einfo) == 0) {
+			if (resolveFieldType(fptr, c, einfo) == 0) {
 				return (NULL);
 			}
 			return (fptr);
 		}
 	}
+
+	if (isStatic) {
+		int i = clp->total_interface_len;
+		Hjava_lang_Class **cp = &clp->interfaces[0];
+
+		while (--i >= 0) {
+			fptr = lookupClassFieldLocal (*cp, name, true);
+
+			if (fptr) {
+				if (resolveFieldType(fptr, *cp, einfo) == 0) {
+					return (NULL);
+				}
+				return (fptr);
+			}
+			cp++;
+		}	
+
+	}
+
 DBG(RESERROR,
-	dprintf("lookupClassField failed %s:%s\n",
-		clp->name->data, name->data);
+	dprintf("lookupClassField for %s failed %s:%s\n",
+		isStatic?"static":"non-static",clp->name->data, name->data);
     )
 	postExceptionMessage(einfo, JAVA_LANG(NoSuchFieldError), "%s", name->data);
 	return (0);
@@ -2788,7 +2807,7 @@
 
 	nargs = countArgsInSignature(signature->data);
 	sig = (parsed_signature_t*)gc_malloc(sizeof(*sig) +
-					     nargs * sizeof(sig->ret_and_args[0]), GC_ALLOC_FIXED);
+					     nargs * sizeof(sig->ret_and_args[0]), GC_ALLOC_CLASSMISC);
 	if (sig == NULL) {
 		postOutOfMemory(einfo);
 		return (NULL);
Index: kaffe/kaffe/kaffevm/classPool.c
diff -u kaffe/kaffe/kaffevm/classPool.c:1.21 kaffe/kaffe/kaffevm/classPool.c:1.22
--- kaffe/kaffe/kaffevm/classPool.c:1.21	Sun Jul 27 16:53:46 2003
+++ kaffe/kaffe/kaffevm/classPool.c	Mon Sep 22 15:31:24 2003
@@ -77,7 +77,7 @@
 		return (entry);
 
 	/* Failed to find class entry - create a new one */
-	entry = KMALLOC(sizeof(classEntry));
+	entry = gc_malloc(sizeof(classEntry), GC_ALLOC_CLASSPOOL);
 	if (entry == 0) {
 		postOutOfMemory(einfo);
 		return (0);
Index: kaffe/kaffe/kaffevm/code-analyse.c
diff -u kaffe/kaffe/kaffevm/code-analyse.c:1.38 kaffe/kaffe/kaffevm/code-analyse.c:1.39
--- kaffe/kaffe/kaffevm/code-analyse.c:1.38	Mon Jul  7 13:46:35 2003
+++ kaffe/kaffe/kaffevm/code-analyse.c	Mon Sep 22 15:31:24 2003
@@ -89,8 +89,8 @@
 		return false;
 	}
 
-	codeInfo = KMALLOC(sizeof(codeinfo) + (meth->c.bcode.codelen *
-					       sizeof(perPCInfo)));
+	codeInfo = gc_malloc(sizeof(codeinfo) + meth->c.bcode.codelen*sizeof(perPCInfo),
+			     GC_ALLOC_CODEANALYSE);
 	*pcodeinfo = codeInfo;
 	if (!codeInfo) {
 		postOutOfMemory(einfo);
@@ -99,7 +99,7 @@
 	/* Allocate space for local register info - we add in an extra one
 	 * to avoid mallocing 0 bytes.
 	 */
-	localuse = KCALLOC(sizeof(localUse), meth->localsz+1);
+	localuse = gc_malloc(sizeof(localUse) * (meth->localsz+1), GC_ALLOC_CODEANALYSE);
 	if (!localuse) {
 		KFREE(codeInfo);
 		postOutOfMemory(einfo);
Index: kaffe/kaffe/kaffevm/code-analyse.h
diff -u kaffe/kaffe/kaffevm/code-analyse.h:1.17 kaffe/kaffe/kaffevm/code-analyse.h:1.18
--- kaffe/kaffe/kaffevm/code-analyse.h:1.17	Thu Feb  6 21:35:07 2003
+++ kaffe/kaffe/kaffevm/code-analyse.h	Mon Sep 22 15:31:24 2003
@@ -147,7 +147,7 @@
 					  IS_STARTOFEXCEPTION(pc)) && \
 					  !IS_DONEVERIFY(pc))
 
-#define	ALLOCFRAME()			KMALLOC((codeInfo->stacksz+codeInfo->localsz+1) * sizeof(frameElement))
+#define	ALLOCFRAME()			gc_malloc((codeInfo->stacksz+codeInfo->localsz+1) * sizeof(frameElement), GC_ALLOC_CODEANALYSE)
 
 #define	ATTACH_NEW_BASICBLOCK(DPC)				\
 	if ((DPC) != 0 && !IS_STARTOFBASICBLOCK(DPC) &&		\
Index: kaffe/kaffe/kaffevm/code.c
diff -u kaffe/kaffe/kaffevm/code.c:1.10 kaffe/kaffe/kaffevm/code.c:1.11
--- kaffe/kaffe/kaffevm/code.c:1.10	Sun Aug 31 22:09:01 2003
+++ kaffe/kaffe/kaffevm/code.c	Mon Sep 22 15:31:24 2003
@@ -139,7 +139,7 @@
 
 	readu2(&nr, fp);
 
-	lines = KMALLOC(sizeof(lineNumbers)+sizeof(lineNumberEntry) * nr);
+	lines = gc_malloc(sizeof(lineNumbers)+sizeof(lineNumberEntry) * nr, GC_ALLOC_LINENRTABLE);
 	if (!lines) {
 		postOutOfMemory(info);
 		return false;
@@ -177,7 +177,7 @@
 	}
 
 	m->ndeclared_exceptions = nr;
-	idx = KMALLOC(sizeof(constIndex) * nr);
+	idx = gc_malloc(sizeof(constIndex) * nr, GC_ALLOC_DECLAREDEXC);
 	if (!idx) {
 		postOutOfMemory(info);
 		return false;
Index: kaffe/kaffe/kaffevm/exception.c
diff -u kaffe/kaffe/kaffevm/exception.c:1.72 kaffe/kaffe/kaffevm/exception.c:1.73
--- kaffe/kaffe/kaffevm/exception.c:1.72	Sun Aug 31 22:09:01 2003
+++ kaffe/kaffe/kaffevm/exception.c	Mon Sep 22 15:31:24 2003
@@ -253,6 +253,7 @@
 	if (vmstate == 0) {
 		vmstate =
 		  (Hjava_lang_VMThrowable*)newObject(javaLangVMThrowable);
+		unhand(eobj)->vmState = vmstate;
 	}
 	backtrace = buildStackTrace(0);
 	unhand(vmstate)->backtrace = backtrace;
@@ -315,7 +316,7 @@
 	/* XXX */
 	_Jv_Throw(eobj); /* no return */
 #endif
-  
+
 	/* Search down exception stack for a match */
 	DBG(ELOOKUP,
 	    dprintf ("dispatchException(): %s\n", ((Hjava_lang_Object*)eobj)->dtable->class->name->data);)
@@ -489,7 +490,6 @@
 
 	ae = (Hjava_lang_Throwable*)newObject(javaLangArithmeticException);
 	vmstate = (Hjava_lang_VMThrowable*)newObject(javaLangVMThrowable);
-	backtrace = buildStackTrace(frame);
 	backtrace = buildStackTrace(frame);
 	unhand(vmstate)->backtrace = backtrace;
 	unhand(ae)->vmState = vmstate;
Index: kaffe/kaffe/kaffevm/external.c
diff -u kaffe/kaffe/kaffevm/external.c:1.49 kaffe/kaffe/kaffevm/external.c:1.50
--- kaffe/kaffe/kaffevm/external.c:1.49	Thu Sep 11 16:51:20 2003
+++ kaffe/kaffe/kaffevm/external.c	Mon Sep 22 15:31:24 2003
@@ -54,7 +54,7 @@
 
 #ifndef LIBRARYINIT
 static inline lt_ptr_t kdlmalloc(size_t len) { 
-	void *ptr = KMALLOC(len);
+	void *ptr = gc_malloc(len, GC_ALLOC_NATIVELIB);
 	addToCounter(&ltmem, "vmmem-libltdl", 1, GCSIZEOF(ptr));
 	return (ptr);
 }
@@ -62,7 +62,7 @@
 	jlong len0;
 	void *ptr;
 	len0 = (jlong)GCSIZEOF(ptr0);
-	ptr = KREALLOC(ptr0, len);
+	ptr = gc_realloc(ptr0, len, GC_ALLOC_NATIVELIB);
 	addToCounter(&ltmem, "vmmem-libltdl", 1, ((jlong)GCSIZEOF(ptr))-len0);
 	return (ptr);
 }
@@ -156,7 +156,7 @@
 	/*
 	 * Build a library path from the given library path.
 	 */
-	libraryPath = KMALLOC(len+1);
+	libraryPath = gc_malloc(len+1, GC_ALLOC_NATIVELIB);
 	addToCounter(&ltmem, "vmmem-libltdl", 1, GCSIZEOF(libraryPath));
 	if (lpath != 0) {
 		strcat(libraryPath, lpath);
@@ -305,7 +305,7 @@
 		return -1;
 	}
 
-        lib->name = KMALLOC(strlen(path)+1);
+        lib->name = gc_malloc(strlen(path)+1, GC_ALLOC_NATIVELIB);
         strcpy (lib->name, path);
 
 	lib->ref = default_refs;
Index: kaffe/kaffe/kaffevm/gc.h
diff -u kaffe/kaffe/kaffevm/gc.h:1.19 kaffe/kaffe/kaffevm/gc.h:1.20
--- kaffe/kaffe/kaffevm/gc.h:1.19	Sun Sep 21 18:18:18 2003
+++ kaffe/kaffe/kaffevm/gc.h	Mon Sep 22 15:31:24 2003
@@ -33,38 +33,53 @@
 /*
  * Garbage collector interface.
  */
+/* allocation types for different kinds of java objects */
 #define	GC_ALLOC_JAVASTRING	0
 #define	GC_ALLOC_NOWALK		1
 #define	GC_ALLOC_NORMALOBJECT	2
 #define	GC_ALLOC_PRIMARRAY	3
 #define	GC_ALLOC_REFARRAY	4
-#define	GC_ALLOC_CLASSOBJECT	5
-#define	GC_ALLOC_FINALIZEOBJECT	6
-#define	GC_ALLOC_BYTECODE	7
-#define	GC_ALLOC_EXCEPTIONTABLE	8
-#define	GC_ALLOC_JITCODE	9
-#define	GC_ALLOC_STATICDATA	10
-#define	GC_ALLOC_CONSTANT	11
-#define	GC_ALLOC_FIXED		12
-#define	GC_ALLOC_DISPATCHTABLE	13
-#define	GC_ALLOC_METHOD		14
-#define	GC_ALLOC_FIELD		15
-#define	GC_ALLOC_UTF8CONST	16
-#define	GC_ALLOC_INTERFACE	17
-#define	GC_ALLOC_LOCK		18
-#define	GC_ALLOC_THREADCTX	19
-#define	GC_ALLOC_REF		20
-#define	GC_ALLOC_JITTEMP	21
-#define	GC_ALLOC_JAVALOADER	22
-#define	GC_ALLOC_JAR	        23
-#define	GC_ALLOC_JIT_SEQ	24
-#define	GC_ALLOC_JIT_CONST	25
-#define	GC_ALLOC_JIT_ARGS	26
-#define	GC_ALLOC_JIT_FAKE_CALL	27
-#define	GC_ALLOC_JIT_SLOTS	28
-#define	GC_ALLOC_JIT_CODEBLOCK	29
-#define	GC_ALLOC_JIT_LABELS	30
-#define	GC_ALLOC_MAX_INDEX	31
+#define	GC_ALLOC_FINALIZEOBJECT	5
+#define	GC_ALLOC_JAVALOADER     6
+
+/* allocation types related to the translator engines */
+#define	GC_ALLOC_JITCODE	7
+#define	GC_ALLOC_JITTEMP	8
+#define	GC_ALLOC_JIT_SEQ	9	
+#define	GC_ALLOC_JIT_CONST	10
+#define	GC_ALLOC_JIT_ARGS	11
+#define	GC_ALLOC_JIT_FAKE_CALL	12
+#define	GC_ALLOC_JIT_SLOTS	13
+#define	GC_ALLOC_JIT_CODEBLOCK	14
+#define	GC_ALLOC_JIT_LABELS	15
+#define	GC_ALLOC_TRAMPOLINE	16
+
+/* allocation types used for java.lang.Class and its parts */
+#define	GC_ALLOC_CLASSOBJECT	17
+#define	GC_ALLOC_BYTECODE	18
+#define	GC_ALLOC_EXCEPTIONTABLE	19
+#define	GC_ALLOC_STATICDATA	20
+#define	GC_ALLOC_CONSTANT	21
+#define	GC_ALLOC_DISPATCHTABLE  22
+#define	GC_ALLOC_METHOD         23
+#define	GC_ALLOC_FIELD          24
+#define	GC_ALLOC_INTERFACE      25
+#define	GC_ALLOC_LINENRTABLE	26
+#define	GC_ALLOC_DECLAREDEXC	27
+#define	GC_ALLOC_CLASSMISC	28
+
+/* miscelanious allocation types */
+#define	GC_ALLOC_FIXED         	29
+#define	GC_ALLOC_UTF8CONST	30
+#define	GC_ALLOC_LOCK          	31
+#define	GC_ALLOC_THREADCTX      32
+#define	GC_ALLOC_REF            33
+#define	GC_ALLOC_JAR            34
+#define	GC_ALLOC_CODEANALYSE    35
+#define	GC_ALLOC_CLASSPOOL	36
+#define	GC_ALLOC_VERIFIER	37
+#define	GC_ALLOC_NATIVELIB	38
+#define	GC_ALLOC_MAX_INDEX	39
 
 /*
  * Define a COM-like GC interface.
Index: kaffe/kaffe/kaffevm/gcFuncs.c
diff -u kaffe/kaffe/kaffevm/gcFuncs.c:1.48 kaffe/kaffe/kaffevm/gcFuncs.c:1.49
--- kaffe/kaffe/kaffevm/gcFuncs.c:1.48	Sun Sep 21 18:18:18 2003
+++ kaffe/kaffe/kaffevm/gcFuncs.c	Mon Sep 22 15:31:24 2003
@@ -637,7 +637,15 @@
 	GC_registerFixedTypeByIndex(gc, GC_ALLOC_THREADCTX, "thread-ctxts");
 	GC_registerFixedTypeByIndex(gc, GC_ALLOC_REF, "gc-refs");
 	GC_registerFixedTypeByIndex(gc, GC_ALLOC_JITTEMP, "jit-temp-data");
-        GC_registerFixedTypeByIndex(gc, GC_ALLOC_JAR, "jar");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_JAR, "jar");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_CODEANALYSE, "code-analyse");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_CLASSPOOL, "class-pool");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_LINENRTABLE, "linenr-table");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_DECLAREDEXC, "declared-exc");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_CLASSMISC, "class-misc");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_VERIFIER, "verifier");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_TRAMPOLINE, "trampoline");
+	GC_registerFixedTypeByIndex(gc, GC_ALLOC_NATIVELIB, "native-lib");
 	GC_registerFixedTypeByIndex(gc, GC_ALLOC_JIT_SEQ, "jit-seq");
 	GC_registerFixedTypeByIndex(gc, GC_ALLOC_JIT_CONST, "jit-const");
 	GC_registerFixedTypeByIndex(gc, GC_ALLOC_JIT_ARGS, "jit-args");
Index: kaffe/kaffe/kaffevm/inflate.c
diff -u kaffe/kaffe/kaffevm/inflate.c:1.10 kaffe/kaffe/kaffevm/inflate.c:1.11
--- kaffe/kaffe/kaffevm/inflate.c:1.10	Thu Jul 31 22:46:46 2003
+++ kaffe/kaffe/kaffevm/inflate.c	Mon Sep 22 15:31:24 2003
@@ -19,8 +19,8 @@
 #include "config-mem.h"
 #include "debug.h"
 #include "gtypes.h"
+#include "gc.h"
 #include "inflate.h"
-#include "kaffe/jmalloc.h"
 
 #define	WSIZE	0x8000
 
@@ -524,7 +524,7 @@
 {
 	inflateInfo* info;
 
-	info = KMALLOC(sizeof(inflateInfo));
+	info = gc_malloc(sizeof(inflateInfo), GC_ALLOC_FIXED);
 	if (!info) {
 		return 0;
 	}
@@ -532,9 +532,9 @@
 	info->fixed_td = 0;
 	info->fixed_bl = 0;
 	info->fixed_bd = 0;
-	info->slide = KMALLOC(WSIZE);
+	info->slide = gc_malloc(WSIZE, GC_ALLOC_FIXED);
 	if (!info->slide){
-		KFREE(info);
+		gc_free(info);
 		return 0;
 	}
 
@@ -616,8 +616,8 @@
       huft_free(pG->fixed_tl);
       pG->fixed_td = pG->fixed_tl = 0;
     }
-    KFREE(pG->slide);
-    KFREE(pG);
+    gc_free(pG->slide);
+    gc_free(pG);
   }
 
   return 0;
@@ -752,7 +752,7 @@
         l[h] = j;               /* set table size in stack */
 
         /* allocate and link in new table */
-        if ((q = (huft *)KMALLOC((z + 1)*sizeof(huft))) ==
+        if ((q = (huft *)gc_malloc((z + 1)*sizeof(huft), GC_ALLOC_FIXED)) ==
             0)
         {
           if (h)
@@ -829,7 +829,7 @@
   while (p != 0)
   {
     q = (--p)->v.t;
-    KFREE(p);
+    gc_free(p);
     p = q;
   }
   return 0;
Index: kaffe/kaffe/kaffevm/locks.c
diff -u kaffe/kaffe/kaffevm/locks.c:1.45 kaffe/kaffe/kaffevm/locks.c:1.46
--- kaffe/kaffe/kaffevm/locks.c:1.45	Sat Jul 26 16:50:49 2003
+++ kaffe/kaffe/kaffevm/locks.c	Mon Sep 22 15:31:24 2003
@@ -108,7 +108,9 @@
 DBG(SLOWLOCKS,
     			dprintf("    got cached lock\n");
 )
-			/* XXX is it possible to leak a heavyLock here ? */
+			if (lk != heavyLock) {
+				gc_free (lk);
+			}
 
 			lk = (iLock*)(((uintp)old) & (uintp)-2);
 		}
Index: kaffe/kaffe/kaffevm/lookup.c
diff -u kaffe/kaffe/kaffevm/lookup.c:1.33 kaffe/kaffe/kaffevm/lookup.c:1.34
--- kaffe/kaffe/kaffevm/lookup.c:1.33	Sun Aug 31 22:09:02 2003
+++ kaffe/kaffe/kaffevm/lookup.c	Mon Sep 22 15:31:24 2003
@@ -288,7 +288,7 @@
 	/* XXX Should we verify that ret->signature matches field? */
 
 	ret->field = field;
-	ret->class = class;
+	ret->class = field->clazz;
 	return (true);
 }
 
Index: kaffe/kaffe/kaffevm/string.c
diff -u kaffe/kaffe/kaffevm/string.c:1.26 kaffe/kaffe/kaffevm/string.c:1.27
--- kaffe/kaffe/kaffevm/string.c:1.26	Thu Jul 31 22:46:46 2003
+++ kaffe/kaffe/kaffevm/string.c	Mon Sep 22 15:31:24 2003
@@ -38,7 +38,7 @@
 {
 	char* str;
 
-	str = KMALLOC(STRING_SIZE(js) + 1);
+	str = gc_malloc(STRING_SIZE(js) + 1, GC_ALLOC_FIXED);
 	if (str != 0) {
 		stringJava2CBuf(js, str, STRING_SIZE(js) + 1);
 	}
@@ -86,7 +86,7 @@
 
 	/* Get buffer */
 	if (len * sizeof(*ary) > sizeof(buf)) {
-		ary = KMALLOC(len * sizeof(*ary));
+		ary = gc_malloc(len * sizeof(*ary), GC_ALLOC_FIXED);
 		if (!ary) return 0;
 	} else {
 		ary = buf;
@@ -162,7 +162,7 @@
 
 	/* Get buffer */
 	if (uniLen * sizeof(jchar) > sizeof(buf)) {
-		jc = KMALLOC(uniLen * sizeof(*jc));
+		jc = gc_malloc(uniLen * sizeof(*jc), GC_ALLOC_FIXED);
 		if (!jc) return 0;
 	} else {
 		jc = buf;
@@ -205,7 +205,7 @@
 	/* convert characters only if necessary */
 	if (slength != 0 && from != to) {
 		int i;
-		chars = KMALLOC(sizeof(jchar) * slength);
+		chars = gc_malloc(sizeof(jchar) * slength, GC_ALLOC_FIXED);
 
 		for (i = 0; i < slength; i++) {
 			jchar ci = ((jchar *)STRING_DATA(str))[i];
@@ -279,7 +279,7 @@
 
 	/* XXX assumes stringLock isn't acquired recursively (which it isn't) */
 	locks_internal_unlockMutex(&stringLock.lock, myRoot, &stringLock.heavyLock);
-	p = KCALLOC(1, sz);
+	p = gc_malloc(sz, GC_ALLOC_FIXED);
 	locks_internal_lockMutex(&stringLock.lock, myRoot, &stringLock.heavyLock);
 	stringLockRoot = myRoot;
 	return (p);
@@ -432,8 +432,8 @@
 
 		/* Construct a temporary and fake String object */
 		if (sizeof(*fakeAry) + (len * sizeof(*data)) > sizeof(buf)) {
-			fakeAry = KMALLOC(sizeof(*fakeAry)
-					+ (len * sizeof(*data)));
+			fakeAry = gc_malloc(sizeof(*fakeAry) + len * sizeof(*data),
+					    GC_ALLOC_FIXED);
 		} else {
 			fakeAry = (HArrayOfChar*)buf;
 		}
Index: kaffe/kaffe/kaffevm/support.h
diff -u kaffe/kaffe/kaffevm/support.h:1.24 kaffe/kaffe/kaffevm/support.h:1.25
--- kaffe/kaffe/kaffevm/support.h:1.24	Sun Aug 31 22:09:02 2003
+++ kaffe/kaffe/kaffevm/support.h	Mon Sep 22 15:31:24 2003
@@ -143,8 +143,8 @@
 #define BITMAP_BYTE_SIZE(b) (((b) + BITMAP_BPI - 1) / BITMAP_BPI)
 
 /* create a new bitmap for b bits */
-#define BITMAP_NEW(b)	\
-    (int *)KCALLOC(BITMAP_BYTE_SIZE(b), sizeof(int))
+#define BITMAP_NEW(b, gctype)	\
+    (int *)gc_calloc(BITMAP_BYTE_SIZE(b), sizeof(int), (gctype))
 
 /* set nth bit, counting from MSB to the right */
 #define BITMAP_SET(m, n) \
Index: kaffe/kaffe/kaffevm/verify.c
diff -u kaffe/kaffe/kaffevm/verify.c:1.27 kaffe/kaffe/kaffevm/verify.c:1.28
--- kaffe/kaffe/kaffevm/verify.c:1.27	Thu Sep 11 16:51:20 2003
+++ kaffe/kaffe/kaffevm/verify.c	Mon Sep 22 15:31:24 2003
@@ -1253,7 +1253,7 @@
 	 **************************************************************************************************/
 	DBG(VERIFY3, dprintf("        allocating memory for verification (codelen = %d)...\n", codelen); );
 	
-        status   = checkPtr((char*)KMALLOC(codelen * sizeof(uint32)));
+        status   = checkPtr((char*)gc_malloc(codelen * sizeof(uint32), GC_ALLOC_VERIFIER));
 	
 	// find basic blocks and allocate memory for them
 	blocks = verifyMethod3a(einfo, method, status, &numBlocks);
@@ -1940,7 +1940,7 @@
 	
 	DBG(VERIFY3, dprintf("    Verifier Pass 3a: third pass to allocate memory for basic blocks...\n"); );
 	
-	blocks = checkPtr((BlockInfo**)KMALLOC(blockCount * sizeof(BlockInfo*)));
+	blocks = checkPtr((BlockInfo**)gc_malloc(blockCount * sizeof(BlockInfo*), GC_ALLOC_VERIFIER));
 	
 	for (inABlock = true, n = 0, pc = 0; pc < codelen; pc++) {
 		if (status[pc] & START_BLOCK) {
@@ -3316,11 +3316,11 @@
 				
 				sig = CLASS_NAMED(idx, pool);
 				if (*sig == '[') {
-					namestr = checkPtr(KMALLOC(sizeof(char) * (strlen(sig) + 2)));
+					namestr = checkPtr(gc_malloc(sizeof(char) * (strlen(sig) + 2), GC_ALLOC_VERIFIER));
 					*sigs = pushSig(*sigs, namestr);
 					sprintf(namestr, "[%s", sig);
 				} else {
-					namestr = checkPtr(KMALLOC(sizeof(char) * (strlen(sig) + 4)));
+					namestr = checkPtr(gc_malloc(sizeof(char) * (strlen(sig) + 4), GC_ALLOC_VERIFIER));
 					*sigs = pushSig(*sigs, namestr);
 					sprintf(namestr, "[L%s;", sig);
 				}
@@ -3902,7 +3902,7 @@
 	uint32 nargs                     = countSizeOfArgsInSignature(sig);
 	
 	uint32 paramIndex                = 0;
-	char* argbuf                     = checkPtr(KMALLOC(strlen(sig) * sizeof(char)));
+	char* argbuf                     = checkPtr(gc_malloc(strlen(sig) * sizeof(char), GC_ALLOC_VERIFIER));
 	
 	
 	DBG(VERIFY3, dprintf("%scalling method %s%s\n", indent, METHODREF_NAMED(idx, pool), sig); );
@@ -4164,7 +4164,7 @@
 	
 	// the +1 skips the initial '('
 	const char* sig = METHOD_SIGD(method) + 1;
-	char* argbuf    = checkPtr(KMALLOC((strlen(sig)+1) * sizeof(char)));
+	char* argbuf    = checkPtr(gc_malloc((strlen(sig)+1) * sizeof(char), GC_ALLOC_VERIFIER));
 	char* newsig    = NULL;
 	
 	Type* locals = block->locals;
@@ -4219,7 +4219,7 @@
 			
 		case '[':
 		case 'L':
-			newsig = checkPtr(KMALLOC((strlen(argbuf) + 1) * sizeof(char)));
+			newsig = checkPtr(gc_malloc((strlen(argbuf) + 1) * sizeof(char), GC_ALLOC_VERIFIER));
 			*sigs = pushSig(*sigs, newsig);
 			sprintf(newsig, "%s", argbuf);
 			locals[paramCount].tinfo = TINFO_SIG;
@@ -4281,7 +4281,7 @@
 		sig = type->data.sig;
 		
 		if (*sig != '[') {
-			tmp = checkPtr(KMALLOC((strlen(sig) + 3) * sizeof(char)));
+			tmp = checkPtr(gc_malloc((strlen(sig) + 3) * sizeof(char), GC_ALLOC_VERIFIER));
 			sprintf(tmp, "L%s;", sig);
 			sig = tmp;
 		}
@@ -4653,14 +4653,14 @@
 {
 	int i;
 	
-	BlockInfo* binfo = checkPtr((BlockInfo*)KMALLOC(sizeof(BlockInfo)));
+	BlockInfo* binfo = checkPtr((BlockInfo*)gc_malloc(sizeof(BlockInfo), GC_ALLOC_VERIFIER));
 	
 	binfo->startAddr   = 0;
 	binfo->status      = IS_INSTRUCTION | START_BLOCK;  // not VISITED or CHANGED
 	
 	// allocate memory for locals
 	if (method->localsz > 0) {
-		binfo->locals = checkPtr(KMALLOC(method->localsz * sizeof(Type)));
+		binfo->locals = checkPtr(gc_malloc(method->localsz * sizeof(Type), GC_ALLOC_VERIFIER));
 		
 		for (i = 0; i < method->localsz; i++) {
 			binfo->locals[i] = *TUNSTABLE;
@@ -4673,7 +4673,7 @@
 	// allocate memory for operand stack
 	binfo->stacksz = 0;
 	if (method->stacksz > 0) {
-		binfo->opstack = checkPtr(KMALLOC(method->stacksz * sizeof(Type)));
+		binfo->opstack = checkPtr(gc_malloc(method->stacksz * sizeof(Type), GC_ALLOC_VERIFIER));
 		
 		for (i = 0; i < method->stacksz; i++) {
 			binfo->opstack[i] = *TUNSTABLE;
@@ -4763,7 +4763,7 @@
 SigStack*
 pushSig(SigStack* sigs, const char* sig)
 {
-	SigStack* new_sig = checkPtr(KMALLOC(sizeof(SigStack)));
+	SigStack* new_sig = checkPtr(gc_malloc(sizeof(SigStack), GC_ALLOC_VERIFIER));
 	new_sig->sig = sig;
 	new_sig->next = sigs;
 	return new_sig;
@@ -4825,7 +4825,7 @@
 UninitializedType*
 pushUninit(UninitializedType* uninits, const Type* type)
 {
-	UninitializedType* uninit = checkPtr(KMALLOC(sizeof(UninitializedType)));
+	UninitializedType* uninit = checkPtr(gc_malloc(sizeof(UninitializedType), GC_ALLOC_VERIFIER));
 	uninit->type = *type;
 	uninit->prev = NULL;
 	




More information about the kaffe mailing list