[kaffe] CVS kaffe (hkraemer): fixed support for sysdepCallMethod using libffi

Kaffe CVS cvs-commits at kaffe.org
Fri Aug 27 05:32:05 PDT 2004


PatchSet 5112 
Date: 2004/08/27 12:22:00
Author: hkraemer
Branch: HEAD
Tag: (none) 
Log:
fixed support for sysdepCallMethod using libffi

Members: 
	ChangeLog:1.2668->1.2669 
	config/Makefile.am:1.49->1.50 
	config/Makefile.in:1.155->1.156 
	config/sysdepCallMethod-ffi.h:INITIAL->1.1 
	kaffe/kaffevm/support.c:1.72->1.73 
	kaffe/kaffevm/intrp/methodcalls.c:1.1->1.2 
	kaffe/kaffevm/jit/methodcalls.c:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2668 kaffe/ChangeLog:1.2669
--- kaffe/ChangeLog:1.2668	Fri Aug 27 08:40:51 2004
+++ kaffe/ChangeLog	Fri Aug 27 12:22:00 2004
@@ -1,3 +1,16 @@
+2004-08-27  Helmer Kraemer  <hkraemer at freenet.de>
+
+	* kaffe/kaffevm/support.c: moved libffi related stuff ...
+
+	* config/sysdepCallMethod-ffi.h: ... into this new file
+
+	* kaffe/kaffevm/intrp/methodcalls.c, kaffe/kaffevm/jit/methodcalls.c:
+	include sysdepCallMethod-ffi.h if HAVE_LIBFFI is defined
+
+	* config/Makefile.am (noinst_HEADERS): added sysdepCallMethod-ffi.h
+
+	* config/Makefile.in: regenerated 
+
 2004-08-27  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* configure.ac: Moved AC_CONFIG_SUBDIRS to make configure
Index: kaffe/config/Makefile.am
diff -u kaffe/config/Makefile.am:1.49 kaffe/config/Makefile.am:1.50
--- kaffe/config/Makefile.am:1.49	Wed Aug 18 14:29:52 2004
+++ kaffe/config/Makefile.am	Fri Aug 27 12:22:03 2004
@@ -46,7 +46,8 @@
 	config-setjmp.h \
 	config-signal.h \
 	config-std.h \
-	kaffe-unix-stack.h
+	kaffe-unix-stack.h \
+	sysdepCallMethod-ffi.h
 
 EXTRA_DIST = \
 	config.alias \
Index: kaffe/config/Makefile.in
diff -u kaffe/config/Makefile.in:1.155 kaffe/config/Makefile.in:1.156
--- kaffe/config/Makefile.in:1.155	Wed Aug 18 14:29:52 2004
+++ kaffe/config/Makefile.in	Fri Aug 27 12:22:03 2004
@@ -371,7 +371,8 @@
 	config-setjmp.h \
 	config-signal.h \
 	config-std.h \
-	kaffe-unix-stack.h
+	kaffe-unix-stack.h \
+	sysdepCallMethod-ffi.h
 
 EXTRA_DIST = \
 	config.alias \
===================================================================
Checking out kaffe/config/sysdepCallMethod-ffi.h
RCS:  /home/cvs/kaffe/kaffe/config/sysdepCallMethod-ffi.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/sysdepCallMethod-ffi.h	Fri Aug 27 12:32:04 2004
@@ -0,0 +1,68 @@
+/*
+ * sysdepCallMethod-ffi.h
+ * Implementation of sysdepCallMethod using libffi
+ *
+ * Copyright (c) 2004
+ *      The kaffe.org's developers. See ChangeLog for details.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#ifndef __sysdepCallMethod_ffi_h__
+#define __sysdepCallMethod_ffi_h__
+
+#include <ffi.h>
+static inline ffi_type *j2ffi(char type)
+{
+        ffi_type *ftype;
+
+        switch (type) {
+        case 'J':
+                ftype = &ffi_type_sint64;
+                break;
+        case 'D':
+                ftype = &ffi_type_double;
+                break;
+        case 'F':
+                ftype = &ffi_type_float;
+                break;
+        default:
+                ftype = &ffi_type_uint;
+        }
+        return ftype;
+}
+
+#define sysdepCallMethod(CALL)                                          \
+do {                                                                    \
+        int i;                                                          \
+        ffi_cif cif;                                                    \
+        ffi_type *rtype;                                                \
+        ffi_type *argtypes[(CALL)->nrargs + 1];                         \
+        void *argvals[(CALL)->nrargs + 1];                              \
+        int fargs = 0;                                                  \
+        for (i = 0; i < (CALL)->nrargs; i++) {                          \
+                switch ((CALL)->callsize[i]) {                          \
+                case 1:                                                 \
+                        argtypes[fargs] = j2ffi((CALL)->calltype[i]);   \
+                        argvals[fargs] = &((CALL)->args[i].i);          \
+                        fargs++;                                        \
+                        break;                                          \
+                case 2:                                                 \
+                        argtypes[fargs] = j2ffi((CALL)->calltype[i]);   \
+                        argvals[fargs] = &((CALL)->args[i].j);          \
+                        fargs++;                                        \
+                default:                                                \
+                        break;                                          \
+                }                                                       \
+        }                                                               \
+        rtype = j2ffi ((CALL)->rettype);                                \
+        if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, fargs,                  \
+            rtype, argtypes) == FFI_OK) {                               \
+                ffi_call(&cif, (CALL)->function, (CALL)->ret, argvals); \
+        }                                                               \
+        else                                                            \
+                ABORT();                                                \
+} while (0);
+
+#endif /* __sysdepCallMethod_ffi_h__ */
Index: kaffe/kaffe/kaffevm/support.c
diff -u kaffe/kaffe/kaffevm/support.c:1.72 kaffe/kaffe/kaffevm/support.c:1.73
--- kaffe/kaffe/kaffevm/support.c:1.72	Thu Aug 19 19:29:02 2004
+++ kaffe/kaffe/kaffevm/support.c	Fri Aug 27 12:22:04 2004
@@ -28,9 +28,6 @@
 #include "exception.h"
 #include "slots.h"
 #include "support.h"
