HP tweaks to 0.8.3

Bernie Solomon kaffe@kaffe.org
Tue, 08 Apr 1997 15:01:45 +0000


This is a multi-part message in MIME format.

--------------3C67627810E2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I've just caught up with 0.8.3 having been on holiday and discovered a
few problems in the HP changes including a major one to do with garbage
collection. The current code assumed that the stack always grew
downwards in memory which is not true for HP. I have put a tweak in
thread.c to scan the appropriate bit of stack correctly by using a
#define put in the HP md.h (STACK_GROWS_UP). I am not sure but I would
assume one could get configure to sort this out for you but I haven't
bothered to work out how to do that.

I have also made some tweaks so it compiles with the HP ANSI compiler
which does not take the "double align[0];" idiom so I have replaced
stuff with unions except for ctx which I have just stuck a double on the
end (memory for thread contexts didn't seem the most critical problem -
maybe there is a better way of doing this?). I have coded the unions for
HP non-GCC only but I don't see why they couldn't be used everywhere
given their simplicity and the use of macros to hide them already.

I attach all the diffs I have applied (includes some previously posted).
The second attachment is an assembler file which should be placed in
config/parisc/hpux/md.s and is used because the HP compiler won't take
inline assembler (its an alternative to md.c and configure will pick it
depending on the C compiler).

Note I haven't yet retried on the HP GCC because I found a bug in it
(2.7.2.1 that is) so I have been sticking to the HP compiler.
-- 
Bernie Solomon (bernard@edsug.com or Bernard.Solomon@acm.org)
Unigraphics Architecture, EDS-Unigraphics, Cambridge, UK

--------------3C67627810E2
Content-Type: text/plain; charset=us-ascii; name="diffs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="diffs"

diff -c -r orig-kaffe-0.8.3/configure kaffe-0.8.3/configure
*** orig-kaffe-0.8.3/configure	Mon Apr  7 18:05:41 1997
--- kaffe-0.8.3/configure	Mon Apr  7 19:11:53 1997
***************
*** 979,994 ****
  	host_cpu=parisc
  	host_os=hpux
  	if test ac_cv_prog_gcc = yes ; then
! 		PIC=fpic
! 		#LDFLAGS='-Wl,+b,${libdir}'
! 		#LDSHARE='-b -E'
! 		LIBEXT=.sl
! 		INSTALL_DATA='${INSTALL} -m 555'
  	else
  		# for the HP-UX c compiler only
! 		dynamic_libraries=no
  		CFLAGS="-g -Aa +e -Dunix -Dhpux -D_HPUX_SOURCE"
  	fi
  	;;
  
  
--- 979,995 ----
  	host_cpu=parisc
  	host_os=hpux
  	if test ac_cv_prog_gcc = yes ; then
! 		PIC=-fpic
  	else
  		# for the HP-UX c compiler only
! 		PIC=+z
! 		LIBEXT=.sl
  		CFLAGS="-g -Aa +e -Dunix -Dhpux -D_HPUX_SOURCE"
  	fi
+ 	KAFFEFLAGS='-Wl,+s'
+ 	LIBSHARE='-b -E'
+ 	LIBEXT=.sl
+ 	INSTALL_DATA='${INSTALL} -m 555'
  	;;
  
  
***************
*** 4364,4372 ****
  
  EOF
  
  cat >> $CONFIG_STATUS <<EOF
! ac_sources="config/$host_cpu/$host_os/md.h config/$host_cpu/$host_os/md.c $jitsrc"
! ac_dests="config/md.h kaffe/kaffevm/md.c $jitdst"
  EOF
  
  cat >> $CONFIG_STATUS <<\EOF
--- 4365,4378 ----
  
  EOF
  
+ md_src=md.c
+ if test "$host_cpu" = "parisc" && test $ac_cv_prog_gcc = no; then
+   md_src=md.s
+ fi
+ 
  cat >> $CONFIG_STATUS <<EOF
! ac_sources="config/$host_cpu/$host_os/md.h config/$host_cpu/$host_os/$md_src $jitsrc"
! ac_dests="config/md.h kaffe/kaffevm/$md_src $jitdst"
  EOF
  
  cat >> $CONFIG_STATUS <<\EOF
