diff options
author | Ulf Hermann <[email protected]> | 2016-04-21 16:57:10 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2016-05-02 09:03:20 +0000 |
commit | a2e64a20777867726b51a9c9196dc1b8dd68f512 (patch) | |
tree | 3c0462e5b5db214c42f58e3bd6d5e48ae9cc2eed /src/qml/jsruntime/qv4profiling.cpp | |
parent | d93daba909d0aeb8a32fe3b0e0a7145b60d77531 (diff) |
V4 profiler: Don't duplicate function locations
Saving the name/file/line/column over and over for each function call
is wasteful. We can instead key them by the pointer to the JS Function
object. Also, make sure we don't accidentally detach the data when
sending messages.
Task-number: QTBUG-52937
Change-Id: I8a03e4003dc3239f88b49c56424df05cd8b9ef8a
Reviewed-by: Anton Kudryavtsev <[email protected]>
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4profiling.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4profiling.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp index c0a4129d9d..a59190b846 100644 --- a/src/qml/jsruntime/qv4profiling.cpp +++ b/src/qml/jsruntime/qv4profiling.cpp @@ -46,26 +46,35 @@ QT_BEGIN_NAMESPACE namespace QV4 { namespace Profiling { -FunctionCallProperties FunctionCall::resolve() const +FunctionLocation FunctionCall::resolveLocation() const { - FunctionCallProperties props = { - m_start, - m_end, + FunctionLocation location = { m_function->name()->toQString(), m_function->compilationUnit->fileName(), m_function->compiledFunction->location.line, m_function->compiledFunction->location.column }; - return props; + return location; } +FunctionCallProperties FunctionCall::properties() const +{ + FunctionCallProperties props = { + m_start, + m_end, + reinterpret_cast<quintptr>(m_function) + }; + return props; +} Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine(engine) { - static int meta = qRegisterMetaType<QVector<QV4::Profiling::FunctionCallProperties> >(); - static int meta2 = qRegisterMetaType<QVector<QV4::Profiling::MemoryAllocationProperties> >(); - Q_UNUSED(meta); - Q_UNUSED(meta2); + static const int metatypes[] = { + qRegisterMetaType<QVector<QV4::Profiling::FunctionCallProperties> >(), + qRegisterMetaType<QVector<QV4::Profiling::MemoryAllocationProperties> >(), + qRegisterMetaType<FunctionLocationHash>() + }; + Q_UNUSED(metatypes); m_timer.start(); } @@ -85,13 +94,16 @@ bool operator<(const FunctionCall &call1, const FunctionCall &call2) void Profiler::reportData() { std::sort(m_data.begin(), m_data.end()); - QVector<FunctionCallProperties> resolved; - resolved.reserve(m_data.size()); + QVector<FunctionCallProperties> properties; + QHash<qint64, FunctionLocation> locations; + properties.reserve(m_data.size()); - foreach (const FunctionCall &call, m_data) - resolved.append(call.resolve()); + foreach (const FunctionCall &call, m_data) { + properties.append(call.properties()); + locations[properties.constLast().id] = call.resolveLocation(); + } - emit dataReady(resolved, m_memory_data); + emit dataReady(locations, properties, m_memory_data); m_data.clear(); m_memory_data.clear(); } |