aboutsummaryrefslogtreecommitdiffstats
path: root/qv4isel_p.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2012-12-11 10:03:40 +0100
committerLars Knoll <lars.knoll@digia.com>2012-12-11 23:16:32 +0100
commit5e39d56c0974faa28c5060a12064e1ad7f611ea0 (patch)
treea2f900ab936799f002e769e9a48d191af773d3d8 /qv4isel_p.cpp
parentbcdddfda8ca81752b249540b0abaefb46eb5f766 (diff)
Remove IR::Function from the runtime.
This fixes potential leaks of IR::Functions, lowers the memory usage of the functions that the VM needs (because the IR fields are not present in the VM::Function), and makes both managed by the module respectively the ExecutionEngine. Change-Id: I6748ad98b062f994eae9dd14f1919aec5aa7c0b0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'qv4isel_p.cpp')
-rw-r--r--qv4isel_p.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/qv4isel_p.cpp b/qv4isel_p.cpp
index 175cea547e..5a668fa246 100644
--- a/qv4isel_p.cpp
+++ b/qv4isel_p.cpp
@@ -1,9 +1,46 @@
+#include "debugging.h"
+#include "qmljs_engine.h"
+#include "qv4ir_p.h"
#include "qv4isel_p.h"
+#include "qv4isel_util_p.h"
+
+#include <QString>
+
+#include <cassert>
using namespace QQmlJS;
+EvalInstructionSelection::EvalInstructionSelection(VM::ExecutionEngine *engine, IR::Module *module)
+ : _engine(engine)
+{
+ assert(engine);
+ assert(module);
+
+ foreach (IR::Function *f, module->functions)
+ _irToVM.insert(f, createFunctionMapping(engine, f));
+}
+
EvalInstructionSelection::~EvalInstructionSelection()
{}
EvalISelFactory::~EvalISelFactory()
{}
+
+VM::Function *EvalInstructionSelection::createFunctionMapping(VM::ExecutionEngine *engine, IR::Function *irFunction)
+{
+ VM::Function *vmFunction = engine->newFunction(irFunction->name ? *irFunction->name : QString());
+ vmFunction->hasDirectEval = irFunction->hasDirectEval;
+ vmFunction->isStrict = irFunction->isStrict;
+
+ foreach (const QString *formal, irFunction->formals)
+ if (formal)
+ vmFunction->formals.append(*formal);
+ foreach (const QString *local, irFunction->locals)
+ if (local)
+ vmFunction->locals.append(*local);
+
+ if (engine->debugger)
+ engine->debugger->mapFunction(vmFunction, irFunction);
+
+ return vmFunction;
+}