Commit Graph

66219 Commits (7ce75b1a2bd9f22a7b2b83d48df875c68a47b390)

Author SHA1 Message Date
Thiago Macieira 7ce75b1a2b QAbstractEventDispatcher: add an adaptation layer to use V2 methods
This way, we can begin using the V2 methods now, regardless of whether
the concrete dispatcher class has been ported or not.

Change-Id: I83dda2d36c904517b3c0fffd17b52a6256b083af
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-13 17:29:12 -08:00
Thiago Macieira af6afad3b3 Short-live QAbstractEventDispatcherV2
This class is a temporary hack to enable transition to an API based on
std::chrono for the Qt event dispatcher. In Qt 7, it will be merged with
QAbstractEventDispatcher, replacing the pure virtuals there with the
ones defined here.

The new API differs from V1 in the following ways:
 - uses Qt::TimerId instead of int to identify timer IDs, so we can't
   accidentally confuse them with something else
 - uses Duration (nanoseconds) to specify the interval, instead of a mix
   of int and qint64
 - add the missing const to remainingTime()
 - rename registeredTimers() to timersForObject() (I'd have kept the
   original name but we can't overload the name if the parameters are
   exactly the same; we could have used QT6_DECL_NEW_OVERLOAD_TAIL, but
   I think the new name is actually better)

Because the old API was mixing int and qint64, we didn't officially
support any timer for more than 2^31 ms (~24.85 days). This should
extend the valid range to 292 years once the dispatchers are ported
over.

Change-Id: I83dda2d36c904517b3c0fffd17b3a7e0afef4b59
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-13 17:29:12 -08:00
Thiago Macieira d18d8a7ad1 tst_QHostInfo: increase the timeout to 15s
That seems to be enough for me when trying to reverse-resolve host names
inside the corporate network.

Pick-to: 6.7
Change-Id: I6818d78a57394e37857bfffd17bc6b0ebd39f51b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-13 18:29:12 -07:00
Thiago Macieira 78cf5740a9 tst_QHostInfo: don't use the test class to store results
Because QHostInfo is threaded, so if the look up times out and we exit a
given test, the results may still be delivered to the next test.
Especially if the next test is also about to time out -- in which case
it doesn't and prints a nonsensical output.

Before:

FAIL!  : tst_QHostInfo::lookupIPv4(WithCache:literal_ip4) '!QTestEventLoop::instance().timeout()' returned FALSE. ()
   Loc: [tst_qhostinfo.cpp(220)]
FAIL!  : tst_QHostInfo::lookupIPv6(WithCache:aaaa-single) Compared values are not the same
   Actual   (tmp.join(' ').toLower())     : "192.0.2.1"
   Expected (expected.join(' ').toLower()): "2001:db8::1"
   Loc: [tst_qhostinfo.cpp(281)]

Now:

FAIL!  : tst_QHostInfo::lookupIPv4(WithCache:literal_ip4) 'helper.waitForResults()' returned FALSE. ()
   Loc: [tst_qhostinfo.cpp(278)]
PASS   : tst_QHostInfo::lookupIPv6(WithCache:aaaa-single)

Pick-to: 6.7
Change-Id: I6818d78a57394e37857bfffd17bc66e241cab24d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-14 01:29:12 +00:00
Alexandru Croitor fb69efb9c9 CMake: Make a few more auto tests standalone
Pick-to: 6.7
Change-Id: I80988114bd906447a2ab712d5432a489e095a5c1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-14 01:14:18 +01:00
Joerg Bornemann 2cf66d49ef configure: Fully remove support for -c++std c++14/c++17
This amends commit 205f8fbff0.

We silently supported the values c++14 and c++17 for the -c++std
argument. Support for both versions of the C++ standard was removed in
above mentioned commit.

Change-Id: I8f7dbc33f0a23164f712ac3d2e0a40bb8d12f225
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-13 20:43:14 +01:00
Anton Kudryavtsev e10c9b5c0f QTextMarkdownImporter: use string view more
to reduce allocations. While touching code, reorder condition
and extract string literal to remove magic number

Change-Id: I3972097dc9b976438e9ba0029f674cea2614f966
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-13 19:34:23 +00:00
Anton Kudryavtsev ed553b720d QTextDocumentFragment: use range for more
to improve readability

