diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-23 14:37:05 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-23 14:43:46 +0100 |
commit | 24d0266ee45cf6a3c5b9142453966199702fbf90 (patch) | |
tree | 3484070112f5d4cbd1da4683398d0b41d748be65 /src/qml/compiler | |
parent | 12569460e765ea01935ab60e06b5a5acf770ebe7 (diff) | |
parent | 8f5366aed675ce7928448be2f6d739d0548b350e (diff) |
Merge remote-tracking branch 'origin/5.9' into HEAD
Conflicts:
src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
src/qml/jit/qv4assembler.cpp
src/qml/jit/qv4assembler_p.h
src/qml/jit/qv4isel_masm.cpp
src/qml/jsruntime/qv4context.cpp
src/qml/jsruntime/qv4context_p.h
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4vme_moth.cpp
src/qml/memory/qv4mmdefs_p.h
Change-Id: I9966750b7cd9106b78e4c4779f12b95a481cca40
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 4 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper.cpp | 7 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper_p.h | 4 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper_unix.cpp | 5 | ||||
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper_win.cpp | 4 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 7 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 18 | ||||
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth.cpp | 75 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_moth_p.h | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4jsir_p.h | 4 |
12 files changed, 66 insertions, 68 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index ecec0cf49a..3234e7ee63 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1497,7 +1497,7 @@ IR::Expr *Codegen::identifier(const QString &name, int line, int col) IR::Function *f = _function; while (f && e->parent) { - if (f->insideWithOrCatch || (f->isNamedExpression && f->name == name)) + if (f->insideWithOrCatch || (f->isNamedExpression && QStringRef(f->name) == name)) return _block->NAME(name, line, col); int index = e->findMember(name); @@ -1508,7 +1508,7 @@ IR::Expr *Codegen::identifier(const QString &name, int line, int col) al->isArgumentsOrEval = true; return al; } - const int argIdx = f->indexOfArgument(&name); + const int argIdx = f->indexOfArgument(QStringRef(&name)); if (argIdx != -1) return _block->ARG(argIdx, scope); diff --git a/src/qml/compiler/qv4compilationunitmapper.cpp b/src/qml/compiler/qv4compilationunitmapper.cpp index 1ae0fb190c..d94f7ac238 100644 --- a/src/qml/compiler/qv4compilationunitmapper.cpp +++ b/src/qml/compiler/qv4compilationunitmapper.cpp @@ -59,7 +59,7 @@ CompilationUnitMapper::~CompilationUnitMapper() close(); } -bool CompilationUnitMapper::verifyHeader(const CompiledData::Unit *header, const QString &sourcePath, QString *errorString) +bool CompilationUnitMapper::verifyHeader(const CompiledData::Unit *header, QDateTime sourceTimeStamp, QString *errorString) { if (strncmp(header->magic, CompiledData::magic_str, sizeof(header->magic))) { *errorString = QStringLiteral("Magic bytes in the header do not match"); @@ -77,11 +77,6 @@ bool CompilationUnitMapper::verifyHeader(const CompiledData::Unit *header, const } if (header->sourceTimeStamp) { - QFileInfo sourceCode(sourcePath); - QDateTime sourceTimeStamp; - if (sourceCode.exists()) - sourceTimeStamp = sourceCode.lastModified(); - // Files from the resource system do not have any time stamps, so fall back to the application // executable. if (!sourceTimeStamp.isValid()) diff --git a/src/qml/compiler/qv4compilationunitmapper_p.h b/src/qml/compiler/qv4compilationunitmapper_p.h index 5b6939f1cf..b24f98df7c 100644 --- a/src/qml/compiler/qv4compilationunitmapper_p.h +++ b/src/qml/compiler/qv4compilationunitmapper_p.h @@ -68,11 +68,11 @@ public: CompilationUnitMapper(); ~CompilationUnitMapper(); - CompiledData::Unit *open(const QString &cacheFilePath, const QString &sourcePath, QString *errorString); + CompiledData::Unit *open(const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); void close(); private: - static bool verifyHeader(const QV4::CompiledData::Unit *header, const QString &sourcePath, QString *errorString); + static bool verifyHeader(const QV4::CompiledData::Unit *header, QDateTime sourceTimeStamp, QString *errorString); #if defined(Q_OS_UNIX) size_t length; diff --git a/src/qml/compiler/qv4compilationunitmapper_unix.cpp b/src/qml/compiler/qv4compilationunitmapper_unix.cpp index 1aa3e05f5f..38dabc41cf 100644 --- a/src/qml/compiler/qv4compilationunitmapper_unix.cpp +++ b/src/qml/compiler/qv4compilationunitmapper_unix.cpp @@ -43,6 +43,7 @@ #include <functional> #include <private/qcore_unix_p.h> #include <private/qdeferredcleanup_p.h> +#include <QDateTime> #include "qv4compileddata_p.h" @@ -50,7 +51,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; -CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, const QString &sourcePath, QString *errorString) +CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, const QDateTime &sourceTimeStamp, QString *errorString) { close(); @@ -72,7 +73,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co return nullptr; } - if (!verifyHeader(&header, sourcePath, errorString)) + if (!verifyHeader(&header, sourceTimeStamp, errorString)) return nullptr; // Data structure and qt version matched, so now we can access the rest of the file safely. diff --git a/src/qml/compiler/qv4compilationunitmapper_win.cpp b/src/qml/compiler/qv4compilationunitmapper_win.cpp index 37cac846a0..d7a93ae233 100644 --- a/src/qml/compiler/qv4compilationunitmapper_win.cpp +++ b/src/qml/compiler/qv4compilationunitmapper_win.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; -CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, const QString &sourcePath, QString *errorString) +CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, const QDateTime &sourceTimeStamp, QString *errorString) { close(); @@ -87,7 +87,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co return nullptr; } - if (!verifyHeader(&header, sourcePath, errorString)) + if (!verifyHeader(&header, sourceTimeStamp, errorString)) return nullptr; const uint mappingFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 0cee2996d7..edb5edb0bc 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -95,7 +95,6 @@ static QString cacheFilePath(const QUrl &url) #ifndef V4_BOOTSTRAP CompilationUnit::CompilationUnit() : data(0) - , runtimeStrings(0) , engine(0) , runtimeLookups(0) , runtimeRegularExpressions(0) @@ -351,7 +350,7 @@ bool CompilationUnit::verifyChecksum(QQmlEngine *engine, sizeof(data->dependencyMD5Checksum)) == 0; } -bool CompilationUnit::loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory, QString *errorString) +bool CompilationUnit::loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, EvalISelFactory *iselFactory, QString *errorString) { if (!QQmlFile::isLocalFile(url)) { *errorString = QStringLiteral("File has to be a local file."); @@ -361,7 +360,7 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory const QString sourcePath = QQmlFile::urlToLocalFileOrQrc(url); QScopedPointer<CompilationUnitMapper> cacheFile(new CompilationUnitMapper()); - CompiledData::Unit *mappedUnit = cacheFile->open(cacheFilePath(url), sourcePath, errorString); + CompiledData::Unit *mappedUnit = cacheFile->open(cacheFilePath(url), sourceTimeStamp, errorString); if (!mappedUnit) return false; @@ -784,7 +783,7 @@ void Unit::generateChecksum() #ifndef V4_BOOTSTRAP QCryptographicHash hash(QCryptographicHash::Md5); - const int checksummableDataOffset = qOffsetOf(QV4::CompiledData::Unit, md5Checksum) + sizeof(md5Checksum); + const int checksummableDataOffset = offsetof(QV4::CompiledData::Unit, md5Checksum) + sizeof(md5Checksum); const char *dataPtr = reinterpret_cast<const char *>(this) + checksummableDataOffset; hash.addData(dataPtr, unitSize - checksummableDataOffset); diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 48c78c6a01..9c21d5e9ae 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE // Bump this whenever the compiler data structures change in an incompatible way. -#define QV4_DATA_STRUCTURE_VERSION 0x09 +#define QV4_DATA_STRUCTURE_VERSION 0x11 class QIODevice; class QQmlPropertyCache; @@ -796,11 +796,15 @@ typedef QVector<QQmlPropertyData*> BindingPropertyData; // This is how this hooks into the existing structures: -//VM::Function -// CompilationUnit * (for functions that need to clean up) -// CompiledData::Function *compiledFunction +struct Q_QML_PRIVATE_EXPORT CompilationUnitBase +{ + QV4::Heap::String **runtimeStrings = 0; // Array +}; -struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount +Q_STATIC_ASSERT(std::is_standard_layout<CompilationUnitBase>::value); +Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeStrings) == 0); + +struct Q_QML_PRIVATE_EXPORT CompilationUnit : public CompilationUnitBase, public QQmlRefCount { #ifdef V4_BOOTSTRAP CompilationUnit() @@ -817,8 +821,6 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount // Called only when building QML, when we build the header for JS first and append QML data virtual QV4::CompiledData::Unit *createUnitData(QmlIR::Document *irDocument); - QV4::Heap::String **runtimeStrings; // Array - #ifndef V4_BOOTSTRAP ExecutionEngine *engine; @@ -898,7 +900,7 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount void destroy() Q_DECL_OVERRIDE; - bool loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory, QString *errorString); + bool loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, EvalISelFactory *iselFactory, QString *errorString); protected: virtual void linkBackendToEngine(QV4::ExecutionEngine *engine) = 0; diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index e9709f5fb4..b81d724fe7 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -427,7 +427,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp } unit.indexOfRootFunction = -1; unit.sourceFileIndex = getStringId(irModule->fileName); - unit.sourceTimeStamp = irModule->sourceTimeStamp; + unit.sourceTimeStamp = irModule->sourceTimeStamp.isValid() ? irModule->sourceTimeStamp.toMSecsSinceEpoch() : 0; unit.nImports = 0; unit.offsetToImports = 0; unit.nObjects = 0; diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 53d9956315..fbd6ac8f99 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -690,7 +690,7 @@ union Instr }; struct instr_binop { MOTH_INSTR_HEADER - uint alu; // offset inside the runtime methods + int alu; // QV4::Runtime::RuntimeMethods enum value Param lhs; Param rhs; Param result; diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index 04844302d9..aefb084971 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -55,70 +55,70 @@ using namespace QV4::Moth; namespace { -inline uint aluOpFunction(IR::AluOp op) +inline QV4::Runtime::RuntimeMethods aluOpFunction(IR::AluOp op) { switch (op) { case IR::OpInvalid: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpIfTrue: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpNot: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpUMinus: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpUPlus: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpCompl: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpBitAnd: - return offsetof(QV4::Runtime, bitAnd); + return QV4::Runtime::bitAnd; case IR::OpBitOr: - return offsetof(QV4::Runtime, bitOr); + return QV4::Runtime::bitOr; case IR::OpBitXor: - return offsetof(QV4::Runtime, bitXor); + return QV4::Runtime::bitXor; case IR::OpAdd: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpSub: - return offsetof(QV4::Runtime, sub); + return QV4::Runtime::sub; case IR::OpMul: - return offsetof(QV4::Runtime, mul); + return QV4::Runtime::mul; case IR::OpDiv: - return offsetof(QV4::Runtime, div); + return QV4::Runtime::div; case IR::OpMod: - return offsetof(QV4::Runtime, mod); + return QV4::Runtime::mod; case IR::OpLShift: - return offsetof(QV4::Runtime, shl); + return QV4::Runtime::shl; case IR::OpRShift: - return offsetof(QV4::Runtime, shr); + return QV4::Runtime::shr; case IR::OpURShift: - return offsetof(QV4::Runtime, ushr); + return QV4::Runtime::ushr; case IR::OpGt: - return offsetof(QV4::Runtime, greaterThan); + return QV4::Runtime::greaterThan; case IR::OpLt: - return offsetof(QV4::Runtime, lessThan); + return QV4::Runtime::lessThan; case IR::OpGe: - return offsetof(QV4::Runtime, greaterEqual); + return QV4::Runtime::greaterEqual; case IR::OpLe: - return offsetof(QV4::Runtime, lessEqual); + return QV4::Runtime::lessEqual; case IR::OpEqual: - return offsetof(QV4::Runtime, equal); + return QV4::Runtime::equal; case IR::OpNotEqual: - return offsetof(QV4::Runtime, notEqual); + return QV4::Runtime::notEqual; case IR::OpStrictEqual: - return offsetof(QV4::Runtime, strictEqual); + return QV4::Runtime::strictEqual; case IR::OpStrictNotEqual: - return offsetof(QV4::Runtime, strictNotEqual); + return QV4::Runtime::strictNotEqual; case IR::OpInstanceof: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpIn: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpAnd: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; case IR::OpOr: - return 0; + return QV4::Runtime::InvalidRuntimeMethod; default: Q_ASSERT(!"Unknown AluOp"); - return 0; + return QV4::Runtime::InvalidRuntimeMethod; } }; @@ -889,24 +889,25 @@ Param InstructionSelection::binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR if (oper == IR::OpInstanceof || oper == IR::OpIn || oper == IR::OpAdd) { Instruction::BinopContext binop; if (oper == IR::OpInstanceof) - binop.alu = offsetof(QV4::Runtime, instanceof); + binop.alu = QV4::Runtime::instanceof; else if (oper == IR::OpIn) - binop.alu = offsetof(QV4::Runtime, in); + binop.alu = QV4::Runtime::in; else - binop.alu = offsetof(QV4::Runtime, add); + binop.alu = QV4::Runtime::add; binop.lhs = getParam(leftSource); binop.rhs = getParam(rightSource); binop.result = getResultParam(target); - Q_ASSERT(binop.alu); + Q_ASSERT(binop.alu != QV4::Runtime::InvalidRuntimeMethod); addInstruction(binop); return binop.result; } else { + auto binopFunc = aluOpFunction(oper); + Q_ASSERT(binopFunc != QV4::Runtime::InvalidRuntimeMethod); Instruction::Binop binop; - binop.alu = aluOpFunction(oper); + binop.alu = binopFunc; binop.lhs = getParam(leftSource); binop.rhs = getParam(rightSource); binop.result = getResultParam(target); - Q_ASSERT(binop.alu); addInstruction(binop); return binop.result; } diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h index 41469f1985..4b84bd2831 100644 --- a/src/qml/compiler/qv4isel_moth_p.h +++ b/src/qml/compiler/qv4isel_moth_p.h @@ -179,7 +179,7 @@ private: int scratchTempIndex() const { return _function->tempCount; } int callDataStart() const { return scratchTempIndex() + 1; } - int outgoingArgumentTempStart() const { return callDataStart() + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value); } + int outgoingArgumentTempStart() const { return callDataStart() + offsetof(QV4::CallData, args)/sizeof(QV4::Value); } int frameSize() const { return outgoingArgumentTempStart() + _function->maxNumberOfArguments; } template <int Instr> diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index 756d90a033..f7c7b76ea8 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -61,6 +61,7 @@ #include <QtCore/QBitArray> #include <QtCore/qurl.h> #include <QtCore/QVarLengthArray> +#include <QtCore/QDateTime> #include <qglobal.h> #if defined(CONST) && defined(Q_OS_WIN) @@ -942,7 +943,7 @@ struct Q_QML_PRIVATE_EXPORT Module { QVector<Function *> functions; Function *rootFunction; QString fileName; - qint64 sourceTimeStamp; + QDateTime sourceTimeStamp; bool isQmlModule; // implies rootFunction is always 0 uint unitFlags; // flags merged into CompiledData::Unit::flags #ifdef QT_NO_QML_DEBUGGER @@ -955,7 +956,6 @@ struct Q_QML_PRIVATE_EXPORT Module { Module(bool debugMode) : rootFunction(0) - , sourceTimeStamp(0) , isQmlModule(false) , unitFlags(0) #ifndef QT_NO_QML_DEBUGGER |