OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 if_nil.Else(); | 743 if_nil.Else(); |
744 if_nil.Return(graph()->GetConstant0()); | 744 if_nil.Return(graph()->GetConstant0()); |
745 } | 745 } |
746 if_nil.End(); | 746 if_nil.End(); |
747 return continuation.IsTrueReachable() | 747 return continuation.IsTrueReachable() |
748 ? graph()->GetConstant1() | 748 ? graph()->GetConstant1() |
749 : graph()->GetConstantUndefined(); | 749 : graph()->GetConstantUndefined(); |
750 } | 750 } |
751 | 751 |
752 | 752 |
753 Handle<Code> UnaryOpStub::GenerateCode() { | |
754 return DoGenerateCode(this); | |
755 } | |
756 | |
757 | |
758 HInstruction* UnaryOpStub::ToHInstruction(HValue* input, | |
759 Handle<Type> type, HGraphBuilder* builder, HContext* context) { | |
760 switch (operation_) { | |
761 default: | |
762 UNREACHABLE(); | |
763 case Token::SUB: { | |
764 HInstruction* minus = HMul::New(builder->zone(), context, | |
765 input, builder->graph()->GetConstantMinus1()); | |
766 if (type->Maybe(Type::Double())) { | |
767 // We have to force a double multiplication if we have seen double, | |
768 // otherwise we will deopt again. | |
769 minus->AssumeRepresentation(Representation::Double()); | |
danno
2013/06/21 16:38:04
Try to move this out with the other representation
| |
770 } | |
771 return minus; | |
772 } | |
773 case Token::BIT_NOT: | |
774 return new(builder->zone()) HBitNot(input); | |
775 } | |
776 } | |
777 | |
778 | |
779 template <> | |
780 HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() { | |
781 UnaryOpStub* stub = casted_stub(); | |
danno
2013/06/21 16:38:04
Please share this code with hydrogen, it should be
| |
782 Handle<Type> type = stub->GetType(graph()->isolate()); | |
783 HValue* input = GetParameter(0); | |
784 | |
785 if (!type->Is(Type::Number())) { | |
786 // If we expect to see other things than Numbers, we will create a generic | |
787 // stub, which handles all numbers and calls into the runtime for the rest. | |
788 IfBuilder if_number(this); | |
789 if_number.If<HIsNumberAndBranch>(input); | |
790 if_number.Then(); | |
791 HInstruction* res = stub->ToHInstruction(input, type, this, context()); | |
792 if_number.Return(AddInstruction(res)); | |
793 if_number.Else(); | |
794 AddInstruction(new(zone()) HPushArgument(GetParameter(0))); | |
795 if_number.Return(AddInstruction(new(zone()) HCallConstantFunction( | |
796 stub->ToJSFunction(isolate()), 1))); | |
797 if_number.End(); | |
798 return graph()->GetConstantUndefined(); | |
799 } | |
800 | |
801 if (type->Is(Type::Integer31())) { | |
802 AddInstruction(new(zone()) HCheckSmi(input)); | |
danno
2013/06/21 16:38:04
Try to avoid the explicit checks by using force re
| |
803 } else if (type->Is(Type::Double())) { | |
804 AddInstruction(new(zone()) HCheckNonSmi(input)); | |
805 } | |
806 | |
807 return AddInstruction(stub->ToHInstruction(input, type, this, context())); | |
808 } | |
809 | |
810 | |
753 Handle<Code> CompareNilICStub::GenerateCode() { | 811 Handle<Code> CompareNilICStub::GenerateCode() { |
754 return DoGenerateCode(this); | 812 return DoGenerateCode(this); |
755 } | 813 } |
756 | 814 |
757 | 815 |
758 template <> | 816 template <> |
759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 817 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
760 ToBooleanStub* stub = casted_stub(); | 818 ToBooleanStub* stub = casted_stub(); |
761 | 819 |
762 IfBuilder if_true(this); | 820 IfBuilder if_true(this); |
763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 821 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
764 if_true.Then(); | 822 if_true.Then(); |
765 if_true.Return(graph()->GetConstant1()); | 823 if_true.Return(graph()->GetConstant1()); |
766 if_true.Else(); | 824 if_true.Else(); |
767 if_true.End(); | 825 if_true.End(); |
768 return graph()->GetConstant0(); | 826 return graph()->GetConstant0(); |
769 } | 827 } |
770 | 828 |
771 | 829 |
772 Handle<Code> ToBooleanStub::GenerateCode() { | 830 Handle<Code> ToBooleanStub::GenerateCode() { |
773 return DoGenerateCode(this); | 831 return DoGenerateCode(this); |
774 } | 832 } |
775 | 833 |
776 | 834 |
777 } } // namespace v8::internal | 835 } } // namespace v8::internal |
OLD | NEW |