All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xin Tong <xerox.time.tech@gmail.com>
To: 陳韋任 <chenwj@iis.sinica.edu.tw>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] TB chaining
Date: Thu, 24 Nov 2011 20:54:36 -0500	[thread overview]
Message-ID: <CALKntY0NrecY8HiBaOu7mYMc-h0icnwHmQsr46vtvmTsVh6kxw@mail.gmail.com> (raw)
In-Reply-To: <20110924111600.GA35317@cs.nctu.edu.tw>

I came back to the block chaining code. This code is still not very
clear to me. Here we are linking tb_next -> tb. jmp_next of the tb
contains the next tbs it will jump to. why are we checking the
!tb->jmp_next[n], but not !tb_next->jmp_next[n] ?

static inline void tb_add_jump(TranslationBlock *tb, int n,
                               TranslationBlock *tb_next)
{
    if (!tb->jmp_next[n]) {
        /* patch the native jump address */
        tb_set_jmp_target(tb, n, (unsigned long)tb_next->tc_ptr);

        /* add in TB jmp circular list */
        tb->jmp_next[n] = tb_next->jmp_first;
        tb_next->jmp_first = (TranslationBlock *)((long)(tb) | (n));
    }
}


Thanks a lot

Xin


On Sat, Sep 24, 2011 at 7:16 AM, 陳韋任 <chenwj@iis.sinica.edu.tw> wrote:
>> Say your are trying to emulate an indirect jump ( i.e. jmp eax). Because eax
>> is unknown at compile time, you will have to return to the mainloop to look
>> it up. However, if you know some likely values, you can do a few cached
>> compare and hope it hits one of them.
>>
>> compare eax = 0x33e3e23
>>    jmp tb 30
>> compare eax = 0332d2ed
>>   jmp tb 30
>> tb exit
>
>  I believe we are talking about the same thing. :-) The terminology
> "IBTC" is coined by "Evaluating Indirect Branch Handling Mechanisms
> in Software Dynamic Translation Systems". QEMU does not implement
> IBTC or inline caching.
>
>> If the branch target is fix, you will still need 2 jmps, one for taken
>> branch another for nottaken branch. can you show me where the code does that
>> is ?
>
>  Take x86 for example, see gen_goto_tb (target-i386/translate.c).
> gen_goto_tb generates TCG IR for block chaining. Here is the code
> snip of gen_goto_tb.
>
>    tcg_gen_goto_tb(tb_num); // tb_num could be taken or nottaken branch
>
>    gen_jmp_im(eip);
>
>    tcg_gen_exit_tb((tcg_target_long)tb + tb_num);
>
> How block chaining is done is a little complicate. You can refer to the
> white paper "Porting QEMU to Plan 9: QEMU Internals and Port Strategy"
> to get a general idea.
>
>  HTH.
>
> Regards,
> chenwj
>
> --
> Wei-Ren Chen (陳韋任)
> Computer Systems Lab, Institute of Information Science,
> Academia Sinica, Taiwan (R.O.C.)
> Tel:886-2-2788-3799 #1667
>

  reply	other threads:[~2011-11-25  1:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-21 23:05 [Qemu-devel] TB chaining Xin Tong
2011-09-22  1:37 ` Lei Li
2011-09-22  1:58   ` 陳韋任
2011-09-22  2:27     ` Lei Li
2011-09-22  2:36       ` 陳韋任
2011-09-22 12:41         ` Xin Tong
2011-09-23  2:14           ` 陳韋任
     [not found]             ` <CALKntY2XeOc1LUE0NGXy_CKUer9+gxQykYC5hDzJnskx+OfdCQ@mail.gmail.com>
2011-09-24  2:50               ` 陳韋任
2011-09-24 10:36                 ` Xin Tong
2011-09-24 11:16                   ` 陳韋任
2011-11-25  1:54                     ` Xin Tong [this message]
2011-11-25  2:52                       ` 陳韋任
2011-09-22  2:15 ` 陳韋任

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALKntY0NrecY8HiBaOu7mYMc-h0icnwHmQsr46vtvmTsVh6kxw@mail.gmail.com \
    --to=xerox.time.tech@gmail.com \
    --cc=chenwj@iis.sinica.edu.tw \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.