[kaffe] CVS kaffe (guilhem): Splitted callMethods + ClassLoader fix + doxification.

Kaffe CVS cvs-commits at kaffe.org
Thu Jun 23 09:51:54 PDT 2005


PatchSet 6660 
Date: 2005/06/23 16:43:54
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Splitted callMethods + ClassLoader fix + doxification.

	* kaffe/kaffevm/Makefile.am
	(libkaffevm_la_SOURCES): Added javacall.c

	* kaffe/kaffevm/Makefile.in: Regenerated.

	* kaffe/kaffevm/classMethod.c,
	kaffe/kaffevm/classMethod.h
	(initCollector): Moved to gc.h
	(parsed_signature): Added real_nargs.
	(PSIG_RNARGS): New macro.
	(KaffeVM_countRealNumberOfArgs): New function to retrieve the real
	number of argument slot used.

	Doxified a bit.

	* kaffe/kaffevm/gc.h
	(initCollector): Moved from classMethod.h

	* kaffe/kaffevm/javacall.c
	(KaffeVM_callMethodA, KaffeVM_callMethodV): Moved from support.c
	along with their macros.
	(KaffeVM_countRealNumberOfArgs): New function.

	kaffe/kaffevm/support.c:
	(KaffeVM_callMethodA, KaffeVM_callMethodV): Moved out.

	* libraries/clib/native/ClassLoader.c
	(loadClass): Check whether the class name is well constructed.

Members: 
	ChangeLog:1.4185->1.4186 
	kaffe/kaffevm/Makefile.am:INITIAL->1.76 
	kaffe/kaffevm/Makefile.in:1.201->1.202 
	kaffe/kaffevm/classMethod.c:1.146->1.147 
	kaffe/kaffevm/classMethod.h:1.81->1.82 
	kaffe/kaffevm/gc.h:INITIAL->1.32 
	kaffe/kaffevm/javacall.c:INITIAL->1.1 
	kaffe/kaffevm/support.c:1.86->1.87 
	libraries/clib/native/ClassLoader.c:1.46->1.47 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4185 kaffe/ChangeLog:1.4186
--- kaffe/ChangeLog:1.4185	Wed Jun 22 15:56:38 2005
+++ kaffe/ChangeLog	Thu Jun 23 16:43:54 2005
@@ -1,3 +1,34 @@
+2005-06-23  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/Makefile.am
+	(libkaffevm_la_SOURCES): Added javacall.c
+
+	* kaffe/kaffevm/Makefile.in: Regenerated.
+
+	* kaffe/kaffevm/classMethod.c,
+	kaffe/kaffevm/classMethod.h
+	(initCollector): Moved to gc.h
+	(parsed_signature): Added real_nargs.
+	(PSIG_RNARGS): New macro.
+	(KaffeVM_countRealNumberOfArgs): New function to retrieve the real
+	number of argument slot used.
+	
+	Doxified a bit.
+	
+	* kaffe/kaffevm/gc.h
+	(initCollector): Moved from classMethod.h
+
+	* kaffe/kaffevm/javacall.c
+	(KaffeVM_callMethodA, KaffeVM_callMethodV): Moved from support.c
+	along with their macros.
+	(KaffeVM_countRealNumberOfArgs): New function.
+	
+	kaffe/kaffevm/support.c:
+	(KaffeVM_callMethodA, KaffeVM_callMethodV): Moved out.
+
+	* libraries/clib/native/ClassLoader.c
+	(loadClass): Check whether the class name is well constructed.
+
 2005-06-23  Ito Kazumitsu  <kaz at maczuka.gcd.org>
 
 	* FAQ/FAQ.charsets: New file.
===================================================================
Checking out kaffe/kaffe/kaffevm/Makefile.am
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/Makefile.am,v
VERS: 1.76
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/Makefile.am	Thu Jun 23 16:51:53 2005
@@ -0,0 +1,183 @@
+# Makefile.am for kaffevm - a Java(tm) compatible virtual machine.
+#
+# Copyright (c) 1996, 1997, 1998, 1999
+#	Transvirtual Technologies, Inc.  All rights reserved.
+#
+# Copyright (c) 2004
+#	Kaffe.org contributors, see ChangeLogs for details.  All rights reserved.
+#
+# See the file "license.terms" for information on usage and redistribution 
+# of this file. 
+
+SUBDIRS = $(ENGINE_NAME) systems $(GC_NAME) gcj verifier jni
+DIST_SUBDIRS = boehm-gc kaffe-gc intrp jit jit3 systems gcj verifier jni
+
+EXTRA_DIST = \
+	kaffe.def \
+	systems/win32/winio.c \
+	systems/win32/winthread.c \
+	systems/win32/winthread.h
+
+ at engine_frag@
+AM_CPPFLAGS = \
+	-I$(top_srcdir)/kaffe/kaffevm/$(THREAD_DIR) \
+	-I$(top_srcdir)/kaffe/kaffevm/jni \
+	$(ENGINE_INCLUDES) \
+	-I$(top_srcdir)/libltdl \
+	$(ENGINE_DEFS) \
+	-I$(top_srcdir)/kaffe/jvmpi \
+	-I$(top_srcdir)/kaffe/xprof \
+	-I$(top_builddir)/include \
+	-I$(top_srcdir)/kaffe/kaffevm/verifier \
+	-I$(top_srcdir)/kaffe/kaffevm/jni
+
+native_LTLIBRARIES = libkaffevm.la
+
+ at cpu_frag@
+ at cpu_os_frag@
+ at threads_frag@
+ at gc_frag@
+
+if HAVE_GCJ_SUPPORT
+libgcj = gcj/libgcj.la
+else
+libgcj = #
+endif
+
+libkaffevm_la_CFLAGS = \
+	$(CFLAGS_PG) \
+	$(PTHREAD_CFLAGS)
+
+libkaffevm_la_LDFLAGS = \
+	$(PTHREAD_CFLAGS) \
+        $(PTHREAD_LIBS) \
+        $(SEMAPHORE_LIB) \
+	$(KVMLIBFLAGS) \
+	-no-undefined \
+	-export-dynamic \
+	-release $(PACKAGE_VERSION)
+
+libkaffevm_la_DEPENDENCIES = \
+	$(LIBLTDL) \
+	$(ENGINE_NAME)/libengine.la \
+	$(libgcj) \
+	systems/$(THREAD_SYSTEM)/libkthread.la \
+	verifier/libkaffeverifier.la \
+	$(GC_NAME)/libkaffegc.la \
+	jni/libkaffejni.la \
+        $(top_builddir)/replace/libreplace.la 
+
+libkaffevm_la_LIBADD = \
+	$(libkaffevm_la_DEPENDENCIES) \
+	$(VM_LIBS) \
+	$(M_LIBS)
+
+libkaffevm_la_GEN_SRCS = \
+	md.c
+
+nodist_libkaffevm_la_SOURCES = \
+	$(libkaffevm_la_GEN_SRCS)
+
+if ENABLE_BINRELOC
+BINRELOC_SOURCES=\
+	../../binreloc/prefix.c
+endif
+
+libkaffevm_la_SOURCES = \
+	access.c \
+	baseClasses.c \
+	classMethod.c \
+	classPool.c \
+	methodCache.c \
+	code-analyse.c \
+	code.c \
+	constants.c \
+	debug.c \
+	exception.c \
+	external.c \
+	file.c \
+	findInJar.c \
+	fp.c \
+	gc.c \
+	hashtab.c \
+	inflate.c \
+	itypes.c \
+	jar.c \
+	ksem.c \
+	locks.c \
+	lookup.c \
+	object.c \
+	readClass.c \
+	soft.c \
+	stackTrace.c \
+	stats.c \
+	string.c \
+	stringParsing.c \
+	support.c \
+	javacall.c \
+	thread.c \
+	utf8const.c \
+	gcFuncs.c \
+	reflect.c \
+	reference.c \
+	$(BINRELOC_SOURCES)
+
+noinst_HEADERS = \
+	access.h \
+	baseClasses.h \
+	bytecode.h \
+	classMethod.h \
+	methodCache.h \
+	classpath.h \
+	code-analyse.h \
+	code.h \
+	constants.h \
+	debug.h \
+	exception.h \
+	external.h \
+	file.h \
+	fp.h \
+	gc.h \
+	gtypes.h \
+	hashtab.h \
+	inflate.h \
+	itypes.h \
+	jar.h \
+	ksem.h \
+	lerrno.h \
+	locks.h \
+	lookup.h \
+	object.h \
+	readClass.h \
+	slib.h \
+	soft.h \
+	stackTrace.h \
+	stats.h \
+	stringParsing.h \
+	stringSupport.h \
+	support.h \
+	thread.h \
+	threadData.h \
+	utf8const.h \
+	reflect.h \
+	reference.h \
+	../../binreloc/prefix.h
+
+md.c: stamp-h01
+	@if test ! -f $@; then rm -f stamp-h01; $(MAKE) stamp-h01; \
+	else :; fi
+stamp-h01: $(top_builddir)/config.status
+	$(SHELL) $(REGEN_FORWARD) $(KAFFEVM_MD_C) md.c $@
+
+CLEANFILES = so_locations
+
+DISTCLEANFILES = md.c stamp-h01
+
+dist-hook:
+	@for file in $(DISTCLEANFILES); do \
+	  rm -f $(distdir)/$$file; \
+	done
+
+## This avoids that dependencies produced by `make dist' in a jit
+## configuration prevents intrp builds.
+jit/icode.h:
Index: kaffe/kaffe/kaffevm/Makefile.in
diff -u kaffe/kaffe/kaffevm/Makefile.in:1.201 kaffe/kaffe/kaffevm/Makefile.in:1.202
--- kaffe/kaffe/kaffevm/Makefile.in:1.201	Sat May 14 21:46:30 2005
+++ kaffe/kaffe/kaffevm/Makefile.in	Thu Jun 23 16:43:58 2005
@@ -100,8 +100,8 @@
 	debug.c exception.c external.c file.c findInJar.c fp.c gc.c \
 	hashtab.c inflate.c itypes.c jar.c ksem.c locks.c lookup.c \
 	object.c readClass.c soft.c stackTrace.c stats.c string.c \
