aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-16 14:03:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-16 16:03:57 +0200
commit12c3579136b6925e75cca4f3a9b8bae2e4665db7 (patch)
tree17f82a28141856af0954ffe4eff20ebc679a3265 /src/qml/jsruntime/qv4functionobject.cpp
parentc1c526aafb2fc70ac6155eb775b3784f1e2e6504 (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/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp72
1 files changed, 15 insertions, 57 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 8faf2a74b6..55baef06db 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -443,16 +443,8 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData)
callData->thisObject = obj.asReturnedValue();
ExecutionContext *ctx = context->newCallContext(f.getPointer(), callData);
- ScopedValue result(scope);
- SAVE_JS_STACK(f->scope);
- try {
- result = f->function->code(ctx, f->function->codeData);
- } catch (...) {
- context->rethrowException();
- }
- CHECK_JS_STACK(f->scope);
- ctx->engine->popContext();
-
+ ExecutionContextSaver ctxSaver(context);
+ ScopedValue result(scope, f->function->code(ctx, f->function->codeData));
if (result->isObject())
return result.asReturnedValue();
return obj.asReturnedValue();
@@ -474,16 +466,8 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData)
}
}
- ScopedValue result(scope);
- SAVE_JS_STACK(f->scope);
- try {
- result = f->function->code(ctx, f->function->codeData);
- } catch (...) {
- context->rethrowException();
- }
- CHECK_JS_STACK(f->scope);
- ctx->engine->popContext();
- return result.asReturnedValue();
+ ExecutionContextSaver ctxSaver(context);
+ return f->function->code(ctx, f->function->codeData);
}
DEFINE_MANAGED_VTABLE(SimpleScriptFunction);
@@ -540,16 +524,12 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData)
callData->thisObject = obj;
ExecutionContext *ctx = context->newCallContext(stackSpace, scope.alloc(f->varCount), f.getPointer(), callData);
- try {
- Scoped<Object> result(scope, f->function->code(ctx, f->function->codeData));
- ctx->engine->popContext();
+ ExecutionContextSaver ctxSaver(context);
+ Scoped<Object> result(scope, f->function->code(ctx, f->function->codeData));
- if (!result)
- return obj.asReturnedValue();
- return result.asReturnedValue();
- } catch (...) {
- context->rethrowException();
- }
+ if (!result)
+ return obj.asReturnedValue();
+ return result.asReturnedValue();
}
ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData)
@@ -570,16 +550,8 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData)
}
}
- ScopedValue result(scope);
- SAVE_JS_STACK(f->scope);
- try {
- result = f->function->code(ctx, f->function->codeData);
- } catch (...) {
- context->rethrowException();
- }
- CHECK_JS_STACK(f->scope);
- ctx->engine->popContext();
- return result.asReturnedValue();
+ ExecutionContextSaver ctxSaver(context);
+ return f->function->code(ctx, f->function->codeData);
}
@@ -613,15 +585,8 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData)
ctx.callData = callData;
v4->pushContext(&ctx);
- ScopedValue result(scope);
- try {
- result = f->code(&ctx);
- } catch (...) {
- context->rethrowException();
- }
-
- context->engine->popContext();
- return result.asReturnedValue();
+ ExecutionContextSaver ctxSaver(context);
+ return f->code(&ctx);
}
ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData)
@@ -637,15 +602,8 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData)
ctx.callData = callData;
v4->pushContext(&ctx);
- ScopedValue result(scope);
- try {
- result = f->code(&ctx, f->index);
- } catch (...) {
- context->rethrowException();
- }
-
- context->engine->popContext();
- return result.asReturnedValue();
+ ExecutionContextSaver ctxSaver(context);
+ return f->code(&ctx, f->index);
}
DEFINE_MANAGED_VTABLE(IndexedBuiltinFunction);