Merge remote-tracking branch 'origin/5.15' into dev

Change-Id: Iab9b3a7d004a2e4b4de816f4a2d7ed2fb936d3ae
This commit is contained in:
Qt Forward Merge Bot 2019-10-10 01:01:26 +02:00
commit 8b91c68315
26 changed files with 204 additions and 33 deletions

View File

@ -132,6 +132,23 @@ attribute_target("rdrnd") int test_rdrnd()
}
#endif
#if T(RDSEED)
attribute_target("rdseed") int test_rdseed()
{
unsigned short us;
unsigned int ui;
if (_rdseed16_step(&us))
return 1;
if (_rdseed32_step(&ui))
return 1;
# if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
unsigned long long ull;
if (_rdseed64_step(&ull))
return 1;
# endif
}
#endif
#if T(SHANI)
attribute_target("sha") void test_shani()
{

View File

@ -527,6 +527,10 @@
"label": "RDRAND instruction",
"type": "x86Simd"
},
"rdseed": {
"label": "RDSEED instruction",
"type": "x86Simd"
},
"shani": {
"label": "SHA new instructions",
"type": "x86Simd"
@ -1181,6 +1185,14 @@
{ "type": "define", "name": "QT_COMPILER_SUPPORTS_RDRND", "value": 1 }
]
},
"rdseed": {
"label": "RDSEED",
"condition": "tests.rdseed",
"output": [
"privateConfig",
{ "type": "define", "name": "QT_COMPILER_SUPPORTS_RDSEED", "value": 1 }
]
},
"shani": {
"label": "SHA",
"condition": "features.sse2 && tests.shani",

View File

@ -93,6 +93,7 @@ QMAKE_CFLAGS_SSE4_1 += -msse4.1
QMAKE_CFLAGS_SSE4_2 += -msse4.2
QMAKE_CFLAGS_F16C += -mf16c
QMAKE_CFLAGS_RDRND += -mrdrnd
QMAKE_CFLAGS_RDSEED += -mrdseed
QMAKE_CFLAGS_AVX += -mavx
QMAKE_CFLAGS_AVX2 += -mavx2
QMAKE_CFLAGS_AVX512F += -mavx512f

View File

@ -51,6 +51,7 @@ QMAKE_CFLAGS_AVX512VL += -march=skylake-avx512
QMAKE_CFLAGS_AESNI += -maes
QMAKE_CFLAGS_F16C += $$QMAKE_CFLAGS_AVX2
QMAKE_CFLAGS_RDRND += -mrdrnd
QMAKE_CFLAGS_RDSEED += -mrdseed
QMAKE_CFLAGS_SHANI += -msha
QMAKE_CXX = icpc

View File

@ -50,6 +50,7 @@ greaterThan(QMAKE_MSC_VER, 1799) {
QMAKE_CFLAGS_F16C = -arch:AVX
QMAKE_CFLAGS_RDRND =
QMAKE_CFLAGS_RDSEED =
equals(QMAKE_MSC_VER, 1800) {
QMAKE_CFLAGS_RELEASE += -Zc:strictStrings

View File

@ -137,6 +137,7 @@ addSimdCompiler(avx512ifma)
addSimdCompiler(avx512vbmi)
addSimdCompiler(f16c)
addSimdCompiler(rdrnd)
addSimdCompiler(rdseed)
addSimdCompiler(neon)
addSimdCompiler(mips_dsp)
addSimdCompiler(mips_dspr2)

View File

@ -15,6 +15,7 @@ QMAKE_CFLAGS_AVX = -mavx
QMAKE_CFLAGS_AVX2 = -mavx2
QMAKE_CFLAGS_F16C = -mf16c
QMAKE_CFLAGS_RDRND = -mrdrnd
QMAKE_CFLAGS_RDSEED = -mrdseed
QMAKE_CFLAGS_AVX512F = -mavx512f
QMAKE_CFLAGS_AVX512ER = -mavx512er
QMAKE_CFLAGS_AVX512CD = -mavx512cd

View File

@ -103,10 +103,13 @@ typedef QList<QByteArray>::ConstIterator ByteArrayListConstIt;
Q_GLOBAL_STATIC(QRecursiveMutex, textCodecsMutex);
class TextCodecsMutexLocker {
class TextCodecsMutexLocker
{
using Lock = decltype(qt_unique_lock(std::declval<QRecursiveMutex&>()));
// ### FIXME: this is used when textCodecsMutex already == nullptr
const Lock lock = qt_unique_lock(textCodecsMutex());
public:
TextCodecsMutexLocker() {} // required d/t an ICC 19 bug
};
#if !QT_CONFIG(icu)

View File

@ -54,22 +54,6 @@
#include "qlocale_p.h"
#include "qstring.h"
#if !defined(QT_QLOCALE_NEEDS_VOLATILE)
# if defined(Q_CC_GNU)
# if __GNUC__ == 4
# define QT_QLOCALE_NEEDS_VOLATILE
# elif defined(Q_OS_WIN)
# define QT_QLOCALE_NEEDS_VOLATILE
# endif
# endif
#endif
#if defined(QT_QLOCALE_NEEDS_VOLATILE)
# define NEEDS_VOLATILE volatile
#else
# define NEEDS_VOLATILE
#endif
QT_BEGIN_NAMESPACE
enum StrayCharacterMode {

View File

@ -626,8 +626,40 @@ void qDumpCPUFeatures()
# ifdef Q_PROCESSOR_X86_64
# define _rdrandXX_step _rdrand64_step
# define _rdseedXX_step _rdseed64_step
# else
# define _rdrandXX_step _rdrand32_step
# define _rdseedXX_step _rdseed32_step
# endif
# if QT_COMPILER_SUPPORTS_HERE(RDSEED)
static QT_FUNCTION_TARGET(RDSEED) unsigned *qt_random_rdseed(unsigned *ptr, unsigned *end) noexcept
{
// Unlike for the RDRAND code below, the Intel whitepaper describing the
// use of the RDSEED instruction indicates we should not retry in a loop.
// If the independent bit generator used by RDSEED is out of entropy, it
// may take time to replenish.
// https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) {
if (_rdseedXX_step(reinterpret_cast<qregisteruint *>(ptr)) == 0)
goto out;
ptr += sizeof(qregisteruint)/sizeof(*ptr);
}
if (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) {
if (_rdseed32_step(ptr) == 0)
goto out;
++ptr;
}
out:
return ptr;
}
# else
static unsigned *qt_random_rdseed(unsigned *ptr, unsigned *)
{
return ptr;
}
# endif
QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) noexcept
@ -636,6 +668,9 @@ QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) no
unsigned *end = ptr + count;
int retries = 10;
if (qCpuHasFeature(RDSEED))
ptr = qt_random_rdseed(ptr, end);
while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) {
if (_rdrandXX_step(reinterpret_cast<qregisteruint *>(ptr)))
ptr += sizeof(qregisteruint)/sizeof(*ptr);
@ -657,5 +692,4 @@ out:
}
#endif
QT_END_NAMESPACE

View File

@ -338,7 +338,16 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
}
}
if (!d_ptr->context->makeCurrent(window)) {
bool current = d_ptr->context->makeCurrent(window);
if (!current && !d_ptr->context->isValid()) {
delete d_ptr->blitter;
d_ptr->blitter = nullptr;
d_ptr->textureId = 0;
current = d_ptr->context->create() && d_ptr->context->makeCurrent(window);
}
if (!current) {
qCWarning(lcQpaBackingStore, "composeAndFlush: makeCurrent() failed");
return;
}

View File

@ -1705,6 +1705,10 @@ QRhi::FrameOpResult QRhiVulkan::endFrame(QRhiSwapChain *swapChain, QRhi::EndFram
presInfo.waitSemaphoreCount = 1;
presInfo.pWaitSemaphores = &frame.drawSem; // gfxQueueFamilyIdx == presQueueFamilyIdx ? &frame.drawSem : &frame.presTransSem;
// Do platform-specific WM notification. F.ex. essential on Wayland in
// order to circumvent driver frame callbacks
inst->presentAboutToBeQueued(swapChainD->window);
VkResult err = vkQueuePresentKHR(gfxQueue, &presInfo);
if (err != VK_SUCCESS) {
if (err == VK_ERROR_OUT_OF_DATE_KHR) {

View File

@ -3176,8 +3176,7 @@ QDebug operator<<(QDebug stream, const QFont &font)
QDebug debug(&fontDescription);
debug.nospace();
QFontPrivate priv;
const QFont defaultFont(&priv);
const QFont defaultFont(new QFontPrivate);
for (int property = QFont::FamilyResolved; property < QFont::AllPropertiesResolved; property <<= 1) {
const bool resolved = (font.resolve_mask & property) != 0;

View File

@ -2684,7 +2684,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
QtFontDesc desc;
QList<int> blackListed;
int index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed);
if (index < 0 && QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamilyAliases()) {
if (index < 0 && QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFamilyAliases(family_name)) {
// We populated familiy aliases (e.g. localized families), so try again
index = match(multi ? QChar::Script_Common : script, request, family_name, foundry_name, &desc, blackListed);
}

View File

@ -104,7 +104,7 @@ class Q_GUI_EXPORT QPlatformFontDatabase
public:
virtual ~QPlatformFontDatabase();
virtual void populateFontDatabase();
virtual bool populateFamilyAliases() { return false; }
virtual bool populateFamilyAliases(const QString &missingFamily) { Q_UNUSED(missingFamily); return false; }
virtual void populateFamily(const QString &familyName);
virtual void invalidate();

View File

@ -80,6 +80,11 @@ QPlatformVulkanInstance::~QPlatformVulkanInstance()
{
}
void QPlatformVulkanInstance::presentAboutToBeQueued(QWindow *window)
{
Q_UNUSED(window);
}
void QPlatformVulkanInstance::presentQueued(QWindow *window)
{
Q_UNUSED(window);

View File

@ -77,6 +77,7 @@ public:
virtual QByteArrayList enabledExtensions() const = 0;
virtual PFN_vkVoidFunction getInstanceProcAddr(const char *name) = 0;
virtual bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) = 0;
virtual void presentAboutToBeQueued(QWindow *window);
virtual void presentQueued(QWindow *window);
virtual void setDebugFilters(const QVector<QVulkanInstance::DebugFilter> &filters);

View File

@ -774,6 +774,20 @@ bool QVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, uint32_t
return d_ptr->platformInst->supportsPresent(physicalDevice, queueFamilyIndex, window);
}
/*!
This function should be called by the application's renderer before queuing
a present operation for \a window.
While on some platforms this will be a no-op, some may perform windowing
system dependent synchronization. For example, on Wayland this will
add send a wl_surface.frame request in order to prevent the driver from
blocking for minimized windows.
*/
void QVulkanInstance::presentAboutToBeQueued(QWindow *window)
{
d_ptr->platformInst->presentAboutToBeQueued(window);
}
/*!
This function should be called by the application's renderer after queuing
a present operation for \a window.

View File

@ -186,6 +186,7 @@ public:
bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window);
void presentAboutToBeQueued(QWindow *window);
void presentQueued(QWindow *window);
typedef bool (*DebugFilter)(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object,

View File

@ -2018,6 +2018,10 @@ void QVulkanWindowPrivate::endFrame()
presInfo.waitSemaphoreCount = 1;
presInfo.pWaitSemaphores = gfxQueueFamilyIdx == presQueueFamilyIdx ? &frame.drawSem : &frame.presTransSem;
// Do platform-specific WM notification. F.ex. essential on Wayland in
// order to circumvent driver frame callbacks
inst->presentAboutToBeQueued(q);
err = vkQueuePresentKHR(gfxQueue, &presInfo);
if (err != VK_SUCCESS) {
if (err == VK_ERROR_OUT_OF_DATE_KHR) {

View File

@ -48,6 +48,8 @@
#import <UIKit/UIFont.h>
#endif
#include <QtCore/qelapsedtimer.h>
#include "qcoretextfontdatabase_p.h"
#include "qfontengine_coretext_p.h"
#if QT_CONFIG(settings)
@ -113,39 +115,77 @@ QCoreTextFontDatabase::~QCoreTextFontDatabase()
void QCoreTextFontDatabase::populateFontDatabase()
{
qCDebug(lcQpaFonts) << "Populating font database...";
QElapsedTimer elapsed;
if (lcQpaFonts().isDebugEnabled())
elapsed.start();
QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames();
for (NSString *familyName in familyNames.as<const NSArray *>())
QPlatformFontDatabase::registerFontFamily(QString::fromNSString(familyName));
qCDebug(lcQpaFonts) << "Populating available families took" << elapsed.restart() << "ms";
// Force creating the theme fonts to get the descriptors in m_systemFontDescriptors
if (m_themeFonts.isEmpty())
(void)themeFonts();
qCDebug(lcQpaFonts) << "Resolving theme fonts took" << elapsed.restart() << "ms";
Q_FOREACH (CTFontDescriptorRef fontDesc, m_systemFontDescriptors)
populateFromDescriptor(fontDesc);
qCDebug(lcQpaFonts) << "Populating system descriptors took" << elapsed.restart() << "ms";
Q_ASSERT(!m_hasPopulatedAliases);
}
bool QCoreTextFontDatabase::populateFamilyAliases()
bool QCoreTextFontDatabase::populateFamilyAliases(const QString &missingFamily)
{
#if defined(Q_OS_MACOS)
if (m_hasPopulatedAliases)
return false;
// There's no API to go from a localized family name to its non-localized
// name, so we have to resort to enumerating all the available fonts and
// doing a reverse lookup.
qCDebug(lcQpaFonts) << "Populating family aliases...";
QElapsedTimer elapsed;
elapsed.start();
QString nonLocalizedMatch;
QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames();
NSFontManager *fontManager = NSFontManager.sharedFontManager;
for (NSString *familyName in familyNames.as<const NSArray *>()) {
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSString *localizedFamilyName = [fontManager localizedNameForFamily:familyName face:nil];
if (![localizedFamilyName isEqual:familyName]) {
QPlatformFontDatabase::registerAliasToFontFamily(
QString::fromNSString(familyName),
QString::fromNSString(localizedFamilyName));
QString nonLocalizedFamily = QString::fromNSString(familyName);
QString localizedFamily = QString::fromNSString(localizedFamilyName);
QPlatformFontDatabase::registerAliasToFontFamily(nonLocalizedFamily, localizedFamily);
if (localizedFamily == missingFamily)
nonLocalizedMatch = nonLocalizedFamily;
}
}
m_hasPopulatedAliases = true;
if (lcQpaFonts().isWarningEnabled()) {
QString warningMessage;
QDebug msg(&warningMessage);
msg << "Populating font family aliases took" << elapsed.restart() << "ms.";
if (!nonLocalizedMatch.isNull())
msg << "Replace uses of" << missingFamily << "with its non-localized name" << nonLocalizedMatch;
else
msg << "Replace uses of missing font family" << missingFamily << "with one that exists";
msg << "to avoid this cost.";
qCWarning(lcQpaFonts) << qPrintable(warningMessage);
}
return true;
#else
Q_UNUSED(missingFamily);
return false;
#endif
}

View File

@ -71,7 +71,7 @@ public:
QCoreTextFontDatabase();
~QCoreTextFontDatabase();
void populateFontDatabase() override;
bool populateFamilyAliases() override;
bool populateFamilyAliases(const QString &missingFamily) override;
void populateFamily(const QString &familyName) override;
void invalidate() override;

View File

@ -214,7 +214,7 @@ static QString strippedText(QString s)
NSString *filepath = info.filePath().toNSString();
NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()];
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldEnableURL:url];
|| [self panel:mOpenPanel shouldEnableURL:url];
[self updateProperties];
[mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
@ -233,7 +233,7 @@ static QString strippedText(QString s)
NSString *filepath = info.filePath().toNSString();
NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()];
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldEnableURL:url];
|| [self panel:mSavePanel shouldEnableURL:url];
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];
[mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""];
@ -263,7 +263,7 @@ static QString strippedText(QString s)
NSString *filepath = info.filePath().toNSString();
NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()];
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|| [self panel:nil shouldEnableURL:url];
|| [self panel:mSavePanel shouldEnableURL:url];
[self updateProperties];
[mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]];

View File

@ -3462,6 +3462,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
{
Q_D(const QMacStyle);
const AppearanceSync sync;
const QMacAutoReleasePool pool;
QMacCGContext cg(p);
QWindow *window = w && w->window() ? w->window()->windowHandle() : nullptr;
d->resolveCurrentNSView(window);
@ -4326,7 +4327,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
break;
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
QMacAutoReleasePool pool;
const bool isIndeterminate = (pb->minimum == 0 && pb->maximum == 0);
const bool vertical = pb->orientation == Qt::Vertical;
const bool inverted = pb->invertedAppearance;

View File

@ -0,0 +1,3 @@
QT += widgets
SOURCES += main.cpp
LIBS += -fsanitize=fuzzer

View File

@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QTextLayout>
extern "C" int LLVMFuzzerTestOneInput(const char *Data, size_t Size) {
QTextLayout tl(QByteArray::fromRawData(Data, Size));
tl.beginLayout();
tl.endLayout();
return 0;
}