summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-05-14 18:58:05 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-05-14 18:58:05 +0000
commit727d01d4f6846708f0f32dcf9b086a2fba15bd8c (patch)
tree256b59b27567a801defb06bc443fae0d3b3539c4
parentae2285314189c0ea32fc73d38c1e9b8051d213ab (diff)
downloadqemu-727d01d4f6846708f0f32dcf9b086a2fba15bd8c.tar.gz
return code size
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@162 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--translate-i386.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/translate-i386.c b/translate-i386.c
index 0c171cf31f..086d74a4fc 100644
--- a/translate-i386.c
+++ b/translate-i386.c
@@ -32,10 +32,6 @@
#define IN_OP_I386
#include "cpu-i386.h"
-#ifndef offsetof
-#define offsetof(type, field) ((size_t) &((type *)0)->field)
-#endif
-
/* XXX: move that elsewhere */
static uint16_t *gen_opc_ptr;
static uint32_t *gen_opparam_ptr;
@@ -3721,10 +3717,19 @@ static uint16_t gen_opc_buf[OPC_BUF_SIZE];
static uint32_t gen_opparam_buf[OPPARAM_BUF_SIZE];
/* return non zero if the very first instruction is invalid so that
- the virtual CPU can trigger an exception. */
+ the virtual CPU can trigger an exception.
+
+ '*code_size_ptr' contains the target code size including the
+ instruction which triggered an exception, except in case of invalid
+ illegal opcode. It must never exceed one target page.
+
+ '*gen_code_size_ptr' contains the size of the generated code (host
+ code).
+*/
int cpu_x86_gen_code(uint8_t *gen_code_buf, int max_code_size,
int *gen_code_size_ptr,
- uint8_t *pc_start, uint8_t *cs_base, int flags)
+ uint8_t *pc_start, uint8_t *cs_base, int flags,
+ int *code_size_ptr)
{
DisasContext dc1, *dc = &dc1;
uint8_t *pc_ptr;
@@ -3767,7 +3772,8 @@ int cpu_x86_gen_code(uint8_t *gen_code_buf, int max_code_size,
generate an exception */
if (dc->tf)
break;
- } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end);
+ } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
+ (pc_ptr - pc_start) < (TARGET_PAGE_SIZE - 32));
/* we must store the eflags state if it is not already done */
if (dc->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(dc->cc_op);
@@ -3810,7 +3816,7 @@ int cpu_x86_gen_code(uint8_t *gen_code_buf, int max_code_size,
gen_code_size = dyngen_code(gen_code_buf, gen_opc_buf, gen_opparam_buf);
flush_icache_range((unsigned long)gen_code_buf, (unsigned long)(gen_code_buf + gen_code_size));
*gen_code_size_ptr = gen_code_size;
-
+ *code_size_ptr = pc_ptr - pc_start;
#ifdef DEBUG_DISAS
if (loglevel) {
fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr);