Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1406)

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 17229005: Convert UnaryOpStub to a HydrogenCodeStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 : graph()->GetConstantUndefined(); 757 : graph()->GetConstantUndefined();
758 } 758 }
759 759
760 760
761 Handle<Code> CompareNilICStub::GenerateCode() { 761 Handle<Code> CompareNilICStub::GenerateCode() {
762 return DoGenerateCode(this); 762 return DoGenerateCode(this);
763 } 763 }
764 764
765 765
766 template <> 766 template <>
767 HValue* CodeStubGraphBuilder<UnaryOpStub>::BuildCodeInitializedStub() {
768 UnaryOpStub* stub = casted_stub();
769 Handle<Type> type = stub->GetType(graph()->isolate());
770 HValue* input = GetParameter(0);
771
772 // Prevent unwanted HChange being inserted to ensure that the stub
773 // deopts on newly encountered types.
774 if (!type->Maybe(Type::Double())) {
775 input = AddInstruction(new(zone())
776 HForceRepresentation(input, Representation::Smi()));
777 }
778
779 if (!type->Is(Type::Number())) {
780 // If we expect to see other things than Numbers, we will create a generic
781 // stub, which handles all numbers and calls into the runtime for the rest.
782 IfBuilder if_number(this);
783 if_number.If<HIsNumberAndBranch>(input);
784 if_number.Then();
785 HInstruction* res = BuildUnaryMathOp(input, type, stub->operation());
786 if_number.Return(AddInstruction(res));
787 if_number.Else();
788 AddInstruction(new(zone()) HPushArgument(GetParameter(0)));
789 if_number.Return(AddInstruction(new(zone()) HCallConstantFunction(
790 stub->ToJSFunction(isolate()), 1)));
791 if_number.End();
792 return graph()->GetConstantUndefined();
793 }
794
795 return AddInstruction(BuildUnaryMathOp(input, type, stub->operation()));
796 }
797
798
799 Handle<Code> UnaryOpStub::GenerateCode() {
800 return DoGenerateCode(this);
801 }
802
803
804 template <>
767 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { 805 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
768 ToBooleanStub* stub = casted_stub(); 806 ToBooleanStub* stub = casted_stub();
769 807
770 IfBuilder if_true(this); 808 IfBuilder if_true(this);
771 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); 809 if_true.If<HBranch>(GetParameter(0), stub->GetTypes());
772 if_true.Then(); 810 if_true.Then();
773 if_true.Return(graph()->GetConstant1()); 811 if_true.Return(graph()->GetConstant1());
774 if_true.Else(); 812 if_true.Else();
775 if_true.End(); 813 if_true.End();
776 return graph()->GetConstant0(); 814 return graph()->GetConstant0();
777 } 815 }
778 816
779 817
780 Handle<Code> ToBooleanStub::GenerateCode() { 818 Handle<Code> ToBooleanStub::GenerateCode() {
781 return DoGenerateCode(this); 819 return DoGenerateCode(this);
782 } 820 }
783 821
784 822
785 } } // namespace v8::internal 823 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698