aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-01-18 12:26:50 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-18 12:26:50 +0100
commit65e7af6a0bd1a0785a2534d22681c6b48f0ed899 (patch)
treebb48cab341acfeb503c3e8d29a9672be22d58be5 /src
parent11873ffb7a66195eaa151a599b849c13892bfee5 (diff)
parent6924a8b5be31300d7b3cfc85abce621bad032de9 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4jsir_p.h4
-rw-r--r--src/qml/compiler/qv4regalloc.cpp4
-rw-r--r--src/qml/compiler/qv4ssa.cpp47
-rw-r--r--src/qml/compiler/qv4ssa_p.h16
4 files changed, 59 insertions, 12 deletions
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index 2eba3405fe..46aea546ab 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -248,7 +248,7 @@ struct MemberExpressionResolver
unsigned int isQObjectResolver; // neede for IR dump helpers
};
-struct Expr {
+struct Q_AUTOTEST_EXPORT Expr {
Type type;
Expr(): type(UnknownType) {}
@@ -380,7 +380,7 @@ struct Name: Expr {
virtual void dump(QTextStream &out) const;
};
-struct Temp: Expr {
+struct Q_AUTOTEST_EXPORT Temp: Expr {
enum Kind {
Formal = 0,
ScopedFormal,
diff --git a/src/qml/compiler/qv4regalloc.cpp b/src/qml/compiler/qv4regalloc.cpp
index 7996b134a1..f95cd55b04 100644
--- a/src/qml/compiler/qv4regalloc.cpp
+++ b/src/qml/compiler/qv4regalloc.cpp
@@ -916,8 +916,9 @@ private:
}
}
if (!moveFrom) {
+#if defined(QT_NO_DEBUG)
Q_UNUSED(lifeTimeHole);
-#if !defined(QT_NO_DEBUG)
+#else
Q_ASSERT(!_info->isPhiTarget(it->temp()) || it->isSplitFromInterval() || lifeTimeHole);
if (_info->def(it->temp()) != successorStart && !it->isSplitFromInterval()) {
const int successorEnd = successor->statements.last()->id;
@@ -1495,6 +1496,7 @@ int RegisterAllocator::nextUse(const Temp &t, int startPosition) const
static inline void insertSorted(QVector<LifeTimeInterval> &intervals, const LifeTimeInterval &newInterval)
{
+ newInterval.validate();
for (int i = 0, ei = intervals.size(); i != ei; ++i) {
if (LifeTimeInterval::lessThan(newInterval, intervals.at(i))) {
intervals.insert(i, newInterval);
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 7113dc7c26..6b4d7e7434 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -3634,12 +3634,20 @@ LifeTimeInterval LifeTimeInterval::split(int atPosition, int newStart)
LifeTimeInterval newInterval = *this;
newInterval.setSplitFromInterval(true);
+ // search where to split the interval
for (int i = 0, ei = _ranges.size(); i < ei; ++i) {
- if (_ranges[i].covers(atPosition)) {
- while (_ranges.size() > i + 1)
- _ranges.removeLast();
- while (newInterval._ranges.size() > ei - i)
- newInterval._ranges.removeFirst();
+ if (_ranges[i].start <= atPosition) {
+ if (_ranges[i].end >= atPosition) {
+ // split happens in the middle of a range. Keep this range in both the old and the
+ // new interval, and correct the end/start later
+ _ranges.resize(i + 1);
+ newInterval._ranges.remove(0, i);
+ break;
+ }
+ } else {
+ // split happens between two ranges.
+ _ranges.resize(i);
+ newInterval._ranges.remove(0, i);
break;
}
}
@@ -3648,14 +3656,37 @@ LifeTimeInterval LifeTimeInterval::split(int atPosition, int newStart)
newInterval._ranges.removeFirst();
if (newStart == Invalid) {
- newInterval._ranges.clear();
- newInterval._end = Invalid;
+ // the temp stays inactive for the rest of its lifetime
+ newInterval = LifeTimeInterval();
} else {
+ // find the first range where the temp will get active again:
+ while (!newInterval._ranges.isEmpty()) {
+ const Range &range = newInterval._ranges.first();
+ if (range.start > newStart) {
+ // The split position is before the start of the range. Either we managed to skip
+ // over the correct range, or we got an invalid split request. Either way, this
+ // Should Never Happen <TM>.
+ Q_ASSERT(range.start > newStart);
+ return LifeTimeInterval();
+ } else if (range.start <= newStart && range.end >= newStart) {
+ // yay, we found the range that should be the new first range in the new interval!
+ break;
+ } else {
+ // the temp stays inactive for this interval, so remove it.
+ newInterval._ranges.removeFirst();
+ }
+ }
+ Q_ASSERT(!newInterval._ranges.isEmpty());
newInterval._ranges.first().start = newStart;
_end = newStart;
}
- _ranges.last().end = atPosition;
+ // if we're in the middle of a range, set the end to the split position
+ if (_ranges.last().end > atPosition)
+ _ranges.last().end = atPosition;
+
+ validate();
+ newInterval.validate();
return newInterval;
}
diff --git a/src/qml/compiler/qv4ssa_p.h b/src/qml/compiler/qv4ssa_p.h
index f90fc5b05b..65d4f0834a 100644
--- a/src/qml/compiler/qv4ssa_p.h
+++ b/src/qml/compiler/qv4ssa_p.h
@@ -51,7 +51,7 @@ class QQmlEnginePrivate;
namespace QQmlJS {
namespace V4IR {
-class LifeTimeInterval {
+class Q_AUTOTEST_EXPORT LifeTimeInterval {
public:
struct Range {
int start;
@@ -121,6 +121,20 @@ public:
void dump(QTextStream &out) const;
static bool lessThan(const LifeTimeInterval &r1, const LifeTimeInterval &r2);
static bool lessThanForTemp(const LifeTimeInterval &r1, const LifeTimeInterval &r2);
+
+ void validate() const {
+#if !defined(QT_NO_DEBUG)
+ // Validate the new range
+ if (_end != Invalid) {
+ Q_ASSERT(!_ranges.isEmpty());
+ foreach (const Range &range, _ranges) {
+ Q_ASSERT(range.start >= 0);
+ Q_ASSERT(range.end >= 0);
+ Q_ASSERT(range.start <= range.end);
+ }
+ }
+#endif
+ }
};
class Optimizer