diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-09 14:01:58 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-17 13:33:11 +0000 |
commit | bc9f502d5ff7b6fc874f0e65019f7967916eab11 (patch) | |
tree | 33eb77de54ae6cc3da9b3a49efa3939e898cb8b5 /src | |
parent | ae1c2375f596258c878933adc46a19a541a43a6c (diff) |
Inline dumpConstantTable() into the only place where it's used
... and don't copy byte arrays around for each character of padding
prepended to a number.
Change-Id: I6963d4c9d42aedd780bec9517b4b7a2a83f10185
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4executablecompilationunit.cpp | 27 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth.cpp | 33 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 1 |
3 files changed, 27 insertions, 34 deletions
diff --git a/src/qml/compiler/qv4executablecompilationunit.cpp b/src/qml/compiler/qv4executablecompilationunit.cpp index 432e0c5e37..88e5c1dc0e 100644 --- a/src/qml/compiler/qv4executablecompilationunit.cpp +++ b/src/qml/compiler/qv4executablecompilationunit.cpp @@ -87,6 +87,31 @@ QString ExecutableCompilationUnit::localCacheFilePath(const QUrl &url) return directory + QString::fromUtf8(fileNameHash.result().toHex()) + QLatin1Char('.') + cacheFileSuffix; } +static QString toString(QV4::ReturnedValue v) +{ + Value val = Value::fromReturnedValue(v); + QString result; + if (val.isInt32()) + result = QLatin1String("int "); + else if (val.isDouble()) + result = QLatin1String("double "); + if (val.isEmpty()) + result += QLatin1String("empty"); + else + result += val.toQStringNoThrow(); + return result; +} + +static void dumpConstantTable(const Value *constants, uint count) +{ + QDebug d = qDebug(); + d.nospace() << right; + for (uint i = 0; i < count; ++i) { + d << qSetFieldWidth(8) << i << qSetFieldWidth(0) << ": " + << toString(constants[i].asReturnedValue()).toUtf8().constData() << "\n"; + } +} + QV4::Function *ExecutableCompilationUnit::linkToEngine(ExecutionEngine *engine) { this->engine = engine; @@ -185,7 +210,7 @@ QV4::Function *ExecutableCompilationUnit::linkToEngine(ExecutionEngine *engine) static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE"); if (showCode) { qDebug() << "=== Constant table"; - Moth::dumpConstantTable(constants, data->constantTableSize); + dumpConstantTable(constants, data->constantTableSize); qDebug() << "=== String table"; for (uint i = 0, end = totalStringCount(); i < end; ++i) qDebug() << " " << i << ":" << runtimeStrings[i]->toQString(); diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index 5b637ea567..8a9bd66103 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -56,9 +56,7 @@ int InstrInfo::size(Instr::Type type) static QByteArray alignedNumber(int n) { QByteArray number = QByteArray::number(n); - while (number.size() < 8) - number.prepend(' '); - return number; + return number.prepend(8 - number.size(), ' '); } static QByteArray alignedLineNumber(int line) { @@ -83,25 +81,6 @@ static QByteArray rawBytes(const char *data, int n) return ba; } -static QString toString(QV4::ReturnedValue v) -{ -#ifdef V4_BOOTSTRAP - return QStringLiteral("string-const(%1)").arg(v); -#else // !V4_BOOTSTRAP - Value val = Value::fromReturnedValue(v); - QString result; - if (val.isInt32()) - result = QLatin1String("int "); - else if (val.isDouble()) - result = QLatin1String("double "); - if (val.isEmpty()) - result += QLatin1String("empty"); - else - result += val.toQStringNoThrow(); - return result; -#endif // V4_BOOTSTRAP -} - #define ABSOLUTE_OFFSET() \ (code - start + offset) @@ -128,16 +107,6 @@ const int InstrInfo::argumentCount[] = { FOR_EACH_MOTH_INSTR_ALL(MOTH_COLLECT_NARGS) }; - -void dumpConstantTable(const Value *constants, uint count) -{ - QDebug d = qDebug(); - d.nospace(); - for (uint i = 0; i < count; ++i) - d << alignedNumber(int(i)).constData() << ": " - << toString(constants[i].asReturnedValue()).toUtf8().constData() << "\n"; -} - QString dumpRegister(int reg, int nFormals) { Q_STATIC_ASSERT(offsetof(CallData, function) == 0); diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 35a5fdfba5..e517c6d8b9 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -534,7 +534,6 @@ inline bool operator!=(const StackSlot &l, const StackSlot &r) { return l.stackS // When making changes to the instructions, make sure to bump QV4_DATA_STRUCTURE_VERSION in qv4compileddata_p.h -void dumpConstantTable(const Value *constants, uint count); void dumpBytecode(const char *bytecode, int len, int nLocals, int nFormals, int startLine = 1, const QVector<CompiledData::CodeOffsetToLine> &lineNumberMapping = QVector<CompiledData::CodeOffsetToLine>()); inline void dumpBytecode(const QByteArray &bytecode, int nLocals, int nFormals, int startLine = 1, |