Chromium Code Reviews| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 SINGLE, | 104 SINGLE, |
| 105 MULTIPLE | 105 MULTIPLE |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 HValue* BuildArrayConstructor(ElementsKind kind, | 108 HValue* BuildArrayConstructor(ElementsKind kind, |
| 109 bool disable_allocation_sites, | 109 bool disable_allocation_sites, |
| 110 ArgumentClass argument_class); | 110 ArgumentClass argument_class); |
| 111 HValue* BuildInternalArrayConstructor(ElementsKind kind, | 111 HValue* BuildInternalArrayConstructor(ElementsKind kind, |
| 112 ArgumentClass argument_class); | 112 ArgumentClass argument_class); |
| 113 | 113 |
| 114 HInstruction* BuildUnaryOp( | |
| 115 HValue* input, Handle<Type> type, Token::Value operation); | |
| 116 | |
| 114 private: | 117 private: |
| 115 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); | 118 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); |
| 116 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, | 119 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, |
| 117 ElementsKind kind); | 120 ElementsKind kind); |
| 118 | 121 |
| 119 SmartArrayPointer<HParameter*> parameters_; | 122 SmartArrayPointer<HParameter*> parameters_; |
| 120 HValue* arguments_length_; | 123 HValue* arguments_length_; |
| 121 CompilationInfoWithZone info_; | 124 CompilationInfoWithZone info_; |
| 122 CodeStubInterfaceDescriptor* descriptor_; | 125 CodeStubInterfaceDescriptor* descriptor_; |
| 123 HContext* context_; | 126 HContext* context_; |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 if_nil.Else(); | 746 if_nil.Else(); |
| 744 if_nil.Return(graph()->GetConstant0()); | 747 if_nil.Return(graph()->GetConstant0()); |
| 745 } | 748 } |
| 746 if_nil.End(); | 749 if_nil.End(); |
| 747 return continuation.IsTrueReachable() | 750 return continuation.IsTrueReachable() |
| 748 ? graph()->GetConstant1() | 751 ? graph()->GetConstant1() |
| 749 : graph()->GetConstantUndefined(); | 752 : graph()->GetConstantUndefined(); |
| 750 } | 753 } |
| 751 | 754 |
| 752 | 755 |
| 756 Handle<Code> UnaryOpStub::GenerateCode() { | |
|
danno
2013/06/27 13:31:06
Move this down after the BuildCode method for Unar
oliv
2013/06/27 17:20:48
Done.
| |
| 757 return DoGenerateCode(this); | |
| 758 } | |
| 759 | |
| 760 | |
| 761 HInstruction* CodeStubGraphBuilderBase::BuildUnaryOp(HValue* input, | |
|
danno
2013/06/27 13:31:06
I wouldn't put this on the BuilderBase. If there i
oliv
2013/06/27 17:20:48
Done.
| |
| 762 Handle<Type> type, Token::Value operation) { | |
| 763 | |
| 764 // Prevent unwanted HChange being inserted to ensure that the stub | |
| 765 // deopts on newly encountered types. | |
| 766 if (!type->Maybe(Type::Double())) { | |
| 767 input = AddInstruction(new(zone()) | |
| 768 HForceRepresentation(input, Representation::Smi())); | |
| 769 } | |
| 770 | |
| 771 // We only handle the numeric cases here | |
| 772 Handle<Type> numeric_type = handle( | |
| 773 Type::Intersect(type, handle(Type::Number(), isolate())), isolate()); | |
| 774 | |
| 775 switch (operation) { | |
| 776 default: | |
| 777 UNREACHABLE(); | |
| 778 case Token::SUB: | |
| 779 return BuildSub(input, numeric_type, context()); | |
| 780 case Token::BIT_NOT: | |
| 781 return BuildBitNot(input, numeric_type); | |
| 782 } | |
| 783 } | |
| 784 | |
| 785 | |
| 786 template <> | |
| 787 HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() { | |
| 788 UnaryOpStub* stub = casted_stub(); | |
| 789 Handle<Type> type = stub->GetType(graph()->isolate()); | |
| 790 HValue* input = GetParameter(0); | |
| 791 | |
| 792 if (!type->Is(Type::Number())) { | |
| 793 // If we expect to see other things than Numbers, we will create a generic | |
| 794 // stub, which handles all numbers and calls into the runtime for the rest. | |
| 795 IfBuilder if_number(this); | |
| 796 if_number.If<HIsNumberAndBranch>(input); | |
| 797 if_number.Then(); | |
| 798 HInstruction* res = BuildUnaryOp(input, type, stub->operation()); | |
|
danno
2013/06/27 13:31:06
Yeah, I know it's a generated if, but I don't thin
oliv
2013/06/27 17:20:48
Done.
| |
| 799 if_number.Return(AddInstruction(res)); | |
| 800 if_number.Else(); | |
| 801 AddInstruction(new(zone()) HPushArgument(GetParameter(0))); | |
| 802 if_number.Return(AddInstruction(new(zone()) HCallConstantFunction( | |
| 803 stub->ToJSFunction(isolate()), 1))); | |
| 804 if_number.End(); | |
| 805 return graph()->GetConstantUndefined(); | |
| 806 } | |
| 807 | |
| 808 return AddInstruction(BuildUnaryOp(input, type, stub->operation())); | |
| 809 } | |
| 810 | |
| 811 | |
| 753 Handle<Code> CompareNilICStub::GenerateCode() { | 812 Handle<Code> CompareNilICStub::GenerateCode() { |
|
danno
2013/06/27 13:31:06
Move this up to be under the CompareNil BuildCode
oliv
2013/06/27 17:20:48
Done.
| |
| 754 return DoGenerateCode(this); | 813 return DoGenerateCode(this); |
| 755 } | 814 } |
| 756 | 815 |
| 757 | 816 |
| 758 template <> | 817 template <> |
| 759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 818 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
| 760 ToBooleanStub* stub = casted_stub(); | 819 ToBooleanStub* stub = casted_stub(); |
| 761 | 820 |
| 762 IfBuilder if_true(this); | 821 IfBuilder if_true(this); |
| 763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 822 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
| 764 if_true.Then(); | 823 if_true.Then(); |
| 765 if_true.Return(graph()->GetConstant1()); | 824 if_true.Return(graph()->GetConstant1()); |
| 766 if_true.Else(); | 825 if_true.Else(); |
| 767 if_true.End(); | 826 if_true.End(); |
| 768 return graph()->GetConstant0(); | 827 return graph()->GetConstant0(); |
| 769 } | 828 } |
| 770 | 829 |
| 771 | 830 |
| 772 Handle<Code> ToBooleanStub::GenerateCode() { | 831 Handle<Code> ToBooleanStub::GenerateCode() { |
| 773 return DoGenerateCode(this); | 832 return DoGenerateCode(this); |
| 774 } | 833 } |
| 775 | 834 |
| 776 | 835 |
| 777 } } // namespace v8::internal | 836 } } // namespace v8::internal |
| OLD | NEW |