Change-Id: I42109e33fc076763c5b681d4837a81399c5aed5d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-03-13 22:34:23 +03:00
Tatiana Borisova 1cd95e3165 QCborValue: use new comparison helper macros
Replace public operators operator==() and operator!=() of QCborValue
to friend method comparesEqual().
Replace public operator<() of QCborValue to friend method
compareThreeWay().

Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods
and replace them with a friend.

Delete #if 0 && __has_include(<compare>) blocks,
since they are not required anymore.

Task-number: QTBUG-120300
Change-Id: I884ff6ce2a71618b0e3eaa907f0852f93c2a073c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-03-13 20:34:22 +01:00
Alexey Edelev e7d7eded4c Fix the condition for creating of the plugin init target aliases
Make sure that plugin_init_target is not empty. It's empty when
creating qml plugins.

Amends 566b726b84

Pick-to: 6.7
Change-Id: If23998d50d8d31e20b3966730afb8b4b46b9990c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-13 19:34:22 +00:00
Ivan Solovev 5ea434b09f QOperatingSystemVersion: use partial ordering for relational operators
QOperatingSystemVersion intentionally does not define operator==() and
operator!=() since ae072cd9c4.
It means that we cannot use comparison helper macros.

Still, we can manually define four relational operators or
operator<=>() in C++20 mode, and give the class a partial ordering.
We choose partial ordering, because versions of different OS types are
incomparable.

Implement the operators in terms of helper function compareThreeWay(),
which potentially allows to use this class in some templated code.

As a drive-by: make the static compare() function noexcept, because
it really is.

Fixes: QTBUG-120360
Change-Id: Id4c9ce740e42baa719ca0ee84146d087b21675c6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-13 20:34:22 +01:00
Ivan Solovev e55ee873e9 QTypeRevision: use comparison helper macros
QTypeRevision consists of two quint8 values: major and minor version.
Each of the versions can be unknown.
The rules for comparing with the unknown version are as follows:

 zero version < unknown version < non-zero version

At the same time, two unknown versions are considered equal.

This makes the comparison a bit tricky, but it still fits into the
category of strong ordering.

Replace the existing friend relational operators with helper functions
and comparison helper macros, making this type strongly ordered.

Update the unit-tests to use the new comparison helper test functions.
As the test functions check the reversed arguments as well, we can
reduce the number of rows for the data-driven comparison test.

Fixes: QTBUG-120359
Change-Id: Ib6f1037fc7b5fed148e35ee48b56b05dcd36b3b4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-13 20:34:22 +01:00
Ivan Solovev 81dcb7c8be QTypeRevision: convert comparison test to data-driven
This patch simplifies the checks when migrating the class to comparison
helper macros.

Task-number: QTBUG-120359
Change-Id: I47a6ba20d3b89c31edc2f432621eae9385fbd0a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-13 20:34:22 +01:00
Thiago Macieira b57a9a3cd9 Bootstrap: remove QTemporaryFile
Done by harmonizing the use on the QT_CONFIG(temporaryfile) macro and
fixing one test that was missing. We can't remove the older macro
because it is marked PBULIC) but we don't need to use it ourselves.

Change-Id: I01ec3c774d9943adb903fffd17b7eb4dd1a4e63f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-13 09:41:02 -08:00
Tinja Paavoseppä 7942f7eedf Android: Resize QWindow when its QtView is resized
If the Android View is resized, the QWindow instantiated by it
should be resized accordingly.

Task-number: QTBUG-122626
Pick-to: 6.7
Change-Id: I7bfbca149f927718d1e28cdabfa8759afbd06039
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-13 15:50:14 +00:00
Tinja Paavoseppä d899cdb3a4 Android: Synchronize window creation in QtEmbeddedDelegate
Qt window loading is initiated either when the QtView is attached
to its Android window, or when the Android QPA plugin has been loaded
and is ready, depending on the order. Since the window attachment
happens in the Android UI thread, and the Android QPA plugin callback
happens in Qt thread, add synchronized block to make sure the execution
stays ordered.

