From: Simon Hausmann Date: Thu, 15 Aug 2013 07:41:09 +0000 (+0200) Subject: Initialize formals and locals from the compiled function data instead of in the isel X-Git-Tag: upstream/5.2.1~669^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2aee966baa76f55d9061ed22af7bb0abe4f3541e;p=platform%2Fupstream%2Fqtdeclarative.git Initialize formals and locals from the compiled function data instead of in the isel Change-Id: I9db976df310a5986ceca66d21efeeae536dbede4 Reviewed-by: Lars Knoll --- diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index d02946e..c70fa69 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -124,6 +124,9 @@ struct Function // quint32 offsetForInnerFunctions[nInnerFunctions] // Function[nInnerFunctions] + const quint32 *formalsTable() const { return reinterpret_cast(reinterpret_cast(this) + formalsOffset); } + const quint32 *localsTable() const { return reinterpret_cast(reinterpret_cast(this) + localsOffset); } + static int calculateSize(int nFormals, int nLocals, int nInnerfunctions) { return (sizeof(Function) + (nFormals + nLocals + nInnerfunctions) * sizeof(quint32) + 7) & ~0x7; } diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index 3abe419..29f2343 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -74,9 +74,7 @@ QV4::Function *CompilationUnit::linkBackendToEngine(ExecutionEngine *engine) QV4::Function *runtimeFunction = runtimeFunctions.at(i); const CompiledData::Function *compiledFunction = data->functionAt(i); - runtimeFunction->compilationUnit = this; - runtimeFunction->compilationUnit->ref(); - runtimeFunction->compiledFunction = compiledFunction; + runtimeFunction->init(this, compiledFunction); if (compiledFunction == compiledRootFunction) { assert(!rootRuntimeFunction); diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp index 7081bc8..c81f5df 100644 --- a/src/qml/compiler/qv4isel_p.cpp +++ b/src/qml/compiler/qv4isel_p.cpp @@ -86,13 +86,6 @@ QV4::Function *EvalInstructionSelection::createFunctionMapping(QV4::Function *ou if (outer) outer->addNestedFunction(vmFunction); - foreach (const QString *formal, irFunction->formals) - if (formal) - vmFunction->formals.append(_engine->newString(*formal)); - foreach (const QString *local, irFunction->locals) - if (local) - vmFunction->locals.append(_engine->newString(*local)); - foreach (V4IR::Function *function, irFunction->nestedFunctions) createFunctionMapping(vmFunction, function); diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 6e1645c..58d2cdd 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -65,6 +65,25 @@ Function::~Function() compilationUnit->deref(); } +void Function::init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function) +{ + Q_ASSERT(!compilationUnit); + compilationUnit = unit; + compilationUnit->ref(); + compiledFunction = function; + + formals.resize(compiledFunction->nFormals); + const quint32 *formalsIndices = compiledFunction->formalsTable(); + for (int i = 0; i < compiledFunction->nFormals; ++i) + formals[i] = engine->newString(unit->data->stringAt(formalsIndices[i])->qString()); + + + locals.resize(compiledFunction->nLocals); + const quint32 *localsIndices = compiledFunction->localsTable(); + for (int i = 0; i < compiledFunction->nLocals; ++i) + locals[i] = engine->newString(unit->data->stringAt(localsIndices[i])->qString()); +} + void Function::mark() { if (name) diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index e2274a2..34e570f 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -121,6 +121,9 @@ struct Function { {} ~Function(); + // ### Merge with constructor later. + void init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function); + void ref() { ++refCount; } void deref() { if (!--refCount) delete this; }