diff -c -r orig-kaffe-0.8.3/config/alpha/jit.h kaffe-0.8.3/config/alpha/jit.h
*** orig-kaffe-0.8.3/config/alpha/jit.h	Mon Apr  7 18:05:59 1997
--- kaffe-0.8.3/config/alpha/jit.h	Tue Apr  8 10:48:30 1997
***************
*** 26,33 ****
  #define CALL_KAFFE_FUNCTION(meth, obj)                                  \
  	alpha_call_kaffe_function(meth, obj)
  
! extern jword alpha_call_kaffe_function_varargs(Method*, Hjava_lang_Object*, va_list);
! extern jword alpha_call_kaffe_function(Method*, Hjava_lang_Object*);
  
  
  /**/
--- 26,34 ----
  #define CALL_KAFFE_FUNCTION(meth, obj)                                  \
  	alpha_call_kaffe_function(meth, obj)
  
! struct Hjava_lang_Object;
! extern jword alpha_call_kaffe_function_varargs(Method*, struct Hjava_lang_Object*, va_list);
! extern jword alpha_call_kaffe_function(Method*, struct Hjava_lang_Object*);
  
  
  /**/
diff -c -r orig-kaffe-0.8.3/config/parisc/threads.h kaffe-0.8.3/config/parisc/threads.h
*** orig-kaffe-0.8.3/config/parisc/threads.h	Mon Apr  7 18:06:00 1997
--- kaffe-0.8.3/config/parisc/threads.h	Mon Apr  7 19:15:17 1997
***************
*** 19,24 ****
--- 19,29 ----
  /* Thread handling */
  /**/ 
  #define USE_INTERNAL_THREADS  
+ 
+ extern void parisc_threadswitch(unsigned char **, unsigned char **);
+ #if !defined(__GNUC__)
+ extern void *parisc_get_sp(void);
+ #endif
    
  /* Not sure on this... */
  #define THREADSTACKSIZE		(32 * 1024)
***************
*** 35,48 ****
  		(to)->restorePoint = (void *)regstore;			\
  	} while (0)
  
! #define THREADINFO(ee)
!         do {                                                            \
!                 register uint8 *sp __asm__("%r30");                     \
!                 (ee)->restorePoint = NULL;                              \
!                 (ee)->stackBase = sp;                                   \
!                 (ee)->stackEnd = sp + threadStackSize;                  \
!                 (ee)->flags = THREAD_FLAGS_NOSTACKALLOC;                \
!         } while (0)
  
  #define THREADFRAMES(tid, cnt)                                          \
          do {                                                            \
--- 40,64 ----
  		(to)->restorePoint = (void *)regstore;			\
  	} while (0)
  
! #if defined(__GNUC__)
! #define	THREADINFO(ee)							\
! 	do {								\
! 		register uint8 *sp __asm__("%r30");			\
! 		(ee)->restorePoint = NULL;				\
! 		(ee)->stackBase = sp;					\
! 		(ee)->stackEnd = sp + threadStackSize;			\
! 		(ee)->flags = THREAD_FLAGS_NOSTACKALLOC;		\
! 	} while (0)
! #else
! #define	THREADINFO(ee)							\
! 	do {								\
! 		register uint8 *sp = parisc_get_sp();			\
! 		(ee)->restorePoint = NULL;				\
! 		(ee)->stackBase = sp;					\
! 		(ee)->stackEnd = sp + threadStackSize;			\
! 		(ee)->flags = THREAD_FLAGS_NOSTACKALLOC;		\
! 	} while (0)
! #endif
  
  #define THREADFRAMES(tid, cnt)                                          \
          do {                                                            \
diff -c -r orig-kaffe-0.8.3/config/parisc/hpux/md.h kaffe-0.8.3/config/parisc/hpux/md.h
*** orig-kaffe-0.8.3/config/parisc/hpux/md.h	Mon Apr  7 18:06:00 1997
--- kaffe-0.8.3/config/parisc/hpux/md.h	Tue Apr  8 15:26:25 1997
***************
*** 16,20 ****
--- 16,21 ----
  #include "parisc/threads.h"
  
  #define	LIBRARYPATH	"SHLIB_PATH"
+ #define STACK_GROWS_UP  1
   
  #endif
diff -c -r orig-kaffe-0.8.3/include/native.h kaffe-0.8.3/include/native.h
*** orig-kaffe-0.8.3/include/native.h	Mon Apr  7 18:05:26 1997
--- kaffe-0.8.3/include/native.h	Mon Apr  7 18:30:50 1997
***************
*** 56,64 ****
--- 56,70 ----
  typedef	struct Hjava_lang_Class*	HClass;
  
  /* Compare struct Array in object.h */
+ #if defined(__hpux) && !defined(__GNUC__)
  #define ARRAY_FIELDS \
+ 	union { unsigned int		length;\
+ 		double			align; } array_fields
+ #else
+ #define ARRAY_FIELDS \
  	unsigned int		length;\
  	double			align[0]
+ #endif
  
  /* Array types */
  typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { jbyte body[1]; } data[1]; } HArrayOfByte;
