From 3a8d6123d1947d18db15bf8b30f59cdea7e31380 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 24 Aug 2015 15:31:46 +0200 Subject: Store the stack of executioncontext's on the JS stack This saves one pointer per allocated execution context. Now every execution context that is pushed, allocates two Values on the js stack. One contains the context itself, the other one the offset to the parent context. Things are a bit tricky for with and catch scopes, as those are called from the generated code, and can't open a Scope anymore. In addition, all methods iterating over the js stack frames need to work with ExecutionContext pointers, not ScopedContext's. Change-Id: I6f3013749d4e73d2fac37973b976ba6029686b82 Reviewed-by: Simon Hausmann --- .../qmltooling/qmldbg_debugger/qv4datacollector.cpp | 19 +++++++------------ .../qmltooling/qmldbg_debugger/qv4datacollector.h | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 2ef7713ac7..49dde9e8bf 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -43,13 +43,9 @@ QT_BEGIN_NAMESPACE -QV4::Heap::CallContext *QV4DataCollector::findContext(QV4::Heap::ExecutionContext *ctxt, int frame) +QV4::Heap::CallContext *QV4DataCollector::findContext(QV4::ExecutionEngine *engine, int frame) { - if (!ctxt) - return 0; - - QV4::Scope scope(ctxt->engine); - QV4::ScopedContext ctx(scope, ctxt); + QV4::ExecutionContext *ctx = engine->currentExecutionContext; while (ctx) { QV4::CallContext *cCtxt = ctx->asCallContext(); if (cCtxt && cCtxt->d()->function) { @@ -57,7 +53,7 @@ QV4::Heap::CallContext *QV4DataCollector::findContext(QV4::Heap::ExecutionContex return cCtxt->d(); --frame; } - ctx = ctx->d()->parent; + ctx = engine->parentContext(ctx); } return 0; @@ -82,7 +78,7 @@ QVector QV4DataCollector::getScopeType QVector types; QV4::Scope scope(engine); - QV4::Scoped sctxt(scope, findContext(engine->currentContext(), frame)); + QV4::Scoped sctxt(scope, findContext(engine, frame)); if (!sctxt || sctxt->d()->type < QV4::Heap::ExecutionContext::Type_QmlContext) return types; @@ -384,7 +380,7 @@ void ArgumentCollectJob::run() QV4::Scope scope(engine); QV4::Scoped ctxt( scope, QV4DataCollector::findScope( - QV4DataCollector::findContext(engine->currentContext(), frameNr), scopeNr)); + QV4DataCollector::findContext(engine, frameNr), scopeNr)); if (!ctxt) return; @@ -417,7 +413,7 @@ void LocalCollectJob::run() QV4::Scope scope(engine); QV4::Scoped ctxt( scope, QV4DataCollector::findScope( - QV4DataCollector::findContext(engine->currentContext(), frameNr), scopeNr)); + QV4DataCollector::findContext(engine, frameNr), scopeNr)); if (!ctxt) return; @@ -448,8 +444,7 @@ void ThisCollectJob::run() bool ThisCollectJob::myRun() { QV4::Scope scope(engine); - QV4::ScopedContext ctxt(scope, QV4DataCollector::findContext(engine->currentContext(), - frameNr)); + QV4::ScopedContext ctxt(scope, QV4DataCollector::findContext(engine, frameNr)); while (ctxt) { if (QV4::CallContext *cCtxt = ctxt->asCallContext()) if (cCtxt->d()->activation) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index 7d26d71bdf..f8cd0c1508 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -45,7 +45,7 @@ public: typedef uint Ref; typedef QVector Refs; - static QV4::Heap::CallContext *findContext(QV4::Heap::ExecutionContext *ctxt, int frame); + static QV4::Heap::CallContext *findContext(QV4::ExecutionEngine *engine, int frame); static QV4::Heap::CallContext *findScope(QV4::Heap::ExecutionContext *ctxt, int scope); static QVector getScopeTypes( QV4::ExecutionEngine *engine, int frame); -- cgit v1.2.3