-	stringParsing.c support.c thread.c utf8const.c gcFuncs.c \
-	reflect.c reference.c ../../binreloc/prefix.c
+	stringParsing.c support.c javacall.c thread.c utf8const.c \
+	gcFuncs.c reflect.c reference.c ../../binreloc/prefix.c
 @ENABLE_BINRELOC_TRUE at am__objects_1 = libkaffevm_la-prefix.lo
 am_libkaffevm_la_OBJECTS = libkaffevm_la-access.lo \
 	libkaffevm_la-baseClasses.lo libkaffevm_la-classMethod.lo \
@@ -118,10 +118,10 @@
 	libkaffevm_la-readClass.lo libkaffevm_la-soft.lo \
 	libkaffevm_la-stackTrace.lo libkaffevm_la-stats.lo \
 	libkaffevm_la-string.lo libkaffevm_la-stringParsing.lo \
-	libkaffevm_la-support.lo libkaffevm_la-thread.lo \
-	libkaffevm_la-utf8const.lo libkaffevm_la-gcFuncs.lo \
-	libkaffevm_la-reflect.lo libkaffevm_la-reference.lo \
-	$(am__objects_1)
+	libkaffevm_la-support.lo libkaffevm_la-javacall.lo \
+	libkaffevm_la-thread.lo libkaffevm_la-utf8const.lo \
+	libkaffevm_la-gcFuncs.lo libkaffevm_la-reflect.lo \
+	libkaffevm_la-reference.lo $(am__objects_1)
 am__objects_2 = libkaffevm_la-md.lo
 nodist_libkaffevm_la_OBJECTS = $(am__objects_2)
 libkaffevm_la_OBJECTS = $(am_libkaffevm_la_OBJECTS) \
@@ -515,6 +515,7 @@
 	string.c \
 	stringParsing.c \
 	support.c \
+	javacall.c \
 	thread.c \
 	utf8const.c \
 	gcFuncs.c \
@@ -653,6 +654,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-inflate.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-itypes.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-jar.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-javacall.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-ksem.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-locks.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libkaffevm_la-lookup.Plo at am__quote@
@@ -902,6 +904,13 @@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='support.c' object='libkaffevm_la-support.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libkaffevm_la_CFLAGS) $(CFLAGS) -c -o libkaffevm_la-support.lo `test -f 'support.c' || echo '$(srcdir)/'`support.c
+
+libkaffevm_la-javacall.lo: javacall.c
+ at am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libkaffevm_la_CFLAGS) $(CFLAGS) -MT libkaffevm_la-javacall.lo -MD -MP -MF "$(DEPDIR)/libkaffevm_la-javacall.Tpo" -c -o libkaffevm_la-javacall.lo `test -f 'javacall.c' || echo '$(srcdir)/'`javacall.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libkaffevm_la-javacall.Tpo" "$(DEPDIR)/libkaffevm_la-javacall.Plo"; else rm -f "$(DEPDIR)/libkaffevm_la-javacall.Tpo"; exit 1; fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='javacall.c' object='libkaffevm_la-javacall.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libkaffevm_la_CFLAGS) $(CFLAGS) -c -o libkaffevm_la-javacall.lo `test -f 'javacall.c' || echo '$(srcdir)/'`javacall.c
 
 libkaffevm_la-thread.lo: thread.c
 @am__fastdepCC_TRUE@	if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libkaffevm_la_CFLAGS) $(CFLAGS) -MT libkaffevm_la-thread.lo -MD -MP -MF "$(DEPDIR)/libkaffevm_la-thread.Tpo" -c -o libkaffevm_la-thread.lo `test -f 'thread.c' || echo '$(srcdir)/'`thread.c; \
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.146 kaffe/kaffe/kaffevm/classMethod.c:1.147
--- kaffe/kaffe/kaffevm/classMethod.c:1.146	Thu Jun  9 10:52:25 2005
+++ kaffe/kaffe/kaffevm/classMethod.c	Thu Jun 23 16:43:58 2005
@@ -2785,7 +2785,7 @@
 	return (size);
 }
 
-/*
+/**
  * Count the number of arguments in a signature.
  */
 int
@@ -2800,7 +2800,7 @@
 	return (nargs);
 }
 
-/*
+/**
  * Duplicates a parsed signature.
  */
 static parsed_signature_t*
@@ -2853,6 +2853,8 @@
 	}
 	++sig_iter; /* skip `)' */
 	PSIG_RET(sig) = sig_iter - signature->data;
+
+	PSIG_RNARGS(sig) = KaffeVM_countRealNumberOfArgs(sig); 
 
 	return sig;
 }
