aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-08 16:56:59 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-10 08:19:24 +0000
commit55f17d0faad79dbb9adf793f7ce6e75ff5b70033 (patch)
tree5a5e34a98a196173c707f62d972a3a4984c146de /src/qml/jsruntime/qv4context.cpp
parent5bc4f4d958a3b76f3435d61206ca0109f07aa1a3 (diff)
Get rid of simpleCall
After the recent changes this can easily be unified with the call method without loss of performance. Change-Id: I0385b47b6a86e890f97dcbada3a1be1129ae0b84 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4context.cpp')
-rw-r--r--src/qml/jsruntime/qv4context.cpp49
1 files changed, 18 insertions, 31 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index c9565468ad..f82ea74227 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -57,18 +57,19 @@ DEFINE_MANAGED_VTABLE(ExecutionContext);
DEFINE_MANAGED_VTABLE(CallContext);
DEFINE_MANAGED_VTABLE(CatchContext);
-Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData *callData)
+Heap::CallContext *ExecutionContext::newCallContext(Heap::ExecutionContext *outer, Function *function, CallData *callData)
{
- uint localsAndFormals = function->compiledFunction->nLocals + sizeof(CallData)/sizeof(Value) - 1 + qMax(static_cast<uint>(callData->argc), function->nFormals);
+ uint nFormals = qMax(static_cast<uint>(callData->argc), function->nFormals);
+ uint localsAndFormals = function->compiledFunction->nLocals + sizeof(CallData)/sizeof(Value) - 1 + nFormals;
size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * (localsAndFormals);
- ExecutionEngine *v4 = engine();
+ ExecutionEngine *v4 = outer->internalClass->engine;
Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory, function->internalClass);
c->init(Heap::ExecutionContext::Type_CallContext);
c->v4Function = function;
- c->outer.set(v4, this->d());
+ c->outer.set(v4, outer);
const CompiledData::Function *compiledFunction = function->compiledFunction;
uint nLocals = compiledFunction->nLocals;
@@ -83,9 +84,7 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData
#endif
c->callData = reinterpret_cast<CallData *>(c->locals.values + nLocals);
- ::memcpy(c->callData, callData, sizeof(CallData) - sizeof(Value) + static_cast<uint>(callData->argc) * sizeof(Value));
- if (callData->argc < static_cast<int>(compiledFunction->nFormals))
- std::fill(c->callData->args + c->callData->argc, c->callData->args + compiledFunction->nFormals, Primitive::undefinedValue());
+ ::memcpy(c->callData, callData, sizeof(CallData) - sizeof(Value) + nFormals * sizeof(Value));
return c;
}
@@ -229,38 +228,26 @@ bool ExecutionContext::deleteProperty(String *name)
return !d()->v4Function->isStrict();
}
-// Do a standard call with this execution context as the outer scope
-ReturnedValue ExecutionContext::call(ExecutionEngine *engine, CallData *callData, Function *function, const FunctionObject *f)
+// Do a call with this execution context as the outer scope
+ReturnedValue ExecutionContext::call(Heap::ExecutionContext *context, CallData *callData, Function *function, const FunctionObject *f)
{
- Heap::CallContext *ctx = newCallContext(function, callData);
- if (f)
- ctx->function.set(engine, f->d());
-
- ReturnedValue res = Q_V4_PROFILE(engine, ctx, function, f);
-
- if (function->hasQmlDependencies) {
- Q_ASSERT(d()->type == Heap::ExecutionContext::Type_QmlContext);
- QQmlPropertyCapture::registerQmlDependencies(static_cast<QmlContext *>(this), engine, function->compiledFunction);
- }
-
- return res;
-}
-
-// Do a simple, fast call with this execution context as the outer scope
-ReturnedValue QV4::ExecutionContext::simpleCall(ExecutionEngine *engine, CallData *callData, Function *function)
-{
- Q_ASSERT(function->canUseSimpleFunction());
-
+ ExecutionEngine *engine = context->internalClass->engine;
Value *jsStackTop = engine->jsStackTop;
engine->jsStackTop = reinterpret_cast<QV4::Value *>(callData) + 2 + (int)function->nFormals;
for (int i = callData->argc; i < (int)function->nFormals; ++i)
callData->args[i] = Encode::undefined();
- ReturnedValue res = Q_V4_PROFILE(engine, d(), function, 0);
+ if (!function->canUseSimpleCall) {
+ context = newCallContext(context, function, callData);
+ if (f)
+ static_cast<Heap::CallContext *>(context)->function.set(engine, f->d());
+ }
+
+ ReturnedValue res = Q_V4_PROFILE(engine, context, function, f);
if (function->hasQmlDependencies) {
- Q_ASSERT(d()->type == Heap::ExecutionContext::Type_QmlContext);
- QQmlPropertyCapture::registerQmlDependencies(static_cast<QmlContext *>(this), engine, function->compiledFunction);
+ Q_ASSERT(context->type == Heap::ExecutionContext::Type_QmlContext);
+ QQmlPropertyCapture::registerQmlDependencies(static_cast<Heap::QmlContext *>(context), engine, function->compiledFunction);
}
engine->jsStackTop = jsStackTop;