-#if !defined(HAVE_LIBFFI)
-# define NEED_sysdepCallMethod 1
-#endif /* HAVE_LIBFFI */
 #include "classMethod.h"
 #include "machine.h"
 #include "md.h"
@@ -52,61 +49,6 @@
 
 /* Anchor point for user defined properties */
 userProperty* userProperties = NULL;
-
-#if defined(HAVE_LIBFFI)
-#include <ffi.h>
-static inline ffi_type *j2ffi(char type)
-{
-	ffi_type *ftype;
-
-	switch (type) {
-	case 'J':
-		ftype = &ffi_type_sint64;
-		break;
-	case 'D':
-		ftype = &ffi_type_double;
-		break;
-	case 'F':
-		ftype = &ffi_type_float;
-		break;
-	default:
-		ftype = &ffi_type_uint;
-	}
-	return ftype;
-}
-
-#define sysdepCallMethod(CALL)						\
-do {									\
-	int i;								\
-	ffi_cif cif;							\
-	ffi_type *rtype;						\
-	ffi_type *argtypes[(CALL)->nrargs + 1];				\
-	void *argvals[(CALL)->nrargs + 1];				\
-	int fargs = 0;							\
-	for (i = 0; i < (CALL)->nrargs; i++) {				\
-		switch ((CALL)->callsize[i]) {				\
-		case 1:							\
-			argtypes[fargs] = j2ffi((CALL)->calltype[i]);	\
-			argvals[fargs] = &((CALL)->args[i].i);		\
-			fargs++;					\
-			break;						\
-		case 2:							\
-			argtypes[fargs] = j2ffi((CALL)->calltype[i]);	\
-			argvals[fargs] = &((CALL)->args[i].j);		\
-			fargs++;					\
-		default:						\
-			break;						\
-		}							\
-	}								\
-	rtype = j2ffi ((CALL)->rettype);				\
-	if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, fargs,			\
-	    rtype, argtypes) == FFI_OK) {				\
-		ffi_call(&cif, (CALL)->function, (CALL)->ret, argvals);	\
-	}								\
-	else								\
-		ABORT();						\
-} while (0);
-#endif /* HAVE_LIBFFI */
 
 /**
  * Call a Java method from native code.
Index: kaffe/kaffe/kaffevm/intrp/methodcalls.c
diff -u kaffe/kaffe/kaffevm/intrp/methodcalls.c:1.1 kaffe/kaffe/kaffevm/intrp/methodcalls.c:1.2
--- kaffe/kaffe/kaffevm/intrp/methodcalls.c:1.1	Thu Aug 19 19:29:03 2004
+++ kaffe/kaffe/kaffevm/intrp/methodcalls.c	Fri Aug 27 12:22:05 2004
@@ -11,8 +11,12 @@
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
-
+#include "config.h"
+#if defined(HAVE_LIBFFI)
+#include "sysdepCallMethod-ffi.h"
+#else
 #define NEED_sysdepCallMethod 1
+#endif
 #include "methodcalls.h"
 #include "thread.h"
 #include "slots.h"
Index: kaffe/kaffe/kaffevm/jit/methodcalls.c
diff -u kaffe/kaffe/kaffevm/jit/methodcalls.c:1.2 kaffe/kaffe/kaffevm/jit/methodcalls.c:1.3
--- kaffe/kaffe/kaffevm/jit/methodcalls.c:1.2	Sat Aug 21 14:53:32 2004
+++ kaffe/kaffe/kaffevm/jit/methodcalls.c	Fri Aug 27 12:22:05 2004
@@ -11,8 +11,13 @@
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
  */
-
+#include "config.h"
+#if defined(HAVE_LIBFFI)
+#include "sysdepCallMethod-ffi.h"
+#else
 #define NEED_sysdepCallMethod 1
+#endif
+
 #include "methodcalls.h"
 
 #define TDBG(s)




More information about the kaffe mailing list