Fixes: QTBUG-122626
Pick-to: 6.7
Change-Id: Id476032f02aa8990432a02f62b6bf6237a17e7ac
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-13 15:50:14 +00:00
Kai Köhne 39c4c868a4 Use canonical capitalization of Unicode-3.0 SPDX tag
The SPDX database lists the license as 'Unicode-3.0', and 'Unicode
License v3'. Now, the SPDX standard actually says that

   License identifiers (including license exception identifiers) used
   in SPDX documents or source code files should be matched in a case-
   insensitive manner.

But the website at https://spdx.org/licenses/ doesn't treat it this way,
so the link we generate out of the identifier actually gives a 404. So
it's just easier to use the 'original' capitalization.

Amends 063026cc50

Pick-to: 6.5 6.6 6.7
Change-Id: I826077a914721b7b9499ad62c08fdf20be94e88d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-13 14:43:10 +00:00
Assam Boudjelthia 4bb4d015f7 Android: don't add lib prefix to loaded libs unconditionally
Some libs don't necessarily have the lib prefix in their names,
3rd party libs and Qt for Python might have that, so no need to
always add that prefix to loaded libs is the lib name already
contains a .so suffix.

Fixes: QTBUG-123286
Pick-to: 6.7 6.7.0
Change-Id: Ib65215d9b4410c5c9e00aa0642f48ab45c92fe03
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2024-03-13 18:43:10 +04:00
Paul Wicking 08e6d4b43d QDoc: Drop default arguments from some \fn documentation strings
In the \fn commands for a limited number of methods in the
documentation for Testlib and Widgets, `= 0` is passed as default
argument instead of `= Qt::KeyboardModifiers()`. Until QDoc with Clang
17, inclusive, QDoc generated the correct signature. However, with
Clang 18, QDoc outputs `= 0` in the documentation. While strictly
speaking still correct, this change impacts the documentation
negatively in terms of readability.

Dropping the default argument from the \fn command ensures that QDoc
generates the right signature with both Clang 17 and Clang 18.

Task-number: QTBUG-123130
Pick-to: 6.7
Change-Id: I94ccec2f2c9a02241095fb5b18feb74aa55f97e1
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2024-03-13 15:43:10 +01:00
Mikko Hallamaa 342ae435a1 OpenGL: Add parameters to choose FBO grab orientation
We want to be able to pass as an argument whether the texture grabbed to
an FBO is supposed to have a flipped y-axis or not. This is required for
screen capture on the EGLFS platform.

Task-number: QTBUG-121835
Pick-to: 6.7 6.6 6.5
Change-Id: I6dddc879a4be7ff2c2c189747193423644be55a0
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2024-03-13 14:38:52 +00:00
Alexey Edelev 8db0a12e84 Collect CMAKE_MODULE_PATH from QT_ADDITIONAL_PACKAGES_PREFIX_PATH
This is sensitive for the 'include' calls that expect cmake scripts
to be found in some staging prefixes. In yocto
QT_ADDITIONAL_PACKAGES_PREFIX_PATH points to the package image
path(installation snapshot). If repo provides bundled 3rdparties
the 'include' statement that includes 'FindWrap<3rdparty>ConfigExtra'
is unnable to locate it, since it's expected to be found in Qt
installation, but the file didn't land there at ptest stage.

Fixes: QTBUG-122205
Pick-to: 6.5 6.6 6.7
Change-Id: Idd03f44efd2e3fdaa476873068c73ac28cd0a7b5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-13 15:38:52 +01:00
Giuseppe D'Angelo 3a6c8e02b6 Long live QT_ENABLE_STRICT_MODE_UP_TO
We already have fine-grained macros to individually disable APIs
that we consider "suboptimal" or "dangerous". This commit adds
a shortcut for the user to set all such macros in one go.

QT_ENABLE_STRICT_MODE_UP_TO is versioned, just like
QT_DISABLE_DEPRECATED_UP_TO; the idea is that users should set it
to the minimum Qt version they want to support.

Also, if QT_DISABLE_DEPRECATED_UP_TO is not set, then
QT_ENABLE_STRICT_MODE_UP_TO will set it as well, to the same value.

[ChangeLog][QtCore][QtGlobal] Added the QT_ENABLE_STRICT_MODE_UP_TO
macro.

Change-Id: I5466465986104e047a6a86369928be9294f24ab7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-13 13:08:29 +01:00
Giuseppe D'Angelo 03baf08d2b QT_NO_AS_CONST: rename and add docs
Give it a name in line with the function name:
qAsConst -> QT_NO_QASCONST, as already done for qExchange.
We can do this because we never documented the macro itself.
So, while at it: also document the macro.

