diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-06-29 12:17:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-06-29 10:20:50 +0000 |
commit | 2ac3eaee7f613201690f7b73a234363372f13247 (patch) | |
tree | 7c12c04cff0c1cd2167eff1e8ac169f600abe37b /src/qml | |
parent | 2ffdcb3fd31c85dc42b7b7cc8bf0e0feaa23c07f (diff) |
Lower the maximum call depth for debug builds
Also merge VME::exec and VME::run together, so there is one less frame
on the stack.
Change-Id: I7268e0b1f16fc75766c0c9b7b5e14b9885e6fe7c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth_p.h | 3 |
3 files changed, 19 insertions, 18 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 568413bc57..90e705e42f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -145,7 +145,12 @@ ExecutionEngine::ExecutionEngine() bool ok = false; maxCallDepth = qEnvironmentVariableIntValue("QV4_MAX_CALL_DEPTH", &ok); if (!ok || maxCallDepth <= 0) { +#ifdef QT_NO_DEBUG maxCallDepth = 1234; +#else + // no (tail call) optimization is done, so there'll be a lot mare stack frames active + maxCallDepth = 200; +#endif } } Q_ASSERT(maxCallDepth > 0); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 14aef11e7f..c1d010be49 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -362,7 +362,7 @@ Param traceParam(const Param ¶m) if (engine->hasException) \ goto catchException -QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code) +QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code) { #ifdef DO_TRACE_INSTR qDebug("Starting VME with context=%p and code=%p", context, code); @@ -378,6 +378,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code) #undef MOTH_INSTR_ADDR #endif + QV4::ReturnedValue returnValue = Encode::undefined(); QV4::Value *stack = 0; unsigned stackSize = 0; @@ -429,6 +430,8 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code) } } + if (QV4::Debugging::Debugger *debugger = engine->debugger()) + debugger->enteringFunction(); for (;;) { const Instr *genericInstr = reinterpret_cast<const Instr *>(code); @@ -912,7 +915,8 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code) MOTH_BEGIN_INSTR(Ret) // TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData()); - return VALUE(instr.result).asReturnedValue(); + returnValue = VALUE(instr.result).asReturnedValue(); + goto functionExit; MOTH_END_INSTR(Ret) #ifndef QT_NO_QML_DEBUGGER @@ -960,20 +964,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code) Q_ASSERT(false); catchException: Q_ASSERT(engine->hasException); - if (!exceptionHandler) - return QV4::Encode::undefined(); + if (!exceptionHandler) { + returnValue = QV4::Encode::undefined(); + goto functionExit; + } code = exceptionHandler; } -} -QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code) -{ - VME vme; - QV4::Debugging::Debugger *debugger = engine->debugger(); - if (debugger) - debugger->enteringFunction(); - QV4::ReturnedValue retVal = vme.run(engine, code); - if (debugger) - debugger->leavingFunction(retVal); - return retVal; +functionExit: + if (QV4::Debugging::Debugger *debugger = engine->debugger()) + debugger->leavingFunction(returnValue); + return returnValue; } diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h index 8d46207f2b..8692eabe79 100644 --- a/src/qml/jsruntime/qv4vme_moth_p.h +++ b/src/qml/jsruntime/qv4vme_moth_p.h @@ -66,9 +66,6 @@ class VME { public: static QV4::ReturnedValue exec(QV4::ExecutionEngine *, const uchar *); - -private: - QV4::ReturnedValue run(QV4::ExecutionEngine *, const uchar *code); }; } // namespace Moth |