OLD | NEW |
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 Loading... |
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.IsTagged()) { |
| 4665 rep = Representation::Integer32(); |
| 4666 } |
| 4667 AssumeRepresentation(instr, rep); |
4662 return instr; | 4668 return instr; |
4663 } | 4669 } |
4664 | 4670 |
4665 | 4671 |
4666 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { | 4672 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { |
4667 ASSERT(!HasStackOverflow()); | 4673 ASSERT(!HasStackOverflow()); |
4668 ASSERT(current_block() != NULL); | 4674 ASSERT(current_block() != NULL); |
4669 ASSERT(current_block()->HasPredecessor()); | 4675 ASSERT(current_block()->HasPredecessor()); |
4670 Expression* target = expr->expression(); | 4676 Expression* target = expr->expression(); |
4671 VariableProxy* proxy = target->AsVariableProxy(); | 4677 VariableProxy* proxy = target->AsVariableProxy(); |
4672 Variable* var = proxy->AsVariable(); | 4678 Variable* var = proxy->AsVariable(); |
4673 Property* prop = target->AsProperty(); | 4679 Property* prop = target->AsProperty(); |
4674 ASSERT(var == NULL || prop == NULL); | 4680 ASSERT(var == NULL || prop == NULL); |
4675 bool inc = expr->op() == Token::INC; | 4681 bool inc = expr->op() == Token::INC; |
4676 | 4682 |
4677 if (var != NULL) { | 4683 if (var != NULL) { |
4678 CHECK_ALIVE(VisitForValue(target)); | 4684 CHECK_ALIVE(VisitForValue(target)); |
4679 | 4685 |
4680 // Match the full code generator stack by simulating an extra stack | 4686 // Match the full code generator stack by simulating an extra stack |
4681 // element for postfix operations in a non-effect context. | 4687 // element for postfix operations in a non-effect context. |
4682 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); | 4688 bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); |
4683 HValue* before = has_extra ? Top() : Pop(); | 4689 HValue* before = has_extra ? Top() : Pop(); |
4684 HInstruction* after = BuildIncrement(before, inc); | 4690 HInstruction* after = BuildIncrement(before, inc, expr); |
4685 AddInstruction(after); | 4691 AddInstruction(after); |
4686 Push(after); | 4692 Push(after); |
4687 | 4693 |
4688 if (var->is_global()) { | 4694 if (var->is_global()) { |
4689 HandleGlobalVariableAssignment(var, | 4695 HandleGlobalVariableAssignment(var, |
4690 after, | 4696 after, |
4691 expr->position(), | 4697 expr->position(), |
4692 expr->AssignmentId()); | 4698 expr->AssignmentId()); |
4693 } else if (var->IsStackAllocated()) { | 4699 } else if (var->IsStackAllocated()) { |
4694 Bind(var, after); | 4700 Bind(var, after); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4726 load = BuildLoadNamed(obj, prop, map, name); | 4732 load = BuildLoadNamed(obj, prop, map, name); |
4727 } else { | 4733 } else { |
4728 load = BuildLoadNamedGeneric(obj, prop); | 4734 load = BuildLoadNamedGeneric(obj, prop); |
4729 } | 4735 } |
4730 PushAndAdd(load); | 4736 PushAndAdd(load); |
4731 if (load->HasSideEffects()) AddSimulate(expr->CountId()); | 4737 if (load->HasSideEffects()) AddSimulate(expr->CountId()); |
4732 | 4738 |
4733 HValue* before = Pop(); | 4739 HValue* before = Pop(); |
4734 // There is no deoptimization to after the increment, so we don't need | 4740 // There is no deoptimization to after the increment, so we don't need |
4735 // to simulate the expression stack after this instruction. | 4741 // to simulate the expression stack after this instruction. |
4736 HInstruction* after = BuildIncrement(before, inc); | 4742 HInstruction* after = BuildIncrement(before, inc, expr); |
4737 AddInstruction(after); | 4743 AddInstruction(after); |
4738 | 4744 |
4739 HInstruction* store = BuildStoreNamed(obj, after, prop); | 4745 HInstruction* store = BuildStoreNamed(obj, after, prop); |
4740 AddInstruction(store); | 4746 AddInstruction(store); |
4741 | 4747 |
4742 // Overwrite the receiver in the bailout environment with the result | 4748 // Overwrite the receiver in the bailout environment with the result |
4743 // of the operation, and the placeholder with the original value if | 4749 // of the operation, and the placeholder with the original value if |
4744 // necessary. | 4750 // necessary. |
4745 environment()->SetExpressionStackAt(0, after); | 4751 environment()->SetExpressionStackAt(0, after); |
4746 if (has_extra) environment()->SetExpressionStackAt(1, before); | 4752 if (has_extra) environment()->SetExpressionStackAt(1, before); |
(...skipping 15 matching lines...) Expand all Loading... |
4762 HValue* obj = environment()->ExpressionStackAt(1); | 4768 HValue* obj = environment()->ExpressionStackAt(1); |
4763 HValue* key = environment()->ExpressionStackAt(0); | 4769 HValue* key = environment()->ExpressionStackAt(0); |
4764 | 4770 |
4765 HInstruction* load = BuildLoadKeyed(obj, key, prop); | 4771 HInstruction* load = BuildLoadKeyed(obj, key, prop); |
4766 PushAndAdd(load); | 4772 PushAndAdd(load); |
4767 if (load->HasSideEffects()) AddSimulate(expr->CountId()); | 4773 if (load->HasSideEffects()) AddSimulate(expr->CountId()); |
4768 | 4774 |
4769 HValue* before = Pop(); | 4775 HValue* before = Pop(); |
4770 // There is no deoptimization to after the increment, so we don't need | 4776 // There is no deoptimization to after the increment, so we don't need |
4771 // to simulate the expression stack after this instruction. | 4777 // to simulate the expression stack after this instruction. |
4772 HInstruction* after = BuildIncrement(before, inc); | 4778 HInstruction* after = BuildIncrement(before, inc, expr); |
4773 AddInstruction(after); | 4779 AddInstruction(after); |
4774 | 4780 |
4775 expr->RecordTypeFeedback(oracle()); | 4781 expr->RecordTypeFeedback(oracle()); |
4776 HInstruction* store = BuildStoreKeyed(obj, key, after, expr); | 4782 HInstruction* store = BuildStoreKeyed(obj, key, after, expr); |
4777 AddInstruction(store); | 4783 AddInstruction(store); |
4778 | 4784 |
4779 // Drop the key from the bailout environment. Overwrite the receiver | 4785 // Drop the key from the bailout environment. Overwrite the receiver |
4780 // with the result of the operation, and the placeholder with the | 4786 // with the result of the operation, and the placeholder with the |
4781 // original value if necessary. | 4787 // original value if necessary. |
4782 Drop(1); | 4788 Drop(1); |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6071 } | 6077 } |
6072 } | 6078 } |
6073 | 6079 |
6074 #ifdef DEBUG | 6080 #ifdef DEBUG |
6075 if (graph_ != NULL) graph_->Verify(); | 6081 if (graph_ != NULL) graph_->Verify(); |
6076 if (allocator_ != NULL) allocator_->Verify(); | 6082 if (allocator_ != NULL) allocator_->Verify(); |
6077 #endif | 6083 #endif |
6078 } | 6084 } |
6079 | 6085 |
6080 } } // namespace v8::internal | 6086 } } // namespace v8::internal |
OLD | NEW |