Change-Id: I6eb0834df438e4f4e818ef2cf8e702ed156dc253
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-13 13:08:29 +01:00
Giuseppe D'Angelo 5fe805dcfb QT_NO_QEXCHANGE: doc fix
A \relates was missing.

Change-Id: I30c8a721b2d1e38ac87bebac37aef5a350dfe683
Pick-to: 6.7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-13 13:08:28 +01:00
Lucie Gérard 05ed4a85bf Correct license for statically compiled helper file
Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I19222cbe8a45a27853933191677f433dd0a60771
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-13 13:08:28 +01:00
Marc Mutz 92eb2f691b QGuiApplication: copy a Prealloc value instead of hard-coding 16
The EventPointMap QPointingDevicePrivate::activePoints is actually a
QVarLengthFlatMap<., ., 20>, not 16, so copy the value instead of just
hard-coding something.

Amends 296ede3aab.

Change-Id: Ic8e83f4095f57be74f7708d5cec6a19971772b76
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-13 10:23:52 +00:00
Marc Mutz 73c52ba268 QTest::qWaitFor(., int): restore lost Qt::PreciseTimer'ness
Before the qWaitFor() port from int to QDeadlineTimer, the
implementation constructed a QDeadlineTimer internally, passing int
timeout and Qt::PreciseTimer. The int overload that was retained for
source-compatibility, however, constructs the QDeadlineTimer without
the PreciseTimer flag, which is a behavior change.

Restore the Qt 6.6 behavior and pass Qt::PreciseTimer.

Amends fa296ee1dc.

Pick-to: 6.7 6.7.0
Change-Id: Ib8e5b912c74b70d32a77195edb0d2a30cd7c241d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-03-13 11:23:52 +01:00
Marc Mutz 097f0edc9f QLibrary: fix Clazy warning about QString(const char*)
Wrap dlerror() in QLatin1StringView(), like we already do in
unload_sys().

Amends a6a5681470.

Pick-to: 6.7
Change-Id: Ia8c91d6962c74d5916c47b2abbb3920f051c8e5e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-13 11:23:52 +01:00
Piotr Wiercinski 05f4a77e17 wasm tests: Use WebDriverManager to install chromedriver
Use WebDriverManager to install the correct version of chromedriver.
This will help avoiding mismatch of Chrome/chromedriver versions,
which sometimes happen in CI.

Fixes: QTBUG-122729
Change-Id: I40cf62c02c2cb6f57b031cc83b9fa38f6ed2610e
Reviewed-by: Simo Fält <simo.falt@qt.io>
2024-03-13 09:19:48 +00:00
Thiago Macieira 9e214cbcdd Bootstrap: remove QRandomGenerator
The bootstrapped tools really mustn't produce random output (they must
always be reproducible exactly). Therefore, ensure we don't need this
file.

Change-Id: I01ec3c774d9943adb903fffd17b7eb94dbd4be89
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-13 00:00:48 -08:00
Thiago Macieira cdbc76360a Bootstrap: remove QVariant
I added QT_NO_VARIANT to qconfig-bootstrapped.h to be clearer on what
the #ifs are, but there's no testing of that feature outside of
QT_BOOTSTRAPPED.

Change-Id: I01ec3c774d9943adb903fffd17b7e8ac4340fb89
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-13 00:00:48 -08:00
Thiago Macieira 4be7c046b1 Bootstrap: remove QDataStream
It was only used by the cmake_automoc_parser so it would write a 64-bit
in big-endian format. So bypass QDataStream and write it native
endianness.

