aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-07-27 15:12:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-13 14:52:27 +0200
commitfb74539d7d14c2444950474ad3f45a80443bfc73 (patch)
tree9cff8dec7d91213cf3a671a135ca2eee1add3f85
parent6cd8b6830039aea7f748527882942752f900cefd (diff)
Change post-increment/-decrement to not use a built-in.
Change-Id: I98af408db1e5d23e73a77d2614071bc998170f5e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/compiler/qv4codegen.cpp34
-rw-r--r--src/qml/compiler/qv4jsir_p.h4
2 files changed, 22 insertions, 16 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 969b35831e..e0c77cfa94 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1657,13 +1657,16 @@ bool Codegen::visit(PostDecrementExpression *ast)
throwReferenceError(ast->base->lastSourceLocation(), "Invalid left-hand side expression in postfix operation");
throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->decrementToken);
- if (_expr.accept(nx)) {
- move(*expr, binop(V4IR::OpSub, *expr, _block->CONST(V4IR::NumberType, 1)));
- } else {
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
- args->init(*expr);
- _expr.code = call(_block->NAME(V4IR::Name::builtin_postdecrement, ast->lastSourceLocation().startLine, ast->lastSourceLocation().startColumn), args);
- }
+ const unsigned oldValue = _block->newTemp();
+ move(_block->TEMP(oldValue), unop(V4IR::OpUPlus, *expr));
+
+ const unsigned newValue = _block->newTemp();
+ move(_block->TEMP(newValue), binop(V4IR::OpSub, _block->TEMP(oldValue), _block->CONST(V4IR::NumberType, 1)));
+ move(*expr, _block->TEMP(newValue));
+
+ if (!_expr.accept(nx))
+ _expr.code = _block->TEMP(oldValue);
+
return false;
}
@@ -1674,13 +1677,16 @@ bool Codegen::visit(PostIncrementExpression *ast)
throwReferenceError(ast->base->lastSourceLocation(), "Invalid left-hand side expression in postfix operation");
throwSyntaxErrorOnEvalOrArgumentsInStrictMode(*expr, ast->incrementToken);
- if (_expr.accept(nx)) {
- move(*expr, binop(V4IR::OpAdd, unop(V4IR::OpUPlus, *expr), _block->CONST(V4IR::NumberType, 1)));
- } else {
- V4IR::ExprList *args = _function->New<V4IR::ExprList>();
- args->init(*expr);
- _expr.code = call(_block->NAME(V4IR::Name::builtin_postincrement, ast->lastSourceLocation().startLine, ast->lastSourceLocation().startColumn), args);
- }
+ const unsigned oldValue = _block->newTemp();
+ move(_block->TEMP(oldValue), unop(V4IR::OpUPlus, *expr));
+
+ const unsigned newValue = _block->newTemp();
+ move(_block->TEMP(newValue), binop(V4IR::OpAdd, _block->TEMP(oldValue), _block->CONST(V4IR::NumberType, 1)));
+ move(*expr, _block->TEMP(newValue));
+
+ if (!_expr.accept(nx))
+ _expr.code = _block->TEMP(oldValue);
+
return false;
}
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index d322ea8a96..4b1a334569 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -302,8 +302,8 @@ struct Name: Expr {
builtin_invalid,
builtin_typeof,
builtin_delete,
- builtin_postincrement,
- builtin_postdecrement,
+ builtin_postincrement, // TODO: remove
+ builtin_postdecrement, // TODO: remove
builtin_throw,
builtin_finish_try,
builtin_foreach_iterator_object,