aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-16 17:25:58 +0200
committerLars Knoll <lars.knoll@digia.com>2013-08-16 19:18:48 +0200
commit0f0e7443aea0d9a203b380bec708c485a01450e0 (patch)
treec34a687f99964d9d97c535e6c3cf1fdc232aaebf /src/qml
parentbb8d91829c12b7742205eb96a0e8fbcc164c5e91 (diff)
Refcount the compilation unit and remove refcount from runtime function
Change-Id: Iaa2f96a6814f1b39589ffcfe3c84e3c229e25f1f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp1
-rw-r--r--src/qml/compiler/qv4isel_p.cpp3
-rw-r--r--src/qml/jsruntime/qv4function.cpp7
-rw-r--r--src/qml/jsruntime/qv4function_p.h14
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4script.cpp2
6 files changed, 5 insertions, 26 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 4b7f132d97..59c6a9b7fd 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -58,6 +58,7 @@ CompilationUnit::~CompilationUnit()
delete [] runtimeLookups;
delete [] runtimeRegularExpressions;
free(runtimeClasses);
+ qDeleteAll(runtimeFunctions);
}
QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp
index c81f5dffc5..6cfe7626af 100644
--- a/src/qml/compiler/qv4isel_p.cpp
+++ b/src/qml/compiler/qv4isel_p.cpp
@@ -83,9 +83,6 @@ QV4::Function *EvalInstructionSelection::createFunctionMapping(QV4::Function *ou
QV4::Function *vmFunction = _engine->newFunction(irFunction->name ? *irFunction->name : QString());
_irToVM.insert(irFunction, vmFunction);
- if (outer)
- outer->addNestedFunction(vmFunction);
-
foreach (V4IR::Function *function, irFunction->nestedFunctions)
createFunctionMapping(vmFunction, function);
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 32fd9c3946..c96935de03 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -55,12 +55,6 @@ Function::~Function()
{
engine->functions.remove(engine->functions.indexOf(this));
UnwindHelper::deregisterFunction(this); // ### move to masm compilation unit
-
- Q_ASSERT(!refCount);
- foreach (Function *f, nestedFunctions)
- f->deref();
- if (compilationUnit)
- compilationUnit->deref();
}
void Function::init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function, Value (*codePtr)(ExecutionContext *, const uchar *),
@@ -68,7 +62,6 @@ void Function::init(CompiledData::CompilationUnit *unit, const CompiledData::Fun
{
Q_ASSERT(!compilationUnit);
compilationUnit = unit;
- compilationUnit->ref();
compiledFunction = function;
code = codePtr;
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 47215cf69a..d9ba9dccb8 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -87,7 +87,6 @@ struct LineNumberMapping
};
struct Function {
- int refCount;
String *name;
const CompiledData::Function *compiledFunction;
@@ -98,13 +97,11 @@ struct Function {
QVector<String *> formals;
QVector<String *> locals;
- QVector<Function *> nestedFunctions;
ExecutionEngine *engine;
Function(ExecutionEngine *engine, String *name)
- : refCount(0)
- , name(name)
+ : name(name)
, compiledFunction(0)
, compilationUnit(0)
, code(0)
@@ -118,15 +115,6 @@ struct Function {
void init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize);
- void ref() { ++refCount; }
- void deref() { if (!--refCount) delete this; }
-
- void addNestedFunction(Function *f)
- {
- f->ref();
- nestedFunctions.append(f);
- }
-
inline QString sourceFile() const { return compilationUnit->fileName(); }
inline bool usesArgumentsObject() const { return compiledFunction->flags & CompiledData::Function::UsesArgumentsObject; }
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index fd9c92f7ea..fc5300c23d 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -96,7 +96,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, String *name)
FunctionObject::~FunctionObject()
{
if (function)
- function->deref();
+ function->compilationUnit->deref();
}
Value FunctionObject::newInstance()
@@ -325,7 +325,7 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function)
{
vtbl = &static_vtbl;
this->function = function;
- this->function->ref();
+ this->function->compilationUnit->ref();
assert(function);
assert(function->code);
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 70ab3d4d1d..2997604948 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -67,7 +67,7 @@ struct QmlBindingWrapper : FunctionObject
{
vtbl = &static_vtbl;
function = f;
- function->ref();
+ function->compilationUnit->ref();
usesArgumentsObject = function->usesArgumentsObject();
needsActivation = function->needsActivation();
defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1));