Change-Id: I01ec3c774d9943adb903fffd17b79c78e56db4cf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-13 00:00:48 -08:00
Thiago Macieira 0f56502fb6 QProcess/Unix: fix close() on invalid file descriptor
Commit 90bc0ad41f ("QProcess/Unix: add
failChildProcessModifier()") added this line that set childStartedPipe
so that the failChildProcess() callback had something to write to. But
we left it set on exit from QProcessPrivate::startDetached(), which
caused the QProcess destructor to try and close it.

Noticed when debugging the issue for QTBUG-123083.

Pick-to: 6.7 6.7.0
Task-number: QTBUG-123083
Change-Id: I6818d78a57394e37857bfffd17bbc41c8400270f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-03-12 22:21:13 -07:00
Thiago Macieira 7d4d6e88bc convertDoubleTo: add FP16 support
Currently unused. I've tested that GCC 13 and Clang 17 do compile this
and do output reasonable assembly, with and without AVX512FP16 (I also
tested AVX10.1 with GCC 14).

Clang is unable to allocate a "v" (vector) register when T is qfloat16,
so I could only implement the conversion using _Float16. Strictly
speaking, Clang >= 16 always knows about _Float16, but I didn't want to
have a different detection from qtypes.h.

Change-Id: I6818d78a57394e37857bfffd17bae860f8055324
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-12 18:23:22 -07:00
Thiago Macieira c86e1758dd convertDoubleTo<FP>: add support for x86 intrinsics
The x86 SSE instructions do what we want and set a flag in the MXCSR to
indicate whether we should return false, so we can improve the codegen.
GCC generates for QStringView::toFloat():

        call    _ZNK11QStringView8toDoubleEPb
        movl    $8064, 12(%rsp)
        movl    $1, %eax
 #APP
 # 330 "/home/tjmaciei/src/qt/qt6/qtbase/src/corelib/global/qnumeric_p.h" 1
        vldmxcsr  12(%rsp)
        vcvtsd2ss %xmm0, %xmm0, %xmm0
        vstmxcsr  12(%rsp)
 # 0 "" 2
 #NO_APP
        movl    12(%rsp), %edx
        testb   $24, %dl
        je      .L2120
        ... handling of the under/overflow ...

The MXCSR instructions do need to read and write from memory, but the
stack is usually already in L1 and CPUs have special optimizations for
it.

There are two alternative implementations to the implementation chosen:
first, we could confirm there was no underflow or overflow using an
expression like:

  (v == 0) == (*value == 0) && qt_is_finite(v) == qt_is_finite(*value);

But that is still very costly, with 4 UCOMISx instructions and several
memory loads.

Second, we could use the VFPCLASSSD and VFPCLASSSS (yes, 4 "S")
instructions to confirm whether a finite input became zero or non-
finite, but a) that's only available with AVX512, so of little practical
use today and b) it has a 3-cycle latency. Like the comparisons above,
we'd need 4 of them.

Change-Id: I01ec3c774d9943adb903fffd17b8b9cb2ce805ce
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-12 18:23:20 -07:00
Thiago Macieira 45fd36f148 qHash: make hashing of QLatin1StringView be the same as QString
Everywhere, except for ARM.

Change-Id: I50e2158aeade4256ad1dfffd17b11ca2d57ad1fb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:11 -08:00
Thiago Macieira fff9f5047a qHash: update the pre-AVX512 mask to use the cacheline size
No change in behavior. But instead of trying to guess if we're going to
cross a page boundary, we check for the cacheline: if we don't cross a
cacheline boundary, then we can't cross a page boundary either. Testing
bit 4 can be implemented with a shorter instruction than a test for bit
11.

   f43de:       40 f6 c7 20             test   $0x20,%dil

Change-Id: I664b9f014ffc48cbb49bfffd17b04817a0fb8c6b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:10 -08:00
Thiago Macieira 55959aefab qHash: implement an AES hasher for QLatin1StringView
It's the same aeshash() as before, except we're passing a template
parameter to indicate whether to read half and then zero-extend the
data. That is, it will perform a conversion from Latin1 on the fly.

When running in zero-extending mode, the length parameters are actually
doubled (counting the number of UTF-16 code units) and we then divide
again by 2 when advancing.

The implementation should have the following performance
characteristics:
* QLatin1StringView now will be roughly half as fast as Qt 6.7
* QLatin1StringView now will be roughly as fast as QStringView

For the aeshash128() in default builds of QtCore (will use SSE4.1), the
long loop (32 characters or more) is:

      QStringView                             QLatin1StringView
    movdqu -0x20(%rax),%xmm4       |        pmovzxbw -0x10(%rdx),%xmm2
    movdqu -0x10(%rax),%xmm5       |        pmovzxbw -0x8(%rdx),%xmm3
    add    $0x20,%rax              |        add    $0x10,%rdx
    pxor   %xmm4,%xmm0             |        pxor   %xmm2,%xmm0
    pxor   %xmm5,%xmm1             |        pxor   %xmm3,%xmm1
    aesenc %xmm0,%xmm0                      aesenc %xmm0,%xmm0
    aesenc %xmm1,%xmm1                      aesenc %xmm1,%xmm1
    aesenc %xmm0,%xmm0                      aesenc %xmm0,%xmm0
    aesenc %xmm1,%xmm1                      aesenc %xmm1,%xmm1

