From 234e762265f0b538e65d610751b8488cb596824d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 7 Jul 2016 15:38:01 +0200 Subject: Use on-disk compilation unit if available If we succeeded in saving the compilation unit to disk, then attempt to use it right away. This replaces the C++ heap usage for the compilation unit data as well as the anonymous allocated executable memory with file-backed mmap'ed memory. That means the memory can be discarded when overall availability is low and paged in on-demand. Change-Id: Ide1b1e11752d861eb049a99a26ca12cec5e2502e Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/auto/qml/qqmllanguage') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 1a035be5e0..f32051a26a 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -2118,8 +2118,13 @@ void tst_qqmllanguage::scriptStringWithoutSourceCode() QQmlTypeData *td = eng->typeLoader.getType(url); Q_ASSERT(td); - const QV4::CompiledData::Unit *qmlUnit = td->compilationUnit()->data; - Q_ASSERT(qmlUnit); + const QV4::CompiledData::Unit *readOnlyQmlUnit = td->compilationUnit()->data; + Q_ASSERT(readOnlyQmlUnit); + QV4::CompiledData::Unit *qmlUnit = reinterpret_cast(malloc(readOnlyQmlUnit->unitSize)); + memcpy(qmlUnit, readOnlyQmlUnit, readOnlyQmlUnit->unitSize); + qmlUnit->flags &= ~QV4::CompiledData::Unit::StaticData; + td->compilationUnit()->data = qmlUnit; + const QV4::CompiledData::Object *rootObject = qmlUnit->objectAt(qmlUnit->indexOfRootObject); QCOMPARE(qmlUnit->stringAt(rootObject->inheritedTypeNameIndex), QString("MyTypeObject")); quint32 i; -- cgit v1.2.3