summaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-05-10 14:16:40 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-05-13 09:52:06 -0500
commit3556c233d931ad5ffa46a35cb25cfc057732ebb8 (patch)
treebd7e58516cec0d8567112f1afef447ba58a44bca /qom
parentfa131d94a5c00c6bbea39358d4bca7bf98f6c1f5 (diff)
downloadqemu-3556c233d931ad5ffa46a35cb25cfc057732ebb8.tar.gz
qemu-3556c233d931ad5ffa46a35cb25cfc057732ebb8.tar.bz2
qemu-3556c233d931ad5ffa46a35cb25cfc057732ebb8.zip
qom: allow turning cast debugging off
Cast debugging can have a substantial cost (20% or more). Instead of adding special-cased "fast casts" in the hot paths, we can just disable it in releases. The tracing facilities we just added make it easier to analyze those problems that cast debugging would reveal. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-7-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/qom/object.c b/qom/object.c
index 1b9c5ce4f8..f5f416bc81 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -435,12 +435,11 @@ Object *object_dynamic_cast(Object *obj, const char *typename)
Object *object_dynamic_cast_assert(Object *obj, const char *typename,
const char *file, int line, const char *func)
{
- Object *inst;
-
trace_object_dynamic_cast_assert(obj ? obj->class->type->name : "(null)",
typename, file, line, func);
- inst = object_dynamic_cast(obj, typename);
+#ifdef CONFIG_QOM_CAST_DEBUG
+ Object *inst = object_dynamic_cast(obj, typename);
if (!inst && obj) {
fprintf(stderr, "%s:%d:%s: Object %p is not an instance of type %s\n",
@@ -448,7 +447,9 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
abort();
}
- return inst;
+ assert(obj == inst);
+#endif
+ return obj;
}
ObjectClass *object_class_dynamic_cast(ObjectClass *class,
@@ -509,6 +510,12 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
trace_object_class_dynamic_cast_assert(class ? class->type->name : "(null)",
typename, file, line, func);
+#ifndef CONFIG_QOM_CAST_DEBUG
+ if (!class->interfaces) {
+ return class;
+ }
+#endif
+
ret = object_class_dynamic_cast(class, typename);
if (!ret && class) {
fprintf(stderr, "%s:%d:%s: Object %p is not an instance of type %s\n",