From f3cbd0b8aa96abfc4b3660df4426ed10b11b18e0 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 6 Aug 2013 11:57:42 +0200 Subject: Fix some GC related tests to work with MSVC Using alloca instead of memset we can convince even MSVC to allocate memory on the stack, to overwrite any previous dead V4 pointers. Change-Id: Ic01bebfc6368e9c3ce1f6155a0f0ea206b90764c Reviewed-by: Lars Knoll --- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tests/auto/qml/qjsengine') diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index ca3fa8bca4..1f43d21c51 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -49,16 +49,28 @@ #include #include +#ifdef Q_CC_MSVC +#define NO_INLINE __declspec(noinline) +#else +#define NO_INLINE __attribute__((noinline)) +#endif + +#if defined(Q_OS_WIN) +#include +#else +#include +#endif + Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QObjectList) // The JavaScriptCore GC marks the C stack. To try to ensure that there is // no JSObject* left in stack memory by the compiler, we call this function // to zap some bytes of memory before calling collectGarbage(). -static void zapSomeStack() +static void NO_INLINE zapSomeStack() { - char buf[4096]; - memset(buf, 0, sizeof(buf)); + char *buf = (char*)alloca(4096); + memset(buf, 0, 4096); } static void collectGarbage_helper(QJSEngine &eng) -- cgit v1.2.3