diff options
author | Simon Hausmann <[email protected]> | 2018-05-14 14:14:43 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2018-05-16 09:08:22 +0000 |
commit | 7dcada48d2435e8ceb0cc8a6771f79b76979e11f (patch) | |
tree | 30641af3adebeb94aa7e24339c577438ad82a724 /src/qml/compiler/qv4compilationunitmapper_win.cpp | |
parent | f61a49efa2172dda996f33a7420b81fe33ad1692 (diff) |
Speed up string handling from QML cache files
Currently when extracting a string from a compilation unit, we copy the
data. This happens for example when instantiating objects and setting
string properties and it also happens when creating the JS runtime
strings from the compilation unit.
Since QML cache files that are mapped into memory from disk, we can
avoid the copy by keeping the files mapped and making sure that the
in-memory representation is compatible with QStringData.
This optimization is limited to little-endian architectures.
Task-number: QTBUG-63068
Change-Id: I2450aacd3bf1eda3e5be4264149b23f0281d8b4e
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
Reviewed-by: Erik Verbruggen <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4compilationunitmapper_win.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper_win.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compilationunitmapper_win.cpp b/src/qml/compiler/qv4compilationunitmapper_win.cpp index 29e3e2ac01..3e44d045fc 100644 --- a/src/qml/compiler/qv4compilationunitmapper_win.cpp +++ b/src/qml/compiler/qv4compilationunitmapper_win.cpp @@ -113,8 +113,15 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co void CompilationUnitMapper::close() { - if (dataPtr != nullptr) - UnmapViewOfFile(dataPtr); + if (dataPtr != nullptr) { + // Do not unmap cache files that are built with the StaticData flag. That's the majority of + // them and it's necessary to benefit from the QString literal optimization. There might + // still be QString instances around that point into that memory area. The memory is backed + // on the disk, so the kernel is free to release the pages and all that remains is the + // address space allocation. + if (!(reinterpret_cast<CompiledData::Unit*>(dataPtr)->flags & CompiledData::Unit::StaticData)) + UnmapViewOfFile(dataPtr); + } dataPtr = nullptr; } |