diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-10-16 14:03:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-16 16:03:57 +0200 |
commit | 12c3579136b6925e75cca4f3a9b8bae2e4665db7 (patch) | |
tree | 17f82a28141856af0954ffe4eff20ebc679a3265 /src/qml/jsruntime/qv4function_p.h | |
parent | c1c526aafb2fc70ac6155eb775b3784f1e2e6504 (diff) |
Speed up exception propagation
Avoid catch (...) with re-throw as it turns that this is very slow because it
throws a new exception and the unwinder starts from scratch. Instead use stack
allocated objects and cleaning destructors to restore state before continuing
with the propagation of exceptions.
Change-Id: I6d95026bcd60b58cb6258a9dae28623a46739532
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4function_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 34ab5df73a..35c98897a0 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -86,13 +86,24 @@ struct Function { const CompiledData::Function *compiledFunction; CompiledData::CompilationUnit *compilationUnit; inline ReturnedValue code(ExecutionContext *ctx, const uchar *data) { - SafeValue *stack = ctx->engine->jsStackTop; - try { - return codePtr(ctx, data); - } catch (...) { - ctx->engine->jsStackTop = stack; - ctx->rethrowException(); - } + + struct StackSaver { + ExecutionEngine *engine; + SafeValue *stack; + + StackSaver(ExecutionEngine *engine) + : engine(engine) + , stack(engine->jsStackTop) + {} + + ~StackSaver() + { + engine->jsStackTop = stack; + } + }; + + StackSaver(ctx->engine); + return codePtr(ctx, data); } ReturnedValue (*codePtr)(ExecutionContext *, const uchar *); |