Changeset 5010


Ignore:
Timestamp:
Aug 22, 2006, 1:06:42 AM (18 years ago)
Author:
Gary Byers
Message:

Unbox %arg_z (boxed entrypoint) earlier in _SPffcall, before entering foreign
context. (Need to check PPC version(s) as well.)

Use DARWIN_GS_HACK to swap %gs memory around when transitioning between foreign
code and lisp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lisp-kernel/x86-spentry64.s

    r4949 r5010  
    39613961
    39623962_spentry(ffcall)
     3963        /* Unbox %arg_z.  It's either a fixnum or macptr (or bignum) ;
     3964          if not a fixnum, get the first word */
     3965        __(unbox_fixnum(%arg_z,%imm0))
     3966        __(testb $fixnummask,%arg_z_b)
     3967        __(je 0f)
     3968        __(movq macptr.address(%arg_z),%imm0)
     39690:             
    39633970        /* Save lisp registers   */
    39643971        __(push %temp0)
     
    39823989        __(movq $TCR_STATE_FOREIGN,%rcontext:tcr.valence)
    39833990        __(emms)
     3991        __(ldmxcsr %rcontext:tcr.foreign_mxcsr)
    39843992        __(movq (%rsp),%rbp)
    3985         __(ldmxcsr %rcontext:tcr.foreign_mxcsr)
     3993        __ifdef([DARWIN_GS_HACK])
     3994         /* At this point, %imm0=%rax is live (contains
     3995            the entrypoint); the lisp registers are
     3996            all saved, and the foreign arguments are
     3997            on the foreign stack (about to be popped
     3998            off).  Save the linear TCR address in %save0/%r15
     3999            so that we can restore it later, and preserve
     4000            the entrypoint somewhere where C won't bash it.
     4001            Note that dereferencing the entrypoint from
     4002            foreign code has never been safe (unless it's
     4003            a fixnum */
     4004         __(save_tcr_linear(%save0))
     4005         __(movq %imm0,%save1)
     4006         __(set_foreign_gs_base())
     4007         __(movq %save1,%imm0)
     4008        __endif
    39864009        __(addq $2*node_size,%rsp)
    3987         __(unbox_fixnum(%arg_z,%r11))
    3988         __(testb $fixnummask,%arg_z_b)
    3989         __(movq %arg_z,%r10)
    39904010        __(pop %rdi)
    39914011        __(pop %rsi)
    39924012        __(pop %rdx)
    3993         __(je 0f)
    3994         __(mov macptr.address(%r10),%r11)
    3995 0:             
    39964013        __(pop %rcx)
    39974014        __(pop %r8)
    39984015        __(pop %r9)
    3999         __(call *%r11)
     4016        __(call *%rax)
    40004017        __(movq %rbp,%rsp)
     4018        __ifdef([DARWIN_GS_HACK])
     4019         /* %rax/%rdx contains the return value (maybe), %save0 still
     4020            contains the linear tcr address.  Preserve %rax/%rdx here. */
     4021         __(movq %rax,%save1)
     4022         __(movq %rdx,%save2)
     4023         __(set_gs_base(%save0))
     4024         __(movq %save1,%rax)
     4025         __(movq %save2,%rdx)
     4026        __endif
    40014027        __(movq %rsp,%rcontext:tcr.foreign_sp)       
    40024028        __(clr %save3)
     
    40644090        __(pop %r9)
    40654091        __(syscall)
    4066         __ifdef([FREEBSD])
    4067         __(jnc 0f)
    4068         __(negq %rax)
     4092        __ifdef([SYSCALL_SETS_CARRY_ON_ERROR])
     4093         __(jnc 0f)
     4094         __(negq %rax)
    406940950:     
    40704096        __endif       
     
    42144240        __(movq %r12,%r11)
    42154241        __(call *%rax)
     4242        __ifdef([DARWIN_GS_HACK])
     4243         /* linear TCR address in now in %rax; callback index was
     4244            saved in %r12 a moment ago. */
     4245         __(set_gs_base(%rax))
     4246         __(movq %r12,%r11)
     4247        __endif
    421642481:      /* Align foreign stack for lisp   */
    42174249        __(subq $node_size,%rsp)
     
    42554287        __(addq $node_size,%rsp)
    42564288        __(ldmxcsr %rcontext:tcr.foreign_mxcsr)
     4289        __ifdef([DARWIN_GS_HACK])
     4290         /* Lucky us; nothing is live here */
     4291         __(set_foreign_gs_base())
     4292        __endif
    42574293        __(pop %rbp)
    42584294        __(pop %rbx)
Note: See TracChangeset for help on using the changeset viewer.