[kaffe] CVS kaffe (guilhem): Fixes for Alpha/OSF

Kaffe CVS cvs-commits at kaffe.org
Fri Dec 30 10:45:57 PST 2005


PatchSet 7067 
Date: 2005/12/30 18:38:46
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fixes for Alpha/OSF

	* config/config-std.h: Include config-int.h before everything
	to be sure to include inttypes.h first.

	* kaffe/kaffevm/javacall.c
	(KaffeVM_callMethodA): Do not use args after having called
	sysdepCallMethod.

	* kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
	(jthread_t): Use int and not char for status (fix unalignment
	problems on alpha).

	* libraries/clib/nio/gnu_java_nio_VMSelector.c:
	Include jni.h first.

	* config/alpha/osf/md.c:
	(init_md): Only initialize excLock if LIBEXC is defined.

	* config/alpha/osd/md.h
	(SIGNAL_ARGS, SIGNAL_CONTEXT_POINTER, GET_SIGNAL_CONTEXT_POINTER,
	SIGNAL_PC): Defined.
	Include kaffe-unix-stack.h

Members: 
	ChangeLog:1.4586->1.4587 
	config/config-std.h:1.17->1.18 
	config/alpha/osf/md.c:INITIAL->1.10 
	config/alpha/osf/md.h:1.3->1.4 
	include/jsyscall.h:1.24->1.25 
	kaffe/kaffevm/javacall.c:1.3->1.4 
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.41->1.42 
	libraries/clib/nio/gnu_java_nio_VMSelector.c:1.16->1.17 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4586 kaffe/ChangeLog:1.4587
--- kaffe/ChangeLog:1.4586	Wed Dec 28 23:42:09 2005
+++ kaffe/ChangeLog	Fri Dec 30 18:38:46 2005
@@ -1,3 +1,27 @@
+2005-12-30  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* config/config-std.h: Include config-int.h before everything
+	to be sure to include inttypes.h first.
+
+	* kaffe/kaffevm/javacall.c
+	(KaffeVM_callMethodA): Do not use args after having called
+	sysdepCallMethod.
+
+	* kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
+	(jthread_t): Use int and not char for status (fix unalignment
+	problems on alpha).
+
+	* libraries/clib/nio/gnu_java_nio_VMSelector.c:
+	Include jni.h first.
+
+	* config/alpha/osf/md.c:
+	(init_md): Only initialize excLock if LIBEXC is defined.
+	
+	* config/alpha/osd/md.h
+	(SIGNAL_ARGS, SIGNAL_CONTEXT_POINTER, GET_SIGNAL_CONTEXT_POINTER,
+	SIGNAL_PC): Defined.
+	Include kaffe-unix-stack.h
+
 2005-12-29 Alexander Boettcher  <alex at kaffe.org>
 
 	* kaffe/kaffevm/system/drops-l4threads/jthread.h,
Index: kaffe/config/config-std.h
diff -u kaffe/config/config-std.h:1.17 kaffe/config/config-std.h:1.18
--- kaffe/config/config-std.h:1.17	Thu Aug 18 22:49:21 2005
+++ kaffe/config/config-std.h	Fri Dec 30 18:38:51 2005
@@ -17,6 +17,10 @@
 #ifndef __config_std_h
 #define __config_std_h
 
