qom: fix cast results caching
PATCH 1/1 qom: fix cast results caching
A single cast cache is used for both an object casting and a class casting. In case of interface presence a class cast result may be not the same pointer as opposite to an object casting. So do not cache cast results for an object casting in a presence of interfaces.
--- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qom/object.c +1 -1
@@ -473,7 +473,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,assert (obj == inst); -if (obj && obj == inst) { +if (obj && obj == inst && !obj->class->interfaces) {for (i =1 ; i <OBJECT_CLASS_CAST_CACHE ; i++) { obj->class->cast_cache[i -1 ] = obj->class->cast_cache[i]; }
Signature · 1 line
1.7.9.5
Quoted 5 lines · Sergey Fedorov
A single cast cache is used for both an object casting and a class casting. In case of interface presence a class cast result may be not the same pointer as opposite to an object casting. So do not cache cast results for an object casting in a presence of interfaces.
I think this is fixed by my cast cache splitter patch which is currently enqueued.
http://patchwork.ozlabs.org/patch/294766/
Regards,
Peter
Quoted 22 lines
Signed-off-by Sergey Fedorov <[email protected]>--- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qom/object.c +1
-2@@ -473,7 +473,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,assert (obj == inst); -if (obj && obj == inst) { +if (obj && obj == inst && !obj->class->interfaces) {for (i =1 ; i <OBJECT_CLASS_CAST_CACHE ; i++) { obj->class->cast_cache[i -1 ] = obj->class->cast_cache[i]; } --1.7.9.5
Quoted 6 lines · Peter Crosthwaite
Quoted 5 lines · Sergey Fedorov
A single cast cache is used for both an object casting and a class casting. In case of interface presence a class cast result may be not the same pointer as opposite to an object casting. So do not cache cast results for an object casting in a presence of interfaces.
Quoted 7 lines
I think this is fixed by my cast cache splitter patch which is currently enqueued.
http://patchwork.ozlabs.org/patch/294766/
Regards,
Peter
Yes, your cache splitter looks much better. Thank you.
Best regards,
Sergey Fedorov
Quoted 24 lines
Quoted 24 lines
Signed-off-by Sergey Fedorov <[email protected]>--- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)qom/object.c +1
-2@@ -473,7 +473,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,assert (obj == inst); -if (obj && obj == inst) { +if (obj && obj == inst && !obj->class->interfaces) {for (i =1 ; i <OBJECT_CLASS_CAST_CACHE ; i++) { obj->class->cast_cache[i -1 ] = obj->class->cast_cache[i]; } --1.7.9.5