diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2021-03-11 12:37:37 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-03-13 12:56:47 +0100 |
| commit | 490257d44706862500c11d9a05b476c234c260e7 (patch) | |
| tree | 55d6d636ee346491894e3da11fc48c81b747dddf /src/qml/jsruntime/qv4engine.cpp | |
| parent | eb2386a04260966c5d1f13941f7a10154e11625a (diff) | |
Optimize QML context retrieval for AOT functions
We can cache the QQmlContextWrapper rather than retrieving it twice.
Inline some things, and do not unnecessarily create and destroy ref
pointers.
Change-Id: Ife0980f83b7efe1ea9dc56aacbfbccd029ce77c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 4897454cec..03b99bf564 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -902,11 +902,6 @@ ExecutionEngine::~ExecutionEngine() #endif } -ExecutionContext *ExecutionEngine::currentContext() const -{ - return static_cast<ExecutionContext *>(¤tStackFrame->jsFrame->context); -} - #if QT_CONFIG(qml_debug) void ExecutionEngine::setDebugger(Debugging::Debugger *debugger) { @@ -1214,12 +1209,15 @@ Heap::QmlContext *ExecutionEngine::qmlContext() const if (!currentStackFrame) return nullptr; Heap::ExecutionContext *ctx = currentContext()->d(); + Heap::ExecutionContext *outer = ctx->outer; - if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !ctx->outer) + if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !outer) return nullptr; - while (ctx->outer && ctx->outer->type != Heap::ExecutionContext::Type_GlobalContext) - ctx = ctx->outer; + while (outer && outer->type != Heap::ExecutionContext::Type_GlobalContext) { + ctx = outer; + outer = ctx->outer; + } Q_ASSERT(ctx); if (ctx->type != Heap::ExecutionContext::Type_QmlContext) |
