From 7c1c016ced09c62ce0d857aef5ea734b7c35f394 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 20 Jul 2018 11:57:38 +0200 Subject: Shrink the size of CompiledData::Function by 16 bytes It was previously 68 bytes but rounded up to 72 to be multiple of 8. After removing the rarely used qml offset table properties and calculating them on the fly instead, the data structure shrinks to 56 bytes. Saves 2.8K on examples/quickcontrols/extras/flat/Content.qml and about ~22K RAM on the gallery. Task-number: QTBUG-69588 Change-Id: I13d1efae7fa1dff96674d937ffbad002c2f703c8 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compiler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/qml/compiler/qv4compiler.cpp') diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 8a61333315..a2afc7fefe 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -335,19 +335,19 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte if (!irFunction->idObjectDependencies.isEmpty()) { function->nDependingIdObjects = irFunction->idObjectDependencies.count(); - function->dependingIdObjectsOffset = currentOffset; + Q_ASSERT(function->dependingIdObjectsOffset() == currentOffset); currentOffset += function->nDependingIdObjects * sizeof(quint32); } if (!irFunction->contextObjectPropertyDependencies.isEmpty()) { function->nDependingContextProperties = irFunction->contextObjectPropertyDependencies.count(); - function->dependingContextPropertiesOffset = currentOffset; + Q_ASSERT(function->dependingContextPropertiesOffset() == currentOffset); currentOffset += function->nDependingContextProperties * sizeof(quint32) * 2; } if (!irFunction->scopeObjectPropertyDependencies.isEmpty()) { function->nDependingScopeProperties = irFunction->scopeObjectPropertyDependencies.count(); - function->dependingScopePropertiesOffset = currentOffset; + Q_ASSERT(function->dependingScopePropertiesOffset() == currentOffset); currentOffset += function->nDependingScopeProperties * sizeof(quint32) * 2; } @@ -371,19 +371,19 @@ void QV4::Compiler::JSUnitGenerator::writeFunction(char *f, QV4::Compiler::Conte memcpy(f + function->lineNumberOffset, irFunction->lineNumberMapping.constData(), irFunction->lineNumberMapping.size()*sizeof(CompiledData::CodeOffsetToLine)); // write QML dependencies - quint32_le *writtenDeps = (quint32_le *)(f + function->dependingIdObjectsOffset); + quint32_le *writtenDeps = (quint32_le *)(f + function->dependingIdObjectsOffset()); for (int id : irFunction->idObjectDependencies) { Q_ASSERT(id >= 0); *writtenDeps++ = static_cast(id); } - writtenDeps = (quint32_le *)(f + function->dependingContextPropertiesOffset); + writtenDeps = (quint32_le *)(f + function->dependingContextPropertiesOffset()); for (auto property : irFunction->contextObjectPropertyDependencies) { *writtenDeps++ = property.key(); // property index *writtenDeps++ = property.value(); // notify index } - writtenDeps = (quint32_le *)(f + function->dependingScopePropertiesOffset); + writtenDeps = (quint32_le *)(f + function->dependingScopePropertiesOffset()); for (auto property : irFunction->scopeObjectPropertyDependencies) { *writtenDeps++ = property.key(); // property index *writtenDeps++ = property.value(); // notify index -- cgit v1.2.3