diff options
author | Christiaan Janssen <christiaan.janssen@nokia.com> | 2011-11-30 16:03:47 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-30 16:09:19 +0100 |
commit | 01479573b98747b39833ab09e2cd9ee618ad2a0f (patch) | |
tree | f5e8a68cfac18fb21f96144440a0d57a2e39b4e5 /src | |
parent | dcf1e555d7d2ff435098fe910262cc77dcf835db (diff) |
V8Profiler: make the profiler run in the main thread
Change-Id: I31f126c4014ee2a5045ff6d66dcfef63ec869e98
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/debugger/qv8profilerservice.cpp | 31 | ||||
-rw-r--r-- | src/declarative/debugger/qv8profilerservice_p.h | 3 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp index 6e844b4f25..cf6c04a3e1 100644 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ b/src/declarative/debugger/qv8profilerservice.cpp @@ -84,7 +84,6 @@ class QV8ProfilerServicePrivate : public QDeclarativeDebugServicePrivate public: QV8ProfilerServicePrivate() :initialized(false) - , isolate(0) { } @@ -96,7 +95,6 @@ public: QList<QV8ProfilerData> m_data; bool initialized; - v8::Isolate *isolate; }; QV8ProfilerService::QV8ProfilerService(QObject *parent) @@ -136,30 +134,22 @@ void QV8ProfilerService::messageReceived(const QByteArray &message) QByteArray title; ds >> command >> option; - if (!d->isolate) { - d->isolate = v8::Isolate::New(); - v8::Isolate::Scope scope(d->isolate); - v8::V8::Initialize(); - } - - v8::Isolate::Scope scope(d->isolate); - if (command == "V8PROFILER") { ds >> title; if (option == "start") { - startProfiling(QString::fromUtf8(title)); + QMetaObject::invokeMethod(this, "startProfiling", Qt::QueuedConnection, Q_ARG(QString, QString::fromUtf8(title))); } else if (option == "stop") { - stopProfiling(QString::fromUtf8(title)); - sendProfilingData(); + QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, QString::fromUtf8(title))); + QMetaObject::invokeMethod(this, "sendProfilingData", Qt::QueuedConnection); } d->initialized = true; } if (command == "V8SNAPSHOT") { if (option == "full") - d->takeSnapshot(v8::HeapSnapshot::kFull); + QMetaObject::invokeMethod(this, "takeSnapshot", Qt::QueuedConnection); else if (option == "delete") { - v8::HeapProfiler::DeleteAllSnapshots(); + QMetaObject::invokeMethod(this, "deleteSnapshots", Qt::QueuedConnection); } } @@ -188,6 +178,17 @@ void QV8ProfilerService::stopProfiling(const QString &title) } } +void QV8ProfilerService::takeSnapshot() +{ + Q_D(QV8ProfilerService); + d->takeSnapshot(v8::HeapSnapshot::kFull); +} + +void QV8ProfilerService::deleteSnapshots() +{ + v8::HeapProfiler::DeleteAllSnapshots(); +} + void QV8ProfilerService::sendProfilingData() { Q_D(QV8ProfilerService); diff --git a/src/declarative/debugger/qv8profilerservice_p.h b/src/declarative/debugger/qv8profilerservice_p.h index f8d64173f3..c2b63bd74a 100644 --- a/src/declarative/debugger/qv8profilerservice_p.h +++ b/src/declarative/debugger/qv8profilerservice_p.h @@ -95,8 +95,11 @@ public: static QV8ProfilerService *instance(); static void initialize(); +public slots: void startProfiling(const QString &title); void stopProfiling(const QString &title); + void takeSnapshot(); + void deleteSnapshots(); void sendProfilingData(); |