diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-06-22 10:12:13 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-06-22 11:07:05 +0000 |
commit | 702c4247d74ffb7e4fb1aaca96d70f4591203ba2 (patch) | |
tree | 6c0a41332cf4a8ab0051600efdd27b0746574795 /src/plugins | |
parent | fd0e3c6d569a7410fff33974ce9f908dc2de0e22 (diff) |
V4: Pass scope around as parameters inside the runtime.
The implementation of many (or all) runtime functions consist of first
creating a QV4::Scope, which saves and restores the JS stack pointer.
It also prevents tail-calls because of that restoring behavior. In many
cases it suffices to do that at the entry-point of the runtime.
The return value of a JS function call is now also stored in the scope.
Previously, all return values were stored in a ScopedValue, got loaded
on return, and immediately stored in another ScopedValue in the caller.
This resulted in a lot of stores, where now there is only one store
needed, and no extra ScopedValue for every function.
Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index 43036e9c3c..d54bf98068 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -208,7 +208,7 @@ private: void handleDebuggerDeleted(QObject *debugger); - QV4::ReturnedValue evaluateExpression(QV4::Scope &scope, const QString &expression); + void evaluateExpression(QV4::Scope &scope, const QString &expression); bool checkCondition(const QString &expression); QStringList breakOnSignals; @@ -241,12 +241,11 @@ private: bool NativeDebugger::checkCondition(const QString &expression) { QV4::Scope scope(m_engine); - QV4::ReturnedValue result = evaluateExpression(scope, expression); - QV4::ScopedValue val(scope, result); - return val->booleanValue(); + evaluateExpression(scope, expression); + return scope.result.booleanValue(); } -QV4::ReturnedValue NativeDebugger::evaluateExpression(QV4::Scope &scope, const QString &expression) +void NativeDebugger::evaluateExpression(QV4::Scope &scope, const QString &expression) { m_runningJob = true; @@ -261,12 +260,10 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(QV4::Scope &scope, const Q // That is a side-effect of inheritContext. script.inheritContext = true; script.parse(); - QV4::ScopedValue result(scope); if (!m_engine->hasException) - result = script.run(); + scope.result = script.run(); m_runningJob = false; - return result->asReturnedValue(); } NativeDebugger::NativeDebugger(QQmlNativeDebugServiceImpl *service, QV4::ExecutionEngine *engine) @@ -545,8 +542,8 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject TRACE_PROTOCOL("Evaluate expression: " << expression); m_runningJob = true; - QV4::ReturnedValue eval = evaluateExpression(scope, expression); - QV4::ScopedValue result(scope, eval); + evaluateExpression(scope, expression); + QV4::ScopedValue result(scope, scope.result); m_runningJob = false; if (result->isUndefined()) { |