From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEbBK-0000I0-BU for qemu-devel@nongnu.org; Thu, 31 Dec 2015 06:14:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aEbBF-0002kL-E1 for qemu-devel@nongnu.org; Thu, 31 Dec 2015 06:14:10 -0500 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:37983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEbBF-0002k9-8K for qemu-devel@nongnu.org; Thu, 31 Dec 2015 06:14:05 -0500 Date: Thu, 31 Dec 2015 12:13:50 +0100 From: Aurelien Jarno Message-ID: <20151231111350.GA360@aurel32.net> References: <1450382320-5383-1-git-send-email-rth@twiddle.net> <1450382412-5652-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1450382412-5652-1-git-send-email-rth@twiddle.net> Subject: Re: [Qemu-devel] [PATCH v2 03/14] tcg: Tidy temporary allocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org On 2015-12-17 12:00, Richard Henderson wrote: > In particular, make sure the memory is memset before use. > Continues the increased use of TCGTemp pointers instead of > integer indices where appropriate. > > Signed-off-by: Richard Henderson > --- > tcg/tcg.c | 123 ++++++++++++++++++++++++++++---------------------------------- > 1 file changed, 56 insertions(+), 67 deletions(-) > > diff --git a/tcg/tcg.c b/tcg/tcg.c > index b1864d3..0a6edfb 100644 > --- a/tcg/tcg.c > +++ b/tcg/tcg.c > @@ -429,32 +429,45 @@ void tcg_func_start(TCGContext *s) > s->be = tcg_malloc(sizeof(TCGBackendData)); > } > > -static inline void tcg_temp_alloc(TCGContext *s, int n) > +static inline int temp_idx(TCGContext *s, TCGTemp *ts) > { > - if (n > TCG_MAX_TEMPS) > - tcg_abort(); > + ptrdiff_t n = ts - s->temps; > + tcg_debug_assert(n >= 0 && n < s->nb_temps); > + return n; > +} > + > +static inline TCGTemp *tcg_temp_alloc(TCGContext *s) > +{ > + int n = s->nb_temps++; > + tcg_debug_assert(n < TCG_MAX_TEMPS); > + return memset(&s->temps[n], 0, sizeof(TCGTemp)); > +} > + > +static inline TCGTemp *tcg_global_alloc(TCGContext *s) > +{ > + tcg_debug_assert(s->nb_globals == s->nb_temps); > + s->nb_globals++; > + return tcg_temp_alloc(s); > } This is transforming an abort() which can happen all the time in an assert which can happen only when TCG debug is enabled. Is it really something we want? Maybe we should add a tcg_assert() function. Otherwise it looks fine. Reviewed-by: Aurelien Jarno -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net