Re: [Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-28 Thread Paolo Bonzini
Il 28/03/2014 15:52, Andreas Färber ha scritto: I do wonder if it wouldn't make more sense to simply #define CPU(obj) ((CPUState *)obj) which would catch all uses of CPU() while still allowing to change it to #define CPU(obj) dynamic_cast(obj) or so in the future without touching dozens of places

Re: [Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-28 Thread Andreas Färber
Am 26.03.2014 14:42, schrieb Paolo Bonzini: > QOM casts are only typesafe inasmuch as we know that the argument is > a QOM object. If it is not, the accesses to fields in Object can > access invalid memory and thus cause a segfault. > > Using a QOM cast in ENV_GET_CPU is useless and harmful. Use

Re: [Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-28 Thread Paolo Bonzini
> (average of 5 runs): > - before: 17.8s > - with your patch: 17s What about 1.7? Paolo

Re: [Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-28 Thread Laurent Desnogues
On Wed, Mar 26, 2014 at 2:42 PM, Paolo Bonzini wrote: > QOM casts are only typesafe inasmuch as we know that the argument is > a QOM object. If it is not, the accesses to fields in Object can > access invalid memory and thus cause a segfault. > > Using a QOM cast in ENV_GET_CPU is useless and har

Re: [Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-28 Thread Laurent Desnogues
On Wed, Mar 26, 2014 at 2:55 PM, Paolo Bonzini wrote: > Il 26/03/2014 14:42, Paolo Bonzini ha scritto: > >> QOM casts are only typesafe inasmuch as we know that the argument is >> a QOM object. If it is not, the accesses to fields in Object can >> access invalid memory and thus cause a segfault.

Re: [Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-26 Thread Paolo Bonzini
Il 26/03/2014 14:42, Paolo Bonzini ha scritto: QOM casts are only typesafe inasmuch as we know that the argument is a QOM object. If it is not, the accesses to fields in Object can access invalid memory and thus cause a segfault. Using a QOM cast in ENV_GET_CPU is useless and harmful. Useless,

[Qemu-devel] [PATCH for-2.0] cpu: do not use QOM casts in ENV_GET_CPU

2014-03-26 Thread Paolo Bonzini
QOM casts are only typesafe inasmuch as we know that the argument is a QOM object. If it is not, the accesses to fields in Object can access invalid memory and thus cause a segfault. Using a QOM cast in ENV_GET_CPU is useless and harmful. Useless, because the cast is applied to the result of con