From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=49271 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PnbWj-0000ya-WC for qemu-devel@nongnu.org; Thu, 10 Feb 2011 13:46:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PnbWi-0006fP-QK for qemu-devel@nongnu.org; Thu, 10 Feb 2011 13:46:01 -0500 Received: from hall.aurel32.net ([88.191.126.93]:37586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PnbWi-0006cq-9e for qemu-devel@nongnu.org; Thu, 10 Feb 2011 13:46:00 -0500 Date: Thu, 10 Feb 2011 19:45:59 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH] Make tb_alloc static. Message-ID: <20110210184559.GA598@volta.aurel32.net> References: <1297164135-30510-1-git-send-email-gingold@adacore.com> <20110209185252.GL3131@volta.aurel32.net> <20110210090457.GA65607@ulanbator.act-europe.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20110210090457.GA65607@ulanbator.act-europe.fr> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tristan Gingold Cc: qemu-devel@nongnu.org On Thu, Feb 10, 2011 at 10:04:57AM +0100, Tristan Gingold wrote: > On Wed, Feb 09, 2011 at 07:52:52PM +0100, Aurelien Jarno wrote: > > > > What about moving tb_alloc() (with tb_free()) higher in the file? After > > all it make sense to have the function creating or destructing a tb > > before the function manipulating them. > > Thanks. Like this ? > Yes, perfect. Applied. > Tristan. > > > This function is only used within exec.c, so no need to make it public. > > Signed-off-by: Tristan Gingold > --- > exec-all.h | 1 - > exec.c | 52 ++++++++++++++++++++++++++-------------------------- > 2 files changed, 26 insertions(+), 27 deletions(-) > > diff --git a/exec-all.h b/exec-all.h > index 81497c0..c062693 100644 > --- a/exec-all.h > +++ b/exec-all.h > @@ -182,7 +182,6 @@ static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) > return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); > } > > -TranslationBlock *tb_alloc(target_ulong pc); > void tb_free(TranslationBlock *tb); > void tb_flush(CPUState *env); > void tb_link_page(TranslationBlock *tb, > diff --git a/exec.c b/exec.c > index 477199b..9a7a752 100644 > --- a/exec.c > +++ b/exec.c > @@ -649,6 +649,32 @@ void cpu_exec_init(CPUState *env) > #endif > } > > +/* Allocate a new translation block. Flush the translation buffer if > + too many translation blocks or too much generated code. */ > +static TranslationBlock *tb_alloc(target_ulong pc) > +{ > + TranslationBlock *tb; > + > + if (nb_tbs >= code_gen_max_blocks || > + (code_gen_ptr - code_gen_buffer) >= code_gen_buffer_max_size) > + return NULL; > + tb = &tbs[nb_tbs++]; > + tb->pc = pc; > + tb->cflags = 0; > + return tb; > +} > + > +void tb_free(TranslationBlock *tb) > +{ > + /* In practice this is mostly used for single use temporary TB > + Ignore the hard cases and just back up if this TB happens to > + be the last one generated. */ > + if (nb_tbs > 0 && tb == &tbs[nb_tbs - 1]) { > + code_gen_ptr = tb->tc_ptr; > + nb_tbs--; > + } > +} > + > static inline void invalidate_page_bitmap(PageDesc *p) > { > if (p->code_bitmap) { > @@ -1227,32 +1253,6 @@ static inline void tb_alloc_page(TranslationBlock *tb, > #endif /* TARGET_HAS_SMC */ > } > > -/* Allocate a new translation block. Flush the translation buffer if > - too many translation blocks or too much generated code. */ > -TranslationBlock *tb_alloc(target_ulong pc) > -{ > - TranslationBlock *tb; > - > - if (nb_tbs >= code_gen_max_blocks || > - (code_gen_ptr - code_gen_buffer) >= code_gen_buffer_max_size) > - return NULL; > - tb = &tbs[nb_tbs++]; > - tb->pc = pc; > - tb->cflags = 0; > - return tb; > -} > - > -void tb_free(TranslationBlock *tb) > -{ > - /* In practice this is mostly used for single use temporary TB > - Ignore the hard cases and just back up if this TB happens to > - be the last one generated. */ > - if (nb_tbs > 0 && tb == &tbs[nb_tbs - 1]) { > - code_gen_ptr = tb->tc_ptr; > - nb_tbs--; > - } > -} > - > /* add a new TB and link it to the physical page tables. phys_page2 is > (-1) to indicate that only one page contains the TB. */ > void tb_link_page(TranslationBlock *tb, > -- > 1.7.3.GIT > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net