aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-07-04 13:45:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-05 09:47:05 +0200
commit63193605eb71bd45d9b1a98991fee262c301849f (patch)
tree4a3f5ec5844e549516d7a0b1ae98e8e2ac79fe52 /tests/auto
parentfe6ec7bcc17f88ab1aca5a7934d047456354c942 (diff)
Fix failing GC related tests with gcc in release builds
Our conservative collector might is more likely to find old pointers to QV4::Objects on the C stack in release builds, when gcc optimizes out stores that seem unnecessary. These two tests are prone to that due to temporary QV4::Values potentially ending up on the stack on x86, because vmeProperty returns then through an invisible first argument that is a pointer a a location on the stack. This patch makes those temporaries explicit, clears them out after usages and adds GCC pragmas to disable optimizations for these two test functions. Change-Id: Ie43841e869346792296911fee6fed80c745faeff Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index cb1b0b3212..03d553c49c 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -4891,6 +4891,14 @@ void tst_qqmlecmascript::propertyVarCircular2()
delete object;
}
+#if defined(Q_CC_GNU)
+#if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+#define pop_gcc_flags
+#pragma GCC push_options
+#pragma GCC optimize ("O0")
+#endif
+#endif
+
void tst_qqmlecmascript::propertyVarInheritance()
{
// enforce behaviour regarding element inheritance - ensure handle disposal.
@@ -4913,8 +4921,11 @@ void tst_qqmlecmascript::propertyVarInheritance()
{
// XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only
// public function which can return us a handle to something in the varProperties array.
- icoCanaryHandle = icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ"));
- ccoCanaryHandle = ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ"));
+ QV4::Value tmp = icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ"));
+ icoCanaryHandle = tmp;
+ tmp = ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ"));
+ ccoCanaryHandle = tmp;
+ tmp = QV4::Value::nullValue();
QVERIFY(!icoCanaryHandle.isEmpty());
QVERIFY(!ccoCanaryHandle.isEmpty());
gc(engine);
@@ -4952,7 +4963,9 @@ void tst_qqmlecmascript::propertyVarInheritance2()
QCOMPARE(childObject->property("textCanary").toInt(), 10);
QV4::WeakValue childObjectVarArrayValueHandle;
{
- childObjectVarArrayValueHandle = QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp"));
+ QV4::Value tmp = QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp"));
+ childObjectVarArrayValueHandle = tmp;
+ tmp = QV4::Value::nullValue();
QVERIFY(!childObjectVarArrayValueHandle.isEmpty());
gc(engine);
QVERIFY(!childObjectVarArrayValueHandle.isEmpty()); // should not have been collected yet.
@@ -4966,6 +4979,11 @@ void tst_qqmlecmascript::propertyVarInheritance2()
delete object;
}
+#if defined(pop_gcc_flags)
+#pragma GCC pop_options
+#endif
+
+
// Ensure that QObject type conversion works on binding assignment
void tst_qqmlecmascript::elementAssign()
{