CVS: sml/src/runtime/mach-dep X86.prim.asm,1.8,1.9 signal-sysdep.h,1.11,1.12

John Reppy <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj.commits
Message-ID <[email protected]>
Update of /cvsroot/smlnj/sml/src/runtime/mach-dep
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2909/src/runtime/mach-dep

Modified Files:
	X86.prim.asm signal-sysdep.h 
Log Message:
  Port to Intel Mac.


Index: X86.prim.asm
===================================================================
RCS file: /cvsroot/smlnj/sml/src/runtime/mach-dep/X86.prim.asm,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** X86.prim.asm	3 May 2005 17:26:49 -0000	1.8
--- X86.prim.asm	6 Feb 2006 22:04:00 -0000	1.9
***************
*** 16,19 ****
--- 16,29 ----
  #include "ml-limits.h"
  	
+ #if defined(OPSYS_DARWIN)
+ /* Note: although the MacOS assembler claims to be the GNU assembler, it appears to be
+  * an old version (1.38), which uses different alignment directives.
+  */
+ #undef ALIGNTEXT4
+ #undef ALIGNDATA4
+ #define ALIGNTEXT4	.align 2
+ #define ALIGNDATA4	.align 2
+ #endif
+ 
  /*
   *
***************
*** 66,69 ****
--- 76,81 ----
  #define	stdclos		REGOFF(76,ESP)
  
+ #define espsave		REGOFF(80,ESP)
+ 
  #define ML_STATE_OFFSET 176
  #define mlstate_ptr	REGOFF(ML_STATE_OFFSET, ESP)
***************
*** 85,91 ****
  	D_LONG 0		
  
- SavedSP:
- 	D_LONG 0		/* Value of stack pointer to restore */
- 
  
  #include "mlstate-offsets.h"	/** this file is generated **/
--- 97,100 ----
***************
*** 97,119 ****
   *
   * 	Caller save registers: eax, ecx, edx
!  * 	Callee save registers: ebx, esi, edi, and ebp. 
   * 	Floating point state is caller-save.
   * 	Arguments passed on stack.  Rightmost argument pushed first.
   * 	Word-sized result returned in %eax.
   */
  
  #define cresult	EAX
  
  #define CALLEE_SAVE	\
  	PUSH_L(EBX);	\
  	PUSH_L(ESI);	\
! 	PUSH_L(EDI);	\
! 	PUSH_L(EBP)	
  
  #define CALLEE_RESTORE	\
- 	POP_L(EBP);	\
  	POP_L(EDI);	\
  	POP_L(ESI);	\
! 	POP_L(EBX) 
  
  /* MOVE copies one memory location to another, using a specified temporary. */
--- 106,132 ----
   *
   * 	Caller save registers: eax, ecx, edx
!  * 	Callee save registers: ebx, esi, edi, and ebp.
!  *	Save frame pointer (ebx) first to match standard function prelude
   * 	Floating point state is caller-save.
   * 	Arguments passed on stack.  Rightmost argument pushed first.
   * 	Word-sized result returned in %eax.
+  *	On Darwin, stack frame must be multiple of 16 bytes
   */
  
  #define cresult	EAX
  
+ #define CALLEE_SAVE_SZB 16	/* ebp, ebx, esi, edi */
+ 
  #define CALLEE_SAVE	\
+ 	PUSH_L(EBP);	\
  	PUSH_L(EBX);	\
  	PUSH_L(ESI);	\
! 	PUSH_L(EDI)
  
  #define CALLEE_RESTORE	\
  	POP_L(EDI);	\
  	POP_L(ESI);	\
! 	POP_L(EBX);	\
! 	POP_L(EBP)
  
  /* MOVE copies one memory location to another, using a specified temporary. */
***************
*** 185,189 ****
  
  /* Request a fault.  The floating point coprocessor must be reset
!  * (thus trashing the FP registers) since we don't know whether a 
   * value has been pushed into the temporary "register".	 This is OK 
   * because no floating point registers will be live at the start of 
--- 198,202 ----
  
  /* Request a fault.  The floating point coprocessor must be reset
!  * (thus trashing the FP registers) since we do not know whether a 
   * value has been pushed into the temporary "register".	 This is OK 
   * because no floating point registers will be live at the start of 
***************
*** 191,195 ****
   */
  ENTRY(request_fault)
! 	CALL(CSYM(FPEEnable))          /* Doesn't trash any general regs. */
  	MOV_L(CONST(REQ_FAULT), request_w)
  	MOVE(stdlink,temp,pc)
--- 204,208 ----
   */
  ENTRY(request_fault)
! 	CALL(CSYM(FPEEnable))          /* Does not trash any general regs. */
  	MOV_L(CONST(REQ_FAULT), request_w)
  	MOVE(stdlink,temp,pc)
***************
*** 249,253 ****
  
  	/* Pop the stack frame and return to run_ml(). */
! 	MOV_L(SavedSP, ESP)
  	CALLEE_RESTORE
  	RET
