diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-10-17 13:02:17 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-07 07:24:09 +0000 |
commit | 1c3e1df2536712c7c2aef4ec5f68316a7e32e4ff (patch) | |
tree | 503616ae443ed0e4386e92d67f94454efcc69fab /src/qml/debugger | |
parent | 573ad68f8295e5b8e578bb6bad9d1ca932cccaf6 (diff) |
Move a couple of data members required for new JIT
Mark CompilationUnit final and get rid of it's vtable.
Fix initializations with 0 instead of nullptr.
Change-Id: Ieec260bd45d8f08cf5d8964becd312b221cbb2a9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/debugger')
-rw-r--r-- | src/qml/debugger/qqmlprofiler_p.h | 157 |
1 files changed, 104 insertions, 53 deletions
diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h index 88f8e94f25..9b51b5ab46 100644 --- a/src/qml/debugger/qqmlprofiler_p.h +++ b/src/qml/debugger/qqmlprofiler_p.h @@ -149,74 +149,120 @@ class Q_QML_PRIVATE_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDef Q_OBJECT public: - class FunctionRefCount : public QQmlRefCount { - public: - FunctionRefCount(QV4::Function *function): - m_function(function) + struct Location { + Location(const QQmlSourceLocation &location = QQmlSourceLocation(), + const QUrl &url = QUrl()) : + location(location), url(url) {} + QQmlSourceLocation location; + QUrl url; + }; + + // Unfortunately we have to resolve the locations right away because the QML context might not + // be available anymore when we send the data. + struct RefLocation : public Location { + RefLocation() + : Location(), locationType(MaximumRangeType), sent(false) { - m_function->compilationUnit->addref(); + function = nullptr; } - FunctionRefCount(const FunctionRefCount &other) : - QQmlRefCount(other), m_function(other.m_function) + RefLocation(QV4::Function *ref) + : Location(ref->sourceLocation()), locationType(Binding), sent(false) { - m_function->compilationUnit->addref(); + function = ref; + function->compilationUnit->addref(); } - FunctionRefCount &operator=(const FunctionRefCount &other) + RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj, const QString &type) + : Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url), + locationType(Creating), sent(false) + { + unit = ref; + unit->addref(); + } + + RefLocation(QQmlBoundSignalExpression *ref) + : Location(ref->sourceLocation()), locationType(HandlingSignal), sent(false) + { + boundSignal = ref; + boundSignal->addref(); + } + + RefLocation(QQmlDataBlob *ref) + : Location(QQmlSourceLocation()), locationType(Compiling), sent(false) + { + blob = ref; + blob->addref(); + } + + RefLocation(const RefLocation &other) + : Location(other), + locationType(other.locationType), + function(other.function), + sent(other.sent) + { + addref(); + } + + RefLocation &operator=(const RefLocation &other) { if (this != &other) { - QQmlRefCount::operator=(other); - other.m_function->compilationUnit->addref(); - m_function->compilationUnit->release(); - m_function = other.m_function; + release(); + Location::operator=(other); + locationType = other.locationType; + function = other.function; + sent = other.sent; + addref(); } return *this; } - ~FunctionRefCount() + ~RefLocation() { - m_function->compilationUnit->release(); + release(); } - private: - QV4::Function *m_function; - }; - - struct Location { - Location(const QQmlSourceLocation &location = QQmlSourceLocation(), - const QUrl &url = QUrl()) : - location(location), url(url) {} - QQmlSourceLocation location; - QUrl url; - }; + void addref() + { + switch (locationType) { + case Binding: + function->compilationUnit->addref(); + break; + case Creating: + unit->addref(); + break; + case HandlingSignal: + boundSignal->addref(); + break; + case Compiling: + blob->addref(); + break; + default: + Q_ASSERT(locationType == MaximumRangeType); + break; + } + } - // Unfortunately we have to resolve the locations right away because the QML context might not - // be available anymore when we send the data. - struct RefLocation : public Location { - RefLocation() : Location(), locationType(MaximumRangeType), ref(nullptr), sent(false) - {} - - RefLocation(QV4::Function *function) : - Location(function->sourceLocation()), locationType(Binding), - ref(new FunctionRefCount(function), - QQmlRefPointer<QQmlRefCount>::Adopt), sent(false) - {} - - RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj, - const QString &type) : - Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url), - locationType(Creating), ref(ref), sent(false) - {} - - RefLocation(QQmlBoundSignalExpression *ref) : - Location(ref->sourceLocation()), locationType(HandlingSignal), ref(ref), sent(false) - {} - - RefLocation(QQmlDataBlob *ref) : - Location(QQmlSourceLocation(), ref->url()), locationType(Compiling), ref(ref), - sent(false) - {} + void release() + { + switch (locationType) { + case Binding: + function->compilationUnit->release(); + break; + case Creating: + unit->release(); + break; + case HandlingSignal: + boundSignal->release(); + break; + case Compiling: + blob->release(); + break; + default: + Q_ASSERT(locationType == MaximumRangeType); + break; + } + } bool isValid() const { @@ -224,7 +270,12 @@ public: } RangeType locationType; - QQmlRefPointer<QQmlRefCount> ref; + union { + QV4::Function *function; + QV4::CompiledData::CompilationUnit *unit; + QQmlBoundSignalExpression *boundSignal; + QQmlDataBlob *blob; + }; bool sent; }; |