]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commitdiff
TCG op size estimation fix.
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 31 Mar 2008 17:07:36 +0000 (17:07 +0000)
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 31 Mar 2008 17:07:36 +0000 (17:07 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4154 c046a42c-6fe2-441c-8c8c-71466251a162

exec-all.h
exec.c
translate-all.c

index 62b8191913e3a58c3310a59a31cb7e4e553a03f4..898cf687c22fad0e144147d4e1eef9df8c8cd927 100644 (file)
@@ -36,6 +36,12 @@ struct TranslationBlock;
 #define OPC_BUF_SIZE 512
 #define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR)
 
+/* Maximum size a TCG op can expand to.  This is complicated because a
+   single op may require several host instructions and regirster reloads.
+   For now take a wild guess at 128 bytes, which should allow at least
+   a couple of fixup instructions per argument.  */
+#define TCG_MAX_OP_SIZE 128
+
 #define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM)
 
 extern target_ulong gen_opc_pc[OPC_BUF_SIZE];
diff --git a/exec.c b/exec.c
index 48dabd67ad28f842d8ae7971517f5eac5534496c..8015202a68dc870164b06b746259dd5c7da25d12 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -367,6 +367,9 @@ void tb_flush(CPUState *env1)
            nb_tbs, nb_tbs > 0 ?
            ((unsigned long)(code_gen_ptr - code_gen_buffer)) / nb_tbs : 0);
 #endif
+    if ((unsigned long)(code_gen_ptr - code_gen_buffer) > CODE_GEN_BUFFER_SIZE)
+        cpu_abort(env1, "Internal error: code buffer overflow\n");
+
     nb_tbs = 0;
 
     for(env = first_cpu; env != NULL; env = env->next_cpu) {
index 6a273a852fb83ec921c372bb1d2fbc45f2e30f76..061bb901a31cf23873f1cbcda42e732151328553 100644 (file)
@@ -71,6 +71,7 @@ unsigned long code_gen_max_block_size(void)
     static unsigned long max;
 
     if (max == 0) {
+        max = TCG_MAX_OP_SIZE;
 #define DEF(s, n, copy_size) max = copy_size > max? copy_size : max;
 #include "tcg-opc.h"
 #undef DEF