diff options
| author | Liang Qi <liang.qi@qt.io> | 2017-02-28 13:04:16 +0100 |
|---|---|---|
| committer | Liang Qi <liang.qi@qt.io> | 2017-02-28 13:04:17 +0100 |
| commit | afec9016d0fd51345ea93a1bbadb99b5c3fdf629 (patch) | |
| tree | 39aa0d02457c643065fbfb298645b2f3877c92bb /src/qml/compiler/qv4codegen.cpp | |
| parent | bb1acc24587ebdecc4051ef4b573ef32cfb8a8c5 (diff) | |
| parent | ba68c325688acf3072715757480497524f61c425 (diff) | |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I92b13a9c1727644d63e125c1e6f1fdac72720ad7
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
| -rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index fae4e48066..0afc97e4bf 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -73,6 +73,25 @@ static inline void setLocation(IR::Stmt *s, const SourceLocation &loc) s->location = loc; } +static bool cjumpCanHandle(IR::AluOp op) +{ + switch (op) { + case IR::OpIn: + case IR::OpInstanceof: + case IR::OpEqual: + case IR::OpNotEqual: + case IR::OpGe: + case IR::OpGt: + case IR::OpLe: + case IR::OpLt: + case IR::OpStrictEqual: + case IR::OpStrictNotEqual: + return true; + default: + return false; + } +} + Codegen::ScanFunctions::ScanFunctions(Codegen *cg, const QString &sourceCode, CompilationMode defaultProgramMode) : _cg(cg) , _sourceCode(sourceCode) @@ -727,7 +746,7 @@ IR::Stmt *Codegen::cjump(IR::Expr *cond, IR::BasicBlock *iftrue, IR::BasicBlock if (hasError) return 0; - if (! (cond->asTemp() || cond->asBinop())) { + if (! (cond->asTemp() || (cond->asBinop() && cjumpCanHandle(cond->asBinop()->op)) )) { const unsigned t = _block->newTemp(); move(_block->TEMP(t), cond); cond = _block->TEMP(t); @@ -1293,14 +1312,7 @@ bool Codegen::visit(BinaryExpression *ast) if (_expr.accept(cx)) { setLocation(cjump(binop(IR::binaryOperator(ast->op), left, *right, ast->operatorToken), _expr.iftrue, _expr.iffalse), ast->operatorToken); } else { - IR::Expr *e = binop(IR::binaryOperator(ast->op), left, *right, ast->operatorToken); - if (e->asConst() || e->asString()) - _expr.code = e; - else { - const unsigned t = _block->newTemp(); - setLocation(move(_block->TEMP(t), e), ast->operatorToken); - _expr.code = _block->TEMP(t); - } + _expr.code = binop(IR::binaryOperator(ast->op), left, *right, ast->operatorToken); } break; } @@ -1326,14 +1338,7 @@ bool Codegen::visit(BinaryExpression *ast) if (hasError) return false; - IR::Expr *e = binop(IR::binaryOperator(ast->op), left, *right, ast->operatorToken); - if (e->asConst() || e->asString()) - _expr.code = e; - else { - const unsigned t = _block->newTemp(); - setLocation(move(_block->TEMP(t), e), ast->operatorToken); - _expr.code = _block->TEMP(t); - } + _expr.code = binop(IR::binaryOperator(ast->op), left, *right, ast->operatorToken); break; } |
