diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-05-07 11:02:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-28 15:34:45 +0200 |
commit | 4a2c3f319485dd1df008ec2d7e262d860952b3df (patch) | |
tree | d96433656c342855f0f98f24b51fd7723c73cfb1 /src/qml/compiler/qv4jsir_p.h | |
parent | cc1929da585664aa16c53e5c0cd624fe5e699345 (diff) |
V4 IR: make statement numbering fixed and clean up statement worklists.
Every statement in the IR now gets a fixed unique number. This number
can be used to store statements or information for a statement into an
array where the number is used as an index. This removes the need for
many hashes.
In the process of changing the code the two statement worklists in the
optimizer are merged into one. A single instance can be (and is) re-used
by the various algorithms.
Change-Id: I8f49ec7b1df79cf6914c5747f5d2c994dad110b2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4jsir_p.h')
-rw-r--r-- | src/qml/compiler/qv4jsir_p.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index ea866f67f1..6b2f4a90a7 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -387,7 +387,11 @@ struct Q_AUTOTEST_EXPORT Temp: Expr { // Used when temp is used as base in member expression MemberExpressionResolver memberResolver; - Temp(): kind(Invalid) {} + Temp() + : index((1 << 28) - 1) + , kind(Invalid) + , isReadOnly(0) + {} void init(unsigned kind, unsigned index) { @@ -614,11 +618,13 @@ struct Stmt { QVector<Expr *> incoming; // used by Phi nodes }; + enum { InvalidId = -1 }; + Data *d; - int id; QQmlJS::AST::SourceLocation location; - Stmt(): d(0), id(-1) {} + explicit Stmt(int id): d(0), _id(id) {} + virtual ~Stmt() { #ifdef Q_CC_MSVC @@ -637,17 +643,25 @@ struct Stmt { virtual Ret *asRet() { return 0; } virtual Phi *asPhi() { return 0; } + int id() const { return _id; } + private: // For memory management in BasicBlock friend struct BasicBlock; void destroyData() { delete d; d = 0; } + +private: + friend struct Function; + int _id; }; struct Exp: Stmt { Expr *expr; + Exp(int id): Stmt(id) {} + void init(Expr *expr) { this->expr = expr; @@ -663,6 +677,8 @@ struct Move: Stmt { Expr *source; bool swap; + Move(int id): Stmt(id) {} + void init(Expr *target, Expr *source) { this->target = target; @@ -678,6 +694,8 @@ struct Move: Stmt { struct Jump: Stmt { BasicBlock *target; + Jump(int id): Stmt(id) {} + void init(BasicBlock *target) { this->target = target; @@ -694,6 +712,8 @@ struct CJump: Stmt { BasicBlock *iftrue; BasicBlock *iffalse; + CJump(int id): Stmt(id) {} + void init(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse) { this->cond = cond; @@ -710,6 +730,8 @@ struct CJump: Stmt { struct Ret: Stmt { Expr *expr; + Ret(int id): Stmt(id) {} + void init(Expr *expr) { this->expr = expr; @@ -724,6 +746,8 @@ struct Ret: Stmt { struct Phi: Stmt { Temp *targetTemp; + Phi(int id): Stmt(id) {} + virtual void accept(StmtVisitor *v) { v->visitPhi(this); } virtual Phi *asPhi() { return this; } }; @@ -976,7 +1000,10 @@ struct Function { PropertyDependencyMap contextObjectPropertyDependencies; PropertyDependencyMap scopeObjectPropertyDependencies; - template <typename _Tp> _Tp *New() { return new (pool->allocate(sizeof(_Tp))) _Tp(); } + template <typename T> T *New() { return new (pool->allocate(sizeof(T))) T(); } + template <typename T> T *NewStmt() { + return new (pool->allocate(sizeof(T))) T(getNewStatementId()); + } Function(Module *module, Function *outer, const QString &name); ~Function(); @@ -1016,9 +1043,14 @@ struct Function { void setScheduledBlocks(const QVector<BasicBlock *> &scheduled); void renumberBasicBlocks(); + unsigned getNewStatementId() { return _statementCount++; } + unsigned statementCount() const { return _statementCount; } + void renumberForLifeRanges(); + private: QVector<BasicBlock *> _basicBlocks; QVector<BasicBlock *> *_allBasicBlocks; + unsigned _statementCount; }; class CloneExpr: protected IR::ExprVisitor |