aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4function.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-27 17:23:39 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-03 08:08:53 +0000
commitdeaa99f66ddedc2ea79e6902c665925b04665e68 (patch)
treeaf0cb554eb40d9138f9cf723f0aa982991205635 /src/qml/jsruntime/qv4function.cpp
parent2666fe4a1440cc798b9db68fcc807450d46069c2 (diff)
Refactor initialization code for JS stack frames
Move code into qv4stackframe_p.h, so that it can be re-used from different places. Clean up VME::exec and the generatorfunctions using this. Change-Id: Ib4f7eceeb5f55d98dd6ccf2584d13a3b864caea1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
-rw-r--r--src/qml/jsruntime/qv4function.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 9f442d1d68..5e3860a660 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -47,16 +47,35 @@
#include <private/qv4mm_p.h>
#include <private/qv4identifiertable_p.h>
#include <assembler/MacroAssemblerCodeRef.h>
+#include <private/qv4vme_moth_p.h>
#include <private/qqmlglobal_p.h>
QT_BEGIN_NAMESPACE
using namespace QV4;
+ReturnedValue Function::call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context) {
+ ExecutionEngine *engine = context->engine();
+ CppStackFrame frame;
+ frame.init(engine, this, argv, argc);
+ frame.setupJSFrame(engine->jsStackTop, Primitive::undefinedValue(), context->d(),
+ thisObject ? *thisObject : Primitive::undefinedValue(),
+ Primitive::undefinedValue());
+
+ frame.push();
+ engine->jsStackTop += frame.requiredJSStackFrameSize();
+
+ ReturnedValue result = Moth::VME::exec(&frame, engine);
+
+ frame.pop();
+
+ return result;
+}
+
Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function)
- : compiledFunction(function)
- , compilationUnit(unit)
- , codeData(function->code())
+ : compiledFunction(function)
+ , compilationUnit(unit)
+ , codeData(function->code())
, jittedCode(nullptr)
, codeRef(nullptr)
, hasQmlDependencies(function->hasQmlDependencies())