***************
*** 72,78 ****
--- 78,88 ----
  typedef struct { Hjava_lang_Object base; ARRAY_FIELDS; struct { Hjava_lang_Object* body[1]; } data[1]; } HArrayOfObject;
  
  /* Get length of arrays */
+ #if defined(__hpux) && !defined(__GNUC__)
+ #define	obj_length(_obj)	((_obj)->array_fields.length)
+ #else
  #define	obj_length(_obj)	((_obj)->length)
+ #endif
  
  /* Get the strings */
  #ifndef __baseclasses_h
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/Makefile.in kaffe-0.8.3/kaffe/kaffevm/Makefile.in
*** orig-kaffe-0.8.3/kaffe/kaffevm/Makefile.in	Mon Apr  7 18:05:30 1997
--- kaffe-0.8.3/kaffe/kaffevm/Makefile.in	Tue Apr  8 15:39:09 1997
***************
*** 28,33 ****
--- 28,34 ----
  KVER=		@KVER@
  OBJEXT=		@OBJEXT@
  LIBEXT=		@LIBVMEXT@
+ AS=		@CC@ @PIC@ -c
  
  INCLUDES=	-I. -I$(srcdir) -I$(srcdir)/../../config -I../../config -I../../include
  CFLAGS=		@CFLAGS@
***************
*** 74,80 ****
  		$(LN) $(LIB) $(LLIB)
  
  $(LIB):		$(OBJECT) lib.exp
! 		@LINKVMLIB@
  
  .c$(OBJEXT):
  		$(CC) $(ALL_CFLAGS) -c $(PIC) $<
--- 75,81 ----
  		$(LN) $(LIB) $(LLIB)
  
  $(LIB):		$(OBJECT) lib.exp
! 		@LINKVMLIB@ @NET_LIBRARIES@
  
  .c$(OBJEXT):
  		$(CC) $(ALL_CFLAGS) -c $(PIC) $<
***************
*** 83,89 ****
  		rm -f $(LIB) $(LLIB) $(OBJECT) lib.exp
  
  distclean:	clean
! 		rm -f md.c jit.def icode.h
  		rm -f Makefile
  
  install:
--- 84,90 ----
  		rm -f $(LIB) $(LLIB) $(OBJECT) lib.exp
  
  distclean:	clean
! 		rm -f md.c md.s jit.def icode.h
  		rm -f Makefile
  
  install:
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/baseClasses.c kaffe-0.8.3/kaffe/kaffevm/baseClasses.c
*** orig-kaffe-0.8.3/kaffe/kaffevm/baseClasses.c	Mon Apr  7 18:05:34 1997
--- kaffe-0.8.3/kaffe/kaffevm/baseClasses.c	Tue Apr  8 14:26:37 1997
***************
*** 22,27 ****
--- 22,28 ----
  #include "constants.h"
  #include "classMethod.h"
  #include "baseClasses.h"
+ #include "thread.h"
  #include "lookup.h"
  #include "slots.h"
  #include "machine.h"
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/classMethod.c kaffe-0.8.3/kaffe/kaffevm/classMethod.c
*** orig-kaffe-0.8.3/kaffe/kaffevm/classMethod.c	Mon Apr  7 18:05:29 1997
--- kaffe-0.8.3/kaffe/kaffevm/classMethod.c	Tue Apr  8 14:27:04 1997
***************
*** 28,33 ****
--- 28,34 ----
  #include "file.h"
  #include "readClass.h"
  #include "baseClasses.h"
