Skip to contentSkip to conversation

exec.c: Fix calculation of code_gen_buffer_max_size

PATCH Applied Peter Maydell 2 participants 3 messages Jun 22, 2011 – Jul 12, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exec.c: Fix calculation of code_gen_buffer_max_size

When calculating the point at which we should not try to put another TB into the code gen buffer, we have to allow not just for OPC_MAX_SIZE but OPC_BUF_SIZE. This is because the target translate.c will only stop when an instruction has put it past the OPC_MAX_SIZE limit, so we have to include the MAX_OP_PER_INSTR margin which that final insn might have used.

---
 exec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
exec.c +2 -2
index 09928a3..c910840 100644
@@ -555,8 +555,8 @@ static void code_gen_alloc(unsigned long tb_size)
 #endif
 #endif /* !USE_STATIC_CODE_GEN_BUFFER */
     map_exec(code_gen_prologue, sizeof(code_gen_prologue));
-    code_gen_buffer_max_size = code_gen_buffer_size - 
-        (TCG_MAX_OP_SIZE * OPC_MAX_SIZE);
+    code_gen_buffer_max_size = code_gen_buffer_size -
+        (TCG_MAX_OP_SIZE * OPC_BUF_SIZE);
     code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
     tbs = qemu_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
 }
Signature · 1 line
1.7.1
#1 lore raw

Ping?

Quoted 29 lines · Peter Maydell

When calculating the point at which we should not try to put another TB into the code gen buffer, we have to allow not just for OPC_MAX_SIZE but OPC_BUF_SIZE. This is because the target translate.c will only stop when an instruction has put it past the OPC_MAX_SIZE limit, so we have to include the MAX_OP_PER_INSTR margin which that final insn might have used.

---
 exec.c |    4 ++--

 1 files changed, 2 insertions(+), 2 deletions(-)
exec.c +2 -3
index 09928a3..c910840 100644
@@ -555,8 +555,8 @@ static void code_gen_alloc(unsigned long tb_size)
  #endif
  #endif /* !USE_STATIC_CODE_GEN_BUFFER */
     map_exec(code_gen_prologue, sizeof(code_gen_prologue));
-    code_gen_buffer_max_size = code_gen_buffer_size -
-        (TCG_MAX_OP_SIZE * OPC_MAX_SIZE);
+    code_gen_buffer_max_size = code_gen_buffer_size -
+        (TCG_MAX_OP_SIZE * OPC_BUF_SIZE);
     code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
     tbs = qemu_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
  }
--

1.7.1

Applied
#2 lore raw

Thanks, applied.

Quoted 34 lines · Peter Maydell

Ping?

Quoted 29 lines · Peter Maydell

When calculating the point at which we should not try to put another TB into the code gen buffer, we have to allow not just for OPC_MAX_SIZE but OPC_BUF_SIZE. This is because the target translate.c will only stop when an instruction has put it past the OPC_MAX_SIZE limit, so we have to include the MAX_OP_PER_INSTR margin which that final insn might have used.

---
 exec.c |    4 ++--

 1 files changed, 2 insertions(+), 2 deletions(-)
exec.c +2 -3
index 09928a3..c910840 100644
@@ -555,8 +555,8 @@ static void code_gen_alloc(unsigned long tb_size)
  #endif
  #endif /* !USE_STATIC_CODE_GEN_BUFFER */
     map_exec(code_gen_prologue, sizeof(code_gen_prologue));
-    code_gen_buffer_max_size = code_gen_buffer_size -
-        (TCG_MAX_OP_SIZE * OPC_MAX_SIZE);
+    code_gen_buffer_max_size = code_gen_buffer_size -
+        (TCG_MAX_OP_SIZE * OPC_BUF_SIZE);
     code_gen_max_blocks = code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE;
     tbs = qemu_malloc(code_gen_max_blocks * sizeof(TranslationBlock));
  }
--

1.7.1