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

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

Issue 25494007: Reland "Hydrogenisation of binops" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: change output-type selection again and adjust pregen set accordingly Created 7 years, 2 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
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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 : graph()->GetConstantUndefined(); 844 : graph()->GetConstantUndefined();
845 } 845 }
846 846
847 847
848 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { 848 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) {
849 return DoGenerateCode(isolate, this); 849 return DoGenerateCode(isolate, this);
850 } 850 }
851 851
852 852
853 template <> 853 template <>
854 HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() {
855 BinaryOpStub* stub = casted_stub();
856 HValue* left = GetParameter(0);
857 HValue* right = GetParameter(1);
858
859 Handle<Type> left_type = stub->GetLeftType(isolate());
860 Handle<Type> right_type = stub->GetRightType(isolate());
861 Handle<Type> result_type = stub->GetResultType(isolate());
862
863 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) &&
864 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None())));
865
866 HValue* result = NULL;
867 if (stub->operation() == Token::ADD &&
868 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) &&
869 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) {
870 // For the generic add stub a fast case for String add is performance
871 // critical.
872 if (left_type->Maybe(Type::String())) {
873 IfBuilder left_string(this);
874 left_string.IfNot<HIsSmiAndBranch>(left);
875 left_string.AndIf<HIsStringAndBranch>(left);
876 left_string.Then();
877 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_RIGHT));
878 left_string.Else();
879 Push(AddInstruction(BuildBinaryOperation(stub->operation(),
880 left, right, left_type, right_type, result_type,
881 stub->fixed_right_arg(), true)));
882 left_string.End();
883 result = Pop();
884 } else {
885 IfBuilder right_string(this);
886 right_string.IfNot<HIsSmiAndBranch>(right);
887 right_string.AndIf<HIsStringAndBranch>(right);
888 right_string.Then();
889 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_LEFT));
890 right_string.Else();
891 Push(AddInstruction(BuildBinaryOperation(stub->operation(),
892 left, right, left_type, right_type, result_type,
893 stub->fixed_right_arg(), true)));
894 right_string.End();
895 result = Pop();
896 }
897 } else {
898 result = AddInstruction(BuildBinaryOperation(stub->operation(),
899 left, right, left_type, right_type, result_type,
900 stub->fixed_right_arg(), true));
901 }
902
903 // If we encounter a generic argument, the number conversion is
904 // observable, thus we cannot afford to bail out after the fact.
905 if (!stub->HasSideEffects(isolate())) {
906 if (result_type->Is(Type::Smi())) {
907 if (stub->operation() == Token::SHR && !SmiValuesAre32Bits()) {
908 // TODO(olivf) Replace this by a SmiTagU Instruction.
909 // 0x40000000: this number would convert to negative when interpreting
910 // the register as signed value;
911 IfBuilder if_of(this);
912 if_of.IfNot<HCompareNumericAndBranch>(result,
913 Add<HConstant>(static_cast<int>(0x40000000)), Token::EQ_STRICT);
914 if_of.Then();
915 if_of.ElseDeopt("UInt->Smi oveflow");
916 if_of.End();
917 }
918 }
919 result = EnforceNumberType(result, result_type);
920 }
921
922 // Reuse the double box if we are allowed to (i.e. chained binops).
923 if (stub->CanReuseDoubleBox()) {
924 HValue* reuse = (stub->mode() == OVERWRITE_LEFT) ? left : right;
925 IfBuilder if_heap_number(this);
926 if_heap_number.IfNot<HIsSmiAndBranch>(reuse);
927 if_heap_number.Then();
928 HValue* res_val = Add<HForceRepresentation>(result,
929 Representation::Double());
930 HObjectAccess access = HObjectAccess::ForHeapNumberValue();
931 Add<HStoreNamedField>(reuse, access, res_val);
932 Push(reuse);
933 if_heap_number.Else();
934 Push(result);
935 if_heap_number.End();
936 result = Pop();
937 }
938
939 return result;
940 }
941
942
943 Handle<Code> BinaryOpStub::GenerateCode(Isolate* isolate) {
944 return DoGenerateCode(isolate, this);
945 }
946
947
948 template <>
854 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { 949 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
855 ToBooleanStub* stub = casted_stub(); 950 ToBooleanStub* stub = casted_stub();
856 951
857 IfBuilder if_true(this); 952 IfBuilder if_true(this);
858 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); 953 if_true.If<HBranch>(GetParameter(0), stub->GetTypes());
859 if_true.Then(); 954 if_true.Then();
860 if_true.Return(graph()->GetConstant1()); 955 if_true.Return(graph()->GetConstant1());
861 if_true.Else(); 956 if_true.Else();
862 if_true.End(); 957 if_true.End();
863 return graph()->GetConstant0(); 958 return graph()->GetConstant0();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 return js_function; 1231 return js_function;
1137 } 1232 }
1138 1233
1139 1234
1140 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { 1235 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) {
1141 return DoGenerateCode(isolate, this); 1236 return DoGenerateCode(isolate, this);
1142 } 1237 }
1143 1238
1144 1239
1145 } } // namespace v8::internal 1240 } } // namespace v8::internal
OLDNEW
« src/code-stubs.cc ('K') | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698