diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-15 09:23:03 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-17 09:26:50 +0200 |
commit | d83c35a2e6216d2568f005c2260a06991134d8cf (patch) | |
tree | d683d245699d1ee6253f61f7b9dcb4c3b797c103 | |
parent | f69b5f260e301dc01c7d85cd1cb9d45582ef3d6d (diff) | |
download | qtdeclarative-d83c35a2e6216d2568f005c2260a06991134d8cf.tar.gz |
Move ScopedStackFrame into qv4stackframe_p.h
This is where it belongs. We need to apply some tricks to avoid
cyclic includes, but that's better than what we have so far.
Also, sort and clean up the includes in the affected files.
Change-Id: Ia7a957d06c0ca284045d831417740c3f9920bc92
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 7 | ||||
-rw-r--r-- | src/qml/jit/qv4assemblercommon_p.h | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4argumentsobject.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 30 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 31 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4jscall_p.h | 35 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4module.cpp | 9 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 20 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qmlcontext.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4referenceobject_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexpobject_p.h | 36 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 52 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stackframe_p.h | 25 | ||||
-rw-r--r-- | src/qmlworkerscript/qv4serialize.cpp | 7 |
15 files changed, 157 insertions, 130 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 6ed24f29d1..1b47d6e241 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -3,12 +3,13 @@ #include "qv4debugjob.h" -#include <private/qv4script_p.h> #include <private/qqmlcontext_p.h> -#include <private/qv4qmlcontext_p.h> -#include <private/qv4qobjectwrapper_p.h> #include <private/qqmldebugservice_p.h> #include <private/qv4jscall_p.h> +#include <private/qv4qmlcontext_p.h> +#include <private/qv4qobjectwrapper_p.h> +#include <private/qv4script_p.h> +#include <private/qv4stackframe_p.h> #include <QtQml/qqmlengine.h> diff --git a/src/qml/jit/qv4assemblercommon_p.h b/src/qml/jit/qv4assemblercommon_p.h index cccd90fab8..0c94b4bf20 100644 --- a/src/qml/jit/qv4assemblercommon_p.h +++ b/src/qml/jit/qv4assemblercommon_p.h @@ -16,12 +16,15 @@ // #include <private/qv4engine_p.h> -#include <private/qv4global_p.h> #include <private/qv4function_p.h> -#include <QHash> +#include <private/qv4global_p.h> +#include <private/qv4stackframe_p.h> + #include <wtf/Vector.h> #include <assembler/MacroAssembler.h> +#include <QtCore/qhash.h> + #if QT_CONFIG(qml_jit) QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 52731ca221..74b79cb400 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -1,14 +1,16 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include <qv4argumentsobject_p.h> -#include <qv4arrayobject_p.h> -#include <qv4scopedvalue_p.h> -#include <qv4string_p.h> -#include <qv4function_p.h> -#include <qv4jscall_p.h> -#include <qv4symbol_p.h> + +#include "qv4argumentsobject_p.h" #include <private/qv4alloca_p.h> +#include <private/qv4arrayobject_p.h> +#include <private/qv4function_p.h> +#include <private/qv4jscall_p.h> +#include <private/qv4scopedvalue_p.h> +#include <private/qv4stackframe_p.h> +#include <private/qv4string_p.h> +#include <private/qv4symbol_p.h> using namespace QV4; diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index ec1150120d..b4fe8602f1 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -14,23 +14,22 @@ // We mean it. // -#include "qv4global_p.h" -#include "qv4context_p.h" -#include "qv4stackframe_p.h" #include <private/qintrusivelist_p.h> -#include "qv4enginebase_p.h" -#include <private/qqmlrefcount_p.h> #include <private/qqmldelayedcallqueue_p.h> -#include <QtCore/qelapsedtimer.h> -#include <QtCore/qmutex.h> -#include <QtCore/qset.h> -#include <QtCore/qprocessordetection.h> - -#include "qv4function_p.h" +#include <private/qqmlrefcount_p.h> #include <private/qv4compileddata_p.h> +#include <private/qv4context_p.h> +#include <private/qv4enginebase_p.h> #include <private/qv4executablecompilationunit_p.h> +#include <private/qv4function_p.h> +#include <private/qv4global_p.h> #include <private/qv4stacklimits_p.h> +#include <QtCore/qelapsedtimer.h> +#include <QtCore/qmutex.h> +#include <QtCore/qprocessordetection.h> +#include <QtCore/qset.h> + namespace WTF { class BumpPointerAllocator; class PageAllocation; @@ -536,7 +535,14 @@ public: void setProfiler(Profiling::Profiler *profiler); #endif // QT_CONFIG(qml_debug) - ExecutionContext *currentContext() const { return currentStackFrame->context(); } + // We don't want to #include <private/qv4stackframe_p.h> here, but we still want + // currentContext() to be inline. Therefore we shift the requirement to provide the + // complete type of CppStackFrame to the caller by making this a template. + template<typename StackFrame = CppStackFrame> + ExecutionContext *currentContext() const + { + return static_cast<const StackFrame *>(currentStackFrame)->context(); + } // ensure we always get odd prototype IDs. This helps make marking in QV4::Lookup fast quintptr newProtoId() { return (protoIdCount += 2); } diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 32e93cedb4..37548ffc9f 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -2,25 +2,28 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qv4globalobject_p.h" -#include <private/qv4mm_p.h> -#include "qv4value_p.h" -#include "qv4context_p.h" -#include "qv4function_p.h" -#include "qv4script_p.h" -#include "qv4scopedvalue_p.h" -#include "qv4string_p.h" -#include <private/qv4codegen_p.h> #include <private/qv4alloca_p.h> -#include "private/qlocale_tools_p.h" -#include "private/qtools_p.h" - -#include <QtCore/QDebug> -#include <QtCore/QString> -#include <iostream> +#include <private/qv4codegen_p.h> +#include <private/qv4context_p.h> +#include <private/qv4function_p.h> +#include <private/qv4mm_p.h> +#include <private/qv4scopedvalue_p.h> +#include <private/qv4script_p.h> +#include <private/qv4stackframe_p.h> +#include <private/qv4string_p.h> +#include <private/qv4value_p.h> #include <wtf/MathExtras.h> +#include <QtCore/private/qlocale_tools_p.h> +#include <QtCore/private/qtools_p.h> + +#include <QtCore/qdebug.h> +#include <QtCore/qstring.h> + +#include <iostream> + using namespace QV4; using QtMiscUtils::toHexUpper; using QtMiscUtils::fromHex; diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h index 4126a25758..cb6e708eee 100644 --- a/src/qml/jsruntime/qv4jscall_p.h +++ b/src/qml/jsruntime/qv4jscall_p.h @@ -14,14 +14,11 @@ // We mean it. // -#include "qv4object_p.h" -#include "qv4function_p.h" -#include "qv4functionobject_p.h" -#include "qv4context_p.h" -#include "qv4scopedvalue_p.h" -#include "qv4stackframe_p.h" -#include "qv4qobjectwrapper_p.h" #include <private/qv4alloca_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qv4object_p.h> +#include <private/qv4qobjectwrapper_p.h> +#include <private/qv4scopedvalue_p.h> QT_BEGIN_NAMESPACE @@ -99,30 +96,6 @@ ReturnedValue FunctionObject::call(const JSCallData &data) const void populateJSCallArguments(ExecutionEngine *v4, JSCallArguments &jsCall, int argc, void **args, const QMetaType *types); -struct ScopedStackFrame -{ - ScopedStackFrame(const Scope &scope, ExecutionContext *context) - : engine(scope.engine) - { - if (auto currentFrame = engine->currentStackFrame) { - frame.init(currentFrame->v4Function, nullptr, context, nullptr, nullptr, 0); - frame.instructionPointer = currentFrame->instructionPointer; - } else { - frame.init(nullptr, nullptr, context, nullptr, nullptr, 0); - } - frame.push(engine); - } - - ~ScopedStackFrame() - { - frame.pop(engine); - } - -private: - ExecutionEngine *engine = nullptr; - MetaTypesStackFrame frame; -}; - template<typename Callable> ReturnedValue convertAndCall( ExecutionEngine *engine, const QQmlPrivate::TypedFunction *aotFunction, diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index ff6b349ad9..4d4036d826 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -1,10 +1,12 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include "qv4lookup_p.h" -#include "qv4functionobject_p.h" + +#include <private/qv4functionobject_p.h> #include <private/qv4identifiertable_p.h> -#include <QtQml/private/qv4runtime_p.h> -#include <QtQml/private/qv4qobjectwrapper_p.h> +#include <private/qv4lookup_p.h> +#include <private/qv4qobjectwrapper_p.h> +#include <private/qv4runtime_p.h> +#include <private/qv4stackframe_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4module.cpp b/src/qml/jsruntime/qv4module.cpp index 1e1a059dfa..1a289f25b8 100644 --- a/src/qml/jsruntime/qv4module.cpp +++ b/src/qml/jsruntime/qv4module.cpp @@ -4,13 +4,14 @@ #include "qv4module_p.h" -#include <private/qv4mm_p.h> -#include <private/qv4vme_moth_p.h> #include <private/qv4context_p.h> -#include <private/qv4symbol_p.h> #include <private/qv4identifiertable_p.h> +#include <private/qv4mm_p.h> +#include <private/qv4stackframe_p.h> +#include <private/qv4symbol_p.h> +#include <private/qv4vme_moth_p.h> -#include <QScopeGuard> +#include <QtCore/qscopeguard.h> using namespace QV4; diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index b3b907352b..6475ec6e06 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -2,16 +2,18 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qv4object_p.h" -#include "qv4stringobject_p.h" -#include "qv4argumentsobject_p.h" + +#include <private/qv4argumentsobject_p.h> +#include <private/qv4identifiertable_p.h> +#include <private/qv4jscall_p.h> +#include <private/qv4lookup_p.h> +#include <private/qv4memberdata_p.h> #include <private/qv4mm_p.h> -#include "qv4lookup_p.h" -#include "qv4scopedvalue_p.h" -#include "qv4memberdata_p.h" -#include "qv4identifiertable_p.h" -#include "qv4jscall_p.h" -#include "qv4symbol_p.h" -#include "qv4proxy_p.h" +#include <private/qv4proxy_p.h> +#include <private/qv4scopedvalue_p.h> +#include <private/qv4stackframe_p.h> +#include <private/qv4stringobject_p.h> +#include <private/qv4symbol_p.h> #include <QtCore/qloggingcategory.h> diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index e585adfa5b..d9d0fe09bf 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -19,6 +19,7 @@ #include <private/qv4module_p.h> #include <private/qv4objectproto_p.h> #include <private/qv4qobjectwrapper_p.h> +#include <private/qv4stackframe_p.h> #include <private/qv4value_p.h> #include <QtCore/qloggingcategory.h> diff --git a/src/qml/jsruntime/qv4referenceobject_p.h b/src/qml/jsruntime/qv4referenceobject_p.h index 5378a0c362..094749ce6e 100644 --- a/src/qml/jsruntime/qv4referenceobject_p.h +++ b/src/qml/jsruntime/qv4referenceobject_p.h @@ -16,6 +16,7 @@ // #include <private/qv4object_p.h> +#include <private/qv4stackframe_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 10702c48bd..31e13f5984 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -14,17 +14,13 @@ // We mean it. // -#include "qv4engine_p.h" -#include "qv4context_p.h" -#include "qv4functionobject_p.h" -#include "qv4managed_p.h" -#include "qv4regexp_p.h" - -#include <QtCore/QString> -#include <QtCore/QHash> -#include <QtCore/QScopedPointer> -#include <cstdio> -#include <cassert> +#include <private/qv4context_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4functionobject_p.h> +#include <private/qv4managed_p.h> + +#include <QtCore/qhash.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -110,11 +106,19 @@ struct Q_QML_PRIVATE_EXPORT RegExpObject: Object { return s->toQString(); } - Heap::RegExp *value() const { return d()->value; } - uint flags() const { return d()->value->flags; } - bool global() const { return d()->value->global(); } - bool sticky() const { return d()->value->sticky(); } - bool unicode() const { return d()->value->unicode(); } + // We cannot name Heap::RegExp here since we don't want to include qv4regexp_p.h but we still + // want to keep the methods inline. We shift the requirement to name the type to the caller by + // making it a template. + template<typename RegExp = Heap::RegExp> + RegExp *value() const { return d()->value; } + template<typename RegExp = Heap::RegExp> + uint flags() const { return value<RegExp>()->flags; } + template<typename RegExp = Heap::RegExp> + bool global() const { return value<RegExp>()->global(); } + template<typename RegExp = Heap::RegExp> + bool sticky() const { return value<RegExp>()->sticky(); } + template<typename RegExp = Heap::RegExp> + bool unicode() const { return value<RegExp>()->unicode(); } ReturnedValue builtinExec(ExecutionEngine *engine, const String *s); }; diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index c7ee35b810..500d1ae0ba 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1,42 +1,44 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include "qv4global_p.h" #include "qv4runtime_p.h" -#include "qv4engine_p.h" -#include "qv4object_p.h" -#include "qv4globalobject_p.h" -#include "qv4argumentsobject_p.h" -#include "qv4lookup_p.h" -#include "qv4function_p.h" -#include "qv4regexp_p.h" -#include "qv4regexpobject_p.h" -#include "private/qlocale_tools_p.h" -#include "qv4scopedvalue_p.h" -#include "qv4jscall_p.h" -#include <private/qv4qmlcontext_p.h> -#include <private/qqmltypewrapper_p.h> + #include <private/qqmlengine_p.h> #include <private/qqmljavascriptexpression_p.h> #include <private/qqmljsast_p.h> +#include <private/qqmltypewrapper_p.h> #include <private/qqmlvaluetypewrapper_p.h> -#include "qv4qobjectwrapper_p.h" -#include "qv4symbol_p.h" -#include "qv4generatorobject_p.h" -#include <QtQml/private/qv4math_p.h> - -#include <QtCore/QDebug> -#include <cassert> -#include <cstdio> -#include <stdlib.h> +#include <private/qv4argumentsobject_p.h> +#include <private/qv4engine_p.h> +#include <private/qv4function_p.h> +#include <private/qv4generatorobject_p.h> +#include <private/qv4global_p.h> +#include <private/qv4globalobject_p.h> +#include <private/qv4jscall_p.h> +#include <private/qv4lookup_p.h> +#include <private/qv4math_p.h> +#include <private/qv4object_p.h> +#include <private/qv4qmlcontext_p.h> +#include <private/qv4qobjectwrapper_p.h> +#include <private/qv4regexp_p.h> +#include <private/qv4regexpobject_p.h> +#include <private/qv4scopedvalue_p.h> +#include <private/qv4stackframe_p.h> +#include <private/qv4symbol_p.h> #include <wtf/MathExtras.h> +#include <QtCore/private/qlocale_tools_p.h> +#include <QtCore/qdebug.h> + #ifdef QV4_COUNT_RUNTIME_FUNCTIONS -# include <QtCore/QBuffer> -# include <QtCore/QDebug> +# include <QtCore/qbuffer.h> #endif // QV4_COUNT_RUNTIME_FUNCTIONS +#include <cassert> +#include <cstdio> +#include <stdlib.h> + QT_BEGIN_NAMESPACE namespace QV4 { diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 9c3e3700ce..3effd3c236 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -14,6 +14,7 @@ // We mean it. // +#include <private/qv4scopedvalue_p.h> #include <private/qv4context_p.h> #include <private/qv4enginebase_p.h> #include <private/qv4calldata_p.h> @@ -287,6 +288,30 @@ inline ExecutionContext *CppStackFrame::context() const return static_cast<const MetaTypesStackFrame *>(this)->context(); } +struct ScopedStackFrame +{ + ScopedStackFrame(const Scope &scope, ExecutionContext *context) + : engine(scope.engine) + { + if (auto currentFrame = engine->currentStackFrame) { + frame.init(currentFrame->v4Function, nullptr, context, nullptr, nullptr, 0); + frame.instructionPointer = currentFrame->instructionPointer; + } else { + frame.init(nullptr, nullptr, context, nullptr, nullptr, 0); + } + frame.push(engine); + } + + ~ScopedStackFrame() + { + frame.pop(engine); + } + +private: + ExecutionEngine *engine = nullptr; + MetaTypesStackFrame frame; +}; + Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(JSTypesStackFrame)); Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(MetaTypesStackFrame)); Q_STATIC_ASSERT(std::is_standard_layout_v<CppStackFrame>); diff --git a/src/qmlworkerscript/qv4serialize.cpp b/src/qmlworkerscript/qv4serialize.cpp index 06f7828b4c..cacaf1b0dd 100644 --- a/src/qmlworkerscript/qv4serialize.cpp +++ b/src/qmlworkerscript/qv4serialize.cpp @@ -3,12 +3,13 @@ #include "qv4serialize_p.h" -#include <private/qv4value_p.h> #include <private/qv4dateobject_p.h> -#include <private/qv4regexpobject_p.h> -#include <private/qv4sequenceobject_p.h> #include <private/qv4objectproto_p.h> #include <private/qv4qobjectwrapper_p.h> +#include <private/qv4regexp_p.h> +#include <private/qv4regexpobject_p.h> +#include <private/qv4sequenceobject_p.h> +#include <private/qv4value_p.h> QT_BEGIN_NAMESPACE |