QV4::CompiledData::CompilationUnit *compile(bool generateUnitData = true);
void setUseFastLookups(bool b) { useFastLookups = b; }
+ void setUseTypeInference(bool onoff) { useTypeInference = onoff; }
int registerString(const QString &str) { return jsGenerator->registerString(str); }
uint registerIndexedGetterLookup() { return jsGenerator->registerIndexedGetterLookup(); }
virtual QV4::CompiledData::CompilationUnit *backendCompileStep() = 0;
bool useFastLookups;
+ bool useTypeInference;
QV4::ExecutableAllocator *executableAllocator;
QV4::Compiler::JSUnitGenerator *jsGenerator;
QScopedPointer<QV4::Compiler::JSUnitGenerator> ownJSGenerator;
void reset()
{
+ worklist.assign(worklist.size(), false);
+ worklistSize = 0;
+
foreach (Stmt *s, stmts) {
if (!s)
continue;
// constant propagation:
if (Const *sourceConst = m->source->asConst()) {
+ Q_ASSERT(sourceConst->type != UnknownType);
replaceUses(targetTemp, sourceConst, W);
defUses.removeDef(*targetTemp);
W.remove(s);
doneSomething = true;
break;
case OpUPlus:
- constOperand->type = unop->type;
+ if (unop->type != UnknownType)
+ constOperand->type = unop->type;
doneSomething = true;
break;
case OpCompl:
, inSSA(false)
{}
-void Optimizer::run(QQmlEnginePrivate *qmlEngine)
+void Optimizer::run(QQmlEnginePrivate *qmlEngine, bool doTypeInference, bool peelLoops)
{
#if defined(SHOW_SSA)
qout << "##### NOW IN FUNCTION " << (function->name ? qPrintable(*function->name) : "anonymous!")
showMeTheCode(function);
// cfg2dot(function, loopDetection.allLoops());
- QVector<LoopDetection::LoopInfo *> innerLoops = loopDetection.innermostLoops();
- LoopPeeling(df).run(innerLoops);
+ if (peelLoops) {
+ QVector<LoopDetection::LoopInfo *> innerLoops = loopDetection.innermostLoops();
+ LoopPeeling(df).run(innerLoops);
-// cfg2dot(function, loopDetection.allLoops());
- showMeTheCode(function);
- if (!innerLoops.isEmpty())
- verifyImmediateDominators(df, function);
+// cfg2dot(function, loopDetection.allLoops());
+ showMeTheCode(function);
+ if (!innerLoops.isEmpty())
+ verifyImmediateDominators(df, function);
+ }
}
verifyCFG(function);
StatementWorklist worklist(function);
-// qout << "Running type inference..." << endl;
- TypeInference(qmlEngine, defUses).run(worklist);
- showMeTheCode(function);
+ if (doTypeInference) {
+// qout << "Running type inference..." << endl;
+ TypeInference(qmlEngine, defUses).run(worklist);
+ showMeTheCode(function);
-// qout << "Doing reverse inference..." << endl;
- ReverseInference(defUses).run(function);
-// showMeTheCode(function);
+// qout << "Doing reverse inference..." << endl;
+ ReverseInference(defUses).run(function);
+// showMeTheCode(function);
-// qout << "Doing type propagation..." << endl;
- TypePropagation(defUses).run(function, worklist);
-// showMeTheCode(function);
- verifyNoPointerSharing(function);
+// qout << "Doing type propagation..." << endl;
+ TypePropagation(defUses).run(function, worklist);
+// showMeTheCode(function);
+ verifyNoPointerSharing(function);
+ }
static bool doOpt = qgetenv("QV4_NO_OPT").isEmpty();
if (doOpt) {