The number of instructions is identical, but there are actually 2 more
uops per iteration. LLVM-MCA simulation shows this should execute in the
same number of cycles on older CPUs that do not have support for VAES
(see <https://analysis.godbolt.org/z/x95Mrfrf7>).

For the VAES version in aeshash256() and the AVX10 version in
aeshash256_256():

      QStringView                             QLatin1StringView
    vpxor  -0x40(%rax),%ymm1,%ym   |        vpmovzxbw -0x20(%rax),%ymm3
    vpxor  -0x20(%rax),%ymm0,%ym   |        vpmovzxbw -0x10(%rax),%ymm2
    add    $0x40,%rax              |        add    $0x20,%rax
                                   |        vpxor  %ymm3,%ymm0,%ymm0
                                   |        vpxor  %ymm2,%ymm1,%ymm1
    vaesenc %ymm1,%ymm1,%ymm1      <
    vaesenc %ymm0,%ymm0,%ymm0               vaesenc %ymm0,%ymm0,%ymm0
    vaesenc %ymm1,%ymm1,%ymm1               vaesenc %ymm1,%ymm1,%ymm1
    vaesenc %ymm0,%ymm0,%ymm0               vaesenc %ymm0,%ymm0,%ymm0
                                   >        vaesenc %ymm1,%ymm1,%ymm1

In this case, the increase in number of instructions matches the
increase in number of uops. The LLVM-MCA simulation says that the
QLatin1StringView version is faster at 11 cycles/iteration vs 14 cyc/it
(see <https://analysis.godbolt.org/z/1Gv1coz13>), but that can't be
right.

Measured performance of CPU cycles, on an Intel Core i9-7940X (Skylake,
no VAES support), normalized on the QString performance (QByteArray is
used as a stand-in for the performance in Qt 6.7):

                        aeshash              |  siphash
                QByteArray  QL1SV   QString     QByteArray  QString
dictionary      94.5%       79.7%   100.0%      150.5%*     159.8%
paths-small     90.2%       93.2%   100.0%      202.8%      290.3%
uuids           81.8%       100.7%  100.0%      215.2%      350.7%
longstrings     42.5%       100.8%  100.0%      185.7%      353.2%
numbers         95.5%       77.9%   100.0%      155.3%*     164.5%

On an Intel Core i7-1165G7 (Tiger Lake, capable of VAES and AVX512VL):

                        aeshash              |  siphash
                QByteArray  QL1SV   QString     QByteArray  QString
dictionary      90.0%       91.1%   100.0%      103.3%*     157.1%
paths-small     99.4%       104.8%  100.0%      237.5%      358.0%
uuids           88.5%       117.6%  100.0%      274.5%      461.7%
longstrings     57.4%       111.2%  100.0%      503.0%      974.3%
numbers         90.6%       89.7%   100.0%      98.7%*      149.9%

On an Intel 4th Generation Xeon Scalable Platinum (Sapphire Rapids, same
Golden Cove core as Alder Lake):

                        aeshash              |  siphash
                QByteArray  QL1SV   QString     QByteArray  QString
dictionary      89.9%       102.1%  100.0%      158.1%*     172.7%
paths-small     78.0%       89.4%   100.0%      159.4%      258.0%
uuids           109.1%      107.9%  100.0%      279.0%      496.3%
longstrings     52.1%       112.4%  100.0%      564.4%      1078.3%
numbers         85.8%       98.9%   100.0%      152.6%*     190.4%

* dictionary contains very short entries (6 characters)
* paths-small contains strings of varying length, but very few over 32
* uuids-list contains fixed-length strings (38 characters)
* longstrings is the same but 304 characters
* numbers also a lot contains very short strings (1 to 6 chars)

What this shows:
* For short strings, the performance difference is negligible between
  all three
* For longer strings, QLatin1StringView now costs between 7 and 17% more
  than QString on the tested machines instead of up to ~50% less, except on
  the older machine (where I think the main QString hashing is suffering
  from memory bandwidth limitations)
* The AES hash implementation is anywhere from 1.6 to 11x faster than
  Siphash
* Murmurhash (marked with asterisk) is much faster than Siphash, but it
  only managed to beat the AES hash in one test

Change-Id: I664b9f014ffc48cbb49bfffd17b045c1811ac0ed
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 18:23:09 -07:00
Thiago Macieira 970aad5418 qHash: implement chunked hashing of QLatin1StringView
So that it hashes to the same value as QString{,View}.

In order to test this, you must either run on a CPU other than ARM and
x86, or disable the AES hasher. I did that and can confirm siphash and
murmurhash do work with on-the-fly conversion from Latin-1.

Change-Id: I664b9f014ffc48cbb49bfffd17b03e5e62ec4e89
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:09 -08:00
Thiago Macieira 9a2e21174a QHash: implement the heterogeneous non-const operator[]
This complements the previous commit by adding the heterogeneous lookup
in operator[]. Unlike the members of the previous commit, this one may
insert into the hash, in which case it needs a way to cast from the
heterogeneous type K to the actual Key type.

Change-Id: I664b9f014ffc48cbb49bfffd17b037c1063dfb91
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:08 -08:00
Thiago Macieira b53c153a10 QHash: add support for heterogeneous key lookups
This implements support in QHash and QMultiHash for lookups of
heterogeneous key types that produce the same hash value. This is
implemented by duplicating each of the following functions into an
overload on Key and one a template that is enable_if-constrained to a
key type that meets the requirement:
 * contains
 * count
 * equals_range
 * find
 * operator[] (const only)
 * remove
 * take
 * value
 * values (QMultiHash)

The non-const operator[] may insert into the hash, so it's not part of
this commit.

Change-Id: I664b9f014ffc48cbb49bfffd17b037852f0fd192
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:06 -08:00
Thiago Macieira 52abff8cc1 QHash: add the ability to detect whether qHash(t) == qHash(K(t))
The typical examples are views and their corresponding owning
container. Since they are different types, the search is heterogeneous,
hence the name.

We have to do it differently from the Standard Library. There, because
the hasher is a template parameter to std::unordered_{map,set}, it can
be a structure with overloads for different types, all of which the
implementer guarantees produce the same hash for input that also
compares equal. For QHash/QSet, we don't have a template parameter.

One alternative solution would be to detect the existence of
qHashEquals(T1, T2) or qHashHeterogeneousEquals() or something.

Change-Id: I664b9f014ffc48cbb49bfffd17b0318c0775a2b5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:05 -08:00
Thiago Macieira 07c8cece05 QHash: merge the two equal_range() overloads
They were literally identical (as in, they used exactly the same letters
in the exact same order), but changed on whether *this was const or not.
So pass *this as a parameter so we can have just one implementation.

QMultiHash doesn't need this change because its non-const equal_range()
calls the const version after making a copy.

Change-Id: I6818d78a57394e37857bfffd17ba06aee2e7db0b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:05 -08:00
Thiago Macieira ba24125cbf QHash/QMultiHash: further simplify the key() and value() overloads
Complements commit 7fe5611365 by moving
the default value selection into a lambda that is passed to the Impl
function. This makes the two pairs of overloads in each of the classes
be a single line.

Change-Id: I6818d78a57394e37857bfffd17ba067beb3a42fa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:03 -08:00
Thiago Macieira 21dfb0ebcc QString/QByteArray: add explicit constructors for Q{String,ByteArray}View
std::string has them too, see constructor 10 in [1]. There, they are
StringViewLike, something we may want to do here too, which would also
lower the precedence of the constructor in the overload resolution.

This will be needed for the non-const heterogeneous QHash::operator[].

[ChangeLog][QtCore][QByteArray] Added a constructor to create a
QByteArray from QByteArrayView.

[ChangeLog][QtCore][QString] Added a constructor to create a QString
from QStringView.

[1] https://en.cppreference.com/w/cpp/string/basic_string/basic_string

Change-Id: I6818d78a57394e37857bfffd17b9ab03bd0253e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:03 -08:00
Thiago Macieira 025c45d628 tst_QStorageInfo: try harder to make the free space change
This merges the tempFile and caching tests, which had been updated in
commit ae03ffaffd to attempt other
filesystems than APFS and btrfs.

Instead of adding yet another item to the list (xfs), let's insist by
writing more and flushing the OS buffers. Local testing says that btrfs
usually updates after the first write(), no later than the second, and
that APFS and XFS "just works" now (without the fsync() even).

Pick-to: 6.7
Fixes: QTBUG-123151
Change-Id: I6818d78a57394e37857bfffd17bbe7427307efc4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-12 14:34:32 -07:00
Ahmad Samir d7340d5c31 tst_qfile: fix GCC 13.2.1 compiler warning [-Wenum-compare]
By using "wt" for all OS's; according to Thiago the 't' is ignored
everywhere except on Windows.

tests/auto/corelib/io/qfile/tst_qfile.cpp:2846:70: warning: comparison
between ‘enum QOperatingSystemVersionBase::OSType’ and ‘enum
QOperatingSystemVersion::OSType’ [-Wenum-compare]
2846 |     const char *openMode = QOperatingSystemVersion::current().type() != QOperatingSystemVersion::Windows
|                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Amends 3446313c7a

Pick-to: 6.7 6.6 6.5 6.2
Change-Id: I310d7d6ce3833756ffdc47b000e052ef3afdfdef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 23:28:34 +02:00
Dennis Oberst dea548ef04 qstringalgorithms: include <iterator> in favor of <string.h>
The switch from <string> to <string.h> dropped the definition of
std::size. Include <iterator> since <string.h> is no longer used to
pull in std::size.

Amends: dc2ae08e02.

Pick-to: 6.7
Change-Id: Ib742538eb5d21c77fcae7ee9abb6d5329bbcfd63
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-12 22:27:21 +01:00
Ivan Solovev 285a2a75b4 QVariant: use comparison helper macros
The relational operators were removed in
8652c79df0 with the argument that they
do not have a total order. Back than it was a valid argument, because Qt
did not support any of the C++20 ordering types.

Now Qt has its own implementation for all three ordering types, so we
could technically add relational operators and claim that QVariant
provides partial ordering.

However, that could potentially lead to many bugs and/or unexpected
results, if people start using QVariant as a key in std::map/QMap
containers.

We do not want that to happen, so we only use the helper macros to
implement (in)equality operators.

This commit also extends the unit tests, providing more extensive
testing of (in)equality operators and the pre-existing
QVariant::compare() method.

Fixes: QTBUG-113234
Change-Id: I783f3b5df552da782627f4ed0a5bb1b577753a23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 21:51:43 +01:00
Thiago Macieira 33159f5e0f QDataStream: make the public-ish private members smaller in Qt 7
pahole says:
  class QScopedPointer<QDataStreamPrivate> d;      /*     0     8 */
  class QIODevice *          dev;                  /*     8     8 */
  bool                       owndev;               /*    16     1 */
  bool                       noswap;               /*    17     1 */
  quint8                     fpPrecision;          /*    18     1 */
  quint8                     q_status;             /*    19     1 */
  enum ByteOrder             byteorder;            /*    20     4 */
  int                        ver;                  /*    24     4 */
  quint16                    transactionDepth;     /*    28     2 */
  /* size: 32, cachelines: 1, members: 10 */

Which is unnecessary overhead. The previous commit took care of
byteorder for Qt 7; this one reduces the size a bit more, to 16 bytes on
32-bit systems and 24 on 64-bit ones.

After this, pahole says for the bootstrap library:
  class QScopedPointer<QDataStreamPrivate> d;      /*     0     8 */
  class QIODevice *          dev;                  /*     8     8 */
  bool                       owndev;               /*    16     1 */
  bool                       noswap;               /*    17     1 */
  quint8                     fpPrecision;          /*    18     1 */
  quint8                     q_status;             /*    19     1 */
  enum Version               ver;                  /*    20     1 */
  /* XXX 1 byte hole, try to pack */
  quint16                    transactionDepth;     /*    22     2 */
  /* size: 24, cachelines: 1, members: 9 */

Further packing isn't possible, because of the alignment at 64-bit for
this class.

Change-Id: I50e2158aeade4256ad1dfffd17b29b80237a8c5b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-03-12 12:51:43 -08:00