Changeset 9449


Ignore:
Timestamp:
May 9, 2008, 9:01:14 PM (11 years ago)
Author:
rme
Message:

callback_to_lisp: save/restore extra nodes in TCR (save0--save3,
next_method_context) to/from vstack around callback into lisp. Also
save node_regs_mask around callback.

wait_for_exception_lock_in_handler: save node_regs_mask in xframe

unlock_exception_lock_in_hander: restore node_regs_mask from xframe

recognize_alloc_instruction: recognize x8632 instruction sequences

pc_luser_xp: x8632 conditionalization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ia32/lisp-kernel/x86-exceptions.c

    r9399 r9449  
    270270finish_function_entry(ExceptionInformation *xp)
    271271{
     272#ifdef X8664
    272273  natural nargs = (xpGPR(xp,Inargs)&0xffff)>> fixnumshift;
     274#else
     275  natural nargs = xpGPR(xp,Inargs)>>fixnumshift;
     276#endif
    273277  signed_natural disp;
    274278  LispObj *vsp =  (LispObj *) xpGPR(xp,Isp), ra = *vsp++;
     
    367371#ifdef X8632
    368372  if (fulltag_of(tra) == fulltag_tra) {
    369     unsigned char *p = (unsigned char *)tra;
    370 
    371     if (*p == RECOVER_FN_OPCODE) {
    372       tra_f = (LispObj)(*((natural *)(p + 1)));
     373    if (*(unsigned char *)tra == RECOVER_FN_OPCODE) {
     374      tra_f = (LispObj)*(LispObj *)(tra + 1);
    373375    }
    374376    if (tra_f && header_subtag(header_of(tra_f)) != subtag_function) {
     
    490492  int delta;
    491493  unsigned old_mxcsr = get_mxcsr();
     494#ifdef X8632
     495  natural saved_node_regs_mask = tcr->node_regs_mask;
     496  LispObj *vsp = (LispObj *)xpGPR(xp, Isp);
     497#endif
    492498
    493499  set_mxcsr(0x1f80);
    494500
    495501  /* Put the active stack pointers where .SPcallback expects them */
     502#ifdef X8664
    496503  tcr->save_vsp = (LispObj *) xpGPR(xp, Isp);
    497 #ifdef X8664
    498504  tcr->save_rbp = (LispObj *) xpGPR(xp, Irbp);
    499505#else
    500   tcr->save_ebp = (LispObj *) xpGPR(xp, Iebp);
     506  tcr->node_regs_mask = X8632_DEFAULT_NODE_REGS_MASK;
     507
     508  *--vsp = tcr->save0;
     509  *--vsp = tcr->save1;
     510  *--vsp = tcr->save2;
     511  *--vsp = tcr->save3;
     512  *--vsp = tcr->next_method_context;
     513  xpGPR(xp, Isp) = (LispObj)vsp;
     514
     515  tcr->save_vsp = (LispObj *)xpGPR(xp, Isp);
     516  tcr->save_ebp = (LispObj *)xpGPR(xp, Iebp);
    501517#endif
    502518
     
    508524  delta = ((int (*)())callback_ptr) (xp, arg1, arg2, arg3, arg4, arg5);
    509525  LOCK(lisp_global(EXCEPTION_LOCK), tcr);
     526
     527#ifdef X8632
     528  tcr->next_method_context = *vsp++;
     529  tcr->save3 = *vsp++;
     530  tcr->save2 = *vsp++;
     531  tcr->save1 = *vsp++;
     532  tcr->save0 = *vsp++;
     533  xpGPR(xp, Isp) = (LispObj)vsp;
     534
     535  tcr->node_regs_mask = saved_node_regs_mask;
     536#endif
    510537  set_mxcsr(old_mxcsr);
    511538  return delta;
     
    577604      */
    578605      LispObj *vsp =(LispObj *)save_vsp, ra = *vsp;
     606#ifdef X8664
    579607      int nargs = (xpGPR(xp, Inargs) & 0xffff)>>fixnumshift;
    580      
     608#else
     609      int nargs = xpGPR(xp, Inargs)>>fixnumshift;
     610#endif
     611
     612#ifdef X8664
    581613      if (nargs > 3) {
    582614        xpGPR(xp,Isp)=(LispObj) (vsp + (1 + 2 + (nargs - 3)));
    583615        push_on_lisp_stack(xp,ra);
    584616      }
     617#else
     618      if (nargs > 2) {
     619        xpGPR(xp,Isp)=(LispObj) (vsp + (1 + 2 + (nargs - 2)));
     620        push_on_lisp_stack(xp,ra);
     621      }
     622#endif
    585623      xpPC(xp) = xpGPR(xp,Ifn);
    586624      xpGPR(xp,Inargs) = 1<<fixnumshift;
     
    10061044#endif
    10071045  xf->curr = context;
     1046#ifdef X8632
     1047  xf->node_regs_mask = tcr->node_regs_mask;
     1048#endif
    10081049  xf->prev = tcr->xframe;
    10091050  tcr->xframe =  xf;
     
    10161057{
    10171058  tcr->pending_exception_context = tcr->xframe->curr;
     1059#ifdef X8632
     1060  tcr->node_regs_mask = tcr->xframe->node_regs_mask;
     1061#endif
    10181062  tcr->xframe = tcr->xframe->prev;
    10191063  tcr->valence = TCR_STATE_EXCEPTION_RETURN;
     
    17311775*/
    17321776
     1777#ifdef X8664
    17331778opcode load_allocptr_reg_from_tcr_save_allocptr_instruction[] =
    17341779  {0x65,0x48,0x8b,0x1c,0x25,0xd8,0x00,0x00,0x00};
     
    17441789  {0x48,0x89,0x43,0xf3};
    17451790
    1746 
    17471791alloc_instruction_id
    17481792recognize_alloc_instruction(pc program_counter)
     
    17641808  return ID_unrecognized_alloc_instruction;
    17651809}
    1766      
     1810#endif
     1811#ifdef X8632
     1812opcode load_allocptr_reg_from_tcr_save_allocptr_instruction[] =
     1813  {0x64,0x8b,0x0d,0x84,0x00,0x00,0x00};
     1814opcode compare_allocptr_reg_to_tcr_save_allocbase_instruction[] =
     1815  {0x64,0x3b,0x0d,0x88,0x00,0x00,0x00};
     1816opcode branch_around_alloc_trap_instruction[] =
     1817  {0x7f,0x02};
     1818opcode alloc_trap_instruction[] =
     1819  {0xcd,0xc5};
     1820opcode clear_tcr_save_allocptr_tag_instruction[] =
     1821  {0x64,0x80,0x25,0x84,0x00,0x00,0x00,0xf8};
     1822opcode set_allocptr_header_instruction[] =
     1823  {0x0f,0x7e,0x41,0xfa};
     1824
     1825alloc_instruction_id
     1826recognize_alloc_instruction(pc program_counter)
     1827{
     1828  switch(program_counter[0]) {
     1829  case 0xcd: return ID_alloc_trap_instruction;
     1830  case 0x7f: return ID_branch_around_alloc_trap_instruction;
     1831  case 0x0f: return ID_set_allocptr_header_instruction;
     1832  case 0x64:
     1833    switch(program_counter[1]) {
     1834    case 0x80: return ID_clear_tcr_save_allocptr_tag_instruction;
     1835    case 0x3b: return ID_compare_allocptr_reg_to_tcr_save_allocbase_instruction;
     1836    case 0x8b: return ID_load_allocptr_reg_from_tcr_save_allocptr_instruction;
     1837    }
     1838  }
     1839  return ID_unrecognized_alloc_instruction;
     1840}
     1841#endif     
    17671842 
    17681843void
    17691844pc_luser_xp(ExceptionInformation *xp, TCR *tcr, signed_natural *interrupt_displacement)
    17701845{
    1771 #ifdef X8664
    17721846  pc program_counter = (pc)xpPC(xp);
    17731847  int allocptr_tag = fulltag_of((LispObj)(tcr->save_allocptr));
     
    17751849  if (allocptr_tag != 0) {
    17761850    alloc_instruction_id state = recognize_alloc_instruction(program_counter);
     1851#ifdef X8664
    17771852    signed_natural
    17781853      disp = (allocptr_tag == fulltag_cons) ?
    17791854      sizeof(cons) - fulltag_cons :
    17801855      xpGPR(xp,Iimm1);
     1856#else
     1857      signed_natural disp = (allocptr_tag == fulltag_cons) ?
     1858      sizeof(cons) - fulltag_cons :
     1859      xpMMXreg(xp,Imm0);
     1860#endif
    17811861    LispObj new_vector;
    17821862
     
    17881868    switch(state) {
    17891869    case ID_set_allocptr_header_instruction:
    1790       /* We were consing a vector and we won.  Set the header of the new vector
    1791          (in the allocptr register) to the header in %rax and skip over this
    1792          instruction, then fall into the next case. */
     1870      /* We were consing a vector and we won.  Set the header of the
     1871         new vector (in the allocptr register) to the header in
     1872         %eax/%rax and skip over this instruction, then fall into the
     1873         next case. */
    17931874      new_vector = xpGPR(xp,Iallocptr);
    17941875      deref(new_vector,0) = xpGPR(xp,Iimm0);
     
    18201901      break;
    18211902    case ID_branch_around_alloc_trap_instruction:
    1822       /* If we'd take the branch - which is a 'jg" - around the alloc trap,
     1903      /* If we'd take the branch - which is a "jg" - around the alloc trap,
    18231904         we might as well finish the allocation.  Otherwise, back out of the
    18241905         attempt. */
     
    18851966      /* The conditional store succeeded.  Set the refbit, return to ra0 */
    18861967      val = xpGPR(xp,Iarg_z);
     1968#ifdef X8664
    18871969      ea = (LispObj*)(xpGPR(xp,Iarg_x) + (unbox_fixnum((signed_natural)
    18881970                                                       xpGPR(xp,Itemp0))));
     1971#else
     1972      ea = (LispObj *)(misc_data_offset + xpGPR(xp,Itemp1) + xpGPR(xp,Itemp0));
     1973#endif
    18891974      xpGPR(xp,Iarg_z) = t_value;
    18901975      need_store = false;
    18911976    } else if (program_counter >= &egc_set_hash_key) {
     1977#ifdef X8664
    18921978      root = xpGPR(xp,Iarg_x);
     1979#else
     1980      root = xpGPR(xp,Itemp0);
     1981#endif
    18931982      ea = (LispObj *) (root+xpGPR(xp,Iarg_y)+misc_data_offset);
    18941983      val = xpGPR(xp,Iarg_z);
    18951984      need_memoize_root = true;
    18961985    } else if (program_counter >= &egc_gvset) {
     1986#ifdef X8664
    18971987      ea = (LispObj *) (xpGPR(xp,Iarg_x)+xpGPR(xp,Iarg_y)+misc_data_offset);
     1988#else
     1989      ea = (LispObj *) (xpGPR(xp,Itemp0)+xpGPR(xp,Iarg_y)+misc_data_offset);
     1990#endif
    18981991      val = xpGPR(xp,Iarg_z);
    18991992    } else if (program_counter >= &egc_rplacd) {
     
    19222015         to pop the return address off the stack and set
    19232016         the PC there. */
    1924       LispObj *rsp = (LispObj *)xpGPR(xp,Isp), ra = *rsp++;
     2017      LispObj *sp = (LispObj *)xpGPR(xp,Isp), ra = *sp++;
    19252018      xpPC(xp) = ra;
    1926       xpGPR(xp,Isp)=(LispObj)rsp;
     2019      xpGPR(xp,Isp)=(LispObj)sp;
    19272020    }
    19282021    return;
    19292022  }
    1930 #endif
    19312023}
    19322024
Note: See TracChangeset for help on using the changeset viewer.