+/* We put config-int at the top because stdio.h may overwrite some
+ * types which are defined by inttypes.h (and incorrectly of course)
+ */
+#include "config-int.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
===================================================================
Checking out kaffe/config/alpha/osf/md.c
RCS:  /home/cvs/kaffe/kaffe/config/alpha/osf/md.c,v
VERS: 1.10
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/alpha/osf/md.c	Fri Dec 30 18:45:56 2005
@@ -0,0 +1,229 @@
+/*
+ * alpha/osf/md.c
+ * OSF/1 Alpha specific functions.
+ *
+ * Copyright (c) 1999, 2000, 2001
+ *	Edouard G. Parmelan.  All rights reserved.
+ *
+ * Copyright (c) 1996, 1997, 1999, 2000, 2001
+ *	Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include <machine/fpu.h>
+#include <sys/sysinfo.h>
+#include <machine/hal_sysinfo.h>
+#include <sys/proc.h>
+
+#include <assert.h>
+
+#include "md.h"
+
+#ifndef FPCR_INED
+#define FPCR_INED 0
+#endif
+#ifndef FPCR_UNFD
+#define FPCR_UNFD 0
+#endif
+#ifndef FPCR_OVFD
+#define FPCR_OVFD 0
+#endif
+#ifndef FPCR_DZED
+#define FPCR_DZED 0
+#endif
+
+#if defined(USE_LIBEXC)
+#include "locks.h"
+/* libexc is not thread safe :-( */
+static iStaticLock excLock;
+#endif
+
+void
+init_md(void)
+{
+	/* `Alpha Architecture Handbook' say that's user mode _must
+           not_ change fpcr but use OS function as next one.  */
+#if 0
+	/* Set the bits in the hw fpcr for cpu's that implement
+	   all the bits.  */
+	__asm__ __volatile__(
+		"excb\n\t"
+		"mt_fpcr %0\n\t"
+		"excb"
+		: : "f"(FPCR_INED | FPCR_UNFD | FPCR_DYN_NORMAL
+			| FPCR_OVFD | FPCR_DZED));
+#endif
+
+#if 0 /* This breaks DoublePrint and DoubleComp tests.  */
+	/* Set the software emulation bits in the kernel for
+	   those that don't.  */
+	ieee_set_fp_control(IEEE_TRAP_ENABLE_INV);
+#endif
+
+#if defined(USE_LIBEXC)
+	initStaticLock(&excLock);
+#endif
+}
+
+
+/* This bit turns off unaligned access fixups in favour of SIGBUS.  It
+   is not called by Kaffe, but it is useful to invoke from within
+   the debugger.  */
+
+void alpha_disable_uac(void)
+{
+  int buf[2];
+
+  buf[0] = SSIN_UACPROC;
+  buf[1] = UAC_SIGBUS;
+  setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0);
+}
+
+
+#if defined(TRANSLATOR)
+/* Native support for exception */
+
+#if defined(USE_LIBEXC)
+#include <pdsc.h>
+#include <excpt.h>
+
+#include "debug.h"
+
+void __alpha_osf_firstFrame (exceptionFrame *frame)
+{
+
+	/* Retreive caller frame as current one will be invalidate
+           after function exit. */
+	lockStaticMutex (&excLock);
+	exc_capture_context (&frame->sc);
+	exc_virtual_unwind (NULL, &frame->sc);
+	unlockStaticMutex (&excLock);
+
+	DBG(STACKTRACE,
+	    dprintf("__alpha_osf_firstFrame(0x%p) pc 0x%p fp 0x%p sp 0x%p\n", frame,
+		    (void*)frame->sc.sc_pc, (void*)frame->sc.sc_regs[15],
+		    (void*)frame->sc.sc_regs[30]); );
+}
+
+exceptionFrame * __alpha_osf_nextFrame (exceptionFrame *frame)
+{
+
+	DBG(STACKTRACE,
+	    dprintf("__alpha_osf_nextFrame(0x%p) pc 0x%p fp 0x%p sp 0x%p\n", frame,
+		    (void*)frame->sc.sc_pc, (void*)frame->sc.sc_regs[15],
+		    (void*)frame->sc.sc_regs[30]); );
+	/* exc_virtual_unwind() will call last chance handler if RPD
+           is not found.  So lookup the corresponding table before
+           real unwind.  Note that exc_lookup_function_table() return
+           the table address, not the entry address that could be used
+           by exc_virtual_unwind().  */
+	lockStaticMutex (&excLock);
+	if (exc_lookup_function_table (frame->sc.sc_pc) != NULL) {
+		exc_virtual_unwind (NULL, &frame->sc);
+	}
+	else {
+		/* No table found, is this method GCed after throw but
+                   before printStackTrace() ??? */
+#if 0
+		DBG(STACKTRACE,
+		    dprintf ("__alpha_osf_nextFrame(): no PDSC_RPD for pc %p\n",
+			     (void*)frame->sc.sc_pc); );
+#endif
+		frame->sc.sc_pc = 0;
+	}
+	unlockStaticMutex (&excLock);
+	DBG(STACKTRACE,
+	    dprintf(" -> pc 0x%p fp 0x%p sp 0x%p\n",
+		    (void*)frame->sc.sc_pc, (void*)frame->sc.sc_regs[15],
+		    (void*)frame->sc.sc_regs[30]); );
+	return frame->sc.sc_pc == 0 ? NULL : frame;
+}
+
+/* Construct JIT Exception information and register it.  */
+void __alpha_osf_register_jit_exc (void *methblock, void *codebase, void *codeend)
+{
+	extern int maxLocal, maxStack, maxTemp, maxArgs, maxPush;
+	struct {
+		pdsc_crd crd[2];
+		struct pdsc_long_stack_rpd rpd;
+	} *pdsc = methblock;
+	int framesize;			/* frame size in 64 bit words */
+	int rsa_offset;			/* rsa offset from $sp in 64 bit words */
+	int codelen = codeend - codebase;
+
+	assert (sizeof (*pdsc) == MD_JIT_EXCEPTION_INFO_LENGTH);
+
+	/* same as LABEL_Lframe() and LABEL_Lrsa() */
+	framesize = maxLocal + maxStack +
+		maxTemp + (maxArgs < 6 ? maxArgs : 6) +
+		alpha_jit_info.rsa_size +
+		(maxPush <= 6 ? 0 : maxPush - 6);
+	framesize += framesize & 1;	/* octaword-aligned */
+	rsa_offset = (maxPush < 6 ? 0 : maxPush - 6);
+
+	/* create Code Range Descriptor Table */
+	pdsc->crd[0].words.begin_address = (pdsc_offset) ((char *) codebase
+		- (char *) pdsc);
+	pdsc->crd[0].words.rpd_offset = (pdsc_offset) ((char *) &pdsc->rpd
+		- (char *) &pdsc->crd[0].words.rpd_offset);
+	pdsc->crd[1].words.begin_address = pdsc->crd[0].words.begin_address
+		+ codelen;
+	pdsc->crd[1].words.rpd_offset = 0;
+
+	/* create Runtime Procedure Descriptor */
+#if 0
+	/* With -ieee, GCC alway add .eflag 48 event if function does
+           not use float nor double.  */
+	pdsc->rpd.flags = PDSC_EXC_IEEE;
+#else
+	pdsc->rpd.flags = (alpha_jit_info.ieee ? PDSC_EXC_IEEE : 0);
+#endif
+	pdsc->rpd.entry_ra = 26;
+	pdsc->rpd.rsa_offset = rsa_offset;
+	pdsc->rpd.sp_set = alpha_jit_info.sp_set;
+	pdsc->rpd.entry_length = alpha_jit_info.entry_length;
+	pdsc->rpd.frame_size = framesize;
+	pdsc->rpd.reserved = 0;
+	pdsc->rpd.imask = alpha_jit_info.imask;
+	pdsc->rpd.fmask = alpha_jit_info.fmask;
+
+	DBG(STACKTRACE,
+	    dprintf("__alpha_osf_register_jit() 0x%p pc [0x%p - 0x%p[\n",
+		    methblock, codebase, codebase + codelen);
+	    dprintf(" crd[0] begin_address %d rpd_offset\n",
+		    pdsc->crd[0].words.begin_address,
+		    pdsc->crd[0].words.rpd_offset);
+	    dprintf(" crd[1] begin_address %d rpd_offset\n",
+		    pdsc->crd[1].words.begin_address,
+		    pdsc->crd[1].words.rpd_offset);
+	    dprintf(" maxLocal %d maxStack %d maxTemp %d maxArgs %d maxPush %d\n",
+		    maxLocal, maxStack, maxTemp, maxArgs, maxPush);
+	    dprintf(" framesize %d rsa_offset %d rsa_size %d\n",
+		    framesize, rsa_offset, alpha_jit_info.rsa_size);
+	    );
+	/* Register this runtime procedure descriptor */
+	lockStaticMutex (&excLock);
+	exc_add_pc_range_table (methblock, 2);
+	exc_add_gp_range ((exc_address) codebase, codelen, (exc_address) codebase);
+	unlockStaticMutex (&excLock);
+}
+
+void __alpha_osf_unregister_jit_exc (void *methblock, void *codebase, void *codeend)
+{
+	int codelen = codeend - codebase;
+
+	DBG(STACKTRACE,
+	    dprintf("__alpha_osf_unregister_jit() 0x%p pc [0x%p - 0x%p[\n",
+		    methblock, codebase, codebase + codelen) );
+	/* Unregister this runtime procedure descriptor */
+	lockStaticMutex (&excLock);
+	exc_remove_pc_range_table (methblock);
+	exc_remove_gp_range ((exc_address) codebase);
+	unlockStaticMutex (&excLock);
+}
+#else
+#include "alpha/alpha.c"
+#endif
+#endif
Index: kaffe/config/alpha/osf/md.h
diff -u kaffe/config/alpha/osf/md.h:1.3 kaffe/config/alpha/osf/md.h:1.4
--- kaffe/config/alpha/osf/md.h:1.3	Mon Feb  8 21:44:23 1999
+++ kaffe/config/alpha/osf/md.h	Fri Dec 30 18:38:52 2005
@@ -19,8 +19,18 @@
 #include "jit-md.h"
 #endif
 
