[kaffe] CVS kaffe (robilad): partial kaffe cleanup for fedora core 5 / debian etch

Kaffe CVS cvs-commits at kaffe.org
Sun Jun 11 16:23:49 PDT 2006


PatchSet 7308 
Date: 2006/06/11 23:12:04
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
partial kaffe cleanup for fedora core 5 / debian etch

2006-06-11  Dalibor Topic  <robilad at kaffe.org>

        Fixed 16 gcc 4.1.1 warnings due to abuse of a methods
        field in class to store different types for array and primitive
        classes.

        * kaffe/kaffevm/classMethod.h:
        (struct Hjava_lang_Class): New union cache of methods,
        element_type and array_cache.
        (Kaffe_get_class_methods, Kaffe_set_class_methods,
        Kaffe_get_array_element_type, Kaffe_set_array_element_type,
        Kaffe_get_primitive_array_cache, Kaffe_set_primitive_array_cache)
        New accessor functions.
        (CLASS_METHODS, CLASS_ELEMENT_TYPE, CLASS_ARRAY_CACHE) Removed.

        * kaffe/jvmpi/jvmpi_kaffe.c,
        kaffe/kaffevm/access.c,
        kaffe/kaffevm/classMethod.c,
        kaffe/kaffevm/classPool.c,
        kaffe/kaffevm/code.c,
        kaffe/kaffevm/gcFuncs.c,
        kaffe/kaffevm/gcj/gcj-class.cc,
        kaffe/kaffevm/gcj/gcj-glue.c,
        kaffe/kaffevm/jit/machine.c,
        kaffe/kaffevm/jit3/machine.c,
        kaffe/kaffevm/jni/jni-helpers.c,
        kaffe/kaffevm/jni/jni.c,
        kaffe/kaffevm/lookup.c,
        kaffe/kaffevm/object.c,
        kaffe/kaffevm/reflect.c,
        kaffe/kaffevm/soft.c,
        kaffe/kaffevm/verifier/verify.c,
        kaffe/kaffevm/verifier/verify2.c,
        kaffe/xprof/debugFile.c,
        libraries/clib/native/Class.c,
        libraries/clib/native/Constructor.c,
        libraries/clib/native/Method.c,
        libraries/clib/native/Object.c,
        libraries/clib/native/System.c,
        libraries/extensions/microsoft/clib/Delegate.c,
        test/internal/jitBasic.c:
        Use accessor functions instead of removed macros.

Members: 
	ChangeLog:1.4812->1.4813 
	kaffe/jvmpi/jvmpi_kaffe.c:1.20->1.21 
	kaffe/kaffevm/access.c:1.17->1.18 
	kaffe/kaffevm/classMethod.c:1.158->1.159 
	kaffe/kaffevm/classMethod.h:1.91->1.92 
	kaffe/kaffevm/classPool.c:1.39->1.40 
	kaffe/kaffevm/code.c:1.21->1.22 
	kaffe/kaffevm/gcFuncs.c:1.85->1.86 
	kaffe/kaffevm/lookup.c:1.49->1.50 
	kaffe/kaffevm/object.c:1.38->1.39 
	kaffe/kaffevm/reflect.c:1.5->1.6 
	kaffe/kaffevm/soft.c:1.81->1.82 
	kaffe/kaffevm/gcj/gcj-class.cc:1.4->1.5 
	kaffe/kaffevm/gcj/gcj-glue.c:1.11->1.12 
	kaffe/kaffevm/jit/machine.c:1.86->1.87 
	kaffe/kaffevm/jit3/machine.c:1.83->1.84 
	kaffe/kaffevm/jni/jni-helpers.c:1.14->1.15 
	kaffe/kaffevm/jni/jni.c:1.44->1.45 
	kaffe/kaffevm/verifier/verify.c:1.16->1.17 
	kaffe/kaffevm/verifier/verify2.c:1.7->1.8 
	kaffe/xprof/debugFile.c:INITIAL->1.9 
	libraries/clib/native/Class.c:1.92->1.93 
	libraries/clib/native/Constructor.c:1.14->1.15 
	libraries/clib/native/Method.c:1.45->1.46 
	libraries/clib/native/Object.c:1.18->1.19 
	libraries/clib/native/System.c:1.67->1.68 
	libraries/extensions/microsoft/clib/Delegate.c:1.7->1.8 
	test/internal/jitBasic.c:1.10->1.11 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4812 kaffe/ChangeLog:1.4813
--- kaffe/ChangeLog:1.4812	Wed Jun  7 13:46:37 2006
+++ kaffe/ChangeLog	Sun Jun 11 23:12:04 2006
@@ -1,3 +1,46 @@
+2006-06-11  Dalibor Topic  <robilad at kaffe.org>
+
+	Fixed 16 gcc 4.1.1 warnings due to abuse of a methods
+	field in class to store different types for array and primitive
+	classes.
+
+        * kaffe/kaffevm/classMethod.h:
+	(struct Hjava_lang_Class): New union cache of methods,
+	element_type and array_cache.
+	(Kaffe_get_class_methods, Kaffe_set_class_methods,
+	Kaffe_get_array_element_type, Kaffe_set_array_element_type,
+	Kaffe_get_primitive_array_cache, Kaffe_set_primitive_array_cache)
+	New accessor functions.
+	(CLASS_METHODS, CLASS_ELEMENT_TYPE, CLASS_ARRAY_CACHE) Removed.
+
+	* kaffe/jvmpi/jvmpi_kaffe.c,
+        kaffe/kaffevm/access.c,
+        kaffe/kaffevm/classMethod.c,
+        kaffe/kaffevm/classPool.c,
+        kaffe/kaffevm/code.c,
+        kaffe/kaffevm/gcFuncs.c,
+        kaffe/kaffevm/gcj/gcj-class.cc,
+        kaffe/kaffevm/gcj/gcj-glue.c,
+        kaffe/kaffevm/jit/machine.c,
+        kaffe/kaffevm/jit3/machine.c,
+        kaffe/kaffevm/jni/jni-helpers.c,
+        kaffe/kaffevm/jni/jni.c,
+        kaffe/kaffevm/lookup.c,
+        kaffe/kaffevm/object.c,
+        kaffe/kaffevm/reflect.c,
+        kaffe/kaffevm/soft.c,
+        kaffe/kaffevm/verifier/verify.c,
+        kaffe/kaffevm/verifier/verify2.c,
+        kaffe/xprof/debugFile.c,
+        libraries/clib/native/Class.c,
+        libraries/clib/native/Constructor.c,
+        libraries/clib/native/Method.c,
+        libraries/clib/native/Object.c,
+        libraries/clib/native/System.c,
+        libraries/extensions/microsoft/clib/Delegate.c,
+        test/internal/jitBasic.c:
+	Use accessor functions instead of removed macros.
+
 2006-06-07  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/external/classpath: Resynced with GNU Classpath.
