Changeset 14993


Ignore:
Timestamp:
Sep 20, 2011, 6:03:22 PM (8 years ago)
Author:
rme
Message:

Remove DARWIN_GS_HACK code.

Location:
trunk/source/lisp-kernel
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/m4macros.m4

    r14872 r14993  
    328328
    329329equate_if_defined(`HAVE_TLS')
    330 /* DARWIN_GS_HACK is hopefully short-lived */
    331 equate_if_defined(`DARWIN_GS_HACK')
    332330
    333331equate_if_defined(`TCR_IN_GPR')
  • trunk/source/lisp-kernel/thread_manager.c

    r14992 r14993  
    575575suspend_resume_handler(int signo, siginfo_t *info, ExceptionInformation *context)
    576576{
    577 #ifdef DARWIN_GS_HACK
    578   Boolean gs_was_tcr = ensure_gs_pthread();
    579 #endif
    580577  TCR *tcr = get_interrupt_tcr(false);
    581578 
     
    599596    TCR_AUX(tcr)->suspend_context = NULL;
    600597  }
    601 #ifdef DARWIN_GS_HACK
    602   if (gs_was_tcr) {
    603     set_gs_address(tcr);
    604   }
    605 #endif
    606598  SIGRETURN(context);
    607599}
     
    883875#endif
    884876#ifdef DARWIN
    885   /* There's no way to do this yet.  See DARWIN_GS_HACK */
     877  /*
     878   * There's apparently no way to do this.  We used to use a horrible
     879   * and slow kludge conditionalized on DARWIN_GS_HACK (which involved
     880   * sharing gs between lisp and pthreads), hoping that Apple would
     881   * eventually provide a way to set fsbase.  We got tired of waiting,
     882   * and have now resigned ourselves to keeping the TCR in a GPR.
     883   */
    886884  /* darwin_set_x8664_fs_reg(tcr); */
    887885#endif
  • trunk/source/lisp-kernel/x86-asmutils64.s

    r13337 r14993  
    187187_endfn
    188188        __endif
    189 
    190        
    191        
    192         __ifdef(`DARWIN_GS_HACK')
    193 /* Check (in an ugly, non-portable way) to see if %gs is addressing
    194    pthreads data.  If it was, return 0; otherwise, assume that it's
    195    addressing a lisp tcr and set %gs to point to the tcr's tcr.osid,
    196    then return 1. */
    197        
    198 thread_signature = 0x54485244 /* 'THRD' */
    199        
    200 _exportfn(C(ensure_gs_pthread))
    201         __(cmpl $thread_signature,%gs:0)
    202         __(movl $0,%eax)
    203         __(je 9f)
    204         __(movq %gs:tcr.osid,%rdi)
    205         __(movl $0x3000003,%eax)
    206         __(syscall)
    207         __(movl $1,%eax)
    208 9:      __(repret)
    209 _endfn
    210 
    211         /* Ensure that %gs addresses the linear address in %rdi */
    212         /* This incidentally returns the segment selector .*/
    213 _exportfn(C(set_gs_address))
    214         __(movl $0x3000003,%eax)
    215         __(syscall)
    216         __(ret)
    217 _endfn
    218         __endif
    219 
     189       
    220190        __ifdef(`WIN_64')
    221191/* %rcx = CONTEXT, %rdx = tcr, %r8 = old_valence.  This pretty
  • trunk/source/lisp-kernel/x86-exceptions.c

    r14992 r14993  
    13771377)
    13781378{
    1379 #ifdef DARWIN_GS_HACK
    1380   Boolean gs_was_tcr = ensure_gs_pthread();
    1381 #endif
    13821379  xframe_list xframe_link;
    13831380#ifndef DARWIN
     
    14081405#endif
    14091406  /* raise_pending_interrupt(tcr); */
    1410 #ifdef DARWIN_GS_HACK
    1411   if (gs_was_tcr) {
    1412     set_gs_address(tcr);
    1413   }
    1414 #endif
    14151407#ifndef DARWIN_USE_PSEUDO_SIGRETURN
    14161408  SIGRETURN(context);
     
    15861578                               ExceptionInformation *context,
    15871579                               LispObj return_address
    1588 #ifdef DARWIN_GS_HACK
    1589                                , Boolean gs_was_tcr
    1590 #endif
    15911580                               )
    15921581{
     
    16251614#endif
    16261615  *--foreign_rsp = return_address;
    1627 #ifdef DARWIN_GS_HACK
    1628   if (gs_was_tcr) {
    1629     set_gs_address(tcr);
    1630   }
    1631 #endif
    16321616  switch_to_foreign_stack(foreign_rsp,handler,signum,info_copy,xp);
    16331617}
     
    16591643                                     context,
    16601644                                     (LispObj)__builtin_return_address(0)
    1661 #ifdef DARWIN_GS_HACK
    1662                                      , false
    1663 #endif
    16641645
    16651646                                     );
     
    16851666     
    16861667  handle_signal_on_foreign_stack(tcr,signal_handler,signum,info,context,(LispObj)__builtin_return_address(0)
    1687 #ifdef DARWIN_GS_HACK
    1688                                  , false
    1689 #endif
    16901668);
    16911669}
     
    17101688interrupt_handler (int signum, siginfo_t *info, ExceptionInformation *context)
    17111689{
    1712 #ifdef DARWIN_GS_HACK
    1713   Boolean gs_was_tcr = ensure_gs_pthread();
    1714 #endif
    17151690  TCR *tcr = get_interrupt_tcr(false);
    17161691  int old_valence = tcr->valence;
     
    17731748    }
    17741749  }
    1775 #ifdef DARWIN_GS_HACK
    1776   if (gs_was_tcr) {
    1777     set_gs_address(tcr);
    1778   }
    1779 #endif
    17801750#ifdef WINDOWS
    17811751  restore_windows_context(context,tcr,old_valence);
     
    17911761arbstack_interrupt_handler (int signum, siginfo_t *info, ExceptionInformation *context)
    17921762{
    1793 #ifdef DARWIN_GS_HACK
    1794   Boolean gs_was_tcr = ensure_gs_pthread();
    1795 #endif
    17961763  TCR *tcr = get_interrupt_tcr(false);
    17971764  area *vs = tcr->vs_area;
     
    18061773                                   context,
    18071774                                   (LispObj)__builtin_return_address(0)
    1808 #ifdef DARWIN_GS_HACK
    1809                                    ,gs_was_tcr
    1810 #endif
    18111775                                   );
    18121776  } else {
    18131777    /* If we're not on the value stack, we pretty much have to be on
    18141778       the C stack.  Just run the handler. */
    1815 #ifdef DARWIN_GS_HACK
    1816     if (gs_was_tcr) {
    1817       set_gs_address(tcr);
    1818     }
    1819 #endif
    18201779    interrupt_handler(signum, info, context);
    18211780  }
     
    18271786altstack_interrupt_handler (int signum, siginfo_t *info, ExceptionInformation *context)
    18281787{
    1829 #ifdef DARWIN_GS_HACK
    1830   Boolean gs_was_tcr = ensure_gs_pthread();
    1831 #endif
    18321788  TCR *tcr = get_interrupt_tcr(false);
    18331789  handle_signal_on_foreign_stack(tcr,interrupt_handler,signum,info,context,(LispObj)__builtin_return_address(0)
    1834 #ifdef DARWIN_GS_HACK
    1835                                  ,gs_was_tcr
    1836 #endif
    18371790                                 );
    18381791}
     
    21042057arbstack_suspend_resume_handler(int signum, siginfo_t *info, ExceptionInformation  *context)
    21052058{
    2106 #ifdef DARWIN_GS_HACK
    2107   Boolean gs_was_tcr = ensure_gs_pthread();
    2108 #endif
    21092059  TCR *tcr = get_interrupt_tcr(false);
    21102060  if (tcr != NULL) {
     
    21212071                                       context,
    21222072                                       (LispObj)__builtin_return_address(0)
    2123 #ifdef DARWIN_GS_HACK
    2124                                        ,gs_was_tcr
    2125 #endif
    21262073                                       );
    21272074    } else {
    21282075      /* If we're not on the value stack, we pretty much have to be on
    21292076         the C stack.  Just run the handler. */
    2130 #ifdef DARWIN_GS_HACK
    2131       if (gs_was_tcr) {
    2132         set_gs_address(tcr);
    2133       }
    2134 #endif
    21352077    }
    21362078  }
     
    21432085altstack_suspend_resume_handler(int signum, siginfo_t *info, ExceptionInformation  *context)
    21442086{
    2145 #ifdef DARWIN_GS_HACK
    2146   Boolean gs_was_tcr = ensure_gs_pthread();
    2147 #endif
    21482087  TCR* tcr = get_tcr(true);
    21492088  handle_signal_on_foreign_stack(tcr,
     
    21532092                                 context,
    21542093                                 (LispObj)__builtin_return_address(0)
    2155 #ifdef DARWIN_GS_HACK
    2156                                  ,gs_was_tcr
    2157 #endif
    21582094                                 );
    21592095}
     
    21942130thread_kill_handler(int signum, siginfo_t *info, ExceptionInformation *xp)
    21952131{
    2196 #ifdef DARWIN_GS_HACK
    2197   Boolean gs_was_tcr = ensure_gs_pthread();
    2198 #endif
    21992132  TCR *tcr = get_tcr(false);
    22002133  sigset_t mask;
     
    22142147arbstack_thread_kill_handler(int signum, siginfo_t *info, ExceptionInformation *context)
    22152148{
    2216 #ifdef DARWIN_GS_HACK
    2217   Boolean gs_was_tcr = ensure_gs_pthread();
    2218 #endif
    22192149  TCR *tcr = get_interrupt_tcr(false);
    22202150  area *vs = tcr->vs_area;
     
    22292159                                   context,
    22302160                                   (LispObj)__builtin_return_address(0)
    2231 #ifdef DARWIN_GS_HACK
    2232                                    ,gs_was_tcr
    2233 #endif
    22342161                                   );
    22352162  } else {
    22362163    /* If we're not on the value stack, we pretty much have to be on
    22372164       the C stack.  Just run the handler. */
    2238 #ifdef DARWIN_GS_HACK
    2239     if (gs_was_tcr) {
    2240       set_gs_address(tcr);
    2241     }
    2242 #endif
    22432165    thread_kill_handler(signum, info, context);
    22442166  }
     
    22502172altstack_thread_kill_handler(int signum, siginfo_t *info, ExceptionInformation *context)
    22512173{
    2252 #ifdef DARWIN_GS_HACK
    2253   Boolean gs_was_tcr = ensure_gs_pthread();
    2254 #endif
    22552174  TCR* tcr = get_tcr(true);
    22562175  handle_signal_on_foreign_stack(tcr,
     
    22602179                                 context,
    22612180                                 (LispObj)__builtin_return_address(0)
    2262 #ifdef DARWIN_GS_HACK
    2263                                  ,gs_was_tcr
    2264 #endif
    22652181                                 );
    22662182}
  • trunk/source/lisp-kernel/x86-exceptions.h

    r14991 r14993  
    6565} alloc_instruction_id;
    6666
    67 
    68 
    69 
    70 
    71 /* Please go away. */
    72 #ifdef DARWIN_GS_HACK
    73 extern Boolean ensure_gs_pthread(void);
    74 extern void set_gs_address(void *);
    75 #endif
    76 
    77 
    7867/* sigaltstack isn't thread-specific on The World's Most Advanced OS */
    7968#ifdef DARWIN
  • trunk/source/lisp-kernel/x86-macros.s

    r14631 r14993  
    647647')
    648648
    649 /* This should only be called from a foreign context; it should be */
    650 /* assumed to bash all non-volatile C registers.  And of course it is */
    651 /* ugly, awful, non-portable, and slow.  %rdi should point to the */
    652 /* linear address that %gs should be made to address (tcr or pthread data) */
    653                                
    654 ifdef(`DARWIN_GS_HACK',`
    655 define(`set_gs_base',`
    656         ifelse($1,`',`
    657         ',`
    658         __(movq $1,%rdi)
    659         ')
    660         __(movl `$'0x3000003,%eax)
    661         __(syscall)
    662 ')
    663 
    664 /* %gs addresses the tcr.  Make it address pthread data before running */
    665 /* foreign code */       
    666        
    667 define(`set_foreign_gs_base',`
    668         set_gs_base(`rcontext(tcr.osid)')
    669 ')
    670 
    671 /* %gs addresses the tcr.  Get the linear address of the tcr and */
    672 /* copy it to $1 */
    673 
    674 define(`save_tcr_linear',`
    675         __(movq rcontext(tcr.linear),$1)
    676 ')
    677        
    678 ')
    679 
    680649/*  On AMD hardware (at least), a one-byte RET instruction should be */
    681650/*  prefixed with a REP prefix if it (a) is the target of a  */
  • trunk/source/lisp-kernel/x86-spentry64.s

    r14827 r14993  
    40014001        __endif
    40024002        __(movq (%rsp),%rbp)
    4003         __ifdef(`DARWIN_GS_HACK')
    4004          /* At this point, %imm1=%rdx is live (contains
    4005             the entrypoint) and %imm0.b=%al contains
    4006             info about xmm register arguments; the lisp registers are
    4007             all saved, and the foreign arguments are
    4008             on the foreign stack (about to be popped
    4009             off).  Save the linear TCR address in %save0/%r15
    4010             so that we can restore it later, and preserve
    4011             the entrypoint somewhere where C won't bash it.
    4012             Note that dereferencing the entrypoint from
    4013             foreign code has never been safe (unless it's
    4014             a fixnum */
    4015          __(save_tcr_linear(%csave0))
    4016          __(movq %imm1,%csave1)
    4017          __(movq %imm0,%csave2)
    4018          __(set_foreign_gs_base())
    4019          __(movq %csave1,%imm1)
    4020          __(movq %csave2,%imm0)
    4021         __endif
    40224003        __ifdef(`TCR_IN_GPR')
    40234004        /* Preserve TCR pointer */
     
    40494030        __endif
    40504031        __(movq %rbp,%rsp)
    4051         __ifdef(`DARWIN_GS_HACK')
    4052          /* %rax/%rdx contains the return value (maybe), %csave1 still
    4053             contains the linear tcr address.  Preserve %rax/%rdx here. */
    4054          __(movq %rax,%csave1)
    4055          __(movq %rdx,%csave2)
    4056          __(set_gs_base(%csave0))
    4057          __(movq %csave1,%rax)
    4058          __(movq %csave2,%rdx)
    4059         __endif
    40604032        __ifdef(`TCR_IN_GPR')
    40614033        __(movq %csave0, %rcontext_reg)
     
    42334205        __(emms)
    42344206        __(movq (%rsp),%rbp)
    4235         __ifdef(`DARWIN_GS_HACK')
    4236          /* At this point, %imm1=%rdx is live (contains
    4237             the entrypoint) and %imm0.b=%al contains
    4238             xmm argument info; the lisp registers are
    4239             all saved, and the foreign arguments are
    4240             on the foreign stack (about to be popped
    4241             off).  Save the linear TCR address in %csave1/%r12
    4242             so that we can restore it later, and preserve
    4243             the entrypoint somewhere where C won't bash it.
    4244             Note that dereferencing the entrypoint from
    4245             foreign code has never been safe (unless it's
    4246             a fixnum */
    4247          __(save_tcr_linear(%csave1))
    4248          __(movq %imm0,%csave2)
    4249          __(movq %imm1,%csave3)
    4250          __(set_foreign_gs_base())
    4251          __(movq %csave2,%imm0)
    4252          __(movq %csave3,%imm1)
    4253         __endif
    42544207        __ifdef(`TCR_IN_GPR')
    42554208        /* Preserve TCR pointer */
     
    42814234        __(movsd %xmm1,24(%csave0))
    42824235        __(movq %rbp,%rsp)
    4283         __ifdef(`DARWIN_GS_HACK')
    4284          /* %rax/%rdx contains the return value (maybe), %save0 still
    4285             contains the linear tcr address.  Preserve %rax/%rdx here. */
    4286          __(set_gs_base(%csave1))
    4287          __(movq (%csave0),%rax)
    4288          __(movq 8(%csave0),%rdx)
    4289          __(movsd 16(%csave0),%xmm0)
    4290          __(movsd 24(%csave0),%xmm1)
    4291         __endif
    42924236        __ifdef(`TCR_IN_GPR')
    42934237        __(movq %csave1, %rcontext_reg)
     
    46534597        __(movq %rax, %rcontext_reg)
    46544598        __endif
    4655         __ifdef(`DARWIN_GS_HACK')
    4656          /* linear TCR address in now in %rax; callback index was
    4657             saved in %r12 a moment ago. */
    4658          __(set_gs_base(%rax))
    4659         __endif
    466045991:      /* Align foreign stack for lisp   */
    46614600        __(pushq rcontext(tcr.save_rbp)) /* mark cstack frame's "owner" */
     
    47054644        __(addq $node_size,%rsp)
    47064645        __(ldmxcsr rcontext(tcr.foreign_mxcsr))
    4707         __ifdef(`DARWIN_GS_HACK')
    4708          /* Lucky us; nothing is live here */
    4709          __(set_foreign_gs_base())
    4710         __endif
    47114646        __(pop %rbp)
    47124647        __ifdef(`WINDOWS')
  • trunk/source/lisp-kernel/x86-subprims64.s

    r13337 r14993  
    101101        __(movq %carg0,%rcontext_reg)
    102102        __endif
    103         __ifdef(`DARWIN_GS_HACK')
    104          __(set_gs_base())
    105         __endif
    106103        __(sub $8,%rsp) /* %rsp is now 16-byte aligned  */
    107104        /* Put harmless values in lisp node registers  */
     
    139136        __(pop %csave0)
    140137        __(ldmxcsr rcontext(tcr.foreign_mxcsr))
    141         __ifdef(`DARWIN_GS_HACK')
    142          __(set_foreign_gs_base)
    143         __endif
    144138        __(movl $nil_value,%eax)
    145139        __(leave)
Note: See TracChangeset for help on using the changeset viewer.