aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_engine.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 /qmljs_engine.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 'qmljs_engine.cpp')
-rw-r--r--qmljs_engine.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/qmljs_engine.cpp b/qmljs_engine.cpp
index 4da9564939..a29088f68e 100644
--- a/qmljs_engine.cpp
+++ b/qmljs_engine.cpp
@@ -222,6 +222,7 @@ ExecutionEngine::~ExecutionEngine()
delete globalObject.asObject();
delete rootContext;
delete stringPool;
+ qDeleteAll(functions);
}
ExecutionContext *ExecutionEngine::newContext()
@@ -237,6 +238,13 @@ String *ExecutionEngine::identifier(const QString &s)
return id;
}
+Function *ExecutionEngine::newFunction(const QString &name)
+{
+ VM::Function *f = new VM::Function(name);
+ functions.append(f);
+ return f;
+}
+
FunctionObject *ExecutionEngine::newNativeFunction(ExecutionContext *scope, String *name, Value (*code)(ExecutionContext *))
{
NativeFunction *f = new (memoryManager) NativeFunction(scope, name, code);
@@ -244,8 +252,10 @@ FunctionObject *ExecutionEngine::newNativeFunction(ExecutionContext *scope, Stri
return f;
}
-FunctionObject *ExecutionEngine::newScriptFunction(ExecutionContext *scope, IR::Function *function)
+FunctionObject *ExecutionEngine::newScriptFunction(ExecutionContext *scope, VM::Function *function)
{
+ assert(function);
+
MemoryManager::GCBlocker gcBlocker(memoryManager);
ScriptFunction *f = new (memoryManager) ScriptFunction(scope, function);