+ #include "thread.h"
  #include "itypes.h"
  #include "errors.h"
  #include "exception.h"
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/lookup.c kaffe-0.8.3/kaffe/kaffevm/lookup.c
*** orig-kaffe-0.8.3/kaffe/kaffevm/lookup.c	Mon Apr  7 18:05:33 1997
--- kaffe-0.8.3/kaffe/kaffevm/lookup.c	Tue Apr  8 15:20:12 1997
***************
*** 72,78 ****
  	class = CLASS_CLASS (ci, pool);
  
  DBG(	printf("getMethodSignatureClass(%s,%s,%s)\n",
! 		class->name, name->data, sig->data);		)
  
  	/*
  	 * We now have a complete class and method signature.  We can
--- 72,78 ----
  	class = CLASS_CLASS (ci, pool);
  
  DBG(	printf("getMethodSignatureClass(%s,%s,%s)\n",
! 		class->name->data, name->data, sig->data);		)
  
  	/*
  	 * We now have a complete class and method signature.  We can
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/object.h kaffe-0.8.3/kaffe/kaffevm/object.h
*** orig-kaffe-0.8.3/kaffe/kaffevm/object.h	Mon Apr  7 18:05:33 1997
--- kaffe-0.8.3/kaffe/kaffevm/object.h	Mon Apr  7 18:33:03 1997
***************
*** 32,43 ****
--- 32,52 ----
  struct Array {
  	Hjava_lang_Object	obj;
  	/* Must match ARRAY_FIELDS in native.h. FIXME */
+ #if defined(__hpux) && !defined(__GNUC__)
+ 	union { uint32			length;
+ 		double			align; } array_fields;
+ #else
  	uint32			length;
  	double			align[0];  /* for alignment (Gcc extension) */
+ #endif
  };
  
  /* Number of elements. */
+ #if defined(__hpux) && !defined(__GNUC__)
+ #define	ARRAY_SIZE(ARRAY)	(((Array*)(ARRAY))->array_fields.length)
+ #else
  #define	ARRAY_SIZE(ARRAY)	(((Array*)(ARRAY))->length)
+ #endif
  #define	ARRAY_DATA(ARRAY)	((void*)((Array*)(ARRAY)+1))
  #define	OBJARRAY_DATA(ARRAY)	((Hjava_lang_Object**)((Array*)(ARRAY)+1))
  
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/slib.h kaffe-0.8.3/kaffe/kaffevm/slib.h
*** orig-kaffe-0.8.3/kaffe/kaffevm/slib.h	Mon Apr  7 18:05:35 1997
--- kaffe-0.8.3/kaffe/kaffevm/slib.h	Mon Apr  7 19:18:02 1997
***************
*** 54,61 ****
  #define	LIBRARYFUNCTION(FUNC, SYM)					\
  	{								\
  		shl_t all_libs = 0;					\
! 		if (shl_findsym(&all_libs,SYM,TYPE_PROCEDURE,&FUNC) == 0) { \
! 			break;						\
  		}							\
  	}
  #define	LIBRARYHANDLE	shl_t
--- 54,61 ----
  #define	LIBRARYFUNCTION(FUNC, SYM)					\
  	{								\
  		shl_t all_libs = 0;					\
! 		if (shl_findsym(&all_libs,SYM,TYPE_PROCEDURE,&FUNC) != 0) { \
! 			FUNC = 0;					\
  		}							\
  	}
  #define	LIBRARYHANDLE	shl_t
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/thread.c kaffe-0.8.3/kaffe/kaffevm/thread.c
*** orig-kaffe-0.8.3/kaffe/kaffevm/thread.c	Mon Apr  7 18:05:33 1997
--- kaffe-0.8.3/kaffe/kaffevm/thread.c	Tue Apr  8 15:29:45 1997
***************
*** 1049,1060 ****
--- 1049,1065 ----
  	/* Since this thread my be extended by another class, walk any
  	 * remaining data.
  	 */
+ 	gcStats.markedmem -= (base->size - sizeof(thread));
  	scanConservative(tid+1, base->size - sizeof(thread));
  
  	if (tid->PrivateInfo != 0) {
  		ct = TCTX(tid);
  		/* Nothing in context worth looking at except the stack */
+ #if STACK_GROWS_UP
+ 		scanConservative(ct->stackBase, ct->restorePoint - ct->stackBase);
+ #else
  		scanConservative(ct->restorePoint, ct->stackEnd - ct->restorePoint);
+ #endif
  	}
  }
  
diff -c -r orig-kaffe-0.8.3/kaffe/kaffevm/thread.h kaffe-0.8.3/kaffe/kaffevm/thread.h
*** orig-kaffe-0.8.3/kaffe/kaffevm/thread.h	Mon Apr  7 18:05:34 1997
--- kaffe-0.8.3/kaffe/kaffevm/thread.h	Mon Apr  7 18:45:04 1997
***************
*** 48,54 ****
--- 48,58 ----
  	struct _thread**	blockqueue;
  	uint8			flags;
  	void*			exceptPtr;
