qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Make tb_alloc static.
@ 2011-02-08 11:22 Tristan Gingold
  2011-02-09 18:52 ` Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: Tristan Gingold @ 2011-02-08 11:22 UTC (permalink / raw)
  To: qemu-devel

This function is only used within exec.c, so no need to make it public.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
---
 exec-all.h |    1 -
 exec.c     |    4 +++-
 2 files changed, 3 insertions(+), 2 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..1c59d0b 100644
--- a/exec.c
+++ b/exec.c
@@ -221,6 +221,8 @@ static int tlb_flush_count;
 static int tb_flush_count;
 static int tb_phys_invalidate_count;
 
+static TranslationBlock *tb_alloc(target_ulong pc);
+
 #ifdef _WIN32
 static void map_exec(void *addr, long size)
 {
@@ -1229,7 +1231,7 @@ static inline void tb_alloc_page(TranslationBlock *tb,
 
 /* 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)
+static TranslationBlock *tb_alloc(target_ulong pc)
 {
     TranslationBlock *tb;
 
-- 
1.7.3.GIT

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] Make tb_alloc static.
  2011-02-08 11:22 [Qemu-devel] [PATCH] Make tb_alloc static Tristan Gingold
@ 2011-02-09 18:52 ` Aurelien Jarno
  2011-02-10  9:04   ` Tristan Gingold
  0 siblings, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2011-02-09 18:52 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: qemu-devel

On Tue, Feb 08, 2011 at 12:22:15PM +0100, Tristan Gingold wrote:
> This function is only used within exec.c, so no need to make it public.
> 
> Signed-off-by: Tristan Gingold <gingold@adacore.com>
> ---
>  exec-all.h |    1 -
>  exec.c     |    4 +++-
>  2 files changed, 3 insertions(+), 2 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..1c59d0b 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -221,6 +221,8 @@ static int tlb_flush_count;
>  static int tb_flush_count;
>  static int tb_phys_invalidate_count;
>  
> +static TranslationBlock *tb_alloc(target_ulong pc);
> +

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.

Otherwise looks like a good idea.

>  #ifdef _WIN32
>  static void map_exec(void *addr, long size)
>  {
> @@ -1229,7 +1231,7 @@ static inline void tb_alloc_page(TranslationBlock *tb,
>  
>  /* 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)
> +static TranslationBlock *tb_alloc(target_ulong pc)
>  {
>      TranslationBlock *tb;
>  
> -- 
> 1.7.3.GIT
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] Make tb_alloc static.
  2011-02-09 18:52 ` Aurelien Jarno
@ 2011-02-10  9:04   ` Tristan Gingold
  2011-02-10 18:45     ` Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: Tristan Gingold @ 2011-02-10  9:04 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: qemu-devel

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 ?

Tristan.


This function is only used within exec.c, so no need to make it public.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
---
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] Make tb_alloc static.
  2011-02-10  9:04   ` Tristan Gingold
@ 2011-02-10 18:45     ` Aurelien Jarno
  0 siblings, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2011-02-10 18:45 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: qemu-devel

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 <gingold@adacore.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-10 18:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-08 11:22 [Qemu-devel] [PATCH] Make tb_alloc static Tristan Gingold
2011-02-09 18:52 ` Aurelien Jarno
2011-02-10  9:04   ` Tristan Gingold
2011-02-10 18:45     ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).