Index: kaffe/kaffe/jvmpi/jvmpi_kaffe.c
diff -u kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.20 kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.21
--- kaffe/kaffe/jvmpi/jvmpi_kaffe.c:1.20	Sat Apr 22 23:42:06 2006
+++ kaffe/kaffe/jvmpi/jvmpi_kaffe.c	Sun Jun 11 23:12:09 2006
@@ -138,7 +138,7 @@
 	if( CLASS_IS_ARRAY(cl) )
 	{
 		jint prim_type = 0;
-		Hjava_lang_Class *eclazz = CLASS_ELEMENT_TYPE(cl);
+		Hjava_lang_Class *eclazz = Kaffe_get_array_element_type(cl);
 		
 		if (CLASS_IS_PRIMITIVE(eclazz))
 		  {
@@ -243,7 +243,7 @@
 	for( lpc = 0; lpc < CLASS_NMETHODS(cl); lpc++ )
 	{
 		jvmpiConvertMethod(&ev->u.class_load.methods[lpc],
-				   &CLASS_METHODS(cl)[lpc]);
+				   &(Kaffe_get_class_methods(cl)[lpc]));
 	}
 	for( lpc = 0; lpc < CLASS_NSFIELDS(cl); lpc++ )
 	{
Index: kaffe/kaffe/kaffevm/access.c
diff -u kaffe/kaffe/kaffevm/access.c:1.17 kaffe/kaffe/kaffevm/access.c:1.18
--- kaffe/kaffe/kaffevm/access.c:1.17	Fri Dec 23 23:20:01 2005
+++ kaffe/kaffe/kaffevm/access.c	Sun Jun 11 23:12:10 2006
@@ -194,7 +194,7 @@
 
 		for( lpc = 0; lpc < CLASS_NMETHODS(cl) && !retval; lpc++ )
 		{
-			if( CLASS_METHODS(cl)[lpc].idx == meth->idx )
+			if( Kaffe_get_class_methods(cl)[lpc].idx == meth->idx )
 			{
 				retval = orig_cl->superclass;
 			}
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.158 kaffe/kaffe/kaffevm/classMethod.c:1.159
--- kaffe/kaffe/kaffevm/classMethod.c:1.158	Thu May 25 22:26:40 2006
+++ kaffe/kaffe/kaffevm/classMethod.c	Sun Jun 11 23:12:10 2006
@@ -699,14 +699,14 @@
 	}
 	else
 	*/
-	if( (new_methods = gc_realloc(CLASS_METHODS(cl),
+	if( (new_methods = gc_realloc(Kaffe_get_class_methods(cl),
 				      sizeof(Method) *
 				      (CLASS_NMETHODS(cl) + 1), KGC_ALLOC_METHOD)) )
 	{
 		int i;
 		
 		i = CLASS_NMETHODS(cl);
-		CLASS_METHODS(cl) = new_methods;
+		Kaffe_set_class_methods(cl, new_methods);
 		utf8ConstAddRef(imeth->name);
 		new_methods[i] = *imeth;
 
@@ -765,7 +765,7 @@
 			int foundit = 0;
 			Method *imeth;
 			
-			imeth = &CLASS_METHODS(iface)[j];
+			imeth = &(Kaffe_get_class_methods(iface)[j]);
 			/* Igore statics */
 			if( imeth->accflags & ACC_STATIC )
 				continue;
@@ -778,7 +778,7 @@
 				{
 					Method *cmeth;
 					
-					cmeth = &CLASS_METHODS(cl)[k];
+					cmeth = &(Kaffe_get_class_methods(cl)[k]);
 					if( (cmeth->name == imeth->name) &&
 					    (cmeth->parsed_sig->signature ==
 					     imeth->parsed_sig->signature) )
@@ -982,7 +982,7 @@
 		return 0;
 	}
 	cl->packageLength = findPackageLength(name->data);
-	CLASS_METHODS(cl) = NULL;
+	Kaffe_set_class_methods(cl, NULL);
 	CLASS_NMETHODS(cl) = 0;
 	assert(cl->superclass == 0);
 	cl->superclass = (Hjava_lang_Class*)(uintp)su;
@@ -1129,18 +1129,20 @@
 {
 	if (methct == 0)
 	{
-		this->methods = NULL;
+		Kaffe_set_class_methods(this, NULL);
 	}
 	else
 	{
-		this->methods = gc_malloc(sizeof(Method)*(methct), KGC_ALLOC_METHOD);
-		if (this->methods == NULL)
+		Kaffe_set_class_methods(this, 
+					gc_malloc(sizeof(Method)*(methct), 
+						  KGC_ALLOC_METHOD));
+		if (Kaffe_get_class_methods(this) == NULL)
 		{
 			postOutOfMemory(einfo);
 			return false;
 		}
 	}
-	KGC_WRITE(this, this->methods);
+	KGC_WRITE(this, Kaffe_get_class_methods(this));
 
 	CLASS_NMETHODS(this) = 0; /* updated in addMethod */
 	return true;
@@ -1191,7 +1193,7 @@
 
 #ifdef KAFFE_VMDEBUG
 	/* Search down class for method name - don't allow duplicates */
-	for (ni = CLASS_NMETHODS(c), mt = CLASS_METHODS(c); --ni >= 0; ) {
+	for (ni = CLASS_NMETHODS(c), mt = Kaffe_get_class_methods(c); --ni >= 0; ) {
 		assert(! utf8ConstEqual (name, mt->name)
 		       || ! utf8ConstEqual (signature, METHOD_SIG(mt)));
 	}
@@ -1201,7 +1203,7 @@
 	dprintf("Adding method %s:%s%s (%x)\n", c->name->data, name->data, signature->data, access_flags);
     );
 
-	mt = &CLASS_METHODS(c)[CLASS_NMETHODS(c)];
+	mt = &(Kaffe_get_class_methods(c)[CLASS_NMETHODS(c)]);
 	utf8ConstAssign(mt->name, name);
 	METHOD_PSIG(mt) = parseSignature(signature, einfo);
 	if (METHOD_PSIG(mt) == NULL) {
@@ -2024,7 +2026,7 @@
 	 */
 	for (; super != NULL;  super = super->superclass) {
 		int j = CLASS_NMETHODS(super);
-		Method* mt = CLASS_METHODS(super);
+		Method* mt = Kaffe_get_class_methods(super);
 		for (; --j >= 0;  ++mt) {
 			/* skip methods that are private or static */
 			if ((mt->accflags & (ACC_PRIVATE|ACC_STATIC)) != 0)
@@ -2085,7 +2087,7 @@
 		class->msize = 0;
 	}
 
-	meth = CLASS_METHODS(class);
+	meth = Kaffe_get_class_methods(class);
 	i = CLASS_NMETHODS(class);
 	for (; --i >= 0; meth++) {
 		Hjava_lang_Class* super = class->superclass;
@@ -2130,7 +2132,7 @@
 	mtab = class->vtable->method;
 
 	/* now build a trampoline for each and every method */
-	meth = CLASS_METHODS(class);
+	meth = Kaffe_get_class_methods(class);
 	i = CLASS_NMETHODS(class);
 
 	for (; --i >= 0; meth++) {
@@ -2150,7 +2152,7 @@
 	 * methods so they can be patched up independently
 	 */
 	for (cc = class->superclass; cc != 0; cc = cc->superclass) {
-		meth = CLASS_METHODS(cc);
+		meth = Kaffe_get_class_methods(cc);
 		i = CLASS_NMETHODS(cc);
 		for (; --i >= 0; meth++) {
 			void **where;
@@ -2230,7 +2232,7 @@
 	j = 1;
 	for (i = 0; i < class->total_interface_len; i++) {
 		int inm = CLASS_NMETHODS(class->interfaces[i]);
-		Method *imeth = CLASS_METHODS(class->interfaces[i]);
+		Method *imeth = Kaffe_get_class_methods(class->interfaces[i]);
 
 		/* store interface as first word for type inclusion test */
 		class->itable2dtable[j++] = class->interfaces[i];
@@ -2250,7 +2252,7 @@
 			 */
 			for (ncl = class; ncl != NULL;  ncl = ncl->superclass) {
 				int k = CLASS_NMETHODS(ncl);
-				cmeth = CLASS_METHODS(ncl);
+				cmeth = Kaffe_get_class_methods(ncl);
 				for (; --k >= 0;  ++cmeth) {
 					if (utf8ConstEqual (cmeth->name,
 							    imeth->name) &&
@@ -2479,7 +2481,7 @@
 	Method* meth;
 	int i;
 
-	meth = CLASS_METHODS(class);
+	meth = Kaffe_get_class_methods(class);
 	class->msize = 0;
 
 	/* enumerate indices and store them in meth->idx */
@@ -2895,7 +2897,7 @@
 			return (NULL);
 		}
 
-		arr_class = CLASS_ARRAY_CACHE(c);
+		arr_class = Kaffe_get_primitive_array_cache(c);
 		if (arr_class) {
 			return (arr_class);
 		}
@@ -2973,7 +2975,7 @@
 		centry->data.cl = c = NULL;
 		goto bail;
 	}
-	CLASS_ELEMENT_TYPE(arr_class) = c;
+	Kaffe_set_array_element_type(arr_class, c);
 
 	/* Add the interfaces that arrays implement.  Note that addInterface
 	 * will hold on to arr_interfaces, so it must be a static variable.
@@ -2998,7 +3000,7 @@
 
 	found:;
 	if (c && CLASS_IS_PRIMITIVE(c)) {
-		CLASS_ARRAY_CACHE(c) = centry->data.cl;
+		Kaffe_set_primitive_array_cache(c, centry->data.cl);
 	}
 	
 #if defined(KAFFE_XDEBUGGING)
Index: kaffe/kaffe/kaffevm/classMethod.h
diff -u kaffe/kaffe/kaffevm/classMethod.h:1.91 kaffe/kaffe/kaffevm/classMethod.h:1.92
--- kaffe/kaffe/kaffevm/classMethod.h:1.91	Thu May 25 22:26:40 2006
+++ kaffe/kaffe/kaffevm/classMethod.h	Sun Jun 11 23:12:10 2006
@@ -12,6 +12,8 @@
 #ifndef __classmethod_h
 #define __classmethod_h
 
+#include <assert.h>
+
 #include "gtypes.h"
 #include "machine.h"
 #include "access.h"
@@ -117,7 +119,11 @@
 	/* For regular classes, an array of the methods defined in this class.
 	   For array types, used for CLASS_ELEMENT_TYPE.
 	   For primitive types, used by CLASS_ARRAY_CACHE. */
-	Method*			methods;
+        union {
+	  Method*		       methods;
+	  struct Hjava_lang_Class*     element_type;
+	  struct Hjava_lang_Class*     array_cache;
+	} cache;
 	short			method_count;
 
 	/* Number of methods in the dtable. */
@@ -419,7 +425,6 @@
 struct _field_info;
 struct classFile;
 
-#define CLASS_METHODS(CLASS)  ((CLASS)->methods)
 #define CLASS_NMETHODS(CLASS)  ((CLASS)->method_count)
 
 /* An array containing all the Fields, static fields first. */
@@ -467,11 +472,97 @@
 #define	CLASS_IS_ABSTRACT(CL) ((CL)->accflags & ACC_ABSTRACT)
 #define	CLASS_IS_FINAL(CL) ((CL)->accflags & ACC_FINAL)
 
-/* For an array type, the types of the elements. */
-#define CLASS_ELEMENT_TYPE(ARRAYCLASS) (*(Hjava_lang_Class**)&(ARRAYCLASS)->methods)
+/**
+ * get array of methods in class.
+ * 
+ * @param clazz the class
+ *
+ * @return methods in the class
+ */
+static inline 
+Method * 
+Kaffe_get_class_methods(struct Hjava_lang_Class * clazz)
+{
+  return clazz->cache.methods;
+}
+
+/**
+ * set array of methods in class.
+ *
+ * @param clazz the class
+ * @param methods the methods to set
+ */
+static inline 
+void 
+Kaffe_set_class_methods(struct Hjava_lang_Class * clazz,
+			Method * methods)
+{
+  clazz->cache.methods = methods;
+}
+
+/**
+ * get type of elements in an array class.
+ * 
+ * @param arrayclazz the class
+ *
+ * @return  type of elements in the array class
+ */
+static inline 
+Hjava_lang_Class * 
+Kaffe_get_array_element_type(struct Hjava_lang_Class * arrayclazz)
+{
+  assert(CLASS_IS_ARRAY(arrayclazz));
+
+  return arrayclazz->cache.element_type;
+}
+
+/**
+ * set type of elements in an array class.
+ *
+ * @param arrayclazz the class
+ * @param element_type the type to set
+ */
+static inline 
+void 
+Kaffe_set_array_element_type(struct Hjava_lang_Class * arrayclazz,
+			     Hjava_lang_Class * element_type)
+{
+  assert(CLASS_IS_ARRAY(arrayclazz));
+
+  arrayclazz->cache.element_type = element_type;
+}
+
+/**
+ * get array cache of a primitive class.
+ * 
+ * @param primitive_clazz the class
+ *
+ * @return  array_cache of the primitive class
+ */
+static inline 
+Hjava_lang_Class * 
+Kaffe_get_primitive_array_cache(struct Hjava_lang_Class * primitive_clazz)
+{
+  assert(CLASS_IS_PRIMITIVE(primitive_clazz));
+
+  return primitive_clazz->cache.array_cache;
+}
+
+/**
+ * set array cache in primitive class.
+ *
+ * @param primitive_clazz the class
+ * @param array_cache the new value
+ */
+static inline 
+void 
+Kaffe_set_primitive_array_cache(struct Hjava_lang_Class * primitive_clazz,
+			     Hjava_lang_Class * array_cache)
+{
+  assert(CLASS_IS_PRIMITIVE(primitive_clazz));
 
-/* Used by the lookupArray function. */
-#define CLASS_ARRAY_CACHE(PRIMTYPE) (*(Hjava_lang_Class**)&(PRIMTYPE)->methods)
+  primitive_clazz->cache.array_cache = array_cache;
+}
 
 #define TYPE_PRIM_SIZE(CL) ((CL)->size_in_bytes)
 #define TYPE_SIZE(CL) \
Index: kaffe/kaffe/kaffevm/classPool.c
diff -u kaffe/kaffe/kaffevm/classPool.c:1.39 kaffe/kaffe/kaffevm/classPool.c:1.40
--- kaffe/kaffe/kaffevm/classPool.c:1.39	Sat Apr 22 23:42:06 2006
+++ kaffe/kaffe/kaffevm/classPool.c	Sun Jun 11 23:12:10 2006
@@ -147,7 +147,7 @@
 		for (entry = classEntryPool[ipool];  entry != NULL; entry = entry->next) {
 			if (entry->data.cl != 0) {
 				imeth = CLASS_NMETHODS(entry->data.cl);
-				ptr = CLASS_METHODS(entry->data.cl);
+				ptr = Kaffe_get_class_methods(entry->data.cl);
 				for (; --imeth >= 0;  ptr++) {
 					uintp ncode;
 					if (!METHOD_TRANSLATED(ptr)) {
@@ -608,11 +608,11 @@
 
 	/* methods only if we have some */
 	if (!CLASS_IS_PRIMITIVE(clazz) && !CLASS_IS_ARRAY(clazz)
-		&& CLASS_METHODS(clazz) != 0)
+		&& Kaffe_get_class_methods(clazz) != NULL)
 	{
-		Method *m = CLASS_METHODS(clazz);
+		Method *m = Kaffe_get_class_methods(clazz);
 		int i, n = CLASS_NMETHODS(clazz);
-		misc += SIZE_IFNONZERO(CLASS_METHODS(clazz));
+		misc += SIZE_IFNONZERO(Kaffe_get_class_methods(clazz));
 		for (i = 0; i < n; m++, i++) {
 			miscfixed += SIZE_IFNONZERO(m->parsed_sig);
 			miscfixed += SIZE_IFNONZERO(m->lines);
Index: kaffe/kaffe/kaffevm/code.c
diff -u kaffe/kaffe/kaffevm/code.c:1.21 kaffe/kaffe/kaffevm/code.c:1.22
--- kaffe/kaffe/kaffevm/code.c:1.21	Sat May 14 21:46:31 2005
+++ kaffe/kaffe/kaffevm/code.c	Sun Jun 11 23:12:10 2006
@@ -107,8 +107,8 @@
 				     "Code of a method has length 0",
 				     m->class->name->data,
 				     m->name->data,
-				     m->class->
-				     methods[m - CLASS_METHODS(m->class)].
+				     Kaffe_get_class_methods(m->class)
+				     [m - Kaffe_get_class_methods(m->class)].
 				     parsed_sig->signature->data);
 	}
 	else
@@ -119,8 +119,8 @@
 				     "Code of a method longer than 65535 bytes",
 				     m->class->name->data,
 				     m->name->data,
-				     m->class->
-				     methods[m - CLASS_METHODS(m->class)].
+				     Kaffe_get_class_methods(m->class)
+				     [m - Kaffe_get_class_methods(m->class)].
 				     parsed_sig->signature->data);
 	}
 	return (retval);
Index: kaffe/kaffe/kaffevm/gcFuncs.c
diff -u kaffe/kaffe/kaffevm/gcFuncs.c:1.85 kaffe/kaffe/kaffevm/gcFuncs.c:1.86
--- kaffe/kaffe/kaffevm/gcFuncs.c:1.85	Thu May 25 22:26:40 2006
+++ kaffe/kaffe/kaffevm/gcFuncs.c	Sun Jun 11 23:12:10 2006
@@ -112,8 +112,8 @@
         }
 
         /* destroy all methods, only if this class has indeed a method table */
-        if (!CLASS_IS_ARRAY(clazz) && CLASS_METHODS(clazz) != 0) {
-                Method *m = CLASS_METHODS(clazz);
+        if (!CLASS_IS_ARRAY(clazz) && Kaffe_get_class_methods(clazz) != NULL) {
+                Method *m = Kaffe_get_class_methods(clazz);
                 for (i = 0; i < CLASS_NMETHODS(clazz); i++) {
 			void *ncode = NULL;
 
@@ -151,7 +151,7 @@
 			/* ncode is swept by the GC. */
 			m++;
                 }
-                KFREE(CLASS_METHODS(clazz));
+                KFREE(Kaffe_get_class_methods(clazz));
         }
 
         /* release remaining refs to utf8consts in constant pool */
@@ -437,7 +437,7 @@
                 }
         } else {
                 /* array classes should keep their element type alive */
-		Hjava_lang_Class *etype = CLASS_ELEMENT_TYPE(class);
+		Hjava_lang_Class *etype = Kaffe_get_array_element_type(class);
 		if (etype && !CLASS_IS_PRIMITIVE(etype)) {
 			KGC_markObject(collector, gc_info, etype);
 		}
@@ -462,8 +462,8 @@
 
         /* CLASS_METHODS only points to the method array for non-array and
          * non-primitive classes */
-        if (!CLASS_IS_PRIMITIVE(class) && !CLASS_IS_ARRAY(class) && CLASS_METHODS(class) != 0) {
-                walkMethods(collector, gc_info, CLASS_METHODS(class), CLASS_NMETHODS(class));
+        if (!CLASS_IS_PRIMITIVE(class) && !CLASS_IS_ARRAY(class) && Kaffe_get_class_methods(class) != 0) {
+                walkMethods(collector, gc_info, Kaffe_get_class_methods(class), CLASS_NMETHODS(class));
         }
         KGC_markObject(collector, gc_info, class->loader);
 	KGC_markObject(collector, gc_info, class->signers);
Index: kaffe/kaffe/kaffevm/lookup.c
diff -u kaffe/kaffe/kaffevm/lookup.c:1.49 kaffe/kaffe/kaffevm/lookup.c:1.50
--- kaffe/kaffe/kaffevm/lookup.c:1.49	Mon Apr 17 17:57:07 2006
+++ kaffe/kaffe/kaffevm/lookup.c	Sun Jun 11 23:12:10 2006
@@ -339,7 +339,7 @@
 	 * Also there is no attempt to honour PUBLIC, PRIVATE, etc.
 	 */
 	n = CLASS_NMETHODS(class);
-	for (mptr = CLASS_METHODS(class); --n >= 0; ++mptr) {
+	for (mptr = Kaffe_get_class_methods(class); --n >= 0; ++mptr) {
 		if (utf8ConstEqual (name, mptr->name) && utf8ConstEqual (signature, METHOD_SIG(mptr))) {
 DBG(MLOOKUP,
 			dprintf("findMethodLocal(%s,%s,%s) -> %p\n",
Index: kaffe/kaffe/kaffevm/object.c
diff -u kaffe/kaffe/kaffevm/object.c:1.38 kaffe/kaffe/kaffevm/object.c:1.39
--- kaffe/kaffe/kaffevm/object.c:1.38	Thu Apr  6 01:39:10 2006
+++ kaffe/kaffe/kaffevm/object.c	Sun Jun 11 23:12:10 2006
@@ -241,7 +241,7 @@
       return NULL;
     }
   
-  obj = newArrayChecked(CLASS_ELEMENT_TYPE(clazz), (jsize)dims[0], einfo);
+  obj = newArrayChecked(Kaffe_get_array_element_type(clazz), (jsize)dims[0], einfo);
   if (!obj)
     return NULL;
   
@@ -252,7 +252,7 @@
     {
       int localdim = dims[j];
       
-      prevclazz = CLASS_ELEMENT_TYPE(clazz);
+      prevclazz = Kaffe_get_array_element_type(clazz);
       for (i=0;i<stacksize;i++)
 	{
 	  int localptr = stackptr + stacksize + i*localdim;
@@ -261,7 +261,7 @@
 	  for (k=0;k<localdim;k++)
 	  {
 	    stack[localptr+k] = array[k] = 
-	      newArrayChecked(CLASS_ELEMENT_TYPE(prevclazz), (jsize)dims[j+1], einfo);
+	      newArrayChecked(Kaffe_get_array_element_type(prevclazz), (jsize)dims[j+1], einfo);
 	    if (array[k] == NULL)
 	      return NULL;
 	  }
Index: kaffe/kaffe/kaffevm/reflect.c
diff -u kaffe/kaffe/kaffevm/reflect.c:1.5 kaffe/kaffe/kaffevm/reflect.c:1.6
--- kaffe/kaffe/kaffevm/reflect.c:1.5	Tue Apr 18 18:31:52 2006
+++ kaffe/kaffe/kaffevm/reflect.c	Sun Jun 11 23:12:10 2006
@@ -111,7 +111,7 @@
 	Hjava_lang_reflect_Constructor* meth;
 	Method* mth;
 
-	mth = CLASS_METHODS(clazz) + slot;
+	mth = Kaffe_get_class_methods(clazz) + slot;
 	meth = (Hjava_lang_reflect_Constructor*)
 	    AllocObject("java/lang/reflect/Constructor", NULL);
 
@@ -129,7 +129,7 @@
 	Hjava_lang_reflect_Method* meth;
 	Method* mth;
 
-	mth = CLASS_METHODS(clazz) + slot;
+	mth = Kaffe_get_class_methods(clazz) + slot;
 	meth = (Hjava_lang_reflect_Method*)
 	    AllocObject("java/lang/reflect/Method", NULL);
 
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.81 kaffe/kaffe/kaffevm/soft.c:1.82
--- kaffe/kaffe/kaffevm/soft.c:1.81	Sun Mar  5 14:35:26 2006
+++ kaffe/kaffe/kaffevm/soft.c	Sun Jun 11 23:12:10 2006
@@ -345,8 +345,8 @@
 	/* Skip as many arrays of arrays as we can.  We stop when we find
 	 * a base class in either. */
 	while (CLASS_IS_ARRAY(c) && CLASS_IS_ARRAY(oc)) {
-		c = CLASS_ELEMENT_TYPE(c);
-		oc = CLASS_ELEMENT_TYPE(oc);
+		c = Kaffe_get_array_element_type(c);
+		oc = Kaffe_get_array_element_type(oc);
 	}
 
 	/* If we are still casting to an array then we have failed already */
@@ -614,7 +614,7 @@
 void
 soft_checkarraystore(Hjava_lang_Object* array, Hjava_lang_Object* obj)
 {
-	if (obj != NULL && soft_instanceof(CLASS_ELEMENT_TYPE(OBJECT_CLASS(array)), obj) == 0) {
+	if (obj != NULL && soft_instanceof(Kaffe_get_array_element_type(OBJECT_CLASS(array)), obj) == 0) {
 		Hjava_lang_Throwable* asexc;
 		const char *otype = CLASS_CNAME(OBJECT_CLASS(obj));
 		const char *atype = CLASS_CNAME(OBJECT_CLASS(array));
Index: kaffe/kaffe/kaffevm/gcj/gcj-class.cc
diff -u kaffe/kaffe/kaffevm/gcj/gcj-class.cc:1.4 kaffe/kaffe/kaffevm/gcj/gcj-class.cc:1.5
--- kaffe/kaffe/kaffevm/gcj/gcj-class.cc:1.4	Fri Dec 10 06:23:55 1999
+++ kaffe/kaffe/kaffevm/gcj/gcj-class.cc	Sun Jun 11 23:12:10 2006
@@ -291,7 +291,7 @@
 	fprintf(stderr, "\n");
 
 	for (int i = 0; i < clazz->method_count; i++) {
-		dumpMethod(clazz->methods + i);
+		dumpMethod(Kaffe_get_class_methods(clazz) + i);
 	}
 	for (int i = 0; i < clazz->field_count; i++) {
 		dumpField(clazz->fields + i);
@@ -422,7 +422,7 @@
 
 	for (int i = 0; i < clazz->method_count; i++) {
 		neutralMethodInfo minfo;
-		_Jv_Method *meth = clazz->methods + i;
+		_Jv_Method *meth = Kaffe_get_class_methods(clazz) + i;
 		fillInMethodInfo(&minfo, meth);
 		/* A final classes's methods are automatically final and
 		 * so are private methods.
Index: kaffe/kaffe/kaffevm/gcj/gcj-glue.c
diff -u kaffe/kaffe/kaffevm/gcj/gcj-glue.c:1.11 kaffe/kaffe/kaffevm/gcj/gcj-glue.c:1.12
--- kaffe/kaffe/kaffevm/gcj/gcj-glue.c:1.11	Sat Apr 22 01:53:41 2006
+++ kaffe/kaffe/kaffevm/gcj/gcj-glue.c	Sun Jun 11 23:12:11 2006
@@ -158,9 +158,10 @@
 						   other gcj class */
 
 	if (info->methodCount > 0) {
-		class->methods = gc_malloc(sizeof(Method) * info->methodCount, 
-					   GC_ALLOC_METHOD);
-		if (class->methods == 0) {
+		Kaffe_set_class_methods(class->methods,
+					gc_malloc(sizeof(Method) * info->methodCount, 
+						  GC_ALLOC_METHOD));
+		if (Kaffe_get_class_methods(class) == NULL) {
 			goto oom;
 		}
 	}
@@ -232,7 +233,7 @@
 	Utf8Const *signature;
 	static 	char buf[1024];
 
-        Method *mt = &CLASS_METHODS(c)[CLASS_NMETHODS(c)];
+        Method *mt = &(Kaffe_get_class_methods(c)[CLASS_NMETHODS(c)]);
 	mt->name = utf8ConstFromString(info->name);
 
 	classname2pathname(info->signature, buf);
@@ -590,7 +591,7 @@
         for (; kclass != 0; kclass = kclass->superclass) {
 
 		int n = CLASS_NMETHODS(kclass);        
-		for (meth = CLASS_METHODS(kclass); --n >= 0; ++meth) {
+		for (meth = Kaffe_get_class_methods(kclass); --n >= 0; ++meth) {
 
 			/* Ouch.  GCJ keeps signatures in dotted form, we 
 			 * keep them in slashed form.
@@ -648,7 +649,7 @@
 
 	for (cc = kclass; cc; cc = cc->superclass) {
 		int  nm = CLASS_NMETHODS(cc);
-		meth = CLASS_METHODS(cc);
+		meth = Kaffe_get_class_methods(cc);
 		while (nm-- > 0) {
 			if (!strcmp(mname, meth->name->data) &&
 			    !strncmp(msig, METHOD_SIGD(meth), msiglen)) 
Index: kaffe/kaffe/kaffevm/jit/machine.c
diff -u kaffe/kaffe/kaffevm/jit/machine.c:1.86 kaffe/kaffe/kaffevm/jit/machine.c:1.87
--- kaffe/kaffe/kaffevm/jit/machine.c:1.86	Sat Apr 22 23:42:07 2006
+++ kaffe/kaffe/kaffevm/jit/machine.c	Sun Jun 11 23:12:11 2006
@@ -983,7 +983,8 @@
 	Method *meth;
 	int mindex;
 
-	for (mindex = CLASS_NMETHODS(clazz), meth = clazz->methods; mindex-- > 0; meth++) {
+	for (mindex = CLASS_NMETHODS(clazz), meth = Kaffe_get_class_methods(clazz);
+	     mindex-- > 0; meth++) {
 		if (meth->callsCount == 0)
 			continue;
 
Index: kaffe/kaffe/kaffevm/jit3/machine.c
diff -u kaffe/kaffe/kaffevm/jit3/machine.c:1.83 kaffe/kaffe/kaffevm/jit3/machine.c:1.84
--- kaffe/kaffe/kaffevm/jit3/machine.c:1.83	Sat Apr 22 23:42:07 2006
+++ kaffe/kaffe/kaffevm/jit3/machine.c	Sun Jun 11 23:12:11 2006
@@ -1421,7 +1421,7 @@
 	Method *meth;
 	int mindex;
 
-	for (mindex = CLASS_NMETHODS(clazz), meth = CLASS_METHODS(clazz); mindex-- > 0; meth++) {
+	for (mindex = CLASS_NMETHODS(clazz), meth = Kaffe_get_class_methods(clazz); mindex-- > 0; meth++) {
 		if (meth->callsCount == 0)
 			continue;
 
Index: kaffe/kaffe/kaffevm/jni/jni-helpers.c
diff -u kaffe/kaffe/kaffevm/jni/jni-helpers.c:1.14 kaffe/kaffe/kaffevm/jni/jni-helpers.c:1.15
--- kaffe/kaffe/kaffevm/jni/jni-helpers.c:1.14	Tue Apr 18 18:31:52 2006
+++ kaffe/kaffe/kaffevm/jni/jni-helpers.c	Sun Jun 11 23:12:11 2006
@@ -116,7 +116,7 @@
   method_local = unveil(method);
   realMethod = (Hjava_lang_reflect_Method *)method_local;
 
-  id = (jmethodID) &(unhand(realMethod)->declaringClass->methods[unhand(realMethod)->slot]);
+  id = (jmethodID) &(Kaffe_get_class_methods(unhand(realMethod)->declaringClass)[unhand(realMethod)->slot]);
 
   END_EXCEPTION_HANDLING();
 
@@ -155,7 +155,7 @@
 	cls_local = unveil(cls);
 	clazz = (Hjava_lang_Class *)cls_local;
 	refMeth = NULL;
-	for (allMethods = CLASS_METHODS(clazz), i = 0;
+	for (allMethods = Kaffe_get_class_methods(clazz), i = 0;
 	     i < CLASS_NMETHODS(clazz); 
 	     i++, allMethods++)
 	  {
Index: kaffe/kaffe/kaffevm/jni/jni.c
diff -u kaffe/kaffe/kaffevm/jni/jni.c:1.44 kaffe/kaffe/kaffevm/jni/jni.c:1.45
--- kaffe/kaffe/kaffevm/jni/jni.c:1.44	Sat Apr 22 01:53:41 2006
+++ kaffe/kaffe/kaffevm/jni/jni.c	Sun Jun 11 23:12:11 2006
@@ -690,7 +690,7 @@
 
 	cls_local = unveil(cls);
 
-	meth = CLASS_METHODS((Hjava_lang_Class*)cls_local);
+	meth = Kaffe_get_class_methods((Hjava_lang_Class*)cls_local);
 	nmeth = CLASS_NMETHODS((Hjava_lang_Class*)cls_local);
 
 	for (j = 0; j < nmethods; j++) {
Index: kaffe/kaffe/kaffevm/verifier/verify.c
diff -u kaffe/kaffe/kaffevm/verifier/verify.c:1.16 kaffe/kaffe/kaffevm/verifier/verify.c:1.17
--- kaffe/kaffe/kaffevm/verifier/verify.c:1.16	Wed Sep 28 02:02:21 2005
+++ kaffe/kaffe/kaffevm/verifier/verify.c	Sun Jun 11 23:12:12 2006
@@ -283,7 +283,7 @@
 	});
 	
 	
-	for (n = CLASS_NMETHODS(class), method = CLASS_METHODS(class);
+	for (n = CLASS_NMETHODS(class), method = Kaffe_get_class_methods(class);
 	     n > 0;
 	     --n, ++method) {
 		
Index: kaffe/kaffe/kaffevm/verifier/verify2.c
diff -u kaffe/kaffe/kaffevm/verifier/verify2.c:1.7 kaffe/kaffe/kaffevm/verifier/verify2.c:1.8
--- kaffe/kaffe/kaffevm/verifier/verify2.c:1.7	Thu May 25 22:26:41 2006
+++ kaffe/kaffe/kaffevm/verifier/verify2.c	Sun Jun 11 23:12:12 2006
@@ -347,7 +347,7 @@
 			Method* method;
 			int n;
 		
-			for (n = CLASS_NMETHODS(class), method = CLASS_METHODS(class);
+			for (n = CLASS_NMETHODS(class), method = Kaffe_get_class_methods(class);
 			     n > 0;
 			     --n, ++method) {
 				
@@ -387,7 +387,7 @@
 			int n, m;
 			
 			
-			for (n = CLASS_NMETHODS(class), curMethod = CLASS_METHODS(class);
+			for (n = CLASS_NMETHODS(class), curMethod = Kaffe_get_class_methods(class);
 			     n > 0;
 			     --n, ++curMethod) {
 			
@@ -405,7 +405,7 @@
 			for (superclass = class->superclass; superclass != NULL; superclass = superclass->superclass) {
 				
 			        /* cycle through methods in current super class */
-				for (m = CLASS_NMETHODS(superclass), method = CLASS_METHODS(superclass);
+				for (m = CLASS_NMETHODS(superclass), method = Kaffe_get_class_methods(superclass);
 				     m > 0;
 				     --m, ++method) {
 					
@@ -416,7 +416,7 @@
 					     strcmp("this", METHOD_NAMED(method)))) {
 						
 					        /* make sure the method in question was not overriden in the current class */
-						for (n = CLASS_NMETHODS(class), curMethod = CLASS_METHODS(class);
+						for (n = CLASS_NMETHODS(class), curMethod = Kaffe_get_class_methods(class);
 						     n > 0;
 						     --n, ++curMethod) {
 						
===================================================================
Checking out kaffe/kaffe/xprof/debugFile.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/xprof/debugFile.c,v
VERS: 1.9
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/xprof/debugFile.c	Sun Jun 11 23:23:48 2006
@@ -0,0 +1,640 @@
+/*
+ * debugFile.c
+ * Routines for generating an assembly file with debugging information
+ *
+ * Copyright (c) 2000, 2004 University of Utah and the Flux Group.
+ * All rights reserved.
+ *
+ * This file is licensed under the terms of the GNU Public License.
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * Contributed by the Flux Research Group, Department of Computer Science,
+ * University of Utah, http://www.cs.utah.edu/flux/
+ */
+
+#include "config.h"
+
+#if defined(KAFFE_XDEBUGGING) || defined(KAFFE_XPROFILER)
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stab.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "kaffe/jmalloc.h"
+#include "classMethod.h"
+#include "code.h"
+
+#include "mangle.h"
+#include "debugFile.h"
+#include "xprofiler.h"
+
+struct debug_file *machine_debug_file;
+const char *machine_debug_filename = 0;
+
+/**
+ * Header to be added to every debug file.
+ */
+static const char *debug_header = "This file was automatically generated by Kaffe";
+
+/**
+ * Builtin types to add to the debugging file.
+ */
+static const char *types_header =
+".stabs \"int:t1=r1;0020000000000;0017777777777;\",128,0,0,0\n"
+".stabs \" :t2=*1;\",128,0,0,0\n"
+".stabs \"byte:t3=r3;-128;127;\",128,0,0,0\n"
+".stabs \" :t4=*3;\",128,0,0,0\n"
+".stabs \"short:t5=r5;-32768;32767;\",128,0,0,0\n"
+".stabs \" :t6=*5;\",128,0,0,0\n"
+".stabs \"jchar:t7=-30;\",128,0,0,0\n"
+".stabs \" :t8=*7;\",128,0,0,0\n"
+".stabs \"long:t9=r1;01000000000000000000000;0777777777777777777777;\",128,0,0,0\n"
+".stabs \" :t10=*9;\",128,0,0,0\n"
+".stabs \"float:t11=r1;4;0;\",128,0,0,0\n"
+".stabs \" :t12=*11;\",128,0,0,0\n"
+".stabs \"double:t13=r1;8;0;\",128,0,0,0\n"
+".stabs \" :t14=*13;\",128,0,0,0\n"
+".stabs	\"boolean:t15=@s8;eFalse:0,True:1,;\",128,0,0,0\n"
+".stabs \" :t16=*15;\",128,0,0,0\n"
+".stabs \"void:t17=17\",128,0,0,0\n"
+".stabs \" :t18=*17\",128,0,0,0\n"
+".stabs \" :t19=*xs_dispatchTable:\",128,0,0,0\n"
+".stabs \" :t20=*xs_iLock:\",128,0,0,0\n"
+".stabs \"promoted_byte:t21=r21;0020000000000;0017777777777;\",128,0,0,0\n"
+".stabs \"promoted_short:t22=r22;0020000000000;0017777777777;\",128,0,0,0\n"
+".stabs \"promoted_char:t23=r23;0020000000000;0017777777777;\",128,0,0,0\n"
+".stabs \"promoted_boolean:t24=eFalse:0,True:1,;\",128,0,0,0\n";
+
+/**
+ * Symbols that represent protection values in stabs.
+ */
+typedef enum {
+	STP_PRIVATE = 0,
+	STP_PROTECTED = 1,
+	STP_PUBLIC = 2,
+} st_prot_t;
+
+struct debug_file *createDebugFile(const char *filename)
+{
+	struct debug_file *retval = 0;
+
+	assert(filename != NULL);
+	
+	/* Allocate space for the debug_file struct and filename */
+	if( (retval = (struct debug_file *)
+	     KMALLOC(sizeof(struct debug_file) + strlen(filename) + 1)) )
+	{
+		retval->df_filename = (char *)(retval + 1);
+		strcpy(retval->df_filename, filename);
+		retval->df_current_type_id = STYPE_MAX;
+		if( (retval->df_file = fopen(retval->df_filename, "w")) )
+		{
+			addDebugInfo(retval,
+				     DIA_SourceFile, "$xdb$.java", 0,
+				     DIA_Comment, debug_header,
+				     DIA_DONE);
+			fprintf(retval->df_file, "%s", types_header);
+		}
+		else
+		{
+			KFREE(retval);
+			retval = 0;
+		}
+	}
+	return( retval );
+}
+
+void deleteDebugFile(struct debug_file *df)
+{
+	if( df != NULL )
+	{
+		/* If there was an error in writing the file remove it */
+		if( ferror(df->df_file) )
+			remove(df->df_filename);
+		fclose(df->df_file);
+		KFREE(df);
+		df = NULL;
+	}
+}
+
+/**
+ * Convert Java access flags into a stabs protection value.
+ *
+ * @param af The Java style access flags to convert.
+ * @return The stabs protection value that the access flags map to.
+ */
+static inline st_prot_t acc2prot(accessFlags af)
+{
+    st_prot_t retval = STP_PUBLIC;
+    

*** Patch too long, truncated ***




More information about the kaffe mailing list