[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 07/43] tcg: Add in_code_gen_buffer
From: |
Richard Henderson |
Subject: |
Re: [PATCH v4 07/43] tcg: Add in_code_gen_buffer |
Date: |
Tue, 15 Dec 2020 16:43:12 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 12/14/20 4:09 PM, Philippe Mathieu-Daudé wrote:
> On 12/14/20 3:02 PM, Richard Henderson wrote:
>> Create a function to determine if a pointer is within the buffer.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> include/tcg/tcg.h | 6 ++++++
>> accel/tcg/translate-all.c | 26 ++++++++------------------
>> 2 files changed, 14 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
>> index bb1e97b13b..e4d0ace44b 100644
>> --- a/include/tcg/tcg.h
>> +++ b/include/tcg/tcg.h
>> @@ -680,6 +680,12 @@ extern __thread TCGContext *tcg_ctx;
>> extern void *tcg_code_gen_epilogue;
>> extern TCGv_env cpu_env;
>>
>> +static inline bool in_code_gen_buffer(const void *p)
>> +{
>> + const TCGContext *s = &tcg_init_ctx;
>> + return (size_t)(p - s->code_gen_buffer) <= s->code_gen_buffer_size;
>
> If 'p == s->code_gen_buffer + s->code_gen_buffer_size',
> is it really "in" the buffer?
Well, sort of.
Compare the fact that in C, a pointer to the end of an array is valid as a
pointer even though it can't be dereferenced. This is a pointer to the end of
the buffer.
Extra commentary required?
r~
- Re: [PATCH v4 04/43] util: Specialize flush_idcache_range for aarch64, (continued)
- [PATCH v4 01/43] tcg: Do not flush icache for interpreter, Richard Henderson, 2020/12/14
- [PATCH v4 05/43] tcg: Move tcg prologue pointer out of TCGContext, Richard Henderson, 2020/12/14
- [PATCH v4 06/43] tcg: Move tcg epilogue pointer out of TCGContext, Richard Henderson, 2020/12/14
- [PATCH v4 07/43] tcg: Add in_code_gen_buffer, Richard Henderson, 2020/12/14
- [PATCH v4 08/43] tcg: Introduce tcg_splitwx_to_{rx,rw}, Richard Henderson, 2020/12/14
- [PATCH v4 11/43] tcg: Adjust tcg_out_label for const, Richard Henderson, 2020/12/14
- [PATCH v4 12/43] tcg: Adjust tcg_register_jit for const, Richard Henderson, 2020/12/14
- [PATCH v4 09/43] tcg: Adjust TCGLabel for const, Richard Henderson, 2020/12/14
- [PATCH v4 14/43] tcg: Make DisasContextBase.tb const, Richard Henderson, 2020/12/14
- [PATCH v4 10/43] tcg: Adjust tcg_out_call for const, Richard Henderson, 2020/12/14