Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: src/hydrogen.cc

Issue 6685045: Add support for unary plus in hydrogen compiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 6cb2b240a95b61103609b49d4f2532282985591d..4a99aa90b76e98d13daada80238b42f68d001bff 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -485,6 +485,11 @@ HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer,
}
+HConstant* HGraph::GetConstant0() {
+ return GetConstant(&constant_0_, Smi::FromInt(0));
+}
+
+
HConstant* HGraph::GetConstant1() {
return GetConstant(&constant_1_, Smi::FromInt(1));
}
@@ -4519,7 +4524,7 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
VisitForEffect(expr->expression());
}
- } else if (op == Token::BIT_NOT || op == Token::SUB) {
+ } else if (op == Token::BIT_NOT || op == Token::SUB || op == Token::ADD) {
VISIT_FOR_VALUE(expr->expression());
HValue* value = Pop();
HInstruction* instr = NULL;
@@ -4528,8 +4533,10 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
instr = new HBitNot(value);
break;
case Token::SUB:
- instr = new HMul(graph_->GetConstantMinus1(), value);
+ instr = new HSub(graph_->GetConstant0(), value);
Kevin Millikin (Chromium) 2011/03/14 14:18:46 I'm suspicious of this case. Isn't it true that:
Lasse Reichstein 2011/03/15 12:18:33 Argh, foiled again by -0. Yes, you are correct. In
break;
+ case Token::ADD:
+ instr = new HSub(value, graph_->GetConstant0());
Kevin Millikin (Chromium) 2011/03/14 14:18:46 I'm also suspicious of this: +(-0) = 0-(-0) = 0+0
Lasse Reichstein 2011/03/15 12:18:33 Agree, that's bad too.
default:
UNREACHABLE();
break;
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698