Commit ae063a68dc39f2ee1c87ea2a41c468ba7256acbb

Authored by bellard
1 parent 8636b5d8

generalized use of GOTO_TB() macro


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1207 c046a42c-6fe2-441c-8c8c-71466251a162
exec-all.h
... ... @@ -322,7 +322,7 @@ TranslationBlock *tb_find_pc(unsigned long pc_ptr);
322 322 #if defined(__powerpc__)
323 323  
324 324 /* we patch the jump instruction directly */
325   -#define JUMP_TB(opname, tbparam, n, eip)\
  325 +#define GOTO_TB(opname, tbparam, n)\
326 326 do {\
327 327 asm volatile (ASM_DATA_SECTION\
328 328 ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
... ... @@ -330,20 +330,12 @@ do {\
330 330 ASM_PREVIOUS_SECTION \
331 331 "b " ASM_NAME(__op_jmp) #n "\n"\
332 332 "1:\n");\
333   - T0 = (long)(tbparam) + (n);\
334   - EIP = (int32_t)eip;\
335   - EXIT_TB();\
336   -} while (0)
337   -
338   -#define JUMP_TB2(opname, tbparam, n)\
339   -do {\
340   - asm volatile ("b " ASM_NAME(__op_jmp) #n "\n");\
341 333 } while (0)
342 334  
343 335 #elif defined(__i386__) && defined(USE_DIRECT_JUMP)
344 336  
345 337 /* we patch the jump instruction directly */
346   -#define GOTO_TB(opname, n)\
  338 +#define GOTO_TB(opname, tbparam, n)\
347 339 do {\
348 340 asm volatile (".section .data\n"\
349 341 ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
... ... @@ -353,48 +345,30 @@ do {\
353 345 "1:\n");\
354 346 } while (0)
355 347  
356   -#define JUMP_TB(opname, tbparam, n, eip)\
357   -do {\
358   - asm volatile (".section .data\n"\
359   - ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
360   - ".long 1f\n"\
361   - ASM_PREVIOUS_SECTION \
362   - "jmp " ASM_NAME(__op_jmp) #n "\n"\
363   - "1:\n");\
364   - T0 = (long)(tbparam) + (n);\
365   - EIP = (int32_t)eip;\
366   - EXIT_TB();\
367   -} while (0)
368   -
369   -#define JUMP_TB2(opname, tbparam, n)\
370   -do {\
371   - asm volatile ("jmp " ASM_NAME(__op_jmp) #n "\n");\
372   -} while (0)
373   -
374 348 #else
375 349  
376 350 /* jump to next block operations (more portable code, does not need
377 351 cache flushing, but slower because of indirect jump) */
378   -#define JUMP_TB(opname, tbparam, n, eip)\
  352 +#define GOTO_TB(opname, tbparam, n)\
379 353 do {\
380   - static void __attribute__((unused)) *__op_label ## n = &&label ## n;\
381 354 static void __attribute__((unused)) *dummy ## n = &&dummy_label ## n;\
  355 + static void __attribute__((unused)) *__op_label ## n = &&label ## n;\
382 356 goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n]);\
383   -label ## n:\
384   - T0 = (long)(tbparam) + (n);\
385   - EIP = (int32_t)eip;\
386   -dummy_label ## n:\
387   - EXIT_TB();\
  357 +label ## n: ;\
  358 +dummy_label ## n: ;\
388 359 } while (0)
389 360  
390   -/* second jump to same destination 'n' */
391   -#define JUMP_TB2(opname, tbparam, n)\
  361 +#endif
  362 +
  363 +/* XXX: will be suppressed */
  364 +#define JUMP_TB(opname, tbparam, n, eip)\
392 365 do {\
393   - goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n - 2]);\
  366 + GOTO_TB(opname, tbparam, n);\
  367 + T0 = (long)(tbparam) + (n);\
  368 + EIP = (int32_t)eip;\
  369 + EXIT_TB();\
394 370 } while (0)
395 371  
396   -#endif
397   -
398 372 extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
399 373 extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
400 374 extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];
... ...
target-i386/op.c
... ... @@ -1262,12 +1262,12 @@ void OPPROTO op_clts(void)
1262 1262  
1263 1263 void OPPROTO op_goto_tb0(void)
1264 1264 {
1265   - GOTO_TB(op_goto_tb0, 0);
  1265 + GOTO_TB(op_goto_tb0, PARAM1, 0);
1266 1266 }
1267 1267  
1268 1268 void OPPROTO op_goto_tb1(void)
1269 1269 {
1270   - GOTO_TB(op_goto_tb1, 1);
  1270 + GOTO_TB(op_goto_tb1, PARAM1, 1);
1271 1271 }
1272 1272  
1273 1273 void OPPROTO op_jmp_label(void)
... ...
target-i386/translate.c
... ... @@ -61,6 +61,12 @@ static uint32_t *gen_opparam_ptr;
61 61 static int x86_64_hregs;
62 62 #endif
63 63  
  64 +#ifdef USE_DIRECT_JUMP
  65 +#define TBPARAM(x)
  66 +#else
  67 +#define TBPARAM(x) (long)(x)
  68 +#endif
  69 +
64 70 typedef struct DisasContext {
65 71 /* current insn context */
66 72 int override; /* -1 if no override */
... ... @@ -1782,13 +1788,13 @@ static inline void gen_jcc(DisasContext *s, int b,
1782 1788 l1 = gen_new_label();
1783 1789 func(l1);
1784 1790  
1785   - gen_op_goto_tb0();
  1791 + gen_op_goto_tb0(TBPARAM(tb));
1786 1792 gen_jmp_im(next_eip);
1787 1793 gen_op_movl_T0_im((long)tb + 0);
1788 1794 gen_op_exit_tb();
1789 1795  
1790 1796 gen_set_label(l1);
1791   - gen_op_goto_tb1();
  1797 + gen_op_goto_tb1(TBPARAM(tb));
1792 1798 gen_jmp_im(val);
1793 1799 gen_op_movl_T0_im((long)tb + 1);
1794 1800 gen_op_exit_tb();
... ... @@ -2179,9 +2185,9 @@ static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num)
2179 2185 if (s->cc_op != CC_OP_DYNAMIC)
2180 2186 gen_op_set_cc_op(s->cc_op);
2181 2187 if (tb_num)
2182   - gen_op_goto_tb1();
  2188 + gen_op_goto_tb1(TBPARAM(tb));
2183 2189 else
2184   - gen_op_goto_tb0();
  2190 + gen_op_goto_tb0(TBPARAM(tb));
2185 2191 gen_jmp_im(eip);
2186 2192 gen_op_movl_T0_im((long)tb + tb_num);
2187 2193 gen_op_exit_tb();
... ...