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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 : graph()->GetConstantUndefined(); | 749 : graph()->GetConstantUndefined(); |
| 750 } | 750 } |
| 751 | 751 |
| 752 | 752 |
| 753 Handle<Code> CompareNilICStub::GenerateCode() { | 753 Handle<Code> CompareNilICStub::GenerateCode() { |
| 754 return DoGenerateCode(this); | 754 return DoGenerateCode(this); |
| 755 } | 755 } |
| 756 | 756 |
| 757 | 757 |
| 758 template <> | 758 template <> |
| 759 HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() { | |
| 760 UnaryOpStub* stub = casted_stub(); | |
| 761 Handle<Type> type = stub->GetType(graph()->isolate()); | |
| 762 HValue* input = GetParameter(0); | |
| 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 if (!type->Is(Type::Number())) { | |
| 772 // If we expect to see other things than Numbers, we will create a generic | |
| 773 // stub, which handles all numbers and calls into the runtime for the rest. | |
| 774 IfBuilder if_number(this); | |
| 775 if_number.If<HIsNumberAndBranch>(input); | |
| 776 if_number.Then(); | |
| 777 HInstruction* res = BuildUnaryMathOp(input, type, stub->operation()); | |
| 778 if_number.Return(AddInstruction(res)); | |
| 779 if_number.Else(); | |
| 780 HValue* function = LoadJSBuiltin(stub->ToJSBuiltin(), context()); | |
| 781 AddInstruction(new(zone()) HPushArgument(GetParameter(0))); | |
|
danno
2013/07/05 08:25:48
Add<HPushArgument>(GetParameter(0));
| |
| 782 if_number.Return(AddInstruction(new(zone()) HInvokeFunction( | |
|
danno
2013/07/05 08:25:48
HValue* result = Add<HInvokeFunction>(context(), f
| |
| 783 context(), function, 1))); | |
| 784 if_number.End(); | |
| 785 return graph()->GetConstantUndefined(); | |
| 786 } | |
| 787 | |
| 788 return AddInstruction(BuildUnaryMathOp(input, type, stub->operation())); | |
| 789 } | |
| 790 | |
| 791 | |
| 792 Handle<Code> UnaryOpStub::GenerateCode() { | |
| 793 return DoGenerateCode(this); | |
| 794 } | |
| 795 | |
| 796 | |
| 797 template <> | |
| 759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 798 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
| 760 ToBooleanStub* stub = casted_stub(); | 799 ToBooleanStub* stub = casted_stub(); |
| 761 | 800 |
| 762 IfBuilder if_true(this); | 801 IfBuilder if_true(this); |
| 763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 802 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
| 764 if_true.Then(); | 803 if_true.Then(); |
| 765 if_true.Return(graph()->GetConstant1()); | 804 if_true.Return(graph()->GetConstant1()); |
| 766 if_true.Else(); | 805 if_true.Else(); |
| 767 if_true.End(); | 806 if_true.End(); |
| 768 return graph()->GetConstant0(); | 807 return graph()->GetConstant0(); |
| 769 } | 808 } |
| 770 | 809 |
| 771 | 810 |
| 772 Handle<Code> ToBooleanStub::GenerateCode() { | 811 Handle<Code> ToBooleanStub::GenerateCode() { |
| 773 return DoGenerateCode(this); | 812 return DoGenerateCode(this); |
| 774 } | 813 } |
| 775 | 814 |
| 776 | 815 |
| 777 } } // namespace v8::internal | 816 } } // namespace v8::internal |
| OLD | NEW |