+#include "kaffe-unix-stack.h"
+
 #undef SP_OFFSET
 #define SP_OFFSET 34
+
+#include <machine/context.h>
+#include <machine/signal.h>
+
+#define SIGNAL_ARGS(sig, sc) int sig, int alpha_dummy, struct sigcontext *sc
+#define SIGNAL_CONTEXT_POINTER(scp) struct sigcontext * scp
+#define GET_SIGNAL_CONTEXT_POINTER(sc) (sc)
+#define SIGNAL_PC(scp) ((void *) (scp)->sc_pc)
 
 /* Alpha's require a little initialisation for proper IEEE math.  */
 extern void init_md(void);
Index: kaffe/include/jsyscall.h
diff -u kaffe/include/jsyscall.h:1.24 kaffe/include/jsyscall.h:1.25
--- kaffe/include/jsyscall.h:1.24	Fri Nov 25 21:01:53 2005
+++ kaffe/include/jsyscall.h	Fri Dec 30 18:38:52 2005
@@ -13,6 +13,7 @@
 #define __jsyscall_h
 
 #include "config.h"
+#include "config-int.h"
 
 #if defined(HAVE_NETDB_H)
 #include <netdb.h>
Index: kaffe/kaffe/kaffevm/javacall.c
diff -u kaffe/kaffe/kaffevm/javacall.c:1.3 kaffe/kaffe/kaffevm/javacall.c:1.4
--- kaffe/kaffe/kaffevm/javacall.c:1.3	Wed Aug 10 21:17:49 2005
+++ kaffe/kaffe/kaffevm/javacall.c	Fri Dec 30 18:38:51 2005
@@ -136,6 +136,7 @@
 	int numArgs;
 	callMethodInfo call;	
 	jvalue tmp;
