All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit
Date: Tue, 04 Jun 2013 13:03:48 -0700	[thread overview]
Message-ID: <51AE4824.3000905@twiddle.net> (raw)
In-Reply-To: <1369430452-27598-1-git-send-email-rth@twiddle.net>

Ping.

r~

On 05/24/2013 02:20 PM, Richard Henderson wrote:
> Allows unwinding past the code_gen_buffer.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/arm/tcg-target.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 82 insertions(+), 9 deletions(-)
> 
> diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
> index 3d43412..4a691b1 100644
> --- a/tcg/arm/tcg-target.c
> +++ b/tcg/arm/tcg-target.c
> @@ -2100,23 +2100,31 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
>      tcg_out_movi32(s, COND_AL, ret, arg);
>  }
>  
> +/* Compute frame size via macros, to share between tcg_target_qemu_prologue
> +   and tcg_register_jit.  */
> +
> +#define PUSH_SIZE  ((11 - 4 + 1 + 1) * sizeof(tcg_target_long))
> +
> +#define FRAME_SIZE \
> +    ((PUSH_SIZE \
> +      + TCG_STATIC_CALL_ARGS_SIZE \
> +      + CPU_TEMP_BUF_NLONGS * sizeof(long) \
> +      + TCG_TARGET_STACK_ALIGN - 1) \
> +     & -TCG_TARGET_STACK_ALIGN)
> +
>  static void tcg_target_qemu_prologue(TCGContext *s)
>  {
> -    int frame_size;
> +    int stack_addend;
>  
>      /* Calling convention requires us to save r4-r11 and lr.  */
>      /* stmdb sp!, { r4 - r11, lr } */
>      tcg_out32(s, (COND_AL << 28) | 0x092d4ff0);
>  
> -    /* Allocate the local stack frame.  */
> -    frame_size = TCG_STATIC_CALL_ARGS_SIZE;
> -    frame_size += CPU_TEMP_BUF_NLONGS * sizeof(long);
> -    /* We saved an odd number of registers above; keep an 8 aligned stack.  */
> -    frame_size = ((frame_size + TCG_TARGET_STACK_ALIGN - 1)
> -                  & -TCG_TARGET_STACK_ALIGN) + 4;
> +    /* Reserve callee argument and tcg temp space.  */
> +    stack_addend = FRAME_SIZE - PUSH_SIZE;
>  
>      tcg_out_dat_rI(s, COND_AL, ARITH_SUB, TCG_REG_CALL_STACK,
> -                   TCG_REG_CALL_STACK, frame_size, 1);
> +                   TCG_REG_CALL_STACK, stack_addend, 1);
>      tcg_set_frame(s, TCG_REG_CALL_STACK, TCG_STATIC_CALL_ARGS_SIZE,
>                    CPU_TEMP_BUF_NLONGS * sizeof(long));
>  
> @@ -2127,8 +2135,73 @@ static void tcg_target_qemu_prologue(TCGContext *s)
>  
>      /* Epilogue.  We branch here via tb_ret_addr.  */
>      tcg_out_dat_rI(s, COND_AL, ARITH_ADD, TCG_REG_CALL_STACK,
> -                   TCG_REG_CALL_STACK, frame_size, 1);
> +                   TCG_REG_CALL_STACK, stack_addend, 1);
>  
>      /* ldmia sp!, { r4 - r11, pc } */
>      tcg_out32(s, (COND_AL << 28) | 0x08bd8ff0);
>  }
> +
> +typedef struct {
> +    uint32_t len __attribute__((aligned((sizeof(void *)))));
> +    uint32_t id;
> +    uint8_t version;
> +    char augmentation[1];
> +    uint8_t code_align;
> +    uint8_t data_align;
> +    uint8_t return_column;
> +} DebugFrameCIE;
> +
> +typedef struct {
> +    uint32_t len __attribute__((aligned((sizeof(void *)))));
> +    uint32_t cie_offset;
> +    tcg_target_long func_start __attribute__((packed));
> +    tcg_target_long func_len __attribute__((packed));
> +    uint8_t def_cfa[4];
> +    uint8_t reg_ofs[18];
> +} DebugFrameFDE;
> +
> +typedef struct {
> +    DebugFrameCIE cie;
> +    DebugFrameFDE fde;
> +} DebugFrame;
> +
> +#define ELF_HOST_MACHINE EM_ARM
> +
> +static DebugFrame debug_frame = {
> +    .cie.len = sizeof(DebugFrameCIE)-4, /* length after .len member */
> +    .cie.id = -1,
> +    .cie.version = 1,
> +    .cie.code_align = 1,
> +    .cie.data_align = 0x7c,             /* sleb128 -4 */
> +    .cie.return_column = 14,
> +
> +    .fde.len = sizeof(DebugFrameFDE)-4, /* length after .len member */
> +    .fde.def_cfa = {
> +        12, 13,                         /* DW_CFA_def_cfa sp, ... */
> +        (FRAME_SIZE & 0x7f) | 0x80,     /* ... uleb128 FRAME_SIZE */
> +        (FRAME_SIZE >> 7)
> +    },
> +    .fde.reg_ofs = {
> +        /* The following must match the stmdb in the prologue.  */
> +        0x8e, 1,                        /* DW_CFA_offset, lr, -4 */
> +        0x8b, 2,                        /* DW_CFA_offset, r11, -8 */
> +        0x8a, 3,                        /* DW_CFA_offset, r10, -12 */
> +        0x89, 4,                        /* DW_CFA_offset, r9, -16 */
> +        0x88, 5,                        /* DW_CFA_offset, r8, -20 */
> +        0x87, 6,                        /* DW_CFA_offset, r7, -24 */
> +        0x86, 7,                        /* DW_CFA_offset, r6, -28 */
> +        0x85, 8,                        /* DW_CFA_offset, r5, -32 */
> +        0x84, 9,                        /* DW_CFA_offset, r4, -36 */
> +    }
> +};
> +
> +void tcg_register_jit(void *buf, size_t buf_size)
> +{
> +    /* We're expecting a 2 byte uleb128 encoded value.  */
> +    assert(FRAME_SIZE >> 14 == 0);
> +
> +    debug_frame.fde.func_start = (tcg_target_long) buf;
> +    debug_frame.fde.func_len = buf_size;
> +
> +    tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame));
> +}
> 

  parent reply	other threads:[~2013-06-04 20:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-24 21:20 [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit Richard Henderson
2013-05-24 21:20 ` [Qemu-devel] [PATCH 2/2] tcg: Fix high_pc fields in .debug_info Richard Henderson
2013-06-04 20:03 ` Richard Henderson [this message]
2013-06-05  1:56 ` [Qemu-devel] [PATCH 1/2] tcg-arm: Implement tcg_register_jit li guang
2013-06-05 12:49   ` Richard Henderson
2013-06-05 13:02     ` Andreas Färber
2013-06-05 13:04       ` Richard Henderson
2013-06-05 13:10         ` Peter Maydell
2013-06-05 13:17           ` Richard Henderson
2013-06-06  0:28     ` li guang
2013-06-06 12:48       ` Richard Henderson
2013-06-10  0:56         ` li guang

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=51AE4824.3000905@twiddle.net \
    --to=rth@twiddle.net \
    --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.