OLD | NEW |
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 8601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8612 } | 8612 } |
8613 | 8613 |
8614 | 8614 |
8615 HValue* HGraphBuilder::BuildBinaryOperation( | 8615 HValue* HGraphBuilder::BuildBinaryOperation( |
8616 Token::Value op, | 8616 Token::Value op, |
8617 HValue* left, | 8617 HValue* left, |
8618 HValue* right, | 8618 HValue* right, |
8619 Handle<Type> left_type, | 8619 Handle<Type> left_type, |
8620 Handle<Type> right_type, | 8620 Handle<Type> right_type, |
8621 Handle<Type> result_type, | 8621 Handle<Type> result_type, |
8622 Maybe<int> fixed_right_arg, | 8622 Maybe<int> fixed_right_arg) { |
8623 bool binop_stub) { | |
8624 | 8623 |
8625 Representation left_rep = Representation::FromType(left_type); | 8624 Representation left_rep = Representation::FromType(left_type); |
8626 Representation right_rep = Representation::FromType(right_type); | 8625 Representation right_rep = Representation::FromType(right_type); |
8627 | 8626 |
8628 bool maybe_string_add = op == Token::ADD && | 8627 bool maybe_string_add = op == Token::ADD && |
8629 (left_type->Maybe(Type::String()) || | 8628 (left_type->Maybe(Type::String()) || |
8630 right_type->Maybe(Type::String())); | 8629 right_type->Maybe(Type::String())); |
8631 | 8630 |
8632 if (left_type->Is(Type::None())) { | 8631 if (left_type->Is(Type::None())) { |
8633 Add<HDeoptimize>("Insufficient type feedback for LHS of binary operation", | 8632 Add<HDeoptimize>("Insufficient type feedback for LHS of binary operation", |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8682 ASSERT(left_type->Is(Type::String())); | 8681 ASSERT(left_type->Is(Type::String())); |
8683 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); | 8682 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); |
8684 Add<HPushArgument>(left); | 8683 Add<HPushArgument>(left); |
8685 Add<HPushArgument>(right); | 8684 Add<HPushArgument>(right); |
8686 return AddUncasted<HInvokeFunction>(function, 2); | 8685 return AddUncasted<HInvokeFunction>(function, 2); |
8687 } | 8686 } |
8688 | 8687 |
8689 return AddUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_NONE); | 8688 return AddUncasted<HStringAdd>(left, right, STRING_ADD_CHECK_NONE); |
8690 } | 8689 } |
8691 | 8690 |
8692 if (binop_stub) { | 8691 if (graph()->info()->IsStub()) { |
8693 left = EnforceNumberType(left, left_type); | 8692 left = EnforceNumberType(left, left_type); |
8694 right = EnforceNumberType(right, right_type); | 8693 right = EnforceNumberType(right, right_type); |
8695 } | 8694 } |
8696 | 8695 |
8697 Representation result_rep = Representation::FromType(result_type); | 8696 Representation result_rep = Representation::FromType(result_type); |
8698 | 8697 |
8699 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || | 8698 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || |
8700 (right_rep.IsTagged() && !right_rep.IsSmi()); | 8699 (right_rep.IsTagged() && !right_rep.IsSmi()); |
8701 | 8700 |
8702 HInstruction* instr = NULL; | 8701 HInstruction* instr = NULL; |
8703 // Only the stub is allowed to call into the runtime, since otherwise we would | 8702 // Only the stub is allowed to call into the runtime, since otherwise we would |
8704 // inline several instructions (including the two pushes) for every tagged | 8703 // inline several instructions (including the two pushes) for every tagged |
8705 // operation in optimized code, which is more expensive, than a stub call. | 8704 // operation in optimized code, which is more expensive, than a stub call. |
8706 if (binop_stub && is_non_primitive) { | 8705 if (graph()->info()->IsStub() && is_non_primitive) { |
8707 HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op)); | 8706 HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op)); |
8708 Add<HPushArgument>(left); | 8707 Add<HPushArgument>(left); |
8709 Add<HPushArgument>(right); | 8708 Add<HPushArgument>(right); |
8710 instr = AddUncasted<HInvokeFunction>(function, 2); | 8709 instr = AddUncasted<HInvokeFunction>(function, 2); |
8711 } else { | 8710 } else { |
8712 switch (op) { | 8711 switch (op) { |
8713 case Token::ADD: | 8712 case Token::ADD: |
8714 instr = AddUncasted<HAdd>(left, right); | 8713 instr = AddUncasted<HAdd>(left, right); |
8715 break; | 8714 break; |
8716 case Token::SUB: | 8715 case Token::SUB: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8771 default: | 8770 default: |
8772 UNREACHABLE(); | 8771 UNREACHABLE(); |
8773 } | 8772 } |
8774 } | 8773 } |
8775 | 8774 |
8776 if (instr->IsBinaryOperation()) { | 8775 if (instr->IsBinaryOperation()) { |
8777 HBinaryOperation* binop = HBinaryOperation::cast(instr); | 8776 HBinaryOperation* binop = HBinaryOperation::cast(instr); |
8778 binop->set_observed_input_representation(1, left_rep); | 8777 binop->set_observed_input_representation(1, left_rep); |
8779 binop->set_observed_input_representation(2, right_rep); | 8778 binop->set_observed_input_representation(2, right_rep); |
8780 binop->initialize_output_representation(result_rep); | 8779 binop->initialize_output_representation(result_rep); |
8781 if (binop_stub) { | 8780 if (graph()->info()->IsStub()) { |
8782 // Stub should not call into stub. | 8781 // Stub should not call into stub. |
8783 instr->SetFlag(HValue::kCannotBeTagged); | 8782 instr->SetFlag(HValue::kCannotBeTagged); |
8784 // And should truncate on HForceRepresentation already. | 8783 // And should truncate on HForceRepresentation already. |
8785 if (left->IsForceRepresentation()) { | 8784 if (left->IsForceRepresentation()) { |
8786 left->CopyFlag(HValue::kTruncatingToSmi, instr); | 8785 left->CopyFlag(HValue::kTruncatingToSmi, instr); |
8787 left->CopyFlag(HValue::kTruncatingToInt32, instr); | 8786 left->CopyFlag(HValue::kTruncatingToInt32, instr); |
8788 } | 8787 } |
8789 if (right->IsForceRepresentation()) { | 8788 if (right->IsForceRepresentation()) { |
8790 right->CopyFlag(HValue::kTruncatingToSmi, instr); | 8789 right->CopyFlag(HValue::kTruncatingToSmi, instr); |
8791 right->CopyFlag(HValue::kTruncatingToInt32, instr); | 8790 right->CopyFlag(HValue::kTruncatingToInt32, instr); |
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10665 if (ShouldProduceTraceOutput()) { | 10664 if (ShouldProduceTraceOutput()) { |
10666 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10665 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10667 } | 10666 } |
10668 | 10667 |
10669 #ifdef DEBUG | 10668 #ifdef DEBUG |
10670 graph_->Verify(false); // No full verify. | 10669 graph_->Verify(false); // No full verify. |
10671 #endif | 10670 #endif |
10672 } | 10671 } |
10673 | 10672 |
10674 } } // namespace v8::internal | 10673 } } // namespace v8::internal |
OLD | NEW |