+	jvalue *saveargs;
 
 	if (ret == 0) {
 		ret = &tmp;
@@ -148,7 +149,7 @@
 	i = engine_reservedArgs(meth);
 	s = 0;
 	
-	call.args = (jvalue *)alloca((numArgs+engine_reservedArgs(meth)+2)*(sizeof(jvalue)+2));
+	saveargs = 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];
 
@@ -273,7 +274,7 @@
 	/* Make the call - system dependent */
 	engine_callMethod(&call);
 
-	memset(call.args, 0, (METHOD_NARGS(meth)+engine_reservedArgs(meth)+2)*(sizeof(jvalue)+2));
+	memset(saveargs, 0, (numArgs+engine_reservedArgs(meth)+2)*(sizeof(jvalue)+2));
 	memset(&call, 0, sizeof(call));
 }
 
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.41 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.42
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.41	Tue Jul 19 16:27:38 2005
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h	Fri Dec 30 18:38:52 2005
@@ -66,7 +66,7 @@
   /* wether this is a daemon thread */
   int			daemon;
   int                   interrupting;
-  char                  status;
+  int                  status;
 
   /* convars and mutexes aren't useful in signal handlers, semaphores are */
   repsem_t                 sem;
Index: kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c:1.16 kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c:1.17
--- kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c:1.16	Fri Aug 19 13:48:19 2005
+++ kaffe/libraries/clib/nio/gnu_java_nio_VMSelector.c	Fri Dec 30 18:38:53 2005
@@ -37,6 +37,7 @@
 
 #include "config.h"
 #include "jsyscall.h"
+#include <jni.h>
 
 /* <sys/types.h> needs to be included on OSX before <sys/select.h> */
 #if defined(HAVE_SYS_TYPES_H)
@@ -59,7 +60,6 @@
 
 #include <errno.h>
 
-#include <jni.h>
 #include <jcl.h>
 
 #include "gnu_java_nio_VMSelector.h"




More information about the kaffe mailing list