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

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: fix code stub disass output 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') | src/hydrogen.h » ('J')
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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 AddInstruction(new(zone()) HPushArgument(GetParameter(0)));
781 if_number.Return(AddInstruction(new(zone()) HCallConstantFunction(
782 stub->ToJSFunction(isolate()), 1)));
783 if_number.End();
784 return graph()->GetConstantUndefined();
785 }
786
787 return AddInstruction(BuildUnaryMathOp(input, type, stub->operation()));
788 }
789
790
791 Handle<Code> UnaryOpStub::GenerateCode() {
792 return DoGenerateCode(this);
793 }
794
795
796 template <>
759 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { 797 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
760 ToBooleanStub* stub = casted_stub(); 798 ToBooleanStub* stub = casted_stub();
761 799
762 IfBuilder if_true(this); 800 IfBuilder if_true(this);
763 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); 801 if_true.If<HBranch>(GetParameter(0), stub->GetTypes());
764 if_true.Then(); 802 if_true.Then();
765 if_true.Return(graph()->GetConstant1()); 803 if_true.Return(graph()->GetConstant1());
766 if_true.Else(); 804 if_true.Else();
767 if_true.End(); 805 if_true.End();
768 return graph()->GetConstant0(); 806 return graph()->GetConstant0();
769 } 807 }
770 808
771 809
772 Handle<Code> ToBooleanStub::GenerateCode() { 810 Handle<Code> ToBooleanStub::GenerateCode() {
773 return DoGenerateCode(this); 811 return DoGenerateCode(this);
774 } 812 }
775 813
776 814
777 } } // namespace v8::internal 815 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | src/hydrogen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698