On 29 March 2011 09:55, Alexander Graf <ag...@suse.de> wrote: > On 28.03.2011, at 17:40, Peter Maydell wrote: >> Doesn't this take you over MAX_OP_PER_INSTR for some cases? > > I haven't encountered any case where it does.
This untested patch against your v2 ought to make it print a warning if you do go over the limit: diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 6756b84..35a2351 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -5040,7 +5040,7 @@ static inline void gen_intermediate_code_internal(CPUState *env, DisasContext dc; target_ulong pc_start; uint64_t next_page_start; - uint16_t *gen_opc_end; + uint16_t *gen_opc_end, *gen_opc_insnstart; int j, lj = -1; int num_insns, max_insns; CPUBreakpoint *bp; @@ -5070,6 +5070,8 @@ static inline void gen_intermediate_code_internal(CPUState *env, gen_icount_start(); do { + gen_opc_insnstart = gen_opc_ptr; + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc.pc) { @@ -5104,6 +5106,14 @@ static inline void gen_intermediate_code_internal(CPUState *env, if (env->singlestep_enabled) { gen_debug(&dc); } + + if (gen_opc_ptr > gen_opc_insnstart + MAX_OP_PER_INSTR) { + /* Codegen bug, but not a fatal one -- if we really overran the + * TCG buffer we will assert later. So just warn. + */ + fprintf(stderr, "Too many TCG ops for insn before " + TARGET_FMT_lx " \n", dc.pc); + } } while (!dc.is_jmp && gen_opc_ptr < gen_opc_end && dc.pc < next_page_start && num_insns < max_insns && !env->singlestep_enabled && !singlestep); I'm not yet sure what the right way to do this generically would be. -- PMM