From 5903b961c6364544ea122a3cba77216c6aadee5b Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 19 Aug 2016 15:15:32 +0200 Subject: V4: Replace the ranges QVector with a QVarLengthArray Reduces the instruction count of Optimizer::lifeTimeIntervals with about 33% on x86_64, and the number of malloc calls with about 20%. Change-Id: I2ca303a3919dc940f29e40b2487016ff85e678fb Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4ssa.cpp | 12 ++++++------ src/qml/compiler/qv4ssa_p.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/qml') diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 45eeed57f3..e4eaeaa3f6 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -5119,7 +5119,7 @@ void LifeTimeInterval::setFrom(int from) { Q_ASSERT(from > 0); if (_ranges.isEmpty()) { // this is the case where there is no use, only a define - _ranges.push_front(Range(from, from)); + _ranges.prepend(Range(from, from)); if (_end == InvalidPosition) _end = from; } else { @@ -5133,7 +5133,7 @@ void LifeTimeInterval::addRange(int from, int to) { Q_ASSERT(to >= from); if (_ranges.isEmpty()) { - _ranges.push_front(Range(from, to)); + _ranges.prepend(Range(from, to)); _end = to; return; } @@ -5148,12 +5148,12 @@ void LifeTimeInterval::addRange(int from, int to) { break; p1->start = qMin(p->start, p1->start); p1->end = qMax(p->end, p1->end); - _ranges.pop_front(); + _ranges.remove(0); p = &_ranges.first(); } } else { if (to < p->start) { - _ranges.push_front(Range(from, to)); + _ranges.prepend(Range(from, to)); } else { Q_ASSERT(from > _ranges.last().end); _ranges.push_back(Range(from, to)); @@ -5194,7 +5194,7 @@ LifeTimeInterval LifeTimeInterval::split(int atPosition, int newStart) } if (newInterval._ranges.first().end == atPosition) - newInterval._ranges.removeFirst(); + newInterval._ranges.remove(0); if (newStart == InvalidPosition) { // the temp stays inactive for the rest of its lifetime @@ -5214,7 +5214,7 @@ LifeTimeInterval LifeTimeInterval::split(int atPosition, int newStart) break; } else { // the temp stays inactive for this interval, so remove it. - newInterval._ranges.removeFirst(); + newInterval._ranges.remove(0); } } Q_ASSERT(!newInterval._ranges.isEmpty()); diff --git a/src/qml/compiler/qv4ssa_p.h b/src/qml/compiler/qv4ssa_p.h index b5f7728f14..3a787f0347 100644 --- a/src/qml/compiler/qv4ssa_p.h +++ b/src/qml/compiler/qv4ssa_p.h @@ -75,7 +75,7 @@ public: bool covers(int position) const { return start <= position && position <= end; } }; - typedef QVector Ranges; + typedef QVarLengthArray Ranges; private: Temp _temp; @@ -89,7 +89,7 @@ public: enum { InvalidPosition = -1 }; enum { InvalidRegister = -1 }; - explicit LifeTimeInterval(int rangeCapacity = 2) + explicit LifeTimeInterval(int rangeCapacity = 4) : _end(InvalidPosition) , _reg(InvalidRegister) , _isFixedInterval(0) -- cgit v1.2.3