--- 262,270 ----
  
  	/* Pop the stack frame and return to run_ml(). */
! #if defined(OPSYS_DARWIN)
! 	LEA_L(REGOFF(ML_FRAME_SIZE+12,ESP),ESP)
! #else
! 	MOV_L(espsave, ESP)
! #endif
  	CALLEE_RESTORE
  	RET
***************
*** 256,273 ****
  	ALIGNTEXT4
  ENTRY(restoreregs)
! 	MOV_L(4(ESP), temp)		/* Get argument (MLState ptr). */
  	CALLEE_SAVE
! 
! 	MOV_L(ESP, SavedSP)		/* save stack pointer */
! 
! 	/* Align on 8 byte boundary. Assumes that the stack
  	 * starts out being at least word aligned. But who knows ...
  	 */
  	OR_L(CONST(4), ESP)		
  	SUB_L(CONST(4), ESP)		/* stack grows from high to low */
  	
  #define temp2	EBX
! 	/* Allocate and initialize the ML stack frame. */
! 	SUB_L(CONST(ML_FRAME_SIZE), ESP)
  	MOVE(REGOFF(ExnPtrOffMSP, temp),  temp2, exncont)
  	MOVE(REGOFF(LimitPtrOffMSP, temp), temp2, limitptr)
--- 273,297 ----
  	ALIGNTEXT4
  ENTRY(restoreregs)
! 	MOV_L(REGOFF(4,ESP), temp)	/* Get argument (MLState ptr). */
  	CALLEE_SAVE
! #if defined(OPSYS_DARWIN)
!       /* MacOS X frames must be 16-byte aligned.  We have 20 bytes on
!        * the stack for the return PC and callee-saves, so we need a
!        * 12-byte pad.
!        */
! 	SUB_L(CONST(ML_FRAME_SIZE+12), ESP)
! #else
! 	/* Align sp on 8 byte boundary. Assumes that the stack
  	 * starts out being at least word aligned. But who knows ...
  	 */
+ 	MOV_L(ESP,EBX)
  	OR_L(CONST(4), ESP)		
  	SUB_L(CONST(4), ESP)		/* stack grows from high to low */
+ 	SUB_L(CONST(ML_FRAME_SIZE), ESP)
+ 	MOV_L(EBX,espsave)
+ #endif
  	
  #define temp2	EBX
!       /* Initialize the ML stack frame. */
  	MOVE(REGOFF(ExnPtrOffMSP, temp),  temp2, exncont)
  	MOVE(REGOFF(LimitPtrOffMSP, temp), temp2, limitptr)
***************
*** 301,305 ****
  #define	tmpreg	misc2
  
! 	/* note that we're entering ML */
  	MOV_L(REGOFF(VProcOffMSP,temp),temp)  /* temp is now vsp */
  #define vsp	temp
--- 325,329 ----
  #define	tmpreg	misc2
  
! 	/* note that we are entering ML */
  	MOV_L(REGOFF(VProcOffMSP,temp),temp)  /* temp is now vsp */
  #define vsp	temp

Index: signal-sysdep.h
===================================================================
RCS file: /cvsroot/smlnj/sml/src/runtime/mach-dep/signal-sysdep.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** signal-sysdep.h	16 May 2003 16:59:31 -0000	1.11
--- signal-sysdep.h	6 Feb 2006 22:04:00 -0000	1.12
***************
*** 275,278 ****
--- 275,279 ----
         }
  #    elif defined(OPSYS_MACOS_10_2)
+      /* see /usr/include/mach/ppc/thread_status.h */
  #      define SIG_GetPC(scp)		((scp)->uc_mcontext->ss.srr0)
  #      define SIG_SetPC(scp, addr)	{(scp)->uc_mcontext->ss.srr0 = (int) addr;}
***************
*** 511,514 ****
--- 512,526 ----
  #    define SIG_ZeroLimitPtr(scp)  { ML_X86Frame[LIMITPTR_X86OFFSET] = 0; }
  
+ #  elif defined(OPSYS_DARWIN)
+     /** x86, Darwin **/
+ #    define SIG_FAULT1		SIGFPE
+ #    define INT_DIVZERO(s, c)	(((s) == SIGFPE) && ((c) == FPE_FLTDIV))
+ #    define INT_OVFLW(s, c)	(((s) == SIGFPE) && ((c) == FPE_FLTOVF))
+     /* see /usr/include/mach/i386/thread_status.h */
+ #    define SIG_GetCode(info,scp)	((info)->si_code)
+ #    define SIG_GetPC(scp)		((scp)->uc_mcontext->ss.eip)
+ #    define SIG_SetPC(scp, addr)	{ (scp)->uc_mcontext->ss.eip = (int) addr; }
+ #    define SIG_ZeroLimitPtr(scp)	{ ML_X86Frame[LIMITPTR_X86OFFSET] = 0; }
+ 
  #  else
  #    error "unknown OPSYS for x86"



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.