aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-08-12 16:05:34 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-17 14:05:18 +0000
commit9fcca80bc4682fd274d2e4d8014390962dab5daa (patch)
treec9562bed09a476acea77ffd76259e0bfda5f7e2f /src/qml/compiler
parent9132b7731c5e2b418d240bac998a10112be50938 (diff)
Make the unit mapping on Windows configurable with regards to executable mapping
If we generate byte code, then we can mmap without the executable flags, otherwise we need them. This should make things work out of the box on platforms where special rights are needed before executable mappings are allowed. Change-Id: I24e663f85d661bc51cd3bf2463547b1d1590ea32 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp2
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h1
-rw-r--r--src/qml/compiler/qv4compilationunitmapper_win.cpp9
-rw-r--r--src/qml/compiler/qv4compileddata_p.h5
-rw-r--r--src/qml/compiler/qv4compiler.cpp1
-rw-r--r--src/qml/compiler/qv4jsir_p.h2
6 files changed, 13 insertions, 7 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index ef8ffa8620..31b964897f 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -302,7 +302,6 @@ Document::Document(bool debugMode)
, program(0)
, indexOfRootObject(0)
, jsGenerator(&jsModule)
- , unitFlags(0)
{
}
@@ -1393,7 +1392,6 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, QQmlEngine
QV4::CompiledData::Unit *qmlUnit = reinterpret_cast<QV4::CompiledData::Unit *>(data);
qmlUnit->unitSize = totalSize;
- qmlUnit->flags |= output.unitFlags;
qmlUnit->flags |= QV4::CompiledData::Unit::IsQml;
qmlUnit->offsetToImports = unitSize;
qmlUnit->nImports = output.imports.count();
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index eedc262e7a..cc16dc2104 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -435,7 +435,6 @@ struct Q_QML_PRIVATE_EXPORT Document
int indexOfRootObject;
QVector<Object*> objects;
QV4::Compiler::JSUnitGenerator jsGenerator;
- quint32 unitFlags;
QQmlRefPointer<QV4::CompiledData::CompilationUnit> javaScriptCompilationUnit;
diff --git a/src/qml/compiler/qv4compilationunitmapper_win.cpp b/src/qml/compiler/qv4compilationunitmapper_win.cpp
index 7e62cbfe8b..6c2f36e7a0 100644
--- a/src/qml/compiler/qv4compilationunitmapper_win.cpp
+++ b/src/qml/compiler/qv4compilationunitmapper_win.cpp
@@ -94,9 +94,14 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
if (!verifyHeader(&header, sourcePath, errorString))
return nullptr;
+ const uint mappingFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode
+ ? PAGE_EXECUTE_READ : PAGE_READONLY;
+ const uint viewFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode
+ ? (FILE_MAP_READ | FILE_MAP_EXECUTE) : FILE_MAP_READ;
+
// Data structure and qt version matched, so now we can access the rest of the file safely.
- HANDLE fileMappingHandle = CreateFileMapping(handle, 0, PAGE_EXECUTE_READ, 0, 0, 0);
+ HANDLE fileMappingHandle = CreateFileMapping(handle, 0, mappingFlags, 0, 0, 0);
if (!fileMappingHandle) {
*errorString = qt_error_string(GetLastError());
return false;
@@ -106,7 +111,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
CloseHandle(fileMappingHandle);
});
- dataPtr = MapViewOfFile(fileMappingHandle, FILE_MAP_READ | FILE_MAP_EXECUTE, 0, 0, 0);
+ dataPtr = MapViewOfFile(fileMappingHandle, viewFlags, 0, 0, 0);
if (!dataPtr) {
*errorString = qt_error_string(GetLastError());
return nullptr;
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index a6ca1594a4..b71c1d8185 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 0x02
+#define QV4_DATA_STRUCTURE_VERSION 0x03
class QIODevice;
class QQmlPropertyCache;
@@ -619,7 +619,8 @@ struct Unit
IsQml = 0x2,
StaticData = 0x4, // Unit data persistent in memory?
IsSingleton = 0x8,
- IsSharedLibrary = 0x10 // .pragma shared?
+ IsSharedLibrary = 0x10, // .pragma shared?
+ ContainsMachineCode = 0x20 // used to determine if we need to mmap with execute permissions
};
LEUInt32 flags;
LEUInt32 stringTableSize;
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 50ade2c6e5..c6a872cc34 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -364,6 +364,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
CompiledData::Unit unit;
memcpy(unit.magic, CompiledData::magic_str, sizeof(unit.magic));
unit.flags = QV4::CompiledData::Unit::IsJavascript;
+ unit.flags |= irModule->unitFlags;
unit.version = QV4_DATA_STRUCTURE_VERSION;
unit.qtVersion = QT_VERSION;
unit.architectureIndex = registerString(QSysInfo::buildAbi());
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index 51b8797862..73aa6c4975 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -934,6 +934,7 @@ struct Q_QML_PRIVATE_EXPORT Module {
QString fileName;
qint64 sourceTimeStamp;
bool isQmlModule; // implies rootFunction is always 0
+ uint unitFlags; // flags merged into CompiledData::Unit::flags
#ifdef QT_NO_QML_DEBUGGER
static const bool debugMode = false;
#else
@@ -946,6 +947,7 @@ struct Q_QML_PRIVATE_EXPORT Module {
: rootFunction(0)
, sourceTimeStamp(0)
, isQmlModule(false)
+ , unitFlags(0)
#ifndef QT_NO_QML_DEBUGGER
, debugMode(debugMode)
{}