diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-05-11 10:09:12 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-06-09 07:55:33 +0000 |
commit | 5efbd7165d6867aa376f23c20edcfe49e80518c6 (patch) | |
tree | 2cb510332dcc5973c4c017775567e25677c01e0d /src/qml/compiler/qv4jsir_p.h | |
parent | 4ea6d985fa76786a965443f814f3f9b59620e056 (diff) |
Change temp allocation when generating IR
For functions that won't get optimized, it's useful to limit the number
of temporaries as much as possible.
Change-Id: I6e9be3129c064fdc4c01e1ec6f1617e901c05935
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4jsir_p.h')
-rw-r--r-- | src/qml/compiler/qv4jsir_p.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index caab9c0f9e..6f14e3dfaf 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -1113,7 +1113,11 @@ public: return false; } - unsigned newTemp(); + enum TempForWhom { + NewTempForCodegen, + NewTempForOptimizer + }; + unsigned newTemp(TempForWhom tfw = NewTempForCodegen); Temp *TEMP(unsigned kind); ArgLocal *ARG(unsigned index, unsigned scope); @@ -1278,6 +1282,7 @@ struct Function { Module *module; QQmlJS::MemoryPool *pool; const QString *name; + int currentTemp = 0; int tempCount; int maxNumberOfArguments; QSet<QString> strings; @@ -1485,10 +1490,17 @@ protected: BasicBlock *currentBB; }; -inline unsigned BasicBlock::newTemp() +inline unsigned BasicBlock::newTemp(TempForWhom tfw) { Q_ASSERT(!isRemoved()); - return function->tempCount++; + + if (tfw == NewTempForOptimizer) + return function->tempCount++; + + int t = function->currentTemp++; + if (function->tempCount < function->currentTemp) + function->tempCount = function->currentTemp; + return t; } inline Temp *BasicBlock::TEMP(unsigned index) |