diff mbox

[v2,2/7] translate-all.c: Introduce TCGContext *tcg_cur_ctx

Message ID 1350973278-2236-3-git-send-email-e.voevodin@samsung.com
State New
Headers show

Commit Message

Evgeny Voevodin Oct. 23, 2012, 6:21 a.m. UTC
We will use this pointer from functions where we don't have an
interface to pass tcg_ctx as a parameter.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
---
 tcg/tcg.h       |    1 +
 translate-all.c |    1 +
 2 files changed, 2 insertions(+)

Comments

Richard Henderson Oct. 23, 2012, 9:18 p.m. UTC | #1
On 2012-10-23 16:21, Evgeny Voevodin wrote:
> We will use this pointer from functions where we don't have an
> interface to pass tcg_ctx as a parameter.

I don't think this is worthwhile.  It'll just make the whole thing slower,
passing around unnecessary pointers.


r~
Evgeny Voevodin Oct. 24, 2012, 4:07 a.m. UTC | #2
On 10/24/2012 01:18 AM, Richard Henderson wrote:
> On 2012-10-23 16:21, Evgeny Voevodin wrote:
>> We will use this pointer from functions where we don't have an
>> interface to pass tcg_ctx as a parameter.
> I don't think this is worthwhile.  It'll just make the whole thing slower,
> passing around unnecessary pointers.
>
>
> r~
>

1. I didn't noticed any slow-down of kernel boot process. Maybe it's 
worth to make more
tests with self modifying code but I don't think so, because
2. The most intensive usage of tcg_cur_ctx is in tcg/tcg-op.h functions. 
If we look carefully at
them then we will see that there are only few functions for which single 
excessive dereferencing
of a pointer leads to any significant slow-down. These functions are 
those which make just one
or two operations and exit. And we should keep in mind that there is 
only single dereference of
a pointer since it is stored in the register for further operations.

Of course some slow-down should present but I found it negligible 
(actually I didn't find it at all).
If there are some common tests for TCG generation speed I can try to run 
them and report results.

Also we can specify tcg_cur_ctx as const and in that case I guess that 
dereferencing of tcg_cur_ctx
should not lead to any slow-down.

Also I can drop tcg_cur_ctx and use tcg_ctx.xxx instead as was in the 
first series.

What about the rest patches?
diff mbox

Patch

diff --git a/tcg/tcg.h b/tcg/tcg.h
index 43b4317..d326b36 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -431,6 +431,7 @@  struct TCGContext {
 };
 
 extern TCGContext tcg_ctx;
+extern TCGContext *tcg_cur_ctx;
 extern uint16_t *gen_opc_ptr;
 extern TCGArg *gen_opparam_ptr;
 extern uint16_t gen_opc_buf[];
diff --git a/translate-all.c b/translate-all.c
index 5bd2d37..ccdcddf 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -32,6 +32,7 @@ 
 
 /* code generation context */
 TCGContext tcg_ctx;
+TCGContext *tcg_cur_ctx = &tcg_ctx;
 
 uint16_t gen_opc_buf[OPC_BUF_SIZE];
 TCGArg gen_opparam_buf[OPPARAM_BUF_SIZE];