Skip to content

Commit

Permalink
Call dt_cg_assoc_op() via dt_cg_load_var()
Browse files Browse the repository at this point in the history
To load a variable, we currently call dt_cg_assoc_op() for associative
arrays and dt_cg_load_var() for all other types of variables.  This is
unfortunate since associative arrays and thread-local variables share
a lot of code, and this sharing will increase once NULL strings are
supported.  Further, such splitting is a different model from
dt_cg_store_var(), where all variable types are handled by a common
function.

Therefore, call dt_cg_assoc_op() via dt_cg_load_var().  Subsequent
patches will inline the call and consolidate common code.  This first
step appears separately to clarify the changes.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed May 25, 2023
1 parent 6589fed commit f11e4da
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2617,13 +2617,21 @@ dt_cg_load_scalar(dt_node_t *dnp, uint_t op, ssize_t size, dt_irlist_t *dlp,
dt_cg_promote(dnp, size, dlp, drp);
}

static void
dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp);

static void
dt_cg_load_var(dt_node_t *dst, dt_irlist_t *dlp, dt_regset_t *drp)
{
dt_ident_t *idp = dt_ident_resolve(dst->dn_ident);

idp->di_flags |= DT_IDFLG_DIFR;

if (dst->dn_ident->di_kind == DT_IDENT_ARRAY) {
dt_cg_assoc_op(dst, dlp, drp);
return;
}

/* global and local variables */
if ((idp->di_flags & DT_IDFLG_LOCAL) ||
(!(idp->di_flags & DT_IDFLG_TLS) &&
Expand Down Expand Up @@ -4121,8 +4129,6 @@ dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
assert(!(dnp->dn_ident->di_flags & DT_IDFLG_LOCAL));
assert(dnp->dn_args != NULL);

dnp->dn_ident->di_flags |= DT_IDFLG_DIFR;

/* Get the tuple. */
dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);

Expand Down Expand Up @@ -6250,11 +6256,9 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
break;
}

if (dnp->dn_ident->di_kind == DT_IDENT_ARRAY) {
if (dnp->dn_ident->di_id > DIF_VAR_ARRAY_MAX)
dt_cg_assoc_op(dnp, dlp, drp);
else
dt_cg_array_op(dnp, dlp, drp);
if (dnp->dn_ident->di_kind == DT_IDENT_ARRAY &&
dnp->dn_ident->di_id <= DIF_VAR_ARRAY_MAX) {
dt_cg_array_op(dnp, dlp, drp);
break;
}

Expand Down

0 comments on commit f11e4da

Please sign in to comment.