aboutsummaryrefslogtreecommitdiffstats
path: root/qmljs_objects.h
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_objects.h
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_objects.h')
-rw-r--r--qmljs_objects.h44
1 files changed, 35 insertions, 9 deletions
diff --git a/qmljs_objects.h b/qmljs_objects.h
index 51127f6268..1b0b67fab9 100644
--- a/qmljs_objects.h
+++ b/qmljs_objects.h
@@ -56,13 +56,10 @@
namespace QQmlJS {
-namespace IR {
-struct Function;
-}
-
namespace VM {
struct Value;
+struct Function;
struct Object;
struct BooleanObject;
struct NumberObject;
@@ -525,6 +522,34 @@ protected:
virtual void getCollectables(QVector<Object *> &objects);
};
+struct Function {
+ QString name;
+
+ VM::Value (*code)(VM::ExecutionContext *, const uchar *);
+ const uchar *codeData;
+ JSC::MacroAssemblerCodeRef codeRef;
+
+ QList<QString> formals;
+ QList<QString> locals;
+ QVector<Function *> nestedFunctions;
+
+ bool hasDirectEval: 1;
+ bool isStrict: 1;
+
+ Function(const QString &name)
+ : name(name)
+ , code(0)
+ , codeData(0)
+ , hasDirectEval(false)
+ , isStrict(false)
+ {}
+ ~Function();
+
+ inline bool hasNestedFunctions() const { return !nestedFunctions.isEmpty(); }
+
+ inline bool needsActivation() const { return hasNestedFunctions() || hasDirectEval; }
+};
+
struct FunctionObject: Object {
ExecutionContext *scope;
String *name;
@@ -568,9 +593,9 @@ struct NativeFunction: FunctionObject {
};
struct ScriptFunction: FunctionObject {
- IR::Function *function;
+ VM::Function *function;
- ScriptFunction(ExecutionContext *scope, IR::Function *function);
+ ScriptFunction(ExecutionContext *scope, VM::Function *function);
virtual ~ScriptFunction();
virtual Value call(ExecutionContext *ctx);
@@ -583,9 +608,10 @@ struct EvalFunction : FunctionObject
{
EvalFunction(ExecutionContext *scope);
- static QQmlJS::IR::Function *parseSource(QQmlJS::VM::ExecutionContext *ctx,
- const QString &fileName, const QString &source,
- QQmlJS::Codegen::Mode mode);
+ static QQmlJS::VM::Function *parseSource(QQmlJS::VM::ExecutionContext *ctx,
+ const QString &fileName,
+ const QString &source,
+ QQmlJS::Codegen::Mode mode);
virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);
};