diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-07-25 17:02:45 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-07-28 15:09:33 +0000 |
commit | a7c7b26653c76e6c699a7f4e81f7ffec60dde0be (patch) | |
tree | ec36313bc3c204a83391c310915018ede65293f7 | |
parent | ddde056393b13db4bab7cf3fddf2a0aeb1fdb6e7 (diff) |
V4: Make ExecutionEngine's debugger and profiler private
This will allow us to #define them away on -no-qml-debug, saving two
pointers per engine.
Change-Id: I400cffd32cd7f55ff0e68565734b6002b9f901d5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 9 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4profiling_p.h | 18 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp | 4 |
11 files changed, 48 insertions, 45 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index d54bf98068..5b96163b48 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -761,7 +761,7 @@ void QQmlNativeDebugServiceImpl::stateAboutToBeChanged(QQmlDebugService::State s if (state == Enabled) { foreach (NativeDebugger *debugger, m_debuggers) { QV4::ExecutionEngine *engine = debugger->engine(); - if (!engine->debugger) + if (!engine->debugger()) engine->setDebugger(debugger); } } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index c87ca47c49..00c5c1ad77 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -706,7 +706,7 @@ void QV4DebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine) if (engine){ const QV4::ExecutionEngine *ee = QV8Engine::getV4(engine->handle()); if (ee) { - QV4Debugger *debugger = qobject_cast<QV4Debugger *>(ee->debugger); + QV4Debugger *debugger = qobject_cast<QV4Debugger *>(ee->debugger()); if (debugger) debuggerAgent.removeDebugger(debugger); } @@ -720,7 +720,7 @@ void QV4DebugServiceImpl::stateAboutToBeChanged(State state) if (state == Enabled) { foreach (QV4Debugger *debugger, debuggerAgent.debuggers()) { QV4::ExecutionEngine *ee = debugger->engine(); - if (!ee->debugger) + if (!ee->debugger()) ee->setDebugger(debugger); } } diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp index c88cf559f7..eee1dd7eae 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.cpp @@ -52,19 +52,19 @@ QV4ProfilerAdapter::QV4ProfilerAdapter(QQmlProfilerService *service, QV4::Execut connect(this, &QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting, this, &QV4ProfilerAdapter::forwardEnabledWhileWaiting, Qt::DirectConnection); connect(this, &QV4ProfilerAdapter::v4ProfilingEnabled, - engine->profiler, &QV4::Profiling::Profiler::startProfiling); + engine->profiler(), &QV4::Profiling::Profiler::startProfiling); connect(this, &QV4ProfilerAdapter::v4ProfilingEnabledWhileWaiting, - engine->profiler, &QV4::Profiling::Profiler::startProfiling, Qt::DirectConnection); + engine->profiler(), &QV4::Profiling::Profiler::startProfiling, Qt::DirectConnection); connect(this, &QQmlAbstractProfilerAdapter::profilingDisabled, - engine->profiler, &QV4::Profiling::Profiler::stopProfiling); + engine->profiler(), &QV4::Profiling::Profiler::stopProfiling); connect(this, &QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting, - engine->profiler, &QV4::Profiling::Profiler::stopProfiling, + engine->profiler(), &QV4::Profiling::Profiler::stopProfiling, Qt::DirectConnection); connect(this, &QQmlAbstractProfilerAdapter::dataRequested, - engine->profiler, &QV4::Profiling::Profiler::reportData); + engine->profiler(), &QV4::Profiling::Profiler::reportData); connect(this, &QQmlAbstractProfilerAdapter::referenceTimeKnown, - engine->profiler, &QV4::Profiling::Profiler::setTimer); - connect(engine->profiler, &QV4::Profiling::Profiler::dataReady, + engine->profiler(), &QV4::Profiling::Profiler::setTimer); + connect(engine->profiler(), &QV4::Profiling::Profiler::dataReady, this, &QV4ProfilerAdapter::receiveData); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index bff0df58cf..785094b96a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -136,8 +136,6 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) , currentContext(0) , bumperPointerAllocator(new WTF::BumpPointerAllocator) , jsStack(new WTF::PageAllocation) - , debugger(0) - , profiler(0) , globalCode(0) , v8Engine(0) , argumentsAccessors(0) @@ -145,6 +143,8 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) , m_engineId(engineSerial.fetchAndAddOrdered(1)) , regExpCache(0) , m_multiplyWrappedQObjects(0) + , m_debugger(0) + , m_profiler(0) { if (maxCallDepth == -1) { bool ok = false; @@ -442,10 +442,10 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) ExecutionEngine::~ExecutionEngine() { - delete debugger; - debugger = 0; - delete profiler; - profiler = 0; + delete m_debugger; + m_debugger = 0; + delete m_profiler; + m_profiler = 0; delete m_multiplyWrappedQObjects; m_multiplyWrappedQObjects = 0; delete identifierTable; @@ -467,16 +467,16 @@ ExecutionEngine::~ExecutionEngine() delete [] argumentsAccessors; } -void ExecutionEngine::setDebugger(Debugging::Debugger *debugger_) +void ExecutionEngine::setDebugger(Debugging::Debugger *debugger) { - Q_ASSERT(!debugger); - debugger = debugger_; + Q_ASSERT(!m_debugger); + m_debugger = debugger; } -void ExecutionEngine::setProfiler(Profiling::Profiler *profiler_) +void ExecutionEngine::setProfiler(Profiling::Profiler *profiler) { - Q_ASSERT(!profiler); - profiler = profiler_; + Q_ASSERT(!m_profiler); + m_profiler = profiler; } void ExecutionEngine::initRootContext() @@ -910,8 +910,8 @@ ReturnedValue ExecutionEngine::throwError(const Value &value) else exceptionStackTrace = stackTrace(); - if (debugger) - debugger->aboutToThrow(); + if (QV4::Debugging::Debugger *debug = debugger()) + debug->aboutToThrow(); return Encode::undefined(); } diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 208598efd5..7c8c881255 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -137,9 +137,6 @@ public: IdentifierTable *identifierTable; - QV4::Debugging::Debugger *debugger; - QV4::Profiling::Profiler *profiler; - Object *globalObject; Function *globalCode; @@ -382,6 +379,9 @@ public: ExecutionEngine(EvalISelFactory *iselFactory = 0); ~ExecutionEngine(); + QV4::Debugging::Debugger *debugger() const { return m_debugger; } + QV4::Profiling::Profiler *profiler() const { return m_profiler; } + void setDebugger(Debugging::Debugger *debugger); void setProfiler(Profiling::Profiler *profiler); @@ -484,6 +484,9 @@ public: private: void failStackLimitCheck(Scope &scope); + + QV4::Debugging::Debugger *m_debugger; + QV4::Profiling::Profiler *m_profiler; }; // This is a trick to tell the code generators that functions taking a NoThrowContext won't diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index fce80c46eb..6b9c552350 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -283,7 +283,7 @@ void FunctionCtor::construct(const Managed *that, Scope &scope, CallData *callDa return; } - IR::Module module(scope.engine->debugger != 0); + IR::Module module(scope.engine->debugger() != 0); QQmlJS::RuntimeCodegen cg(scope.engine, f->strictMode()); cg.generateFromFunctionExpression(QString(), function, fe, &module); diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h index fd14c0ae93..e06cb64a61 100644 --- a/src/qml/jsruntime/qv4profiling_p.h +++ b/src/qml/jsruntime/qv4profiling_p.h @@ -76,19 +76,19 @@ QT_END_NAMESPACE #else #define Q_V4_PROFILE_ALLOC(engine, size, type)\ - (engine->profiler &&\ - (engine->profiler->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ - engine->profiler->trackAlloc(size, type) : false) + (engine->profiler() &&\ + (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ + engine->profiler()->trackAlloc(size, type) : false) #define Q_V4_PROFILE_DEALLOC(engine, size, type) \ - (engine->profiler &&\ - (engine->profiler->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ - engine->profiler->trackDealloc(size, type) : false) + (engine->profiler() &&\ + (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\ + engine->profiler()->trackDealloc(size, type) : false) #define Q_V4_PROFILE(engine, function)\ - (engine->profiler &&\ - (engine->profiler->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\ - Profiling::FunctionCallProfiler::profileCall(engine->profiler, engine, function) :\ + (engine->profiler() &&\ + (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\ + Profiling::FunctionCallProfiler::profileCall(engine->profiler(), engine, function) :\ function->code(engine, function->codeData)) QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 97f5cbb786..a2e379ec1a 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -148,7 +148,7 @@ void Script::parse() MemoryManager::GCBlocker gcBlocker(v4->memoryManager); - IR::Module module(v4->debugger != 0); + IR::Module module(v4->debugger() != 0); QQmlJS::Engine ee, *engine = ⅇ Lexer lexer(engine); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 9b46871c85..b6dc7716ba 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -909,7 +909,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code #ifndef QT_NO_QML_DEBUGGER MOTH_BEGIN_INSTR(Debug) engine->current->lineNumber = instr.lineNumber; - QV4::Debugging::Debugger *debugger = context->engine()->debugger; + QV4::Debugging::Debugger *debugger = context->engine()->debugger(); if (debugger && debugger->pauseAtNextOpportunity()) debugger->maybeBreakAtInstruction(); if (qt_v4IsDebugging) @@ -974,7 +974,7 @@ void **VME::instructionJumpTable() QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code) { VME vme; - QV4::Debugging::Debugger *debugger = engine->debugger; + QV4::Debugging::Debugger *debugger = engine->debugger(); if (debugger) debugger->enteringFunction(); QV4::ReturnedValue retVal = vme.run(engine, code); diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 09e10005a0..a61387e411 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2314,7 +2314,7 @@ void QQmlTypeData::dataReceived(const Data &data) return; } QQmlEngine *qmlEngine = typeLoader()->engine(); - m_document.reset(new QmlIR::Document(QV8Engine::getV4(qmlEngine)->debugger != 0)); + m_document.reset(new QmlIR::Document(QV8Engine::getV4(qmlEngine)->debugger() != 0)); m_document->jsModule.sourceTimeStamp = sourceTimeStamp; QmlIR::IRBuilder compiler(QV8Engine::get(qmlEngine)->illegalNames()); if (!compiler.generateFromQml(code, finalUrlString(), m_document.data())) { @@ -2338,7 +2338,7 @@ void QQmlTypeData::dataReceived(const Data &data) void QQmlTypeData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *unit) { QQmlEngine *qmlEngine = typeLoader()->engine(); - m_document.reset(new QmlIR::Document(QV8Engine::getV4(qmlEngine)->debugger != 0)); + m_document.reset(new QmlIR::Document(QV8Engine::getV4(qmlEngine)->debugger() != 0)); unit->loadIR(m_document.data(), unit); continueLoadFromIR(); } @@ -2850,7 +2850,7 @@ void QQmlScriptBlob::dataReceived(const Data &data) } - QmlIR::Document irUnit(v4->debugger != 0); + QmlIR::Document irUnit(v4->debugger() != 0); QString error; QString source = QString::fromUtf8(data.readAll(&error, &irUnit.jsModule.sourceTimeStamp)); diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index 3f89913f3b..a23b7e37eb 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -326,7 +326,7 @@ private slots: private: QV4Debugger *debugger() const { - return static_cast<QV4Debugger *>(m_v4->debugger); + return static_cast<QV4Debugger *>(m_v4->debugger()); } void evaluateJavaScript(const QString &script, const QString &fileName, int lineNumber = 1) { @@ -444,7 +444,7 @@ void tst_qv4debugger::addBreakPointWhilePaused() static QV4::ReturnedValue someCall(QV4::CallContext *ctx) { - static_cast<QV4Debugger *>(ctx->d()->engine->debugger) + static_cast<QV4Debugger *>(ctx->d()->engine->debugger()) ->removeBreakPoint("removeBreakPointForNextInstruction", 2); return QV4::Encode::undefined(); } |