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

Side by Side Diff: src/hydrogen.cc

Issue 21782002: Replaced unary negation by multiplication with -1. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 Add<HStoreKeyed>(object_elements, key_constant, value, kind); 1711 Add<HStoreKeyed>(object_elements, key_constant, value, kind);
1712 } 1712 }
1713 } 1713 }
1714 1714
1715 return object; 1715 return object;
1716 } 1716 }
1717 1717
1718 1718
1719 HInstruction* HGraphBuilder::BuildUnaryMathOp( 1719 HInstruction* HGraphBuilder::BuildUnaryMathOp(
1720 HValue* input, Handle<Type> type, Token::Value operation) { 1720 HValue* input, Handle<Type> type, Token::Value operation) {
1721 ASSERT_EQ(Token::BIT_NOT, operation);
1721 // We only handle the numeric cases here 1722 // We only handle the numeric cases here
1722 type = handle( 1723 type = handle(
1723 Type::Intersect(type, handle(Type::Number(), isolate())), isolate()); 1724 Type::Intersect(type, handle(Type::Number(), isolate())), isolate());
1724 1725 if (type->Is(Type::None())) {
1725 switch (operation) { 1726 Add<HDeoptimize>(Deoptimizer::SOFT);
1726 default:
1727 UNREACHABLE();
1728 case Token::SUB: {
1729 HInstruction* instr =
1730 NewUncasted<HMul>(input, graph()->GetConstantMinus1());
1731 Representation rep = Representation::FromType(type);
1732 if (type->Is(Type::None())) {
1733 Add<HDeoptimize>(Deoptimizer::SOFT);
1734 }
1735 if (instr->IsBinaryOperation()) {
1736 HBinaryOperation* binop = HBinaryOperation::cast(instr);
1737 binop->set_observed_input_representation(1, rep);
1738 binop->set_observed_input_representation(2, rep);
1739 }
1740 return instr;
1741 }
1742 case Token::BIT_NOT:
1743 if (type->Is(Type::None())) {
1744 Add<HDeoptimize>(Deoptimizer::SOFT);
1745 }
1746 return New<HBitNot>(input);
1747 } 1727 }
1728 return New<HBitNot>(input);
1748 } 1729 }
1749 1730
1750 1731
1751 void HGraphBuilder::BuildCompareNil( 1732 void HGraphBuilder::BuildCompareNil(
1752 HValue* value, 1733 HValue* value,
1753 Handle<Type> type, 1734 Handle<Type> type,
1754 int position, 1735 int position,
1755 HIfContinuation* continuation) { 1736 HIfContinuation* continuation) {
1756 IfBuilder if_nil(this, position); 1737 IfBuilder if_nil(this, position);
1757 bool needs_or = false; 1738 bool needs_or = false;
(...skipping 5455 matching lines...) Expand 10 before | Expand all | Expand 10 after
7213 7194
7214 7195
7215 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { 7196 void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
7216 ASSERT(!HasStackOverflow()); 7197 ASSERT(!HasStackOverflow());
7217 ASSERT(current_block() != NULL); 7198 ASSERT(current_block() != NULL);
7218 ASSERT(current_block()->HasPredecessor()); 7199 ASSERT(current_block()->HasPredecessor());
7219 switch (expr->op()) { 7200 switch (expr->op()) {
7220 case Token::DELETE: return VisitDelete(expr); 7201 case Token::DELETE: return VisitDelete(expr);
7221 case Token::VOID: return VisitVoid(expr); 7202 case Token::VOID: return VisitVoid(expr);
7222 case Token::TYPEOF: return VisitTypeof(expr); 7203 case Token::TYPEOF: return VisitTypeof(expr);
7223 case Token::SUB: return VisitSub(expr);
7224 case Token::BIT_NOT: return VisitBitNot(expr); 7204 case Token::BIT_NOT: return VisitBitNot(expr);
7225 case Token::NOT: return VisitNot(expr); 7205 case Token::NOT: return VisitNot(expr);
7226 default: UNREACHABLE(); 7206 default: UNREACHABLE();
7227 } 7207 }
7228 } 7208 }
7229 7209
7230 7210
7231 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { 7211 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) {
7232 Property* prop = expr->expression()->AsProperty(); 7212 Property* prop = expr->expression()->AsProperty();
7233 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 7213 VariableProxy* proxy = expr->expression()->AsVariableProxy();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
7276 7256
7277 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { 7257 void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) {
7278 CHECK_ALIVE(VisitForTypeOf(expr->expression())); 7258 CHECK_ALIVE(VisitForTypeOf(expr->expression()));
7279 HValue* value = Pop(); 7259 HValue* value = Pop();
7280 HValue* context = environment()->context(); 7260 HValue* context = environment()->context();
7281 HInstruction* instr = new(zone()) HTypeof(context, value); 7261 HInstruction* instr = new(zone()) HTypeof(context, value);
7282 return ast_context()->ReturnInstruction(instr, expr->id()); 7262 return ast_context()->ReturnInstruction(instr, expr->id());
7283 } 7263 }
7284 7264
7285 7265
7286 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) {
7287 CHECK_ALIVE(VisitForValue(expr->expression()));
7288 Handle<Type> operand_type = expr->expression()->bounds().lower;
7289 HValue* value = TruncateToNumber(Pop(), &operand_type);
7290 HInstruction* instr = BuildUnaryMathOp(value, operand_type, Token::SUB);
7291 return ast_context()->ReturnInstruction(instr, expr->id());
7292 }
7293
7294
7295 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) { 7266 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) {
7296 CHECK_ALIVE(VisitForValue(expr->expression())); 7267 CHECK_ALIVE(VisitForValue(expr->expression()));
7297 Handle<Type> operand_type = expr->expression()->bounds().lower; 7268 Handle<Type> operand_type = expr->expression()->bounds().lower;
7298 HValue* value = TruncateToNumber(Pop(), &operand_type); 7269 HValue* value = TruncateToNumber(Pop(), &operand_type);
7299 HInstruction* instr = BuildUnaryMathOp(value, operand_type, Token::BIT_NOT); 7270 HInstruction* instr = BuildUnaryMathOp(value, operand_type, Token::BIT_NOT);
7300 return ast_context()->ReturnInstruction(instr, expr->id()); 7271 return ast_context()->ReturnInstruction(instr, expr->id());
7301 } 7272 }
7302 7273
7303 7274
7304 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { 7275 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) {
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after
9730 if (ShouldProduceTraceOutput()) { 9701 if (ShouldProduceTraceOutput()) {
9731 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9702 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9732 } 9703 }
9733 9704
9734 #ifdef DEBUG 9705 #ifdef DEBUG
9735 graph_->Verify(false); // No full verify. 9706 graph_->Verify(false); // No full verify.
9736 #endif 9707 #endif
9737 } 9708 }
9738 9709
9739 } } // namespace v8::internal 9710 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698