[DTrace-devel] [PATCH 32/61] Add dt_cg_push_stack()

Eugene Loh eugene.loh at oracle.com
Mon Aug 8 20:25:49 UTC 2022


Should I post a v2 patch that has this patch squashed into "Add support 
for aggregation keys"?  Or does that just create unnecessary churn for you?

On 8/5/22 11:41, Kris Van Hees wrote:
> Let's defer this and add it to the patch that introduces dt_cg_pop_stack()
> as well.  That (I think) makes more sense, and in the meantime the existing
> code can just remain.  I was planning on introducing such functions down the
> road anyway as part of the spill/fill rewrite but since you have a use for
> it now, let's do it with the other patch:
>
> 	"Add support for aggregation keys"
>
> On Fri, Jul 08, 2022 at 10:45:16AM -0400, eugene.loh--- via DTrace-devel wrote:
>> From: Eugene Loh <eugene.loh at oracle.com>
>>
>> This patch prepares for future, additional uses of this stack.
>>
>> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
>> ---
>>   libdtrace/dt_cg.c | 26 +++++++++++++++++---------
>>   1 file changed, 17 insertions(+), 9 deletions(-)
>>
>> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
>> index 11a9c8c5..b0c2a362 100644
>> --- a/libdtrace/dt_cg.c
>> +++ b/libdtrace/dt_cg.c
>> @@ -2607,6 +2607,22 @@ dt_cg_typecast(const dt_node_t *src, const dt_node_t *dst,
>>   	}
>>   }
>>   
>> +static void
>> +dt_cg_push_stack(dt_irlist_t *dlp, dt_regset_t *drp, int reg)
>> +{
>> +	int tmp;
>> +
>> +	if ((tmp = dt_regset_alloc(drp)) == -1)
>> +		longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
>> +
>> +	emit(dlp, BPF_LOAD(BPF_DW, tmp, BPF_REG_FP, DT_STK_SP));
>> +	emit(dlp, BPF_STORE(BPF_DW, tmp, 0, reg));
>> +	dt_regset_free(drp, reg);
>> +	emit(dlp, BPF_ALU64_IMM(BPF_ADD, tmp, -DT_STK_SLOT_SZ));
>> +	emit(dlp, BPF_STORE(BPF_DW, BPF_REG_FP, DT_STK_SP, tmp));
>> +	dt_regset_free(drp, tmp);
>> +}
>> +
>>   /*
>>    * Generate code to push the specified argument list on to the tuple stack.
>>    * We use this routine for handling the index tuple for associative arrays.
>> @@ -2644,15 +2660,7 @@ dt_cg_arglist(dt_ident_t *idp, dt_node_t *args, dt_irlist_t *dlp,
>>   			longjmp(yypcb->pcb_jmpbuf, EDT_NOTUPREG);
>>   
>>   		dt_cg_node(dnp, dlp, drp);
>> -
>> -		/* Push the component (pointer or value) onto the stack. */
>> -		dt_regset_xalloc(drp, BPF_REG_0);
>> -		emit(dlp, BPF_LOAD(BPF_DW, BPF_REG_0, BPF_REG_FP, DT_STK_SP));
>> -		emit(dlp, BPF_STORE(BPF_DW, BPF_REG_0, 0, dnp->dn_reg));
>> -		dt_regset_free(drp, dnp->dn_reg);
>> -		emit(dlp, BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, -DT_STK_SLOT_SZ));
>> -		emit(dlp, BPF_STORE(BPF_DW, BPF_REG_FP, DT_STK_SP, BPF_REG_0));
>> -		dt_regset_free(drp, BPF_REG_0);
>> +		dt_cg_push_stack(dlp, drp, dnp->dn_reg);
>>   	}
>>   
>>   	TRACE_REGSET("      arglist: Stack");
>> -- 
>> 2.18.4
>>
>>
>> _______________________________________________
>> DTrace-devel mailing list
>> DTrace-devel at oss.oracle.com
>> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list