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

Side by Side Diff: src/hydrogen.cc

Issue 6880276: Use type info for count operation in Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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') | src/type-info.h » ('j') | src/type-info.cc » ('J')
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 4635 matching lines...) Expand 10 before | Expand all | Expand 10 after
4646 break; 4646 break;
4647 default: 4647 default:
4648 return Bailout("Value: unsupported unary operation"); 4648 return Bailout("Value: unsupported unary operation");
4649 break; 4649 break;
4650 } 4650 }
4651 ast_context()->ReturnInstruction(instr, expr->id()); 4651 ast_context()->ReturnInstruction(instr, expr->id());
4652 } 4652 }
4653 } 4653 }
4654 4654
4655 4655
4656 HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) { 4656 HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
4657 bool increment,
4658 CountOperation* expr) {
4657 HConstant* delta = increment 4659 HConstant* delta = increment
4658 ? graph_->GetConstant1() 4660 ? graph_->GetConstant1()
4659 : graph_->GetConstantMinus1(); 4661 : graph_->GetConstantMinus1();
4660 HInstruction* instr = new(zone()) HAdd(value, delta); 4662 HInstruction* instr = new(zone()) HAdd(value, delta);
4661 AssumeRepresentation(instr, Representation::Integer32()); 4663 Representation rep = ToRepresentation(oracle()->IncrementType(expr));
4664 if (rep.Equals(Representation::Tagged())) {
fschneider 2011/04/29 08:56:22 you can write if (rep.IsTagged()) Until we supp
William Hesse 2011/04/29 09:20:34 Done both. We generate the int32 representation.
4665 Bailout("Count operation with non-number input.");
4666 } else {
4667 AssumeRepresentation(instr, rep);
4668 }
4662 return instr; 4669 return instr;
4663 } 4670 }
4664 4671
4665 4672
4666 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { 4673 void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
4667 ASSERT(!HasStackOverflow()); 4674 ASSERT(!HasStackOverflow());
4668 ASSERT(current_block() != NULL); 4675 ASSERT(current_block() != NULL);
4669 ASSERT(current_block()->HasPredecessor()); 4676 ASSERT(current_block()->HasPredecessor());
4670 Expression* target = expr->expression(); 4677 Expression* target = expr->expression();
4671 VariableProxy* proxy = target->AsVariableProxy(); 4678 VariableProxy* proxy = target->AsVariableProxy();
4672 Variable* var = proxy->AsVariable(); 4679 Variable* var = proxy->AsVariable();
4673 Property* prop = target->AsProperty(); 4680 Property* prop = target->AsProperty();
4674 ASSERT(var == NULL || prop == NULL); 4681 ASSERT(var == NULL || prop == NULL);
4675 bool inc = expr->op() == Token::INC; 4682 bool inc = expr->op() == Token::INC;
4676 4683
4677 if (var != NULL) { 4684 if (var != NULL) {
4678 CHECK_ALIVE(VisitForValue(target)); 4685 CHECK_ALIVE(VisitForValue(target));
4679 4686
4680 // Match the full code generator stack by simulating an extra stack 4687 // Match the full code generator stack by simulating an extra stack
4681 // element for postfix operations in a non-effect context. 4688 // element for postfix operations in a non-effect context.
4682 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); 4689 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect();
4683 HValue* before = has_extra ? Top() : Pop(); 4690 HValue* before = has_extra ? Top() : Pop();
4684 HInstruction* after = BuildIncrement(before, inc); 4691 HInstruction* after = BuildIncrement(before, inc, expr);
4685 AddInstruction(after); 4692 AddInstruction(after);
4686 Push(after); 4693 Push(after);
4687 4694
4688 if (var->is_global()) { 4695 if (var->is_global()) {
4689 HandleGlobalVariableAssignment(var, 4696 HandleGlobalVariableAssignment(var,
4690 after, 4697 after,
4691 expr->position(), 4698 expr->position(),
4692 expr->AssignmentId()); 4699 expr->AssignmentId());
4693 } else if (var->IsStackAllocated()) { 4700 } else if (var->IsStackAllocated()) {
4694 Bind(var, after); 4701 Bind(var, after);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4726 load = BuildLoadNamed(obj, prop, map, name); 4733 load = BuildLoadNamed(obj, prop, map, name);
4727 } else { 4734 } else {
4728 load = BuildLoadNamedGeneric(obj, prop); 4735 load = BuildLoadNamedGeneric(obj, prop);
4729 } 4736 }
4730 PushAndAdd(load); 4737 PushAndAdd(load);
4731 if (load->HasSideEffects()) AddSimulate(expr->CountId()); 4738 if (load->HasSideEffects()) AddSimulate(expr->CountId());
4732 4739
4733 HValue* before = Pop(); 4740 HValue* before = Pop();
4734 // There is no deoptimization to after the increment, so we don't need 4741 // There is no deoptimization to after the increment, so we don't need
4735 // to simulate the expression stack after this instruction. 4742 // to simulate the expression stack after this instruction.
4736 HInstruction* after = BuildIncrement(before, inc); 4743 HInstruction* after = BuildIncrement(before, inc, expr);
4737 AddInstruction(after); 4744 AddInstruction(after);
4738 4745
4739 HInstruction* store = BuildStoreNamed(obj, after, prop); 4746 HInstruction* store = BuildStoreNamed(obj, after, prop);
4740 AddInstruction(store); 4747 AddInstruction(store);
4741 4748
4742 // Overwrite the receiver in the bailout environment with the result 4749 // Overwrite the receiver in the bailout environment with the result
4743 // of the operation, and the placeholder with the original value if 4750 // of the operation, and the placeholder with the original value if
4744 // necessary. 4751 // necessary.
4745 environment()->SetExpressionStackAt(0, after); 4752 environment()->SetExpressionStackAt(0, after);
4746 if (has_extra) environment()->SetExpressionStackAt(1, before); 4753 if (has_extra) environment()->SetExpressionStackAt(1, before);
(...skipping 15 matching lines...) Expand all
4762 HValue* obj = environment()->ExpressionStackAt(1); 4769 HValue* obj = environment()->ExpressionStackAt(1);
4763 HValue* key = environment()->ExpressionStackAt(0); 4770 HValue* key = environment()->ExpressionStackAt(0);
4764 4771
4765 HInstruction* load = BuildLoadKeyed(obj, key, prop); 4772 HInstruction* load = BuildLoadKeyed(obj, key, prop);
4766 PushAndAdd(load); 4773 PushAndAdd(load);
4767 if (load->HasSideEffects()) AddSimulate(expr->CountId()); 4774 if (load->HasSideEffects()) AddSimulate(expr->CountId());
4768 4775
4769 HValue* before = Pop(); 4776 HValue* before = Pop();
4770 // There is no deoptimization to after the increment, so we don't need 4777 // There is no deoptimization to after the increment, so we don't need
4771 // to simulate the expression stack after this instruction. 4778 // to simulate the expression stack after this instruction.
4772 HInstruction* after = BuildIncrement(before, inc); 4779 HInstruction* after = BuildIncrement(before, inc, expr);
4773 AddInstruction(after); 4780 AddInstruction(after);
4774 4781
4775 expr->RecordTypeFeedback(oracle()); 4782 expr->RecordTypeFeedback(oracle());
4776 HInstruction* store = BuildStoreKeyed(obj, key, after, expr); 4783 HInstruction* store = BuildStoreKeyed(obj, key, after, expr);
4777 AddInstruction(store); 4784 AddInstruction(store);
4778 4785
4779 // Drop the key from the bailout environment. Overwrite the receiver 4786 // Drop the key from the bailout environment. Overwrite the receiver
4780 // with the result of the operation, and the placeholder with the 4787 // with the result of the operation, and the placeholder with the
4781 // original value if necessary. 4788 // original value if necessary.
4782 Drop(1); 4789 Drop(1);
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
6071 } 6078 }
6072 } 6079 }
6073 6080
6074 #ifdef DEBUG 6081 #ifdef DEBUG
6075 if (graph_ != NULL) graph_->Verify(); 6082 if (graph_ != NULL) graph_->Verify();
6076 if (allocator_ != NULL) allocator_->Verify(); 6083 if (allocator_ != NULL) allocator_->Verify();
6077 #endif 6084 #endif
6078 } 6085 }
6079 6086
6080 } } // namespace v8::internal 6087 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/type-info.h » ('j') | src/type-info.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698