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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 if (!pointer->is_set()) { 478 if (!pointer->is_set()) {
479 HConstant* constant = new HConstant(Handle<Object>(value), 479 HConstant* constant = new HConstant(Handle<Object>(value),
480 Representation::Tagged()); 480 Representation::Tagged());
481 constant->InsertAfter(GetConstantUndefined()); 481 constant->InsertAfter(GetConstantUndefined());
482 pointer->set(constant); 482 pointer->set(constant);
483 } 483 }
484 return pointer->get(); 484 return pointer->get();
485 } 485 }
486 486
487 487
488 HConstant* HGraph::GetConstant0() {
489 return GetConstant(&constant_0_, Smi::FromInt(0));
490 }
491
492
488 HConstant* HGraph::GetConstant1() { 493 HConstant* HGraph::GetConstant1() {
489 return GetConstant(&constant_1_, Smi::FromInt(1)); 494 return GetConstant(&constant_1_, Smi::FromInt(1));
490 } 495 }
491 496
492 497
493 HConstant* HGraph::GetConstantMinus1() { 498 HConstant* HGraph::GetConstantMinus1() {
494 return GetConstant(&constant_minus1_, Smi::FromInt(-1)); 499 return GetConstant(&constant_minus1_, Smi::FromInt(-1));
495 } 500 }
496 501
497 502
(...skipping 4014 matching lines...) Expand 10 before | Expand all | Expand 10 after
4512 4517
4513 HBasicBlock* join = 4518 HBasicBlock* join =
4514 CreateJoin(materialize_false, materialize_true, expr->id()); 4519 CreateJoin(materialize_false, materialize_true, expr->id());
4515 set_current_block(join); 4520 set_current_block(join);
4516 ast_context()->ReturnValue(Pop()); 4521 ast_context()->ReturnValue(Pop());
4517 } else { 4522 } else {
4518 ASSERT(ast_context()->IsEffect()); 4523 ASSERT(ast_context()->IsEffect());
4519 VisitForEffect(expr->expression()); 4524 VisitForEffect(expr->expression());
4520 } 4525 }
4521 4526
4522 } else if (op == Token::BIT_NOT || op == Token::SUB) { 4527 } else if (op == Token::BIT_NOT || op == Token::SUB || op == Token::ADD) {
4523 VISIT_FOR_VALUE(expr->expression()); 4528 VISIT_FOR_VALUE(expr->expression());
4524 HValue* value = Pop(); 4529 HValue* value = Pop();
4525 HInstruction* instr = NULL; 4530 HInstruction* instr = NULL;
4526 switch (op) { 4531 switch (op) {
4527 case Token::BIT_NOT: 4532 case Token::BIT_NOT:
4528 instr = new HBitNot(value); 4533 instr = new HBitNot(value);
4529 break; 4534 break;
4530 case Token::SUB: 4535 case Token::SUB:
4531 instr = new HMul(graph_->GetConstantMinus1(), value); 4536 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
4532 break; 4537 break;
4538 case Token::ADD:
4539 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.
4533 default: 4540 default:
4534 UNREACHABLE(); 4541 UNREACHABLE();
4535 break; 4542 break;
4536 } 4543 }
4537 ast_context()->ReturnInstruction(instr, expr->id()); 4544 ast_context()->ReturnInstruction(instr, expr->id());
4538 } else if (op == Token::TYPEOF) { 4545 } else if (op == Token::TYPEOF) {
4539 VISIT_FOR_VALUE(expr->expression()); 4546 VISIT_FOR_VALUE(expr->expression());
4540 HValue* value = Pop(); 4547 HValue* value = Pop();
4541 ast_context()->ReturnInstruction(new HTypeof(value), expr->id()); 4548 ast_context()->ReturnInstruction(new HTypeof(value), expr->id());
4542 } else { 4549 } else {
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
5906 } 5913 }
5907 } 5914 }
5908 5915
5909 #ifdef DEBUG 5916 #ifdef DEBUG
5910 if (graph_ != NULL) graph_->Verify(); 5917 if (graph_ != NULL) graph_->Verify();
5911 if (allocator_ != NULL) allocator_->Verify(); 5918 if (allocator_ != NULL) allocator_->Verify();
5912 #endif 5919 #endif
5913 } 5920 }
5914 5921
5915 } } // namespace v8::internal 5922 } } // namespace v8::internal
OLDNEW
« 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