Index: kaffe/kaffe/kaffevm/classMethod.h
diff -u kaffe/kaffe/kaffevm/classMethod.h:1.81 kaffe/kaffe/kaffevm/classMethod.h:1.82
--- kaffe/kaffe/kaffevm/classMethod.h:1.81	Mon May 30 21:16:02 2005
+++ kaffe/kaffe/kaffevm/classMethod.h	Thu Jun 23 16:43:58 2005
@@ -296,6 +296,7 @@
 typedef struct _parsed_signature {
 	Utf8Const*		signature;
 	u2			nargs;
+	u2			real_nargs;
 	u2			ret_and_args[1]; /* index into signature */
 	/* ret_and_args[0]: return value
 	   ret_and_args[1]: first argument
@@ -347,8 +348,9 @@
 #define PSIG_UTF8(sig)		((sig)->signature)
 #define PSIG_DATA(sig)		(PSIG_UTF8((sig))->data)
 #define PSIG_RET(sig)		((sig)->ret_and_args[0])
-#define PSIG_NARGS(sig)		(sig->nargs)
+#define PSIG_NARGS(sig)		((sig)->nargs)
 #define PSIG_ARG(sig,n)		((sig)->ret_and_args[1+n])
+#define PSIG_RNARGS(sig)	((sig)->real_nargs)
 
 #define METHOD_PSIG(M)		((M)->parsed_sig)
 #define METHOD_SIG(M)		(PSIG_UTF8(METHOD_PSIG((M))))
@@ -509,17 +511,61 @@
 #define CLASS_CONST_USHORT2(CL, INDEX) \
   ((uint16)((CL)->constants.data[INDEX] >> 16))
 
-/*
+/**
  * 'processClass' is the core of the class initialiser and can prepare a
  * class from the cradle to the grave.
+ *
+ * @param clazz The class to process.
+ * @param state The state to achieve during this process.
+ * @param einfo An error which may have occured.
+ *
+ * @returns false if an error has occured, true if everything is ok.
+ */
+bool			processClass(Hjava_lang_Class* clazz, int state, errorInfo *einfo);
+
+/**
+ * This function loads a class using the given class loader if non-NULL else it uses the 
+ * internal bootstrap class loader to fetch classes. The classes are processed to the linked state.
+ * This function must not be used to "load" a class representing array. For that use loadArray.
+ * 
+ * @param name The name of the class to load.
+ * @param loader The loader to use. It may be NULL if you want to use the internal VM class loader.
+ * @param einfo The error structure to fill if something bad happens.
+ *
+ * @returns A valid class object if the load is successful, NULL otherwise.
+ */
+Hjava_lang_Class*	loadClass(Utf8Const* name, Hjava_lang_ClassLoader* loader, errorInfo *einfo);
+
+/**
+ * This function loads an array with the given name and using the given class loader. The array is usable directly
+ * after that call.
+ *
+ * @param name The name of the array to load.
+ * @param loader The loader to use. It may be NULL If you want to use the internal VM class loader.
+ * @param einfo The error structure to fill if something bad happens.
+ *
+ * @returns A valid class object if the load is successful, NULL otherwise.
  */
-bool			processClass(Hjava_lang_Class*, int, errorInfo *einfo);
+Hjava_lang_Class*	loadArray(Utf8Const* name, Hjava_lang_ClassLoader* loader, errorInfo *einfo);
 
-Hjava_lang_Class*	loadClass(Utf8Const*, Hjava_lang_ClassLoader*, errorInfo *einfo);
-Hjava_lang_Class*	loadArray(Utf8Const*, Hjava_lang_ClassLoader*, errorInfo *einfo);
+/**
+ * This function finds a class in a directory or in a jar file. It implements the internal VM class loader.
+ *
+ * @param centry The class entry representing the class to be loaded.
+ * @param einfo The error structure to fill if something bad happens.
+ *
+ * @returns A valid class object if the load is successful, NULL otherwise.
+ */
 Hjava_lang_Class*	findClass(struct _classEntry* centry, errorInfo *einfo);
 
-void			loadStaticClass(Hjava_lang_Class**, const char*);
+/**
+ * This function is used at the VM boot to preload some classes. The classes are loaded and put in the linked state.
+ * It cannot return an error. If an error happened the VM is aborted.
+ *
+ * @param clazz A pointer to the place where the class object should be put.
+ * @param name The name of the class to load.
+ */
+void			loadStaticClass(Hjava_lang_Class** clazz, const char* name);
 
 Hjava_lang_Class*	setupClass(Hjava_lang_Class*, constIndex,
 				   constIndex, u2, Hjava_lang_ClassLoader*, errorInfo*);
@@ -544,8 +590,6 @@
 int			removeClassEntries(Hjava_lang_ClassLoader*);
 void 			walkClassEntries(Collector *collector, void *gc_info, Hjava_lang_ClassLoader*);
 
-Collector* 		initCollector(void);
-
 Hjava_lang_Class*	lookupClass(const char*, Hjava_lang_ClassLoader*,
 				errorInfo*);
 Hjava_lang_Class*	lookupArray(Hjava_lang_Class*, errorInfo*);
@@ -562,6 +606,7 @@
 Hjava_lang_Class*	getClassFromSignature(const char*, Hjava_lang_ClassLoader*, errorInfo*);
 Hjava_lang_Class*	getClassFromSignaturePart(const char*, Hjava_lang_ClassLoader*, errorInfo*);
 int			countArgsInSignature(const char *);
+int			KaffeVM_countRealNumberOfArgs(parsed_signature_t *);
 parsed_signature_t*	parseSignature(Utf8Const *, errorInfo*);
 
 int			startFields(Hjava_lang_Class*, u2 fieldct, errorInfo*);
@@ -571,34 +616,38 @@
 struct Hjava_lang_String* resolveString(Hjava_lang_Class* clazz, int idx,
 					errorInfo *einfo);
 int			findPackageLength(const char *name);
-/*
+
+/**
  * Start a search for a class.  If no other thread is searching for this
  * mapping then the responsibility falls on the current thread.
  *
- * ce - The mapping to start searching for.
- * out_cl - A placeholder for the class if it has already been bound.
- * einfo - An uninitialized errorInfo object.
- * returns - True, if the class is already bound or if this thread should be
+ * @param ce The mapping to start searching for.
+ * @param out_cl A placeholder for the class if it has already been bound.
+ * @param einfo An uninitialized errorInfo object.
+ *
+ * @returns True, if the class is already bound or if this thread should be
  *   responsible for searching/loading the class.  False, if searching for this
  *   class would result in a class circularity.
  */
 int classMappingSearch(classEntry *ce,
 		       Hjava_lang_Class **out_cl,
 		       errorInfo *einfo);
-/*
+/**
  * Start loading a class.
  *
- * ce - The mapping to start searching for.
- * out_cl - A placeholder for the class if it has already been bound.
- * einfo - An uninitialized errorInfo object.
- * returns - True, if the class is already bound or if this thread should be
+ * @param ce The mapping to start searching for.
+ * @param out_cl A placeholder for the class if it has already been bound.
+ * @param einfo An uninitialized errorInfo object.
+ *
+ * @returns True, if the class is already bound or if this thread should be
  *   responsible for searching/loading the class.  False, if searching for this
  *   class would result in a class circularity.
  */
 int classMappingLoad(classEntry *ce,
 		     Hjava_lang_Class **out_cl,
 		     errorInfo *einfo);
-/*
+
+/**
  * Transition a mapping to the loaded state.
  *
  * ce - The name mapping whose state should be updated.
@@ -607,7 +656,8 @@
  *   it will be the value previously stored in the mapping.
  */
 Hjava_lang_Class *classMappingLoaded(classEntry *ce, Hjava_lang_Class *cl);
-/*
+
+/**
  * Force a mapping to a particular state.
  *
  * ce - The name mapping whose state should be updated.
@@ -615,8 +665,19 @@
  */
 void setClassMappingState(classEntry *ce, name_mapping_state_t nms);
 
+/**
+ * This function walks through the class pool and execute the given function
+ * for each class of the pool.
+ *
+ * @param walker A class walker.
+ * @param param A user parameter.
+ */
 void walkClassPool(int (*walker)(Hjava_lang_Class *clazz, void *), void *param);
 
+
+/**
+ * Initialize internal global variables of the class pool.
+ */
 void KaffeVM_initClassPool(void);
 
 extern Utf8Const* init_name;		/* "<clinit>" */
===================================================================
Checking out kaffe/kaffe/kaffevm/gc.h
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/gc.h,v
VERS: 1.32
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/gc.h	Thu Jun 23 16:51:53 2005
@@ -0,0 +1,240 @@
+/*
+ * gc.h
+ * The garbage collector.
+ *
+ * Copyright (c) 1996, 1997
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+#ifndef __gc_h
+#define __gc_h
+
+#include "gtypes.h"
+
+/*
+ * Default values for initial and maximum heap size and heap increment.
+ */
+#define	MIN_HEAPSIZE	(5*1024*1024)
+#define	MAX_HEAPSIZE	(64*1024*1024)
+#define	ALLOC_HEAPSIZE	(1024*1024)
+
+/* 
+ * We do not support incremental collection as this time.
+ */
+#undef	KGC_INCREMENTAL
+
+typedef struct _Collector Collector;
+typedef void (*walk_func_t)(struct _Collector* collector, void* gc_info, void* obj, uint32 size);
+typedef void (*final_func_t)(struct _Collector* collector, void* obj);
+typedef void (*destroy_func_t)(struct _Collector* collector, void* obj);
+
+#define	KGC_OBJECT_NORMAL	  ((final_func_t)0)
+#define	KGC_OBJECT_FIXED	  ((final_func_t)1)
+
+/*
+ * Garbage collector interface.
+ */
+typedef enum {
+	/* allocation types for different kinds of java objects */
+	KGC_ALLOC_JAVASTRING,
+	KGC_ALLOC_NOWALK,
+	KGC_ALLOC_NORMALOBJECT,
+	KGC_ALLOC_PRIMARRAY,
+	KGC_ALLOC_REFARRAY,
+	KGC_ALLOC_FINALIZEOBJECT,
+	KGC_ALLOC_JAVALOADER,
+
+	/* allocation types related to the translator engines */
+	KGC_ALLOC_JITCODE,
+	KGC_ALLOC_JITTEMP,
+	KGC_ALLOC_JIT_SEQ,
+	KGC_ALLOC_JIT_CONST,
+	KGC_ALLOC_JIT_ARGS,
+	KGC_ALLOC_JIT_FAKE_CALL,
+	KGC_ALLOC_JIT_SLOTS,
+	KGC_ALLOC_JIT_CODEBLOCK,
+	KGC_ALLOC_JIT_LABELS,
+	KGC_ALLOC_TRAMPOLINE,
+	
+	/* allocation types used for java.lang.Class and its parts */
+	KGC_ALLOC_CLASSOBJECT,
+	KGC_ALLOC_BYTECODE,
+	KGC_ALLOC_EXCEPTIONTABLE,
+	KGC_ALLOC_STATICDATA,
+	KGC_ALLOC_CONSTANT,
+	KGC_ALLOC_DISPATCHTABLE,
+	KGC_ALLOC_METHOD,
+	KGC_ALLOC_FIELD,
+	KGC_ALLOC_INTERFACE,
+	KGC_ALLOC_LINENRTABLE,
+	KGC_ALLOC_LOCALVARTABLE,
+	KGC_ALLOC_DECLAREDEXC,
+	KGC_ALLOC_INTERFACE_TABLE,
+	KGC_ALLOC_CLASSMISC,
+
+	/* miscelanious allocation types */
+	KGC_ALLOC_FIXED,
+	KGC_ALLOC_UTF8CONST,
+	KGC_ALLOC_LOCK,
+	KGC_ALLOC_THREADCTX,
+	KGC_ALLOC_STATIC_THREADDATA,
+	KGC_ALLOC_REF,
+	KGC_ALLOC_JAR,
+	KGC_ALLOC_CODEANALYSE,
+	KGC_ALLOC_CLASSPOOL,
+	KGC_ALLOC_VERIFIER,
+	KGC_ALLOC_NATIVELIB,
+	KGC_ALLOC_MAX_INDEX
+} gc_alloc_type_t;
+
+/*
+ * Define a COM-like GC interface.
+ */
+struct GarbageCollectorInterface_Ops;
+
+struct _Collector {
+	struct GarbageCollectorInterface_Ops *ops;
+};
+
+struct GarbageCollectorInterface_Ops {
+
+        const char * (*getCollectorName)(Collector *);
+	void*   reserved2;
+	void*   reserved3;
+	void*	(*malloc)(Collector *, size_t size, gc_alloc_type_t type);
+	void*	(*realloc)(Collector *, void* addr, size_t size, gc_alloc_type_t type);
+	void	(*free)(Collector *, void* addr);
+
+	void	(*invoke)(Collector *, int mustgc);
+	void	(*invokeFinalizer)(Collector *);
+	void	(*init)(Collector *);
+	void	(*enable)(Collector *);
+
+	void	(*markAddress)(Collector *, void *gc_info, const void* addr);
+	void	(*markObject)(Collector *, void *gc_info, const void* obj);
+	uint32	(*getObjectSize)(Collector *, const void* obj);
+	const char* (*getObjectDescription)(Collector *, const void* obj);
+	int	(*getObjectIndex)(Collector *, const void* obj);
+	void*	(*getObjectBase)(Collector *, void* obj);
+
+	void	(*registerFixedTypeByIndex)(Collector *, 
+			gc_alloc_type_t gc_index, const char *description);
+
+	void 	(*registerGcTypeByIndex)(Collector *, 
+			gc_alloc_type_t gc_index,
+			walk_func_t walk, final_func_t final, 
+			destroy_func_t destroy, const char
+					 *description);
+	struct Hjava_lang_Throwable *(*throwOOM)(Collector *);
+
+	void 	(*enableGC)(Collector *);
+	void 	(*disableGC)(Collector *);
+
+        uintp   (*getHeapFree)(Collector *); 
+        uintp   (*getHeapLimit)(Collector *);
+        uintp   (*getHeapTotal)(Collector *);
+
+        bool    (*addRef)(Collector *, const void *mem);
+        bool    (*rmRef)(Collector *, void *ref);
+        bool    (*addWeakRef)(Collector *, void *mem, void **ref);
+        bool    (*rmWeakRef)(Collector *, void *mem, void **ref);
+};
+
+Collector* createGC(void);
+
+/*
+ * Convenience macros
+ */
+#define KGC_malloc(G, size, type)	\
+    ((G)->ops->malloc)((Collector*)(G), (size), (type))
+#define KGC_realloc(G, addr, size, type)	\
+    ((G)->ops->realloc)((Collector*)(G), (addr), (size), (type))
+#define KGC_free(G, addr)		\
+    ((G)->ops->free)((Collector*)(G), (addr))
+#define KGC_invoke(G, mustgc)		\
+    ((G)->ops->invoke)((Collector*)(G), (mustgc))
+#define KGC_invokeFinalizer(G)		\
+    ((G)->ops->invokeFinalizer)((Collector*)(G))
+#define KGC_init(G)		\
+    ((G)->ops->init)((Collector*)(G))
+#define KGC_enable(G)		\
+    ((G)->ops->enable)((Collector*)(G))
+#define KGC_throwOOM(G)		\
+    ((G)->ops->throwOOM)((Collector*)(G))
+#define KGC_markAddress(G, gc_info, addr)		\
+    ((G)->ops->markAddress)((Collector*)(G), (gc_info), (addr))
+#define KGC_addRef(G, addr) \
+    ((G)->ops->addRef)((Collector*)(G), (addr))
+#define KGC_rmRef(G, addr) \
+    ((G)->ops->rmRef)((Collector*)(G), (addr))
+#define KGC_addWeakRef(G, addr, ref) \
+    ((G)->ops->addWeakRef((Collector *)(G), (addr), (ref)))
+#define KGC_rmWeakRef(G, addr, ref) \
+    ((G)->ops->rmWeakRef((Collector *)(G), (addr), (ref)))
+
+#if !defined(KAFFEH)
+static inline void KGC_markObject(void *g, void *gc_info, const void *addr)
+{
+	if (addr)
+		((Collector*) g)->ops->markObject((Collector*) g, gc_info, addr);
+}
+#endif
+
+#define KGC_getObjectSize(G, obj)	\
+    ((G)->ops->getObjectSize)((Collector*)(G), (obj))
+#define KGC_getObjectDescription(G, obj)	\
+    ((G)->ops->getObjectDescription)((Collector*)(G), (obj))
+#define KGC_getObjectIndex(G, obj)	\
+    ((G)->ops->getObjectIndex)((Collector*)(G), (obj))
+#define KGC_getObjectBase(G, obj)	\
+    ((G)->ops->getObjectBase)((Collector*)(G), (obj))
+#define KGC_registerFixedTypeByIndex(G, idx, desc)	\
+    ((G)->ops->registerFixedTypeByIndex)((Collector*)(G),   \
+				(idx), (desc))
+#define KGC_registerGcTypeByIndex(G, idx, walk, final, destroy, desc)	\
+    ((G)->ops->registerGcTypeByIndex)((Collector*)(G), 	     \
+				(idx), (walk), (final), (destroy), (desc))
+#define KGC_enableGC(G)		\
+    ((G)->ops->enableGC)((Collector*)(G));
+#define KGC_disableGC(G)		\
+    ((G)->ops->disableGC)((Collector*)(G));
+
+#define KGC_getHeapFree(G) \
+    ((G)->ops->getHeapFree)((Collector *)(G));
+#define KGC_getHeapLimit(G) \
+    ((G)->ops->getHeapLimit)((Collector *)(G));
+#define KGC_getHeapTotal(G) \
+    ((G)->ops->getHeapTotal)((Collector *)(G));
+#define KGC_getCollectorName(G) \
+    ((G)->ops->getCollectorName)((Collector *)(G));
+#define KGC_WRITE(a, b)
+
+/*
+ * Compatibility macros to access GC functions
+ */
+extern Collector* main_collector;
+
+#define	gc_malloc(A,B)	    KGC_malloc(main_collector,A,B)
+#define	gc_calloc(A,B,C)    KGC_malloc(main_collector,(A)*(B),C)
+#define	gc_realloc(A,B,C)   KGC_realloc(main_collector,(A),(B),C)
+#define	gc_free(A)	    KGC_free(main_collector,(A))
+#define gc_add_ref(A)       KGC_addRef(main_collector, (A))
+#define gc_rm_ref(A)        KGC_rmRef(main_collector, (A))
+
+#define	invokeGC()	    KGC_invoke(main_collector,1)
+#define	adviseGC()	    KGC_invoke(main_collector,0)
+#define	invokeFinalizer()   KGC_invokeFinalizer(main_collector)
+
+#define gc_throwOOM()	    KGC_throwOOM(main_collector)
+
+#define gc_enableGC()	    KGC_enableGC(main_collector)
+#define gc_disableGC()	    KGC_disableGC(main_collector)
+
+extern const char* describeObject(const void* mem);
+
+Collector* 		initCollector(void);
+
+#endif
===================================================================
Checking out kaffe/kaffe/kaffevm/javacall.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/javacall.c,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/javacall.c	Thu Jun 23 16:51:53 2005
@@ -0,0 +1,459 @@
+/*
+ * javacall.c
+ * Building call for java/native methods.
+ *
+ * Copyright (c) 1996, 1997
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2002-2005 
+ *      Kaffe.org contributors. See ChangeLog for details. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution 
+ * of this file. 
+ */
+
+#include "debug.h"
+#include "config.h"
+
+#if !defined(HAVE_LIBFFI)
+#define NEED_sysdepCallMethod 1
+#endif
+
+#include "config-std.h"
+#include "config-mem.h"
+#include <stdarg.h>
+#include "errors.h"
+#include "jni_md.h"
+#include "kaffe/jmalloc.h"
+#include "gtypes.h"
+#include "object.h"
+#include "constants.h"
+#include "baseClasses.h"
+#include "slots.h"
+#include "support.h"
+#include "classMethod.h"
+#include "machine.h"
+#include "md.h"
+#include "itypes.h"
+#include "external.h"
+#include "thread.h"
+#include "jthread.h"
+#include "methodcalls.h"
+#include "native.h"
+
+/* This is defined in the alpha port.  It causes all integer arguments
+   to be promoted to jlong, and all jfloats to be promoted to jdouble,
+   unless explicitly overridden.  It implies NO_HOLES, unless
+   explicitly defined otherwise.  */
+#if defined(PROMOTE_TO_64bits)
+# if !defined(PROMOTE_jint2jlong)
+#  define PROMOTE_jint2jlong 1
+# endif
+# if !defined(PROMOTE_jfloat2jdouble)
+#  define PROMOTE_jfloat2jdouble 1
+# endif
+/* NO_HOLES causes all types to occupy only one slot in callargs, but
+   not affecting their callsizes, that can still be used to
+   distinguish among types.  */
+# if !defined(NO_HOLES)
+#  define NO_HOLES 1
+# endif
+#endif
+
+/* Make sure that undefined macros are defined as 0 */
+#if !defined(PROMOTE_jfloat2jdouble)
+#define PROMOTE_jfloat2jdouble 0
+#endif
+
+#if !defined(PROMOTE_jint2jlong)
+#define PROMOTE_jint2jlong 0
+#endif
+
+#if !defined(NO_HOLES)
+#define NO_HOLES 0
+#endif
+
+/* If PROMOTE_jint2jlong is enabled, all integer values are to be
+   passed as jlongs.  It is only set by PROMOTE_TO_64bits.  */
+#if PROMOTE_jint2jlong
+# define PROM_i j
+#else
+# define PROM_i i
+#endif
+
+/* If PROMOTE_jfloat2jdouble is enabled, jfloats are to be passed as
+   jdoubles.  Note that, when a jfloat is promoted, its calltype will
+   be marked as 'D'.  No known port uses this.  In fact, alpha must
+   explicitly set it to 0, to prevent PROMOTE_TO_64bits from enabling
+   it.  */
+#if PROMOTE_jfloat2jdouble
+# define PROM_f d
+#else
+# define PROM_f f
+#endif
+
+/* This is currently defined in the MIPS O32 port.  It causes jlongs
+   and jdoubles to be forced into even arguments, by introducing a
+   padding integer argument. The argument DO is used to adjust the
+   input argument list.  */
+#if defined(ALIGN_AT_64bits)
+# if NO_HOLES
+#  error "ALIGN_AT_64bits is incompatible with NO_HOLES"
+# endif
+# define ENSURE_ALIGN64(DO) do { \
+		if (call.callsize[i] == 2 && (i & 1)) { \
+			char tmptype = call.calltype[i]; \
+			call.callsize[i] = 0; \
+			call.calltype[i] = 'I'; \
+			DO; \
+			++i; ++s; \
+			call.calltype[i] = tmptype; \
+			call.callsize[i] = 2; \
+		} \
+	} while (0)
+#else
+# define ENSURE_ALIGN64(DO) do {} while (0)
+#endif
+
+/**
+ * Generic routine to call a native or Java method (array style).
+ *
+ * @param meth the struct _methods of the method to be executed
+ * @param func the code that's to be executed
+ * @param obj  the object whose method is to be called (my be 0 iff method is static)
+ * @param args the arguments to be passed to the method
+ * @param ret  buffer for the return value of the method (may be 0 iff return type is void)
+ * @param promoted true iff 64 bit values occupy two entries in args, otherwise false
+ */
+void
+KaffeVM_callMethodA(Method* meth, void* func, void* obj, jvalue* args, jvalue* ret,
+		    int promoted)
+{
+	int i;
+	int j;
+	int s;
+	int numArgs;
+	callMethodInfo call;	
+	jvalue tmp;
+
+	if (ret == 0) {
+		ret = &tmp;
+	}
+	if (!NO_HOLES)
+	        numArgs = sizeofSigMethod(meth, false);
+	else
+	        numArgs = METHOD_NARGS(meth);
+
+	i = engine_reservedArgs(meth);
+	s = 0;
+	
+	call.args = (jvalue *)alloca((numArgs+engine_reservedArgs(meth)+2)*(sizeof(jvalue)+2));
+	call.callsize = (char *)&call.args[numArgs+engine_reservedArgs(meth)+2];
+	call.calltype = (char *)&call.callsize[numArgs+engine_reservedArgs(meth)+2];
+
+	/* If this method isn't static, we must insert the object as
+	 * an argument.
+ 	 */
+	if ((meth->accflags & ACC_STATIC) == 0) {
+		call.callsize[i] = PTR_TYPE_SIZE / SIZEOF_INT;
+		s += call.callsize[i];
+		call.calltype[i] = 'L';
+		call.args[i].l = obj;
+		i++;
+	}
+
+	for (j = 0; j < METHOD_NARGS(meth); i++, j++) {
+		call.calltype[i] = *METHOD_ARG_TYPE(meth, j);
+		switch (call.calltype[i]) {
+		case 'Z':
+			if (promoted) goto use_int;
+			call.callsize[i] = 1;
+			call.args[i].PROM_i = args[j].z;
+			break;
+
+		case 'S':
+			if (promoted) goto use_int;
+			call.callsize[i] = 1;
+			call.args[i].PROM_i = args[j].s;
+			break;
+
+		case 'B':
+			if (promoted) goto use_int;
+			call.callsize[i] = 1;
+			call.args[i].PROM_i = args[j].b;
+			break;
+
+		case 'C':
+			if (promoted) goto use_int;
+			call.callsize[i] = 1;

*** Patch too long, truncated ***




More information about the kaffe mailing list