VirtualBox

Ignore:
Timestamp:
Dec 1, 2008 5:54:20 PM (16 years ago)
Author:
vboxsync
Message:

implemented stack alignment for Darwin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler_new/tcg/i386/tcg-target.c

    r14542 r14881  
    429429
    430430#ifdef VBOX
    431 DECLINLINE(void) tcg_out_long_call(TCGContext *s, tcg_target_long dst)
    432 {
    433     intptr_t disp = dst - (tcg_target_long)s->code_ptr - 5;
     431DECLINLINE(void)
     432tcg_out_long_call(TCGContext *s, void* dst)
     433{
     434    intptr_t disp = (uintptr_t)dst - (uintptr_t)s->code_ptr - 5;
    434435    tcg_out8(s,  0xe8); /* call disp32 */
    435436    tcg_out32(s, disp); /* disp32 */
    436437}
    437 
     438DECLINLINE(void)
     439tcg_out_long_jmp(TCGContext *s, void* dst)
     440{
     441    intptr_t disp = (uintptr_t)dst - (uintptr_t)s->code_ptr - 5;
     442    tcg_out8(s,  0xe9); /* jmp disp32 */
     443    tcg_out32(s, disp); /* disp32 */
     444}
    438445#endif /* VBOX */
    439446
     
    539546};
    540547
     548#ifdef RT_OS_DARWIN
    541549static void tcg_out_vbox_phys_read(TCGContext *s, int index,
    542550                                   int addr_reg,
    543                                    int data_reg, int data_reg2) {
     551                                   int data_reg, int data_reg2)
     552{
     553    int useReg2 = ((index & 3) == 3);
     554
     555    /** @todo:  should we make phys addess accessors fastcalls - probably not a big deal */
     556    /* out parameter (address), note that phys address is always 64-bit */
     557    AssertMsg(sizeof(RTGCPHYS) == 8, ("Physical address must be 64-bits, update caller\n"));
     558   
     559    tcg_out8(s, 0xf7); tcg_out8(s, 0xc4); tcg_out32(s, 0xf); /* test $0xf, %esp */
     560    tcg_out8(s, 0x74); tcg_out8(s, 0x4); /* je 1 */
     561    tcg_out8(s, 0x8d);  tcg_out8(s, 0x64);  tcg_out8(s, 0x24);  tcg_out8(s, 0xf8);      /* lea    -0x8(%esp),%esp */
     562   /* 1: */
     563    tcg_out8(s, 0x6a); tcg_out8(s, 0x00); /* push $0 */
     564    tcg_out_push(s, addr_reg);
     565
     566    tcg_out8(s, 0xe8);  tcg_out32(s, 0); /* call 2 */
     567   /* 2: */
     568    tcg_out8(s, 0x74); tcg_out8(s, 0x6); /* je 3 */
     569    tcg_out8(s, 0x83); tcg_out8(s, 0x04); tcg_out8(s, 0x24); tcg_out8(s, 0x11); /* addl   $0x11,(%esp) */
     570    tcg_out8(s, 0xeb); tcg_out8(s, 0x04); /* jmp 4 */
     571   /* 3: */
     572    tcg_out8(s, 0x83); tcg_out8(s, 0x04); tcg_out8(s, 0x24); tcg_out8(s, 0x14); /* addl   $0x14,(%esp) */
     573   /* 4: */
     574    tcg_out_long_jmp(s, vbox_ld_helpers[index]);
     575
     576   /* return point 1: clear both parameter and alignment */
     577    tcg_out8(s, 0x83);  tcg_out8(s, 0xc4);   tcg_out8(s, 0x08); /* add    $0x8,%esp */
     578   /* return point 2: clear only parameter */
     579    tcg_out8(s, 0x83);  tcg_out8(s, 0xc4);   tcg_out8(s, 0x08); /* add    $0x8,%esp */
     580    /* mov %eax, data_reg */
     581    tcg_out_mov(s, data_reg, TCG_REG_EAX);
     582
     583    /* returned 64-bit value */
     584    if (useReg2)
     585      tcg_out_mov(s, data_reg2, TCG_REG_EDX);
     586}
     587#else
     588static void tcg_out_vbox_phys_read(TCGContext *s, int index,
     589                                   int addr_reg,
     590                                   int data_reg, int data_reg2)
     591{
    544592    int useReg2 = ((index & 3) == 3);
    545593
     
    550598    tcg_out_push(s, addr_reg);
    551599
    552     tcg_out_long_call(s, (tcg_target_long)vbox_ld_helpers[index]);
     600    tcg_out_long_call(s, vbox_ld_helpers[index]);
    553601
    554602    /* mov %eax, data_reg */
     
    562610    tcg_out_addi(s, TCG_REG_ESP, 8);
    563611}
     612#endif
     613
    564614
    565615static void tcg_out_vbox_phys_write(TCGContext *s, int index,
     
    580630
    581631    /* call it */
    582     tcg_out_long_call(s, (tcg_target_long)vbox_st_helpers[index]);
     632    tcg_out_long_call(s, vbox_st_helpers[index]);
    583633   
    584634    /* clean stack after us */
     
    13261376    TCG_REG_EBP,
    13271377    TCG_REG_EBX,
    1328     TCG_REG_ESI, /* currently used for the global env, so no
    1329                     need to save */
     1378    /* TCG_REG_ESI ,*/ /* currently used for the global env, so no
     1379                          need to save */
    13301380    TCG_REG_EDI,
    13311381#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette