aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2015-01-11 21:11:29 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-01-23 13:29:57 +0100
commit43fe684d42d90dd76d7d6c946a37ec0002f703a8 (patch)
treea6b06bc39509ae9b051d11420bb7177f495e6e4a /src
parentfc2da305171eb913eb5f3acdbe4ebd39cca2d1ac (diff)
Move Stmt::d to Phi::d
Phi is the only thing using it. Change-Id: I2b6706884d9e41cc26632a6ad72281b391960f4f Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4jsir.cpp27
-rw-r--r--src/qml/compiler/qv4jsir_p.h23
-rw-r--r--src/qml/compiler/qv4ssa.cpp4
3 files changed, 34 insertions, 20 deletions
diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp
index fbfcf31aa0..13ed3944b8 100644
--- a/src/qml/compiler/qv4jsir.cpp
+++ b/src/qml/compiler/qv4jsir.cpp
@@ -511,8 +511,11 @@ void Function::setStatementCount(int cnt)
BasicBlock::~BasicBlock()
{
- foreach (Stmt *s, _statements)
- s->destroyData();
+ foreach (Stmt *s, _statements) {
+ Phi *p = s->asPhi();
+ if (p)
+ p->destroyData();
+ }
}
unsigned BasicBlock::newTemp()
@@ -766,8 +769,12 @@ void BasicBlock::setStatements(const QVector<Stmt *> &newStatements)
Q_ASSERT(newStatements.size() >= _statements.size());
// FIXME: this gets quite inefficient for large basic-blocks, so this function/case should be re-worked.
foreach (Stmt *s, _statements) {
- if (!newStatements.contains(s))
- s->destroyData();
+ Phi *p = s->asPhi();
+ if (!p)
+ continue;
+
+ if (!newStatements.contains(p))
+ p->destroyData();
}
_statements = newStatements;
}
@@ -816,21 +823,27 @@ void BasicBlock::insertStatementBeforeTerminator(Stmt *stmt)
void BasicBlock::replaceStatement(int index, Stmt *newStmt)
{
Q_ASSERT(!isRemoved());
- _statements[index]->destroyData();
+ Phi *p = _statements[index]->asPhi();
+ if (p)
+ p->destroyData();
_statements[index] = newStmt;
}
void BasicBlock::removeStatement(Stmt *stmt)
{
Q_ASSERT(!isRemoved());
- stmt->destroyData();
+ Phi *p = stmt->asPhi();
+ if (p)
+ p->destroyData();
_statements.remove(_statements.indexOf(stmt));
}
void BasicBlock::removeStatement(int idx)
{
Q_ASSERT(!isRemoved());
- _statements[idx]->destroyData();
+ Phi *p = _statements[idx]->asPhi();
+ if (p)
+ p->destroyData();
_statements.remove(idx);
}
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index c6a192e14a..4f31d848d0 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -602,16 +602,11 @@ struct Member: Expr {
};
struct Stmt {
- struct Data {
- QVector<Expr *> incoming; // used by Phi nodes
- };
-
enum { InvalidId = -1 };
- Data *d;
QQmlJS::AST::SourceLocation location;
- explicit Stmt(int id): d(0), _id(id) {}
+ explicit Stmt(int id): _id(id) {}
virtual ~Stmt()
{
@@ -635,10 +630,6 @@ struct Stmt {
private: // For memory management in BasicBlock
friend struct BasicBlock;
- void destroyData() {
- delete d;
- d = 0;
- }
private:
friend struct Function;
@@ -735,11 +726,21 @@ struct Ret: Stmt {
struct Phi: Stmt {
Temp *targetTemp;
+ struct Data {
+ QVector<Expr *> incoming; // used by Phi nodes
+ };
- Phi(int id): Stmt(id) {}
+ Data *d;
+
+ Phi(int id): Stmt(id), d(0) {}
virtual void accept(StmtVisitor *v) { v->visitPhi(this); }
virtual Phi *asPhi() { return this; }
+
+ void destroyData() {
+ delete d;
+ d = 0;
+ }
};
struct Q_QML_PRIVATE_EXPORT Module {
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 789732bf07..f42fd5228d 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -1277,7 +1277,7 @@ public:
void insertPhiNode(const Temp &a, BasicBlock *y, IR::Function *f) {
Phi *phiNode = f->NewStmt<Phi>();
- phiNode->d = new Stmt::Data;
+ phiNode->d = new Phi::Data;
phiNode->targetTemp = f->New<Temp>();
phiNode->targetTemp->init(a.kind, a.index);
y->prependStatement(phiNode);
@@ -4532,7 +4532,7 @@ protected:
clonedStmt = phi;
phi->targetTemp = clone(stmt->targetTemp);
- phi->d = new Stmt::Data;
+ phi->d = new Phi::Data;
foreach (Expr *in, stmt->d->incoming)
phi->d->incoming.append(clone(in));
block->appendStatement(phi);