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

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

Issue 18712002: Convert UnaryOpStub to a HydrogenCodeStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address review 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 HValue* function = AddLoadJSBuiltin(stub->ToJSBuiltin(), context());
789 Add<HPushArgument>(GetParameter(0));
790 HValue* result = Add<HInvokeFunction>(context(), function, 1);
791 if_number.Return(result);
792 if_number.End();
793 return graph()->GetConstantUndefined();
794 }
795
796 return AddInstruction(BuildUnaryMathOp(input, type, stub->operation()));
797 }
798
799
800 Handle<Code> UnaryOpStub::GenerateCode() {
801 return DoGenerateCode(this);
802 }
803
804
805 template <>
767 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { 806 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
768 ToBooleanStub* stub = casted_stub(); 807 ToBooleanStub* stub = casted_stub();
769 808
770 IfBuilder if_true(this); 809 IfBuilder if_true(this);
771 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); 810 if_true.If<HBranch>(GetParameter(0), stub->GetTypes());
772 if_true.Then(); 811 if_true.Then();
773 if_true.Return(graph()->GetConstant1()); 812 if_true.Return(graph()->GetConstant1());
774 if_true.Else(); 813 if_true.Else();
775 if_true.End(); 814 if_true.End();
776 return graph()->GetConstant0(); 815 return graph()->GetConstant0();
777 } 816 }
778 817
779 818
780 Handle<Code> ToBooleanStub::GenerateCode() { 819 Handle<Code> ToBooleanStub::GenerateCode() {
781 return DoGenerateCode(this); 820 return DoGenerateCode(this);
782 } 821 }
783 822
784 823
785 } } // namespace v8::internal 824 } } // 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