Skip to content

Commit

Permalink
Change lltostr() to take advantage of tstring1 helper
Browse files Browse the repository at this point in the history
Switch the order of arguments in bpf/lltostr.S to accommodate
this change.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Apr 22, 2022
1 parent b27bdde commit 489c745
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
6 changes: 3 additions & 3 deletions bpf/lltostr.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

.text
/*
* int dt_lltostr(char *STR, uint64_t VAL)
* void dt_lltostr(uint64_t VAL, char *STR)
* {
* // start writing at the end (IDX==1 is the last char)
* IDX = 1
Expand Down Expand Up @@ -74,8 +74,8 @@ dt_lltostr:
#define IDX %r8
#define SGN %r9

mov STR, %r1
mov VAL, %r2
mov VAL, %r1
mov STR, %r2

mov IDX, 1 /* IDX = 1 */

Expand Down
31 changes: 1 addition & 30 deletions libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3818,36 +3818,7 @@ dt_cg_subr_index(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
static void
dt_cg_subr_lltostr(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
{
dt_ident_t *idp = dt_dlib_get_func(yypcb->pcb_hdl, "dt_lltostr");
dt_node_t *val = dnp->dn_args;

assert(idp != NULL);

TRACE_REGSET(" subr-lltostr:Begin");
dt_cg_node(val, dlp, drp);

if (dt_regset_xalloc_args(drp) == -1)
longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);

dnp->dn_reg = dt_regset_alloc(drp);
if (dnp->dn_reg == -1)
longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
dt_cg_tstring_alloc(yypcb, dnp);

emit(dlp, BPF_LOAD(BPF_DW, dnp->dn_reg, BPF_REG_FP, DT_STK_DCTX));
emit(dlp, BPF_LOAD(BPF_DW, dnp->dn_reg, dnp->dn_reg, DCTX_MEM));
emit(dlp, BPF_ALU64_IMM(BPF_ADD, dnp->dn_reg, dnp->dn_tstring->dn_value));
emit(dlp, BPF_MOV_REG(BPF_REG_1, dnp->dn_reg));

emit(dlp, BPF_MOV_REG(BPF_REG_2, val->dn_reg));
dt_regset_free(drp, val->dn_reg);

dt_regset_xalloc(drp, BPF_REG_0);
emite(dlp, BPF_CALL_FUNC(idp->di_id), idp);
dt_regset_free_args(drp);
dt_regset_free(drp, BPF_REG_0);

TRACE_REGSET(" subr-lltostr:End ");
dt_cg_subr_arg_to_tstring(dnp, dlp, drp, "dt_lltostr");
}

static void
Expand Down

0 comments on commit 489c745

Please sign in to comment.