From 88bdcd0b7fa62a7ea0fdc2286ad1f51d869fd3cf Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 20 Jul 2018 09:58:08 +0200 Subject: Add debug code for dumping unit stats This is useful for profiling the sizes of cache files. Change-Id: I831d0a20c4eda3d707221a61fa7290857605c7fb Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compiler.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/qml/compiler/qv4compiler.cpp') diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 76779fece8..8a61333315 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -521,15 +521,20 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp nextOffset = (nextOffset + 7) & ~quint32(0x7); + quint32 functionSize = 0; + for (int i = 0; i < module->functions.size(); ++i) { Context *f = module->functions.at(i); blockAndFunctionOffsets[i] = nextOffset; const int qmlIdDepsCount = f->idObjectDependencies.count(); const int qmlPropertyDepsCount = f->scopeObjectPropertyDependencies.count() + f->contextObjectPropertyDependencies.count(); - nextOffset += QV4::CompiledData::Function::calculateSize(f->arguments.size(), f->locals.size(), f->lineNumberMapping.size(), f->nestedContexts.size(), + quint32 size = QV4::CompiledData::Function::calculateSize(f->arguments.size(), f->locals.size(), f->lineNumberMapping.size(), f->nestedContexts.size(), qmlIdDepsCount, qmlPropertyDepsCount, f->code.size()); + functionSize += size - f->code.size(); + nextOffset += size; } + blockAndFunctionOffsets += module->functions.size(); for (int i = 0; i < module->classes.size(); ++i) { @@ -566,5 +571,11 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp unit.unitSize = nextOffset; + static const bool showStats = qEnvironmentVariableIsSet("QML_SHOW_UNIT_STATS"); + if (showStats) { + qDebug() << "Generated JS unit that is" << unit.unitSize << "bytes contains:"; + qDebug() << " " << functionSize << "bytes for non-code function data for" << unit.functionTableSize << "functions"; + } + return unit; } -- cgit v1.2.3