Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-10-16 Thread Stuart Brady
On Mon, Sep 19, 2011 at 09:24:47PM +0100, Stuart Brady wrote: > On Sat, Sep 17, 2011 at 10:00:31PM +0200, Stefan Weil wrote: > [...] > > +u64 = ((helper_function)t0)(tci_read_reg(TCG_REG_R0), > > +tci_read_reg(TCG_REG_R1), > > +

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-19 Thread Stuart Brady
On Sat, Sep 17, 2011 at 10:00:31PM +0200, Stefan Weil wrote: > +#if MAX_OPC_PARAM_IARGS != 4 > +# error Fix needed, number of supported input arguments changed! > +#endif > +#if TCG_TARGET_REG_BITS == 32 > +typedef uint64_t (*helper_function)(tcg_target_ulong, tcg_target_ulong, > +

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-19 Thread Richard Henderson
On 09/17/2011 01:00 PM, Stefan Weil wrote: > +#if TCG_TARGET_HAS_ext8s_i32 > +case INDEX_op_ext8s_i32: > +t0 = *tb_ptr++; > +t1 = tci_read_r8s(&tb_ptr); > +tci_write_reg32(t0, t1); > +break; > +#endif You really ought not need all these ifdef

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-19 Thread Andi Kleen
> You generally want CSE, yes? So you can't blame gcc for getting it > wrong sometimes. There are cases where CSE pessimizes the code, .e.g when it increases memory pressure too much or caches something that is easier recomputed. This is just another one. BTW I checked again and the problem see

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-19 Thread Avi Kivity
On 09/19/2011 09:52 AM, Andi Kleen wrote: > I think it also improves branch target prediction - if you have a tight > loop of a few opcodes the predictor can guess where you're headed (since > there is a separate lookup key for each opcode), whereas with the > original code, there's a single

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-18 Thread Andi Kleen
> I think it also improves branch target prediction - if you have a tight > loop of a few opcodes the predictor can guess where you're headed (since > there is a separate lookup key for each opcode), whereas with the > original code, there's a single key which cannot be used to predict the > branc

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-18 Thread Avi Kivity
On 09/18/2011 10:22 AM, Paolo Bonzini wrote: On 09/18/2011 07:49 AM, Stefan Weil wrote: Is there really any difference in the generated code? gcc already uses a jump table internally to handle the switch cases. You typically save something on range checks, and it enables a lot more tricks for

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-18 Thread Paolo Bonzini
On 09/18/2011 07:49 AM, Stefan Weil wrote: Is there really any difference in the generated code? gcc already uses a jump table internally to handle the switch cases. You typically save something on range checks, and it enables a lot more tricks for use later (e.g. using multiple jump tables to

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-17 Thread Stefan Weil
Am 18.09.2011 06:03, schrieb Andi Kleen: Stefan Weil writes: + + switch (opc) { + case INDEX_op_end: + case INDEX_op_nop: + break; You could probably get some more speed out of this by using a threaded interpreter with gcc's computed goto extension. That's typically significantly faster than

Re: [Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-17 Thread Andi Kleen
Stefan Weil writes: > + > +switch (opc) { > +case INDEX_op_end: > +case INDEX_op_nop: > +break; You could probably get some more speed out of this by using a threaded interpreter with gcc's computed goto extension. That's typically significantly faster than a p

[Qemu-devel] [PATCH 5/8] tcg: Add interpreter for bytecode

2011-09-17 Thread Stefan Weil
Signed-off-by: Stefan Weil --- tcg/tcg.h |4 +- tcg/tci.c | 1200 + 2 files changed, 1203 insertions(+), 1 deletions(-) create mode 100644 tcg/tci.c diff --git a/tcg/tcg.h b/tcg/tcg.h index 1859fae..c99c7ea 100644 --- a/tcg/tcg.h +