diff options
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4isel_p.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 2 | ||||
-rw-r--r-- | tools/v4/main.cpp | 2 |
7 files changed, 7 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)); diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp index 69090c7e2c..14b08d3282 100644 --- a/tools/v4/main.cpp +++ b/tools/v4/main.cpp @@ -218,11 +218,13 @@ int main(int argc, char *argv[]) QV4::Script script(ctx, code, fn); script.parseAsBinding = runAsQml; script.parse(); + script.function()->compilationUnit->ref(); QV4::Value result = script.run(); if (!result.isUndefined()) { if (! qgetenv("SHOW_EXIT_VALUE").isEmpty()) std::cout << "exit value: " << qPrintable(result.toString(ctx)->toQString()) << std::endl; } + script.function()->compilationUnit->deref(); } catch (QV4::Exception& ex) { ex.accept(ctx); showException(ctx, ex); |