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

Side by Side Diff: src/hydrogen.cc

Issue 6810015: Remove unnecessary AST node for ++ and -- operations. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 8 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/full-codegen.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 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 4594 matching lines...) Expand 10 before | Expand all | Expand 10 after
4605 break; 4605 break;
4606 default: 4606 default:
4607 BAILOUT("Value: unsupported unary operation"); 4607 BAILOUT("Value: unsupported unary operation");
4608 break; 4608 break;
4609 } 4609 }
4610 ast_context()->ReturnInstruction(instr, expr->id()); 4610 ast_context()->ReturnInstruction(instr, expr->id());
4611 } 4611 }
4612 } 4612 }
4613 4613
4614 4614
4615 void HGraphBuilder::VisitIncrementOperation(IncrementOperation* expr) {
4616 // IncrementOperation is never visited by the visitor. It only
4617 // occurs as a subexpression of CountOperation.
4618 UNREACHABLE();
4619 }
4620
4621
4622 HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) { 4615 HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) {
4623 HConstant* delta = increment 4616 HConstant* delta = increment
4624 ? graph_->GetConstant1() 4617 ? graph_->GetConstant1()
4625 : graph_->GetConstantMinus1(); 4618 : graph_->GetConstantMinus1();
4626 HInstruction* instr = new(zone()) HAdd(value, delta); 4619 HInstruction* instr = new(zone()) HAdd(value, delta);
4627 AssumeRepresentation(instr, Representation::Integer32()); 4620 AssumeRepresentation(instr, Representation::Integer32());
4628 return instr; 4621 return instr;
4629 } 4622 }
4630 4623
4631 4624
4632 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { 4625 void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
4633 IncrementOperation* increment = expr->increment(); 4626 Expression* target = expr->expression();
4634 Expression* target = increment->expression();
4635 VariableProxy* proxy = target->AsVariableProxy(); 4627 VariableProxy* proxy = target->AsVariableProxy();
4636 Variable* var = proxy->AsVariable(); 4628 Variable* var = proxy->AsVariable();
4637 Property* prop = target->AsProperty(); 4629 Property* prop = target->AsProperty();
4638 ASSERT(var == NULL || prop == NULL); 4630 ASSERT(var == NULL || prop == NULL);
4639 bool inc = expr->op() == Token::INC; 4631 bool inc = expr->op() == Token::INC;
4640 4632
4641 if (var != NULL) { 4633 if (var != NULL) {
4642 VISIT_FOR_VALUE(target); 4634 VISIT_FOR_VALUE(target);
4643 4635
4644 // Match the full code generator stack by simulating an extra stack 4636 // Match the full code generator stack by simulating an extra stack
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4685 4677
4686 HInstruction* load = NULL; 4678 HInstruction* load = NULL;
4687 if (prop->IsMonomorphic()) { 4679 if (prop->IsMonomorphic()) {
4688 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); 4680 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
4689 Handle<Map> map = prop->GetReceiverTypes()->first(); 4681 Handle<Map> map = prop->GetReceiverTypes()->first();
4690 load = BuildLoadNamed(obj, prop, map, name); 4682 load = BuildLoadNamed(obj, prop, map, name);
4691 } else { 4683 } else {
4692 load = BuildLoadNamedGeneric(obj, prop); 4684 load = BuildLoadNamedGeneric(obj, prop);
4693 } 4685 }
4694 PushAndAdd(load); 4686 PushAndAdd(load);
4695 if (load->HasSideEffects()) AddSimulate(increment->id()); 4687 if (load->HasSideEffects()) AddSimulate(expr->CountId());
4696 4688
4697 HValue* before = Pop(); 4689 HValue* before = Pop();
4698 // There is no deoptimization to after the increment, so we don't need 4690 // There is no deoptimization to after the increment, so we don't need
4699 // to simulate the expression stack after this instruction. 4691 // to simulate the expression stack after this instruction.
4700 HInstruction* after = BuildIncrement(before, inc); 4692 HInstruction* after = BuildIncrement(before, inc);
4701 AddInstruction(after); 4693 AddInstruction(after);
4702 4694
4703 HInstruction* store = BuildStoreNamed(obj, after, prop); 4695 HInstruction* store = BuildStoreNamed(obj, after, prop);
4704 AddInstruction(store); 4696 AddInstruction(store);
4705 4697
(...skipping 20 matching lines...) Expand all
4726 HValue* obj = environment()->ExpressionStackAt(1); 4718 HValue* obj = environment()->ExpressionStackAt(1);
4727 HValue* key = environment()->ExpressionStackAt(0); 4719 HValue* key = environment()->ExpressionStackAt(0);
4728 4720
4729 bool is_fast_elements = prop->IsMonomorphic() && 4721 bool is_fast_elements = prop->IsMonomorphic() &&
4730 prop->GetMonomorphicReceiverType()->has_fast_elements(); 4722 prop->GetMonomorphicReceiverType()->has_fast_elements();
4731 4723
4732 HInstruction* load = is_fast_elements 4724 HInstruction* load = is_fast_elements
4733 ? BuildLoadKeyedFastElement(obj, key, prop) 4725 ? BuildLoadKeyedFastElement(obj, key, prop)
4734 : BuildLoadKeyedGeneric(obj, key); 4726 : BuildLoadKeyedGeneric(obj, key);
4735 PushAndAdd(load); 4727 PushAndAdd(load);
4736 if (load->HasSideEffects()) AddSimulate(increment->id()); 4728 if (load->HasSideEffects()) AddSimulate(expr->CountId());
4737 4729
4738 HValue* before = Pop(); 4730 HValue* before = Pop();
4739 // There is no deoptimization to after the increment, so we don't need 4731 // There is no deoptimization to after the increment, so we don't need
4740 // to simulate the expression stack after this instruction. 4732 // to simulate the expression stack after this instruction.
4741 HInstruction* after = BuildIncrement(before, inc); 4733 HInstruction* after = BuildIncrement(before, inc);
4742 AddInstruction(after); 4734 AddInstruction(after);
4743 4735
4744 HInstruction* store = is_fast_elements 4736 HInstruction* store = is_fast_elements
4745 ? BuildStoreKeyedFastElement(obj, key, after, prop) 4737 ? BuildStoreKeyedFastElement(obj, key, after, prop)
4746 : BuildStoreKeyedGeneric(obj, key, after); 4738 : BuildStoreKeyedGeneric(obj, key, after);
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
6002 } 5994 }
6003 } 5995 }
6004 5996
6005 #ifdef DEBUG 5997 #ifdef DEBUG
6006 if (graph_ != NULL) graph_->Verify(); 5998 if (graph_ != NULL) graph_->Verify();
6007 if (allocator_ != NULL) allocator_->Verify(); 5999 if (allocator_ != NULL) allocator_->Verify();
6008 #endif 6000 #endif
6009 } 6001 }
6010 6002
6011 } } // namespace v8::internal 6003 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698