mach_dep.c
上传用户:nthfjj
上传日期:2007-01-07
资源大小:37k
文件大小:7k
- # include "runtime.h"
- /* Call allocobj or allocaobj after first saving at least those registers */
- /* not preserved by the C compiler. The register used for return values */
- /* is not saved, since it will be clobbered anyway. */
- # ifdef RT
- /* This is done in rt_allocobj.s */
- # else
- asm(" .text");
- asm(" .globl __allocobj");
- asm(" .globl __allocaobj");
- asm(" .globl _allocobj");
- asm(" .globl _allocaobj");
- # ifdef M68K
- asm("_allocobj:");
- asm(" link a6,#0");
- asm(" movl d1,sp@-");
- asm(" movl a0,sp@-");
- asm(" movl a1,sp@-");
- asm(" movl sp@(20),sp@-");
- asm(" jbsr __allocobj");
- asm(" addl #4,sp");
- asm(" movl sp@+,a1");
- asm(" movl sp@+,a0");
- asm(" movl sp@+,d1");
- asm(" unlk a6");
- asm(" rts");
-
- asm("_allocaobj:");
- asm(" link a6,#0");
- asm(" movl d1,sp@-");
- asm(" movl a0,sp@-");
- asm(" movl a1,sp@-");
- asm(" movl sp@(20),sp@-");
- asm(" jbsr __allocaobj");
- asm(" addl #4,sp");
- asm(" movl sp@+,a1");
- asm(" movl sp@+,a0");
- asm(" movl sp@+,d1");
- asm(" unlk a6");
- asm(" rts");
- # endif
- # ifdef I386
- asm(".data");
- asm("gc_ret_value: .word 0");
- asm(".word 0");
- asm(".text");
- asm("_allocaobj:");
- asm("pushl %ebp");
- asm("movl %esp,%ebp");
- asm("pushal");
- asm("pushl 8(%ebp)"); /* Push orignal argument */
- asm("call __allocaobj");
- asm("popl %ecx");
- asm("movl %eax,gc_ret_value"); /* Save return value */
- asm("popal");
- asm("movl gc_ret_value,%eax");
- asm("leave");
- asm("ret");
- asm("_allocobj:");
- asm("pushl %ebp");
- asm("movl %esp,%ebp");
- asm("pushal");
- asm("pushl 8(%ebp)"); /* Push orignal argument */
- asm("call __allocobj");
- asm("popl %ecx");
- asm("movl %eax,gc_ret_value"); /* Save return value */
- asm("popal");
- asm("movl gc_ret_value,%eax");
- asm("leave");
- asm("ret");
- # endif
- # ifdef SPARC
- asm("_allocaobj:");
- asm(" ba __allocaobj");
- asm(" nop");
- asm("_allocobj:");
- asm(" ba __allocobj");
- asm(" nop");
-
- # include <sun4/trap.h>
- asm(" .globl _save_regs_in_stack");
- asm("_save_regs_in_stack:");
- asm(" t 0x3 ! ST_FLUSH_WINDOWS");
- asm(" mov %sp,%o0");
- asm(" retl");
- asm(" nop");
- # endif
- # ifdef VAX
- asm("_allocobj:");
- asm(".word 0x3e");
- asm("pushl 4(ap)");
- asm("calls $1,__allocobj");
- asm("ret");
- asm("_allocaobj:");
- asm(".word 0x3e");
- asm("pushl 4(ap)");
- asm("calls $1,__allocaobj");
- asm("ret");
- # endif
- # ifdef NS32K
- asm("_allocobj:");
- asm("enter [],$0");
- asm("movd r1,tos");
- asm("movd r2,tos");
- asm("movd 8(fp),tos");
- asm("bsr ?__allocobj");
- asm("adjspb $-4");
- asm("movd tos,r2");
- asm("movd tos,r1");
- asm("exit []");
- asm("ret $0");
- asm("_allocaobj:");
- asm("enter [],$0");
- asm("movd r1,tos");
- asm("movd r2,tos");
- asm("movd 8(fp),tos");
- asm("bsr ?__allocaobj");
- asm("adjspb $-4");
- asm("movd tos,r2");
- asm("movd tos,r1");
- asm("exit []");
- asm("ret $0");
- # endif
- # if !defined(VAX) && !defined(M68K) && !defined(SPARC) && !defined(I386) && !defined(NS32K)
- --> fix it
- # endif
- # endif
- /* Routine to mark from registers that are preserved by the C compiler */
- mark_regs()
- {
- # ifdef RT
- register long TMP_SP; /* must be bound to r11 */
- # endif
- # ifdef VAX
- /* r1 through r5 are preserved by allocobj, and therefore */
- /* on the stack. */
- asm("pushl r11"); asm("calls $1,_tl_mark");
- asm("pushl r10"); asm("calls $1,_tl_mark");
- asm("pushl r9"); asm("calls $1,_tl_mark");
- asm("pushl r8"); asm("calls $1,_tl_mark");
- asm("pushl r7"); asm("calls $1,_tl_mark");
- asm("pushl r6"); asm("calls $1,_tl_mark");
- asm("movl sp,r11"); /* TMP_SP = stack pointer sp */
- # endif
- # ifdef M68K
- /* a0, a1 and d1 are preserved by allocobj */
- /* and therefore are on stack */
-
- asm("subqw #0x4,sp"); /* allocate word on top of stack */
- asm("movl a0,sp@"); asm("jbsr _tl_mark");
- asm("movl a1,sp@"); asm("jbsr _tl_mark");
- asm("movl a2,sp@"); asm("jbsr _tl_mark");
- asm("movl a3,sp@"); asm("jbsr _tl_mark");
- asm("movl a4,sp@"); asm("jbsr _tl_mark");
- asm("movl a5,sp@"); asm("jbsr _tl_mark");
- /* Skip frame pointer and stack pointer */
- asm("movl d0,sp@"); asm("jbsr _tl_mark");
- asm("movl d1,sp@"); asm("jbsr _tl_mark");
- asm("movl d2,sp@"); asm("jbsr _tl_mark");
- asm("movl d3,sp@"); asm("jbsr _tl_mark");
- asm("movl d4,sp@"); asm("jbsr _tl_mark");
- asm("movl d5,sp@"); asm("jbsr _tl_mark");
- asm("movl d6,sp@"); asm("jbsr _tl_mark");
- asm("movl d7,sp@"); asm("jbsr _tl_mark");
- asm("addqw #0x4,sp"); /* put stack back where it was */
- asm("movl a7,d7"); /* TMP_SP = stack pointer a7 */
- # endif
- # ifdef I386
- asm("pushl %eax"); asm("call _tl_mark"); asm("addl $4,%esp");
- asm("pushl %ecx"); asm("call _tl_mark"); asm("addl $4,%esp");
- asm("pushl %edx"); asm("call _tl_mark"); asm("addl $4,%esp");
- asm("pushl %esi"); asm("call _tl_mark"); asm("addl $4,%esp");
- asm("pushl %edi"); asm("call _tl_mark"); asm("addl $4,%esp");
- asm("pushl %ebx"); asm("call _tl_mark"); asm("addl $4,%esp");
- # endif
- # ifdef NS32K
- asm ("movd r3, tos"); asm ("bsr ?_tl_mark"); asm ("adjspb $-4");
- asm ("movd r4, tos"); asm ("bsr ?_tl_mark"); asm ("adjspb $-4");
- asm ("movd r5, tos"); asm ("bsr ?_tl_mark"); asm ("adjspb $-4");
- asm ("movd r6, tos"); asm ("bsr ?_tl_mark"); asm ("adjspb $-4");
- asm ("movd r7, tos"); asm ("bsr ?_tl_mark"); asm ("adjspb $-4");
- # endif
- # ifdef SPARC
- save_regs_in_stack();
- # endif
- # ifdef RT
- /* we used to think this wasn't necessary, but gcollect */
- /* can be called from many places ... */
- tl_mark(TMP_SP); /* tl_mark from r11 */
- asm("cas r11, r6, r0"); tl_mark(TMP_SP); /* r6 */
- asm("cas r11, r7, r0"); tl_mark(TMP_SP); /* through */
- asm("cas r11, r8, r0"); tl_mark(TMP_SP); /* r10 */
- asm("cas r11, r9, r0"); tl_mark(TMP_SP);
- asm("cas r11, r10, r0"); tl_mark(TMP_SP);
- asm("cas r11, r12, r0"); tl_mark(TMP_SP); /* r12 */
- asm("cas r11, r13, r0"); tl_mark(TMP_SP); /* through */
- asm("cas r11, r14, r0"); tl_mark(TMP_SP); /* r15 */
- asm("cas r11, r15, r0"); tl_mark(TMP_SP);
- # endif
- /* other machines... */
- # if !(defined M68K) && !(defined VAX) && !(defined RT) && !(defined SPARC) && !(defined I386) &&!(defined NS32K)
- --> bad news <--
- # endif
- }