From c860d1399b4ff5f3a5b1b2630bc33112c88c13e8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 11 Sep 2013 13:23:21 +0200 Subject: Change exception handling API This patch changes the exception handling API in the engine slightly, encapsulating any use of direct throw statements and catch blocks with concrete types. In the future we need to be able to change the way these are implemented, in order to ensure that the correct stack unwinding code is triggered for throw and re-throw. This patch separates the C++ exception object thrown from the V4 exception (that includes value, throwing context pointer) and stores the latter inside the engine. In order for that to compile, ExecutionEngine::StackTrace and StackFrame had to move into the QV4 namespace directly. In addition the syntax for catching exceptions changes from try { ... } catch (QV4::Exception &ex) { ex.accept(context); QV4::ScopedValue exceptionValue(scope, ex.value()); } to try { ... } catch (...) { QV4::ScopedValue exception(scope, context->catchException()); } Context::catchException() checks if there's a "current" exception in the engine, and if not assumes that we caught an unrelated exception and consequently re-throws. partiallyUnwind() is also gone and replaced with rethrowException(), in order to encapsulate the re-throw. Lastly, in the future nesting try/catch blocks isn't going to be possible due to limitations in the common C++ ABI with regards to foreign exceptions. Change-Id: Ic81c75b057a2147e3176d8e0b4d326c14278b47d Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 82ceea9c46..ea8a1fe6c7 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2280,8 +2280,8 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons d->args[0] = o; d->thisObject = engine->global(); function->call(d); - } catch (QV4::Exception &e) { - e.accept(ctx); + } catch (...) { + ctx->catchException(); return true; } return false; @@ -2310,8 +2310,8 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o, d->thisObject = engine->global(); value = function->call(d); return __qmljs_strict_equal(value, result); - } catch (QV4::Exception &e) { - e.accept(ctx); + } catch (...) { + ctx->catchException(); } return false; } @@ -2335,8 +2335,8 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef d->args[0] = o; d->thisObject = engine->global(); return function->call(d); - } catch (QV4::Exception &e) { - e.accept(ctx); + } catch (...) { + ctx->catchException(); } return QV4::Encode::undefined(); } -- cgit v1.2.3