+ #if defined(__hpux) && !defined(__GNUC__)
+ 	double			align;
+ #else
  	double			align[0];  /* for alignment (Gcc extension) */
+ #endif
  } ctx;
  
  extern ctx** threadContext;

--------------3C67627810E2
Content-Type: text/plain; charset=us-ascii; name="md.s"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="md.s"

; <bernard@edsug.com> 20-Mar-97
; The native HP compiler doesn't have inline assembler like GCC
; This is basically the same as the GCC version bar the fact we
; need a small routine to get at the stack pointer.

        .LEVEL 1.1
	.SPACE	$TEXT$,SORT=8
	.SUBSPA	$CODE$,QUAD=0,ALIGN=4,ACCESS=0x2c,CODE_ONLY,SORT=24
        .EXPORT parisc_threadswitch,ENTRY,PRIV_LEV=3,RTNVAL=GR
parisc_threadswitch
        .PROC
        .CALLINFO FRAME=192
        .ENTRY
        ldo 192(%r30),%r30
        stw %r2,-180(0,%r30)
        stw %r2,-176(0,%r30)
        stw %r3,-172(0,%r30)
        stw %r4,-168(0,%r30)
        stw %r5,-164(0,%r30)
        stw %r6,-160(0,%r30)
        stw %r7,-156(0,%r30)
        stw %r8,-152(0,%r30)
        stw %r9,-148(0,%r30)
        stw %r10,-144(0,%r30)
        stw %r11,-140(0,%r30)
        stw %r12,-136(0,%r30)
        stw %r13,-132(0,%r30)
        stw %r14,-128(0,%r30)
        stw %r15,-124(0,%r30)
        stw %r16,-120(0,%r30)
        stw %r17,-116(0,%r30)
        stw %r18,-112(0,%r30)
        ldo -104(%r30),%r1
        fstds,ma %fr12,8(0,%r1)
        fstds,ma %fr13,8(0,%r1)
        fstds,ma %fr14,8(0,%r1)
        fstds,ma %fr15,8(0,%r1)
        fstds,ma %fr16,8(0,%r1)
        fstds,ma %fr17,8(0,%r1)
        fstds,ma %fr18,8(0,%r1)
        fstds,ma %fr19,8(0,%r1)
        fstds,ma %fr20,8(0,%r1)
        fstds,ma %fr21,8(0,%r1)
        stw %r30,0(0,%r26)
        ldw 0(0,%r25),%r30
        ldw -172(0,%r30),%r3
        ldw -168(0,%r30),%r4
        ldw -164(0,%r30),%r5
        ldw -160(0,%r30),%r6
        ldw -156(0,%r30),%r7
        ldw -152(0,%r30),%r8
        ldw -148(0,%r30),%r9
        ldw -144(0,%r30),%r10
        ldw -140(0,%r30),%r11
        ldw -136(0,%r30),%r12
        ldw -132(0,%r30),%r13
        ldw -128(0,%r30),%r14
        ldw -124(0,%r30),%r15
        ldw -120(0,%r30),%r16
        ldw -116(0,%r30),%r17
        ldw -112(0,%r30),%r18
        ldo -104(%r30),%r1
        fldds,ma 8(0,%r1),%fr12
        fldds,ma 8(0,%r1),%fr13
        fldds,ma 8(0,%r1),%fr14
        fldds,ma 8(0,%r1),%fr15
        fldds,ma 8(0,%r1),%fr16
        fldds,ma 8(0,%r1),%fr17
        fldds,ma 8(0,%r1),%fr18
        fldds,ma 8(0,%r1),%fr19
        fldds,ma 8(0,%r1),%fr20
        fldds,ma 8(0,%r1),%fr21
        ldw -180(0,%r30),%r2
	comib,<> 0,%r2,__nodyncall
        nop
        ldw -176(0,%r30),%r22
        ldo -192(%r30),%r30
        b,n $$dyncall
__nodyncall
        bv 0(%r2)
        ldo -192(%r30),%r30
        .EXIT
        .PROCEND

        .EXPORT parisc_get_sp,ENTRY,PRIV_LEV=3,RTNVAL=GR
parisc_get_sp
        .PROC
        .CALLINFO FRAME=0
        .ENTRY
        bv 0(%r2)
        copy %r30,%r28
        .EXIT
        .PROCEND

        .IMPORT $$dyncall
        .END


--------------3C67627810E2--