[DTrace-devel] [PATCH 05/14] Call dt_cg_assoc_op() via dt_cg_load_var()
eugene.loh at oracle.com
eugene.loh at oracle.com
Tue May 2 03:47:13 UTC 2023
From: Eugene Loh <eugene.loh at oracle.com>
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 at oracle.com>
---
libdtrace/dt_cg.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 7bfc33a1..35c28bcf 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -2500,6 +2500,9 @@ 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 *dst, 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)
{
@@ -2507,6 +2510,11 @@ dt_cg_load_var(dt_node_t *dst, dt_irlist_t *dlp, dt_regset_t *drp)
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) &&
@@ -4000,8 +4008,6 @@ dt_cg_assoc_op(dt_node_t *dst, dt_irlist_t *dlp, dt_regset_t *drp)
assert(!(dst->dn_ident->di_flags & DT_IDFLG_LOCAL));
assert(dst->dn_args != NULL);
- dst->dn_ident->di_flags |= DT_IDFLG_DIFR;
-
/* Get the tuple. */
dt_cg_arglist(dst->dn_ident, dst->dn_args, dlp, drp);
@@ -6125,11 +6131,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;
}
--
2.18.4
More information about the DTrace-devel
mailing list